-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusables.lua
More file actions
114 lines (104 loc) · 4.28 KB
/
Copy pathusables.lua
File metadata and controls
114 lines (104 loc) · 4.28 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
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
104
105
106
107
108
109
110
111
112
113
114
-----------------------------------------------------------------------------------------------------------------------------------------
-- VRP
-----------------------------------------------------------------------------------------------------------------------------------------
local Tunnel = module("vrp","lib/Tunnel")
local Proxy = module("vrp","lib/Proxy")
local Tools = module("vrp","lib/Tools")
vRP = Proxy.getInterface("vRP")
vRPclient = Tunnel.getInterface("vRP")
vCU = Tunnel.getInterface("inventory_client")
vCLIENT = Tunnel.getInterface("inventory")
vTASKBAR = Tunnel.getInterface("taskbar")
func = {}
Tunnel.bindInterface("ld_inventory-usables", func)
local actived = {}
func.useItem = function(itemName,ramount)
local source = source
local user_id = vRP.getUserId(source)
if ramount == nil then ramount = vRP.getInventoryItemAmount(user_id,itemName) end
if user_id and ramount ~= nil and parseInt(ramount) >= 0 and not actived[user_id] and actived[user_id] == nil then
local type = vRP.itemTypeList(itemName)
if type == 'use' then
if itemName == "mochila" then
if vRP.getBackpack(user_id) >= 90 then
TriggerClientEvent("Notify",source,"negado","Você não pode equipar mais mochilas.",8000)
else
if vRP.tryGetInventoryItem(user_id,"mochila",1) then
local valor = 0
if vRP.getBackpack(user_id) == 6 or vRP.getBackpack(user_id) == 5 or vRP.getBackpack(user_id) == 0 then
valor = 30
elseif vRP.getBackpack(user_id) == 30 then
valor = 60
elseif vRP.getBackpack(user_id) == 60 then
valor = 90
end
vRP.setBackpack(user_id, valor)
TriggerClientEvent("Notify",source,"sucesso","Você equipou uma mochila!")
NotifyItem(user_id, "USOU", itemName,1)
end
end
elseif itemName == "colete" then
if vRP.tryGetInventoryItem(user_id,"colete",1) then
vRPclient.setArmour(source,100)
NotifyItem(user_id, "USOU", itemName,1)
end
elseif itemName == "water" then
local src = source
if vRP.tryGetInventoryItem(user_id,"water",1) then
actived[user_id] = true
TriggerClientEvent('ld-inv:Client:RefreshInventory',source)
vRPclient._CarregarObjeto(src,"amb@world_human_drinking@beer@male@idle_a","idle_a","prop_ld_flow_bottle",49,28422)
TriggerClientEvent("progress",source,10000,"tomando")
TriggerClientEvent("itensNotify",source,'usar',"Bebendo",""..itemName.."")
SetTimeout(10000,function()
actived[user_id] = nil
vRPclient._stopAnim(source,false)
vRP.varyThirst(user_id,-40)
vRP.varyHunger(user_id,0)
vRP.giveInventoryItem(user_id,"garrafa-vazia",1)
vRPclient._DeletarObjeto(src)
NotifyItem(user_id, "USOU", itemName,1)
end)
end
elseif itemName == "attachsflashlight" or itemName == "attachscrosshair" or itemName == "attachssilencer" or itemName == "attachsgrip" then
local returnWeapon = vCLIENT.returnWeapon(source)
if returnWeapon then
if Attachs[user_id][returnWeapon] == nil then
Attachs[user_id][returnWeapon] = {}
end
if Attachs[user_id][returnWeapon][itemName] == nil then
local checkAttachs = vCLIENT.checkAttachs(source,itemName,returnWeapon)
if checkAttachs then
if vRP.tryGetInventoryItem(user_id,itemName,1) then
vCLIENT.putAttachs(source,itemName,returnWeapon)
Attachs[user_id][returnWeapon][itemName] = true
TriggerClientEvent('ld-inv:Client:RefreshInventory',source)
NotifyItem(user_id, "EQUIPOU ATTACH", itemName,1)
end
else
TriggerClientEvent("Notify",source,"importante","O armamento não possui suporte ao componente.",5000)
end
else
TriggerClientEvent("Notify",source,"importante","O armamento já possui o componente equipado.",5000)
end
else
TriggerClientEvent("Notify",source,"negado","Você não possui uma arma equipada!")
TriggerClientEvent('ld-inv:Client:CloseInventory',source)
end
end
end
end
end
function func.giveItem(name,qtd)
local source = source
local user_id = vRP.getUserId(source)
if user_id then
if vRP.computeInvWeight(user_id) + vRP.itemWeightList(name) * qtd <= vRP.getBackpack(user_id) then
vRP.giveInventoryItem(user_id,name,qtd)
return true
else
TriggerClientEvent("Notify",source,"negado","Mochila cheia.",5000)
return false
end
end
end