-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserver.lua
61 lines (43 loc) · 1.62 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
--ESX INIT--
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
--EVENTS--
RegisterServerEvent('coursier:pourboire') --Paie a la livraison d'une pizza + pourboire eventuel
AddEventHandler('coursier:pourboire', function(pourboire)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
xPlayer.addMoney(pourboire)
end)
RegisterServerEvent("coursier:paiefinale") --Paie "bonus" lors de la fin de service
AddEventHandler("coursier:paiefinale", function()
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local flouzefin = math.random(50, 200)
xPlayer.addMoney(flouzefin)
TriggerClientEvent("pNotify:SendNotification", source, {
text = "Voici votre petit bonus final : " .. flouzefin .. "$",
type = "success",
queue = "global",
timeout = 4000,
layout = "bottomRight"
})
end)
RegisterServerEvent("coursier:itemadd") --Ajout temporaire de l'item "pizza"
AddEventHandler("coursier:itemadd", function(nbCours)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
xPlayer.addInventoryItem('colis', tonumber(nbCours))
end)
RegisterServerEvent("coursier:itemrm") --Rm de l'item "pizza"
AddEventHandler("coursier:itemrm", function()
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
xPlayer.removeInventoryItem('colis', 1)
end)
RegisterServerEvent("coursier:deleteAllCours") --Rm de l'item "pizza"
AddEventHandler("coursier:deleteAllCours", function()
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local coursnbr = xPlayer.getInventoryItem('colis').count
xPlayer.removeInventoryItem('colis', coursnbr)
end)