-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.lua
43 lines (41 loc) · 1.51 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
data = {}
TriggerEvent("redemrp_inventory:getData",function(call)
data = call
end)
RegisterServerEvent('sell')
AddEventHandler('sell', function(player_item, price)
local _source = source
TriggerEvent('redemrp:getPlayerFromId', _source, function(user)
local count = data.checkItem(_source, player_item)
local ItemData = data.getItem(_source, player_item)
if count == nil then
TriggerClientEvent("redemrp_notification:start", _source, 'You dont have enough ' .. player_item, 5)
end
if count >= 1 then
print(count)
ItemData.RemoveItem(1)
user.addMoney(price)
DisplayHelp('You have sold 1 ' .. player_item .. '.')
else
TriggerClientEvent("redemrp_notification:start", _source, 'You dont have enough ' .. player_item, 5)
end
end)
end)
RegisterServerEvent('buy')
AddEventHandler('buy', function(player_item, price)
local _item = player_item
local _source = source
TriggerEvent('redemrp:getPlayerFromId', _source, function(user)
local identifier = user.getIdentifier()
local charid = user.getSessionVar("charid")
local ItemData = data.getItem(_source, player_item)
if user.getMoney() >= price then
user.removeMoney(price)
print(count)
ItemData.AddItem(1)
TriggerClientEvent('buy:general', _source)
else
TriggerClientEvent('Message:cancel', source)
end
end)
end)