forked from ghermans/Essential_Freeroam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.lua
34 lines (31 loc) · 1.23 KB
/
server.lua
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
30
31
32
33
34
RegisterServerEvent('playerSpawn')
AddEventHandler('playerSpawn', function()
TriggerClientEvent('es_freeroam:spawnPlayer', source, 464.091, -997.166, 24.915)
end)
AddEventHandler('es:playerLoaded', function(source)
-- Get the players money amount
TriggerEvent("es:getPlayerFromId", source, function(user)
user:setMoney((user.money))
end)
end)
RegisterServerEvent('mission:completed')
AddEventHandler('mission:completed', function(total)
-- Get the players money amount
TriggerEvent('es:getPlayerFromId', source, function(user)
-- update player money amount
user:addMoney((total))
TriggerClientEvent("es_freeroam:notify", source, "CHAR_BANK_MAZE", 1, "Maze Bank", false, "You received ~g~$".. tonumber(total))
end)
end)
RegisterServerEvent('es_freeroam:pay')
AddEventHandler('es_freeroam:pay', function(amount)
-- Get the players money amount
TriggerEvent("es:getPlayerFromId", source, function(user)
if(user.money > amount) then
TriggerClientEvent("es_freeroam:notify", source, "CHAR_BANK_MAZE", 1, "Maze Bank", false, "Your transaction is ~g~completed.")
user:removeMoney((amount))
else
TriggerClientEvent("es_freeroam:notify", source, "CHAR_BANK_MAZE", 1, "Maze Bank", false, "Your transaction is ~r~rejected.")
end
end)
end)