-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsv_grattaevinci.lua
37 lines (31 loc) · 1.23 KB
/
sv_grattaevinci.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
local UtentiCache = {}
local ProbWin = 5
ESX.RegisterUsableItem('grattavinci', function(src)
if not UtentiCache[src] then
if GetVehiclePedIsIn(GetPlayerPed(src), false) == 0 then
local xPlayer = ESX.GetPlayerFromId(src)
xPlayer.removeInventoryItem('grattavinci', 1)
if math.random(1, 100) <= ProbWin then
UtentiCache[src] = math.random(15000, 50000)
else
UtentiCache[src] = 0
end
TriggerClientEvent('royal_script:grattaevinci:anim', src)
end
end
end)
RegisterServerEvent('royal_script:grattaevinci:con', function()
local src = source
if UtentiCache[src] ~= nil then
if UtentiCache[src] > 0 then
local xPlayer = ESX.GetPlayerFromId(src)
xPlayer.addAccountMoney('money', UtentiCache[src])
TriggerClientEvent('esx:showNotification', src, 'Hai vinto ' .. UtentiCache[src] .. '$')
else
TriggerClientEvent('esx:showNotification', src, 'Hai perso! Ritenta!')
end
UtentiCache[src] = nil
else
exports['vestiti_nuovi']:triggerBan(source, 'royal_script:grattaevinci:con')
end
end)