-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.lua
More file actions
34 lines (32 loc) · 2.21 KB
/
Copy pathserver.lua
File metadata and controls
34 lines (32 loc) · 2.21 KB
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
function roundValue(number, decimals)
local power = 10^decimals
return math.floor(number * power) / power
end
RegisterNetEvent("infinity_stores:buy")
AddEventHandler("infinity_stores:buy", function(_InfinitySource, itemdb, price, quantity, PlayerDatas)
local SourceSteamID, result = exports.infinity_core:GetPlayerSource(_InfinitySource)
if tonumber(PlayerDatas._Cash) >= tonumber(price) then
exports.infinity_core:RemoveCash(_InfinitySource, tonumber(price))
exports.infinity_needs:AddInventoryItem(_InfinitySource, itemdb, tonumber(quantity), PlayerDatas._Inventory, false)
exports.infinity_core:notification(_InfinitySource, "Item Buy", '<b class="text-danger">- '..roundValue(price, 2)..'$</b>', 'center_right', 'infinitycore', 3000)
else
exports.infinity_core:notification(_InfinitySource,'<div class="text-danger">No Money</div>', '<small style="font-size:18px;">You dont have money</small>', 'center_right', 'infinitycore', 2500)
end
end)
RegisterNetEvent("infinity_stores:sell")
AddEventHandler("infinity_stores:sell", function(_InfinitySource, itemdb, price, quantity, Xp)
local SourceSteamID = exports.infinity_core:GetPlayerSource(_InfinitySource)
if SourceSteamID then
local PlayerDatas = exports.infinity_core:GetPlayerSession(tonumber(_InfinitySource))
local InventoryQT = exports.infinity_needs:CheckPlayerInventory(_InfinitySource, itemdb)
if InventoryQT ~= nil and tonumber(InventoryQT) > 0 then
XP_Given = tonumber(Xp)
exports.infinity_core:AddXP(_InfinitySource, XP_Given)
exports.infinity_core:notification(_InfinitySource, "<b class='text-success'>Item Sell</b>", '<b class="text-light">+ '..roundValue(price, 2)..'$ <br> +'..XP_Given..'XP</b>', 'center_right', 'redm_min', 2500)
exports.infinity_core:AddCash(_InfinitySource, price)
exports.infinity_needs:RemoveInventoryItem(_InfinitySource, itemdb, tonumber(quantity), PlayerDatas._Inventory, false)
else
exports.infinity_core:notification(_InfinitySource, "<b class='text-danger'>ERROR</b>", 'You dont have this item', 'center_right', 'redm_min', 2500)
end
end
end)