forked from jotadateta/j_clothe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.lua
More file actions
312 lines (277 loc) · 11.1 KB
/
server.lua
File metadata and controls
312 lines (277 loc) · 11.1 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
local QBCore = exports['qb-core']:GetCoreObject()
--------------------
--Adicionar items---função terminada
--------------------
RegisterServerEvent('jotadateta:server:giveitem', function(skin1, skin2, clothe_id, prop)
--Processar o jogador--
local src = source
local player = QBCore.Functions.GetPlayer(src)
if Config.debug then
print("giving item with clothe_id: "..clothe_id)
end
--Receber a informação do tipo de roupa e associar ao respetivo--
if prop then
print("é prop")
if clothe_id == 0 then
clothe = "helmet" --id da roupa ex: helmet = 0 prop
elseif clothe_id == 2 then
clothe = "ears" --id da roupa ex: ears = 2 prop
elseif clothe_id == 6 then
clothe = "watches" --id da roupa ex: watches = 6 prop
elseif clothe_id == 1 then
clothe = "glasses" --id da roupa ex: glasses = 1 prop
elseif clothe_id == 7 then
clothe = "bracelet" --id da roupa ex: bracelet = 7 prop
end
else
print("não é prop")
if clothe_id == 11 then
clothe = "torso" --id da roupa ex: torso = 11
elseif clothe_id == 8 then
clothe = "tshirt" --id da roupa ex: tshirt = 8
elseif clothe_id == 3 then
clothe = "arms" --id da roupa ex: arms = 3
elseif clothe_id == 4 then
clothe = "jeans" --id da roupa ex: jeans = 4
elseif clothe_id == 6 then
clothe = "shoes" --id da roupa ex: shoes = 6
elseif clothe_id == 5 then
clothe = "bag" --id da roupa ex: bag = 5
elseif clothe_id == 7 then
clothe = "chain" --id da roupa ex: chain = 7
elseif clothe_id == 1 then
clothe = "mask" --id da roupa ex: mask = 1
end
end
------------------------------------
if debug then
print("The processed clothe is:"..tostring(clothe))
end
--Registar metada do item--
local info = {
id_clothe = skin1,
id_texture = skin2,
description = 'This is a '..clothe_id..' / '..skin1..' / '..skin2,
}
--Adicionar o item com a metadata--
if Config.debug then
print("Id of the clothe saved: "..tostring(info.id_clothe).." id of the texture: "..tostring(info.id_texture).." Descrição: "..tostring(info.description))
end
player.Functions.AddItem(clothe, 1, true, info)
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[clothe], "add")
end)
-------------------
---- Remove ------- função terminada
-------------------
RegisterNetEvent("jotadateta:server:removeitem", function(item, roupa_id, texture_id)
local Player = QBCore.Functions.GetPlayer(source)
if Config.debug then
print("to compare "..item.info.id_clothe.." with the clothe id "..roupa_id)
end
Player.Functions.RemoveItem(item.name, 1, item.slot, item.info)
TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items[item.name], "remove")
end)
---------------------
--Criar item usavel--
---------------------
QBCore.Functions.CreateUseableItem("torso", function(source, item)
local src = source
if Config.debug then
print("used item: "..tostring(item.name))
print("server the item used is going to set clothe: "..item.info.id_clothe)
print("server the item used is going to set texture: "..item.info.id_texture)
end
local prop = false
TriggerClientEvent("jotadateta:client:setclothes",src, item, prop)
end)
QBCore.Functions.CreateUseableItem("helmet", function(source, item)
local src = source
if Config.debug then
print("used item: "..tostring(item.name))
print("server the item used is going to set clothe: "..item.info.id_clothe)
print("server the item used is going to set texture: "..item.info.id_texture)
end
local prop = true
TriggerClientEvent("jotadateta:client:setclothes",src, item, prop)
end)
QBCore.Functions.CreateUseableItem("ears", function(source, item)
local src = source
if Config.debug then
print("used item: "..tostring(item.name))
print("server the item used is going to set clothe: "..item.info.id_clothe)
print("server the item used is going to set texture: "..item.info.id_texture)
end
local prop = true
TriggerClientEvent("jotadateta:client:setclothes",src, item, prop)
end)
QBCore.Functions.CreateUseableItem("watches", function(source, item)
local src = source
if Config.debug then
print("used item: "..tostring(item.name))
print("server the item used is going to set clothe: "..item.info.id_clothe)
print("server the item used is going to set texture: "..item.info.id_texture)
end
local prop = true
TriggerClientEvent("jotadateta:client:setclothes",src, item, prop)
end)
QBCore.Functions.CreateUseableItem("glasses", function(source, item)
local src = source
if Config.debug then
print("used item: "..tostring(item.name))
print("server the item used is going to set clothe: "..item.info.id_clothe)
print("server the item used is going to set texture: "..item.info.id_texture)
end
local prop = true
TriggerClientEvent("jotadateta:client:setclothes",src, item, prop)
end)
QBCore.Functions.CreateUseableItem("bracelet", function(source, item)
local src = source
if Config.debug then
print("used item: "..tostring(item.name))
print("server the item used is going to set clothe: "..item.info.id_clothe)
print("server the item used is going to set texture: "..item.info.id_texture)
end
local prop = true
TriggerClientEvent("jotadateta:client:setclothes",src, item, prop)
end)
QBCore.Functions.CreateUseableItem("tshirt", function(source, item)
local src = source
if Config.debug then
print("used item: "..tostring(item.name))
print("server the item used is going to set clothe: "..item.info.id_clothe)
print("server the item used is going to set texture: "..item.info.id_texture)
end
local prop = false
TriggerClientEvent("jotadateta:client:setclothes",src, item, prop)
end)
QBCore.Functions.CreateUseableItem("arms", function(source, item)
local src = source
if Config.debug then
print("used item: "..tostring(item.name))
print("server the item used is going to set clothe: "..item.info.id_clothe)
print("server the item used is going to set texture: "..item.info.id_texture)
end
local prop = false
TriggerClientEvent("jotadateta:client:setclothes",src, item, prop)
end)
QBCore.Functions.CreateUseableItem("jeans", function(source, item)
local src = source
if Config.debug then
print("used item: "..tostring(item.name))
print("server the item used is going to set clothe: "..item.info.id_clothe)
print("server the item used is going to set texture: "..item.info.id_texture)
end
local prop = false
TriggerClientEvent("jotadateta:client:setclothes",src, item, prop)
end)
QBCore.Functions.CreateUseableItem("shoes", function(source, item)
local src = source
if Config.debug then
print("used item: "..tostring(item.name))
print("server the item used is going to set clothe: "..item.info.id_clothe)
print("server the item used is going to set texture: "..item.info.id_texture)
end
local prop = false
TriggerClientEvent("jotadateta:client:setclothes",src, item, prop)
end)
QBCore.Functions.CreateUseableItem("bag", function(source, item)
local src = source
if Config.debug then
print("used item: "..tostring(item.name))
print("server the item used is going to set clothe: "..item.info.id_clothe)
print("server the item used is going to set texture: "..item.info.id_texture)
end
local prop = false
TriggerClientEvent("jotadateta:client:setclothes",src, item, prop)
end)
QBCore.Functions.CreateUseableItem("chain", function(source, item)
local src = source
if Config.debug then
print("used item: "..tostring(item.name))
print("server the item used is going to set clothe: "..item.info.id_clothe)
print("server the item used is going to set texture: "..item.info.id_texture)
end
local prop = false
TriggerClientEvent("jotadateta:client:setclothes",src, item, prop)
end)
QBCore.Functions.CreateUseableItem("mask", function(source, item)
local src = source
if Config.debug then
print("used item: "..tostring(item.name))
print("server the item used is going to set clothe: "..item.info.id_clothe)
print("server the item used is going to set texture: "..item.info.id_texture)
end
local prop = false
TriggerClientEvent("jotadateta:client:setclothes",src, item, prop)
end)
-------------------
---- commandos ----
-------------------
QBCore.Commands.Add(Config.torso, Lang:t("description.torso_description"), {}, false, function(source)
local prop = false
local clothe_id = 11
TriggerClientEvent("jotadateta:client:getclothes", source, clothe_id, prop)
end, 'user')
QBCore.Commands.Add(Config.tshirt, Lang:t("description.torso_description"), {}, false, function(source)
local prop = false
local clothe_id = 8
TriggerClientEvent("jotadateta:client:getclothes", source, clothe_id, prop)
end, 'user')
QBCore.Commands.Add(Config.arms, Lang:t("description.torso_description"), {}, false, function(source)
local prop = false
local clothe_id = 3
TriggerClientEvent("jotadateta:client:getclothes", source, clothe_id, prop)
end, 'user')
QBCore.Commands.Add(Config.jeans, Lang:t("description.torso_description"), {}, false, function(source)
local prop = false
local clothe_id = 4
TriggerClientEvent("jotadateta:client:getclothes", source, clothe_id, prop)
end, 'user')
QBCore.Commands.Add(Config.shoes, Lang:t("description.torso_description"), {}, false, function(source)
local prop = false
local clothe_id = 6
TriggerClientEvent("jotadateta:client:getclothes", source, clothe_id, prop)
end, 'user')
QBCore.Commands.Add(Config.bag, Lang:t("description.torso_description"), {}, false, function(source)
local prop = false
local clothe_id = 5
TriggerClientEvent("jotadateta:client:getclothes", source, clothe_id, prop)
end, 'user')
QBCore.Commands.Add(Config.chain, Lang:t("description.torso_description"), {}, false, function(source)
local prop = false
local clothe_id = 7
TriggerClientEvent("jotadateta:client:getclothes", source, clothe_id, prop)
end, 'user')
QBCore.Commands.Add(Config.mask, Lang:t("description.torso_description"), {}, false, function(source)
local prop = false
local clothe_id = 1
TriggerClientEvent("jotadateta:client:getclothes", source, clothe_id, prop)
end, 'user')
-------------------
---- Props --------
-------------------
QBCore.Commands.Add(Config.helmet, Lang:t("description.torso_description"), {}, false, function(source)
local prop = true
local clothe_id = 0
TriggerClientEvent("jotadateta:client:getclothes", source, clothe_id, prop)
end, 'user')
QBCore.Commands.Add(Config.ears, Lang:t("description.torso_description"), {}, false, function(source)
local prop = true
local clothe_id = 2
TriggerClientEvent("jotadateta:client:getclothes", source, clothe_id, prop)
end, 'user')
QBCore.Commands.Add(Config.watches, Lang:t("description.torso_description"), {}, false, function(source)
local prop = true
local clothe_id = 6
TriggerClientEvent("jotadateta:client:getclothes", source, clothe_id, prop)
end, 'user')
QBCore.Commands.Add(Config.glasses, Lang:t("description.torso_description"), {}, false, function(source)
local prop = true
local clothe_id = 1
TriggerClientEvent("jotadateta:client:getclothes", source, clothe_id, prop)
end, 'user')
QBCore.Commands.Add(Config.bracelet, Lang:t("description.torso_description"), {}, false, function(source)
local prop = true
local clothe_id = 7
TriggerClientEvent("jotadateta:client:getclothes", source, clothe_id, prop)
end, 'user')