-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.lua
103 lines (92 loc) · 3.1 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
if cfg.esxLegacy == false then
ESX = nil
TriggerEvent("esx:getSharedObject", function(obj) ESX = obj end)
end
local maxmoney = 1100
RegisterNetEvent("cow:getmilk")
AddEventHandler("cow:getmilk", function()
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
if xPlayer.canCarryItem("milk", 1) then
xPlayer.addInventoryItem("milk", 1)
else
TriggerClientEvent('esx:showNotification', source, cfg.translation['limit'])
end
end)
RegisterNetEvent("apple:getapple")
AddEventHandler("apple:getapple", function()
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
if xPlayer.canCarryItem("apple", 1) then
xPlayer.addInventoryItem("apple", 1)
else
TriggerClientEvent('esx:showNotification', source, cfg.translation['limit'])
end
end)
RegisterNetEvent("potato:getpotato")
AddEventHandler("potato:getpotato", function()
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
if xPlayer.canCarryItem("potato", 1) then
xPlayer.addInventoryItem("potato", 1)
else
TriggerClientEvent('esx:showNotification', source, cfg.translation['limit'])
end
end)
RegisterNetEvent("milk:sell")
AddEventHandler("milk:sell", function()
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local money = 1000
if xPlayer ~= nil then
if money >= maxmoney then
xPlayer.kick("Cheater")
else
local randomMoney = math.random(30,60)
if xPlayer.getInventoryItem("milk").count > 0 then
xPlayer.addMoney(randomMoney)
xPlayer.removeInventoryItem("milk", 1)
else
TriggerClientEvent('esx:showNotification', source, cfg.translation['nomilk'])
end
end
end
end)
RegisterNetEvent("apple:sell")
AddEventHandler("apple:sell", function()
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local money = 1000
if xPlayer ~= nil then
if money >= maxmoney then
xPlayer.kick("Cheater")
else
local randomMoney = math.random(30,60)
if xPlayer.getInventoryItem("apple").count > 0 then
xPlayer.addMoney(randomMoney)
xPlayer.removeInventoryItem("apple", 1)
else
TriggerClientEvent('esx:showNotification', source, cfg.translation['noapple'])
end
end
end
end)
RegisterNetEvent("potato:sell")
AddEventHandler("potato:sell", function()
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local money = 1000
if xPlayer ~= nil then
if money >= maxmoney then
xPlayer.kick("Cheater")
else
local randomMoney = math.random(30,60)
if xPlayer.getInventoryItem("potato").count > 0 then
xPlayer.addMoney(randomMoney)
xPlayer.removeInventoryItem("potato", 1)
else
TriggerClientEvent('esx:showNotification', source, cfg.translation['nopotato'])
end
end
end
end)