This repository has been archived by the owner on May 10, 2022. It is now read-only.
forked from KamuiKody/k-pokemontcg
-
Notifications
You must be signed in to change notification settings - Fork 10
/
client.lua
294 lines (259 loc) · 10.3 KB
/
client.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
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
local QBCore = exports['qb-core']:GetCoreObject()
local assert = assert
local MenuV = assert(MenuV)
local CardShops = {
['Cardshop'] = {
location = vector3(174.08, -1321.79, 29.36),
},
}
function CreateBlips()
for k, v in pairs(Config.Badge) do
local blip = AddBlipForCoord(v.location)
SetBlipAsShortRange(blip, true)
SetBlipSprite(blip, 546)
SetBlipColour(blip, 46)
SetBlipScale(blip, 0.6)
SetBlipDisplay(blip, 6)
BeginTextCommandSetBlipName('STRING')
AddTextComponentString(v.label)
EndTextCommandSetBlipName(blip)
end
-- for k, v in pairs(Config.CardshopLocation) do
-- local blip = AddBlipForCoord(v.location)
-- SetBlipAsShortRange(blip, true)
-- SetBlipSprite(blip, 500)
-- SetBlipColour(blip, 2)
-- SetBlipScale(blip, 0.7)
-- SetBlipDisplay(blip, 6)
-- BeginTextCommandSetBlipName('STRING')
-- AddTextComponentString(v.label)
-- EndTextCommandSetBlipName(blip)
-- end
end
Citizen.CreateThread(function()
CreateBlips()
end)
function DisplayTooltip(suffix)
SetTextComponentFormat('STRING')
AddTextComponentString('Press ~INPUT_PICKUP~ To ' .. suffix)
EndTextCommandDisplayHelp(0, 0, 1, -1)
end
Citizen.CreateThread(function()
while true do
Wait(1)
local sleep = true
local playerCoords = GetEntityCoords(PlayerPedId())
for k, v in pairs(Config.CardshopLocation) do
local loc = v.location
local distance = #(playerCoords - loc)
if distance < 2.5 then
sleep = false
-- DisplayTooltip('Sell Items')
if IsControlJustPressed(1, 94) then
TriggerEvent('Cards:client:openMenu')
end
end
end
for k, v in pairs(Config.Badge) do
local loc = v.location
local distance = #(playerCoords - loc)
if distance < 2.5 then
sleep = false
DisplayTooltip('Trade for a '..v.label)
if IsControlJustPressed(1, 38) then
TriggerServerEvent('Cards:server:badges', k)
end
end
end
end
end)
RegisterNetEvent("Cards:Client:OpenCards")
AddEventHandler("Cards:Client:OpenCards", function()
RequestAnimDict("mp_arresting")
while (not HasAnimDictLoaded("mp_arresting")) do
Citizen.Wait(0)
end
TaskPlayAnim(PlayerPedId(), "mp_arresting" ,"a_uncuff" ,8.0, -8.0, -1, 1, 0, false, false, false )
local PedCoords = GetEntityCoords(PlayerPedId())
propbox = CreateObject(GetHashKey('prop_boosterbox_01'),PedCoords.x, PedCoords.y,PedCoords.z, true, true, true)
AttachEntityToEntity(propbox, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 0xDEAD), 0.1, 0.1, 0.0, 0.0, 10.0, 90.0, false, false, false, false, 2, true)
Citizen.Wait(5)
TriggerServerEvent("InteractSound_SV:PlayOnSource", "boxopen", 0.8)
QBCore.Functions.Progressbar("drink_something", "opening box..", 9500, false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = true,
disableInventory = true,
}, {}, {}, {}, function()-- Done
Citizen.Wait(1)
DeleteEntity(propbox)
ClearPedTasks(PlayerPedId())
end)
end)
RegisterNetEvent("Cards:Client:OpenPack")
AddEventHandler("Cards:Client:OpenPack", function()
RequestAnimDict("mp_arresting")
while (not HasAnimDictLoaded("mp_arresting")) do
Citizen.Wait(0)
end
TaskPlayAnim(PlayerPedId(), "mp_arresting" ,"a_uncuff" ,8.0, -8.0, -1, 1, 0, false, false, false )
local PedCoords = GetEntityCoords(PlayerPedId())
propcards = CreateObject(GetHashKey('prop_boosterpack_01'),PedCoords.x, PedCoords.y,PedCoords.z, true, true, true)
AttachEntityToEntity(propcards, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 0xDEAD), 0.1, 0.1, 0.0, 70.0, 10.0, 90.0, false, false, false, false, 2, true)
QBCore.Functions.Progressbar("drink_something", "opening pack..", 3000, false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = true,
disableInventory = true,
}, {}, {}, {}, function()-- Done
TriggerServerEvent("InteractSound_SV:PlayOnSource", "dealfour", 0.9)
Citizen.Wait(500)
SetNuiFocus(true, true)
SendNUIMessage({
open = true,
class = 'open',
})
DeleteEntity(propcards)
ClearPedTasks(PlayerPedId())
TriggerServerEvent('Cards:Server:RemoveItem')
end)
end)
RegisterNUICallback('Rewardpokemon', function(data)
local pokemon = data.Pokemon
TriggerServerEvent("InteractSound_SV:PlayOnSource", "flip", 0.9)
TriggerServerEvent('Cards:Server:GetPokemon', pokemon)
end)
RegisterNUICallback('randomCard', function()
TriggerServerEvent('Cards:Server:rewarditem')
end)
RegisterNUICallback('CloseNui', function()
SetNuiFocus(false, false)
end)
RegisterNetEvent("Cards:Client:CardChoosed")
AddEventHandler("Cards:Client:CardChoosed", function(card)
SendNUIMessage({
open = true,
class = 'choose',
data = card,
})
end)
RegisterNetEvent("Cards:client:UseBox")
AddEventHandler("Cards:client:UseBox", function()
TaskPlayAnim(PlayerPedId(), "clothingshirt", "try_shirt_positive_d", 8.0, 1.0, -1, 49, 0, 0, 0, 0)
print('Box is Opening')
TaskPlayAnim(PlayerPedId(), "mp_arresting" ,"a_uncuff" ,8.0, -8.0, -1, 1, 0, false, false, false )
local PedCoords = GetEntityCoords(PlayerPedId())
deckbox = CreateObject(GetHashKey('prop_deckbox_01'),PedCoords.x, PedCoords.y,PedCoords.z, true, true, true)
AttachEntityToEntity(deckbox, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 0xDEAD), 0.1, 0.1, 0.0, 0.0, 10.0, 90.0, false, false, false, false, 2, true)
QBCore.Functions.Notify("Box is being opened...", "error")
QBCore.Functions.Progressbar("use_bag", "Box is being opened", 5000, false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = true,
}, {}, {}, {}, function() -- Done
local RLBagData = {
outfitData = {
["bag"] = { item = 41, texture = 0}, -- Nek / Das
}
}
TriggerServerEvent("inventory:server:OpenInventory", "stash", "poke_"..QBCore.Functions.GetPlayerData().citizenid, {maxweight = 0.1, slots = 160})
TriggerEvent("inventory:client:SetCurrentStash", "poke_"..QBCore.Functions.GetPlayerData().citizenid)
TriggerServerEvent("InteractSound_SV:PlayOnSource", "snap", 1.2)
TaskPlayAnim(ped, "clothingshirt", "exit", 8.0, 1.0, -1, 49, 0, 0, 0, 0)
QBCore.Functions.Notify("Box has been opened successfully", "success")
Citizen.Wait(10000)
DeleteEntity(deckbox)
ClearPedTasks(PlayerPedId())
end)
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(2500)
local PlayerData = QBCore.Functions.GetPlayerData()
local ShopCoords = Config.CardshopLocation['Cardshop'].location
local ped = PlayerPedId()
local pos = GetEntityCoords(ped)
local dist = #(pos - ShopCoords)
if dist < 2.5 and not PlayerData.metadata["isdead"] and not PlayerData.metadata["inlaststand"] and not PlayerData.metadata["ishandcuffed"] and not IsPauseMenuActive() then
inshop = true
else
inshop = false
end
if inshop == true then
Citizen.Wait(1000)
QBCore.Functions.TriggerCallback("Cards:server:Menu",function(item,amount)
print(item,amount)
end)
end
end
end)
RegisterNetEvent("qb-pokemontcg:client:badgesound")
AddEventHandler("qb-pokemontcg:client:badgesound", function()
TriggerServerEvent("InteractSound_SV:PlayOnSource", "badge", 0.8)
end)
--------------------------------------------------------
----------------MENU---------------------------------
--Config
local menu = MenuV:CreateMenu(false, 'Player Items', 'topright', 155, 0, 0, 'size-125', 'none', 'menuv', 'test3')
local menu2 = menu:InheritMenu({title = false, subtitle = 'Card Shop', theme = 'default' })
local menu_button = menu:AddButton({ icon = '🔖', label = 'Sell Cards/Badges', value = menu2, description = 'View List Of Items' })
--------------------------------------------------------------------
RegisterNetEvent('Cards:client:openMenu')
AddEventHandler('Cards:client:openMenu', function()
MenuV:OpenMenu(menu)
end)
menu_button:On('select', function(item)
menu2:ClearItems(true)
QBCore.Functions.TriggerCallback('Cards:server:get:drugs:items', function(CardsResult)
for k, v in pairs(CardsResult) do
local itemName = v['Item']
local itemCount = v['Amount']
local price = Config.CardshopItems[itemName]
price = math.ceil(price * itemCount)
local menu_button2 = menu2:AddButton({
label = itemName .. " | Amount : " ..itemCount.." | $" .. price,
name = itemName,
value = {name = itemName, count = itemCount, price = price},
select = function(btn)
local select = btn.Value -- get all the values from v!
TriggerServerEvent('Cards:sellItem', select.name, select.count, select.price)
menu2:ClearItems(false)
end})
end
end)
end)
exports['qb-target']:AddBoxZone("Pokemon1", vector3(337.53, -930.37, 29.25), 1, 1, {
name="Pokemon1",
heading=339.64,
debugPoly=false,
minZ=28.15,
maxZ=31.55
}, {
options = {
{
event = "Cards:client:openMenu",
icon = "Fas Fa-Globe",
label = "Sell Cards",
},
},
distance = 1.7
})
exports['qb-target']:AddBoxZone("Pokemon2", vector3(-143.97, 229.66, 94.95), 1, 1, {
name="Pokemon2",
heading=0,
debugPoly=false,
minZ=93.95,
maxZ=95.75
}, {
options = {
{
event = "qb-shops:marketshop",
icon = "Fas Fa-Globe",
label = "Buy Cards",
},
},
distance = 1.7
})