-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.lua
More file actions
29 lines (25 loc) · 890 Bytes
/
Copy pathserver.lua
File metadata and controls
29 lines (25 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
-- Buy Make Event
RegisterServerEvent('makes:buyMake')
AddEventHandler('makes:buyMake', function(makeName)
local xPlayer = ESX.GetPlayerFromId(source)
local make = nil
-- Find the make in the config
for _, m in ipairs(Config.Makes) do
if m.name == makeName then
make = m
break
end
end
if make then
if xPlayer.getMoney() >= make.price then
xPlayer.removeMoney(make.price)
TriggerClientEvent('esx:showNotification', source, 'You bought ' .. make.label .. ' for $' .. make.price)
else
TriggerClientEvent('esx:showNotification', source, 'You do not have enough money to buy ' .. make.label)
end
else
TriggerClientEvent('esx:showNotification', source, 'Invalid make')
end
end)