local shopData = nil Keys = { ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 } local Licenses = {} Citizen.CreateThread(function() while ESX == nil do TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) Citizen.Wait(0) end while ESX.GetPlayerData().job == nil do Citizen.Wait(10) end PlayerData = ESX.GetPlayerData() end) RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(xPlayer) ESX.PlayerData = xPlayer end) RegisterNetEvent('esx:setJob') AddEventHandler('esx:setJob', function(job) ESX.PlayerData.job = job end) Citizen.CreateThread(function() while true do Citizen.Wait(0) player = GetPlayerPed(-1) coords = GetEntityCoords(player) if IsInRegularShopZone(coords) or IsInRobsLiquorZone(coords) or IsInFastFoodZone(coords) then if IsInFastFoodZone(coords) then if IsControlJustReleased(0, Keys["E"]) then OpenShopInvFastFood("fastfood") Citizen.Wait(2000) end end if IsInRegularShopZone(coords) then if IsControlJustReleased(0, Keys["E"]) then OpenShopInv("regular") Citizen.Wait(2000) end end if IsInRobsLiquorZone(coords) then if IsControlJustReleased(0, Keys["E"]) then OpenShopInv("robsliquor") Citizen.Wait(2000) end end if IsInYouToolZone(coords) then if IsControlJustReleased(0, Keys["E"]) then OpenShopInv("youtool") Citizen.Wait(2000) end end if IsInPrisonShopZone(coords) then if IsControlJustReleased(0, Keys["E"]) then OpenShopInv("prison") Citizen.Wait(2000) end end if IsInWeaponShopZone(coords) then if IsControlJustReleased(0, Keys["E"]) then if Licenses['weapon'] ~= nil then OpenShopInv("weaponshop") Citizen.Wait(2000) else exports['mythic_notify']:SendAlert('error', 'You need a Fire Arms license before you can buy weapons') end end end end end end) function OpenShopInvFastFood(shoptype) text = "TIENDA" data = {text = text} inventory = {} if (ESX.PlayerData.job.name == 'fastfood') then ESX.TriggerServerCallback("suku:getShopItems", function(shopInv) for i = 1, #shopInv, 1 do table.insert(inventory, shopInv[i]) end end, shoptype) Citizen.Wait(500) TriggerEvent("esx_inventoryhud:openShopInventory", data, inventory) else exports['mythic_notify']:SendAlert('error', ' No Eres Trabajador de FastFood ') end end function OpenShopInv(shoptype) text = "shop" data = {text = text} inventory = {} ESX.TriggerServerCallback("suku:getShopItems", function(shopInv) for i = 1, #shopInv, 1 do table.insert(inventory, shopInv[i]) end end, shoptype) Citizen.Wait(500) TriggerEvent("esx_inventoryhud:openShopInventory", data, inventory) end RegisterNetEvent("suku:OpenCustomShopInventory") AddEventHandler("suku:OpenCustomShopInventory", function(type, shopinventory) text = "shop" data = {text = text} inventory = {} ESX.TriggerServerCallback("suku:getCustomShopItems", function(shopInv) for i = 1, #shopInv, 1 do table.insert(inventory, shopInv[i]) end end, type, shopinventory) Citizen.Wait(500) TriggerEvent("esx_inventoryhud:openShopInventory", data, inventory) end) RegisterNetEvent("esx_inventoryhud:openShopInventory") AddEventHandler("esx_inventoryhud:openShopInventory", function(data, inventory) setShopInventoryData(data, inventory, weapons) openShopInventory() end) function setShopInventoryData(data, inventory) shopData = data SendNUIMessage( { action = "setInfoText", text = data.text } ) items = {} SendNUIMessage( { action = "setShopInventoryItems", itemList = inventory } ) end function openShopInventory() loadPlayerInventory() isInInventory = true SendNUIMessage( { action = "display", type = "shop" } ) SetNuiFocus(true, true) end RegisterNUICallback("TakeFromShop", function(data, cb) if IsPedSittingInAnyVehicle(playerPed) then return end if type(data.number) == "number" and math.floor(data.number) == data.number then TriggerServerEvent("suku:SellItemToPlayer", GetPlayerServerId(PlayerId()), data.item.type, data.item.name, tonumber(data.number)) end Wait(150) loadPlayerInventory() cb("ok") end ) RegisterNetEvent("suku:AddAmmoToWeapon") AddEventHandler("suku:AddAmmoToWeapon", function(hash, amount) AddAmmoToPed(GetPlayerPed(-1), hash, amount) end) function IsInFastFoodZone(coords) FastFood = Config.Shops.FastFood.Locations for i = 1, #FastFood, 1 do if GetDistanceBetweenCoords(coords, FastFood[i].x, FastFood[i].y, FastFood[i].z, true) < 1.5 then return true end end return false end function IsInRegularShopZone(coords) RegularShop = Config.Shops.RegularShop.Locations for i = 1, #RegularShop, 1 do if GetDistanceBetweenCoords(coords, RegularShop[i].x, RegularShop[i].y, RegularShop[i].z, true) < 1.5 then return true end end return false end function IsInRobsLiquorZone(coords) RobsLiquor = Config.Shops.RobsLiquor.Locations for i = 1, #RobsLiquor, 1 do if GetDistanceBetweenCoords(coords, RobsLiquor[i].x, RobsLiquor[i].y, RobsLiquor[i].z, true) < 1.5 then return true end end return false end function IsInYouToolZone(coords) YouTool = Config.Shops.YouTool.Locations for i = 1, #YouTool, 1 do if GetDistanceBetweenCoords(coords, YouTool[i].x, YouTool[i].y, YouTool[i].z, true) < 1.5 then return true end end return false end function IsInPrisonShopZone(coords) PrisonShop = Config.Shops.PrisonShop.Locations for i = 1, #PrisonShop, 1 do if GetDistanceBetweenCoords(coords, PrisonShop[i].x, PrisonShop[i].y, PrisonShop[i].z, true) < 1.5 then return true end end return false end function IsInWeaponShopZone(coords) WeaponShop = Config.Shops.WeaponShop.Locations for i = 1, #WeaponShop, 1 do if GetDistanceBetweenCoords(coords, WeaponShop[i].x, WeaponShop[i].y, WeaponShop[i].z, true) < 1.5 then return true end end return false end Citizen.CreateThread(function() while true do Citizen.Wait(0) player = GetPlayerPed(-1) coords = GetEntityCoords(player) if GetDistanceBetweenCoords(coords, Config.WeaponLiscence.x, Config.WeaponLiscence.y, Config.WeaponLiscence.z, true) < 3.0 then ESX.Game.Utils.DrawText3D(vector3(Config.WeaponLiscence.x, Config.WeaponLiscence.y, Config.WeaponLiscence.z), "Press ~r~[E]~s~ to open shop", 0.6) if IsControlJustReleased(0, Keys["E"]) then if Licenses['weapon'] == nil then OpenBuyLicenseMenu() else exports['mythic_notify']:SendAlert('error', 'You already have a Fire arms license!') end Citizen.Wait(2000) end end end end) RegisterNetEvent('suku:GetLicenses') AddEventHandler('suku:GetLicenses', function (licenses) for i = 1, #licenses, 1 do Licenses[licenses[i].type] = true end end) function OpenBuyLicenseMenu() ESX.UI.Menu.CloseAll() ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_license',{ title = 'Register a License?', elements = { { label = 'yes' ..' ($' .. Config.LicensePrice ..')', value = 'yes' }, { label = 'no', value = 'no' }, } }, function (data, menu) if data.current.value == 'yes' then TriggerServerEvent('suku:buyLicense') end menu.close() end, function (data, menu) menu.close() end) end Citizen.CreateThread(function() player = GetPlayerPed(-1) coords = GetEntityCoords(player) for k, v in pairs(Config.Shops.FastFood.Locations) do if GetDistanceBetweenCoords(coords, Config.Shops.FastFood.Locations[k].x, Config.Shops.FastFood.Locations[k].y, Config.Shops.FastFood.Locations[k].z, true) < 1.7 then DrawText3Ds(vector3(Config.Shops.FastFood.Locations[k].x, Config.Shops.FastFood.Locations[k].y, Config.Shops.FastFood.Locations[k].z + 1.0), "Presiona [E] para abrir la tienda", 0.35) ESX.Game.Utils.DrawText3D(vector3(Config.Shops.YouTool.Locations[k].x, Config.Shops.YouTool.Locations[k].y, Config.Shops.YouTool.Locations[k].z + 1.0), "Presioma [E] para abrir la tienda", 0.4) end end for k, v in pairs(Config.Shops.RegularShop.Locations) do CreateBlip(vector3(Config.Shops.RegularShop.Locations[k].x, Config.Shops.RegularShop.Locations[k].y, Config.Shops.RegularShop.Locations[k].z ), "Convenience Store", 3.0, Config.Color, Config.ShopBlipID) end for k, v in pairs(Config.Shops.RobsLiquor.Locations) do CreateBlip(vector3(Config.Shops.RobsLiquor.Locations[k].x, Config.Shops.RobsLiquor.Locations[k].y, Config.Shops.RobsLiquor.Locations[k].z ), "RobsLiquor", 3.0, Config.Color, Config.LiquorBlipID) end for k, v in pairs(Config.Shops.YouTool.Locations) do CreateBlip(vector3(Config.Shops.YouTool.Locations[k].x, Config.Shops.YouTool.Locations[k].y, Config.Shops.YouTool.Locations[k].z ), "YouTool", 3.0, Config.Color, Config.YouToolBlipID) end for k, v in pairs(Config.Shops.YouTool.Locations) do CreateBlip(vector3(Config.Shops.PrisonShop.Locations[k].x, Config.Shops.PrisonShop.Locations[k].y, Config.Shops.PrisonShop.Locations[k].z), "Prison Commissary", 3.0, Config.Color, Config.PrisonShopBlipID) end for k, v in pairs(Config.Shops.WeaponShop.Locations) do CreateBlip(vector3(Config.Shops.WeaponShop.Locations[k].x, Config.Shops.WeaponShop.Locations[k].y, Config.Shops.WeaponShop.Locations[k].z), "Ammunation", 3.0, Config.WeaponColor, Config.WeaponShopBlipID) end CreateBlip(vector3(-755.79, 5596.07, 41.67), "Cablecart", 3.0, 4, 36) end) Citizen.CreateThread(function() while true do Citizen.Wait(0) player = GetPlayerPed(-1) coords = GetEntityCoords(player) for k, v in pairs(Config.Shops.RegularShop.Locations) do if GetDistanceBetweenCoords(coords, Config.Shops.RegularShop.Locations[k].x, Config.Shops.RegularShop.Locations[k].y, Config.Shops.RegularShop.Locations[k].z, true) < 3.0 then ESX.Game.Utils.DrawText3D(vector3(Config.Shops.RegularShop.Locations[k].x, Config.Shops.RegularShop.Locations[k].y, Config.Shops.RegularShop.Locations[k].z + 1.0), "Press ~r~[E]~s~ to open shop", 0.6) end end for k, v in pairs(Config.Shops.RobsLiquor.Locations) do if GetDistanceBetweenCoords(coords, Config.Shops.RobsLiquor.Locations[k].x, Config.Shops.RobsLiquor.Locations[k].y, Config.Shops.RobsLiquor.Locations[k].z, true) < 3.0 then ESX.Game.Utils.DrawText3D(vector3(Config.Shops.RobsLiquor.Locations[k].x, Config.Shops.RobsLiquor.Locations[k].y, Config.Shops.RobsLiquor.Locations[k].z + 1.0), "Press ~r~[E]~s~ to open shop", 0.6) end end for k, v in pairs(Config.Shops.YouTool.Locations) do if GetDistanceBetweenCoords(coords, Config.Shops.YouTool.Locations[k].x, Config.Shops.YouTool.Locations[k].y, Config.Shops.YouTool.Locations[k].z, true) < 3.0 then ESX.Game.Utils.DrawText3D(vector3(Config.Shops.YouTool.Locations[k].x, Config.Shops.YouTool.Locations[k].y, Config.Shops.YouTool.Locations[k].z + 1.0), "Press ~r~[E]~s~ to open shop", 0.6) end end for k, v in pairs(Config.Shops.PrisonShop.Locations) do if GetDistanceBetweenCoords(coords, Config.Shops.PrisonShop.Locations[k].x, Config.Shops.PrisonShop.Locations[k].y, Config.Shops.PrisonShop.Locations[k].z, true) < 3.0 then ESX.Game.Utils.DrawText3D(vector3(Config.Shops.PrisonShop.Locations[k].x, Config.Shops.PrisonShop.Locations[k].y, Config.Shops.PrisonShop.Locations[k].z), "Press ~r~[E]~s~ to open shop", 0.6) end end for k, v in pairs(Config.Shops.WeaponShop.Locations) do if GetDistanceBetweenCoords(coords, Config.Shops.WeaponShop.Locations[k].x, Config.Shops.WeaponShop.Locations[k].y, Config.Shops.WeaponShop.Locations[k].z, true) < 3.0 then ESX.Game.Utils.DrawText3D(vector3(Config.Shops.WeaponShop.Locations[k].x, Config.Shops.WeaponShop.Locations[k].y, Config.Shops.WeaponShop.Locations[k].z + 1.0), "Press ~r~[E]~s~ to open shop", 0.6) end end end end) function CreateBlip(coords, text, radius, color, sprite) local blip = AddBlipForCoord(coords) SetBlipSprite(blip, sprite) SetBlipColour(blip, color) SetBlipScale(blip, 0.8) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName("STRING") AddTextComponentString(text) EndTextCommandSetBlipName(blip) end DrawText3Ds = function(coords, text, scale) local x,y,z = coords.x, coords.y, coords.z local onScreen, _x, _y = World3dToScreen2d(x, y, z) local pX, pY, pZ = table.unpack(GetGameplayCamCoords()) SetTextScale(scale, scale) SetTextFont(4) SetTextProportional(1) SetTextEntry("STRING") SetTextCentre(1) SetTextColour(255, 255, 255, 215) AddTextComponentString(text) DrawText(_x, _y) local factor = (string.len(text)) / 420 DrawRect(_x, _y + 0.0115, 0.032 + factor, 0.033, 41, 11, 41, 100) end