Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W.I.P ESX Branch #6

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
## Dependencies ##
### QBCore - https://github.com/qbcore-framework/qb-core ###
### qb-inventory - https://github.com/qbcore-framework/qb-inventory ### Any other inventory should work with this update now
### es_extended & esx_menu_default - https://github.com/esx-framework/esx-legacy ###
### Interactsound - https://github.com/plunkettscott/interact-sound ###
### menuv - https://github.com/qbcore-framework/menuv ###

## Must have below added to qb-inventory for the box to have its own stash (This stash holds anything with 0 weight so make sure to have anything else that weighs 0 = 1 or something.) ##

## If using another inventory ##

# For shared.lua #
```lua
Expand Down
176 changes: 104 additions & 72 deletions client.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
local assert = assert
local MenuV = assert(MenuV)
local isDead = false

local CardShops = {
['Cardshop'] = {
location = vector3(174.08, -1321.79, 29.36),
},
}

AddEventHandler('esx:onPlayerDeath', function(data)
isDead = true
end)

function CreateBlips()
for k, v in pairs(Config.Badge) do
local blip = AddBlipForCoord(v.location)
Expand Down Expand Up @@ -35,8 +38,8 @@ function CreateBlips()
end
end

Citizen.CreateThread(function()
CreateBlips()
CreateThread(function()
CreateBlips()
end)

function DisplayTooltip(suffix)
Expand All @@ -45,7 +48,7 @@ function DisplayTooltip(suffix)
EndTextCommandDisplayHelp(0, 0, 1, -1)
end

Citizen.CreateThread(function()
CreateThread(function()
while true do
Wait(1)
local sleep = true
Expand All @@ -70,7 +73,7 @@ Citizen.CreateThread(function()
sleep = false
DisplayTooltip('Trade for a '..v.label)
if IsControlJustPressed(1, 38) then
TriggerServerEvent('Cards:server:badges', k)
TriggerServerEvent('Cards:server:badges', k)
end
end
end
Expand All @@ -80,56 +83,87 @@ 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)
while (not HasAnimDictLoaded("mp_arresting")) do
Wait(0)
end

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)
Wait(5)
TriggerServerEvent("InteractSound_SV:PlayOnSource", "boxopen", 0.8)
ESX.Progressbar("opening box..", 9500,{
FreezePlayer = true,
animation ={
type = "anim",
dict = "mp_arresting",
lib ="a_uncuff"
},
onFinish = function()
Wait(1)
DeleteEntity(propbox)
ClearPedTasks(PlayerPedId())
end)
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)
while (not HasAnimDictLoaded("mp_arresting")) do
Wait(0)
end
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)
ESX.Progressbar("opening pack..", 3000,{
FreezePlayer = true,
animation ={
type = "anim",
dict = "mp_arresting",
lib ="a_uncuff"
},
onFinish = function()
TriggerServerEvent("InteractSound_SV:PlayOnSource", "dealfour", 0.9)
Wait(500)
SetNuiFocus(true, true)
SendNUIMessage({
open = true,
class = 'open',
})
DeleteEntity(propcards)
ClearPedTasks(PlayerPedId())
TriggerServerEvent('Cards:Server:RemoveItem')
end})
end)

RegisterNetEvent("Cards:Client:OpenPack")
AddEventHandler("Cards:Client:OpenPack", function()
RequestAnimDict("mp_arresting")
while (not HasAnimDictLoaded("mp_arresting")) do
Wait(0)
end
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)
ESX.Progressbar("opening pack..", 3000,{
FreezePlayer = true ,
animation ={
type = "anim",
dict = "mp_arresting",
lib ="a_uncuff"
},
onFinish = function()
TriggerServerEvent("InteractSound_SV:PlayOnSource", "dealfour", 0.9)
Wait(500)
SetNuiFocus(true, true)
SendNUIMessage({
open = true,
class = 'open',
})
DeleteEntity(propcards)
ClearPedTasks(PlayerPedId())
TriggerServerEvent('Cards:Server:RemoveItem')
end})
end)

RegisterNUICallback('Rewardpokemon', function(data)
Expand Down Expand Up @@ -157,52 +191,50 @@ 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
ESX.ShowNotifcation("Box is being opened...")
ESX.Progressbar("Box is being opened", 5000,{
FreezePlayer = true,
animation ={
type = "anim",
dict = "clothingshirt",
lib ="try_shirt_positive_d"
},
onFinish = function()
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("inventory:server:OpenInventory", "stash", "poke_"..QBCore.Functions.GetPlayerData().citizenid, {maxweight = 0.1, slots = 160}) -- Convert
-- TriggerEvent("inventory:client:SetCurrentStash", "poke_"..QBCore.Functions.GetPlayerData().citizenid) -- Convert
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)
ESX.ShowNotifcation("Box has been opened successfully")
Wait(10000)
DeleteEntity(deckbox)
ClearPedTasks(PlayerPedId())
end)
end})
end)


Citizen.CreateThread(function()
CreateThread(function()
while true do
Citizen.Wait(2500)
local PlayerData = QBCore.Functions.GetPlayerData()
Wait(2500)
local PlayerData = ESX.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
if dist < 2.5 and not isDead 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)
Wait(1000)
ESX.TriggerServerCallback("Cards:server:Menu",function(item,amount)
print(item,amount)
end)
end
Expand Down Expand Up @@ -234,7 +266,7 @@ end)

menu_button:On('select', function(item)
menu2:ClearItems(true)
QBCore.Functions.TriggerCallback('Cards:server:get:drugs:items', function(CardsResult)
ESX.TriggerServerCallback('Cards:server:get:drugs:items', function(CardsResult)
for k, v in pairs(CardsResult) do
local itemName = v['Item']
local itemCount = v['Amount']
Expand Down
19 changes: 9 additions & 10 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,23 @@ ui_page "html/index.html"
fx_version "cerulean"
game "gta5"

shared_script "@qb-core/import.lua"
shared_scripts {
'@es_extended/imports.lua',
'config.lua'
}

client_scripts {
'@menuv/menuv.lua',
'config.lua',
'client.lua'
}

server_scripts {
'config.lua',
'server.lua',
}
server_script 'server.lua'

files {
'html/index.html',
'html/img/*.png',
'html/script.js',
'html/style.css',
'html/index.html',
'html/img/*.png',
'html/script.js',
'html/style.css',
}

dependencies {
Expand Down
18 changes: 9 additions & 9 deletions html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let flippedcard4 = false;

document.onkeyup = function (data) {
if (data.which == 27) { // Escape
$.post('https://qb-pokemontcg/CloseNui')
$.post('https://esx-pokemontcg/CloseNui')
setTimeout(() => { $('.cards').css("display", "none"); }, 2000);
$('.cards').animate({"top": "100%"}, 450)

Expand Down Expand Up @@ -57,11 +57,11 @@ $(document).on('click', '.card', function(e){
var card = document.querySelector('.card');
if (flippedcard1 === false) {
card.classList.toggle('is-flipped');
$.post('https://qb-pokemontcg/randomCard');
$.post('https://esx-pokemontcg/randomCard');

setTimeout(() => {
document.getElementById("myImg").src = "img/" + pokemon + ".png";
$.post('https://qb-pokemontcg/Rewardpokemon', JSON.stringify({
$.post('https://esx-pokemontcg/Rewardpokemon', JSON.stringify({
Pokemon: pokemon,
}))
}, 200);
Expand All @@ -75,11 +75,11 @@ $(document).on('click', '.card2', function(e){
var card = document.querySelector('.card2');
if (flippedcard2 === false) {
card.classList.toggle('is-flipped');
$.post('https://qb-pokemontcg/randomCard');
$.post('https://esx-pokemontcg/randomCard');

setTimeout(() => {
document.getElementById("myImg2").src = "img/" + pokemon + ".png";
$.post('https://qb-pokemontcg/Rewardpokemon', JSON.stringify({
$.post('https://esx-pokemontcg/Rewardpokemon', JSON.stringify({
Pokemon: pokemon,
}))
}, 200);
Expand All @@ -94,11 +94,11 @@ $(document).on('click', '.card3', function(e){
var card = document.querySelector('.card3');
if (flippedcard3 === false) {
card.classList.toggle('is-flipped');
$.post('https://qb-pokemontcg/randomCard');
$.post('https://esx-pokemontcg/randomCard');

setTimeout(() => {
document.getElementById("myImg3").src = "img/" + pokemon + ".png";
$.post('https://qb-pokemontcg/Rewardpokemon', JSON.stringify({
$.post('https://esx-pokemontcg/Rewardpokemon', JSON.stringify({
Pokemon: pokemon,
}))
}, 200);
Expand All @@ -113,11 +113,11 @@ $(document).on('click', '.card4', function(e){
var card = document.querySelector('.card4');
if (flippedcard4 === false) {
card.classList.toggle('is-flipped');
$.post('https://qb-pokemontcg/randomCard');
$.post('https://esx-pokemontcg/randomCard');

setTimeout(() => {
document.getElementById("myImg4").src = "img/" + pokemon + ".png";
$.post('https://qb-pokemontcg/Rewardpokemon', JSON.stringify({
$.post('https://esx-pokemontcg/Rewardpokemon', JSON.stringify({
Pokemon: pokemon,
}))
}, 200);
Expand Down
Loading