Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.
ESX = nil
local GUI = {}
local PlayerData = {}
local lastVehicle = nil
local lastOpen = false
GUI.Time = 0
local vehiclePlate = {}
local arrayWeight = Config.localWeight
local CloseToVehicle = false
local entityWorld = nil
local globalplate = nil
local lastChecked = 0
Citizen.CreateThread(
function()
while ESX == nil do
TriggerEvent(
"esx:getSharedObject",
function(obj)
ESX = obj
end
)
Citizen.Wait(0)
end
end
)
RegisterNetEvent("esx:playerLoaded")
AddEventHandler(
"esx:playerLoaded",
function(xPlayer)
PlayerData = xPlayer
TriggerServerEvent("esx_trunk_inventory:getOwnedVehicule")
lastChecked = GetGameTimer()
end
)
AddEventHandler(
"onResourceStart",
function()
PlayerData = xPlayer
TriggerServerEvent("esx_trunk_inventory:getOwnedVehicule")
lastChecked = GetGameTimer()
end
)
RegisterNetEvent("esx:setJob")
AddEventHandler(
"esx:setJob",
function(job)
PlayerData.job = job
end
)
RegisterNetEvent("esx_trunk_inventory:setOwnedVehicule")
AddEventHandler(
"esx_trunk_inventory:setOwnedVehicule",
function(vehicle)
vehiclePlate = vehicle
--print("vehiclePlate: ", ESX.DumpTable(vehiclePlate))
end
)
function getItemyWeight(item)
local weight = 0
local itemWeight = 0
if item ~= nil then
itemWeight = Config.DefaultWeight
if arrayWeight[item] ~= nil then
itemWeight = arrayWeight[item]
end
end
return itemWeight
end
function VehicleInFront()
local pos = GetEntityCoords(GetPlayerPed(-1))
local entityWorld = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0.0, 4.0, 0.0)
local rayHandle = CastRayPointToPoint(pos.x, pos.y, pos.z, entityWorld.x, entityWorld.y, entityWorld.z, 10, GetPlayerPed(-1), 0)
local a, b, c, d, result = GetRaycastResult(rayHandle)
return result
end
function openmenuvehicle()
local playerPed = GetPlayerPed(-1)
local coords = GetEntityCoords(playerPed)
local vehicle = VehicleInFront()
globalplate = GetVehicleNumberPlateText(vehicle)
if not IsPedInAnyVehicle(playerPed) then
myVeh = false
local thisVeh = VehicleInFront()
PlayerData = ESX.GetPlayerData()
for i = 1, #vehiclePlate do
local vPlate = all_trim(vehiclePlate[i].plate)
local vFront = all_trim(GetVehicleNumberPlateText(thisVeh))
--print('vPlate: ',vPlate)
--print('vFront: ',vFront)
--if vehiclePlate[i].plate == GetVehicleNumberPlateText(vehFront) then
if vPlate == vFront then
myVeh = true
elseif lastChecked < GetGameTimer() - 60000 then
TriggerServerEvent("esx_trunk_inventory:getOwnedVehicule")
lastChecked = GetGameTimer()
Wait(500)
for i = 1, #vehiclePlate do
local vPlate = all_trim(vehiclePlate[i].plate)
local vFront = all_trim(GetVehicleNumberPlateText(thisVeh))
if vPlate == vFront then
myVeh = true
end
end
end
end
if not Config.CheckOwnership or (Config.AllowPolice and PlayerData.job.name == "police") or (Config.CheckOwnership and myVeh) then
if globalplate ~= nil or globalplate ~= "" or globalplate ~= " " then
CloseToVehicle = true
local vehFront = VehicleInFront()
local x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
local closecar = GetClosestVehicle(x, y, z, 4.0, 0, 71)
if vehFront > 0 and closecar ~= nil and GetPedInVehicleSeat(closecar, -1) ~= GetPlayerPed(-1) then
lastVehicle = vehFront
local model = GetDisplayNameFromVehicleModel(GetEntityModel(closecar))
local locked = GetVehicleDoorLockStatus(closecar)
local class = GetVehicleClass(vehFront)
ESX.UI.Menu.CloseAll()
if ESX.UI.Menu.IsOpen("default", GetCurrentResourceName(), "inventory") then
SetVehicleDoorShut(vehFront, 5, false)
else
if locked == 1 or class == 15 or class == 16 or class == 14 then
SetVehicleDoorOpen(vehFront, 5, false, false)
ESX.UI.Menu.CloseAll()
if globalplate ~= nil or globalplate ~= "" or globalplate ~= " " then
CloseToVehicle = true
OpenCoffreInventoryMenu(GetVehicleNumberPlateText(vehFront), Config.VehicleLimit[class], myVeh)
end
else
exports.pNotify:SendNotification(
{
text = _U("trunk_closed"),
type = "error",
timeout = 3000,
layout = "bottomCenter",
queue = "trunk"
}
)
end
end
else
exports.pNotify:SendNotification(
{
text = _U("no_veh_nearby"),
type = "error",
timeout = 3000,
layout = "bottomCenter",
queue = "trunk"
}
)
end
lastOpen = true
GUI.Time = GetGameTimer()
end
else
-- Not their vehicle
exports.pNotify:SendNotification(
{
text = _U("nacho_veh"),
type = "error",
timeout = 3000,
layout = "bottomCenter",
queue = "trunk"
}
)
end
end
end
local count = 0
-- Key controls
Citizen.CreateThread(
function()
while true do
Wait(0)
if IsControlJustReleased(0, Config.OpenKey) and (GetGameTimer() - GUI.Time) > 1000 then
openmenuvehicle()
GUI.Time = GetGameTimer()
end
end
end
)
Citizen.CreateThread(
function()
while true do
Wait(0)
local pos = GetEntityCoords(GetPlayerPed(-1))
if CloseToVehicle then
local vehicle = GetClosestVehicle(pos["x"], pos["y"], pos["z"], 2.0, 0, 70)
if DoesEntityExist(vehicle) then
CloseToVehicle = true
else
CloseToVehicle = false
lastOpen = false
ESX.UI.Menu.CloseAll()
SetVehicleDoorShut(lastVehicle, 5, false)
end
end
end
end
)
RegisterNetEvent("esx:playerLoaded")
AddEventHandler(
"esx:playerLoaded",
function(xPlayer)
PlayerData = xPlayer
TriggerServerEvent("esx_trunk_inventory:getOwnedVehicule")
lastChecked = GetGameTimer()
end
)
function OpenCoffreInventoryMenu(plate, max, myVeh)
ESX.TriggerServerCallback(
"esx_trunk:getInventoryV",
function(inventory)
text = _U("trunk_info", plate, (inventory.weight / 1000), (max / 1000))
data = {plate = plate, max = max, myVeh = myVeh, text = text}
TriggerEvent("esx_inventoryhud:openTrunkInventory", data, inventory.blackMoney, inventory.items, inventory.weapons)
end,
plate
)
end
function all_trim(s)
if s then
return s:match "^%s*(.*)":match "(.-)%s*$"
else
return "noTagProvided"
end
end
function dump(o)
if type(o) == "table" then
local s = "{ "
for k, v in pairs(o) do
if type(k) ~= "number" then
k = '"' .. k .. '"'
end
s = s .. "[" .. k .. "] = " .. dump(v) .. ","
end
return s .. "} "
else
return tostring(o)
end
end
denedim fakat maalesef çözüm olmadı. Halen bu tarz hatalar alıyorum. Bu local 'xPlayer' dediği ne oluyor, tüm hatalar bundan kaynaklanıyor. Bu sorunu nasıl çözebileceğimi bilen yok mu?Son gelen güncellemelerde ESX Framework'nün Belirli kod yapısı değiştirildi.
Scriptlerinizi güncellerseniz sorun ortadan kalkacaktır diye düşünüyorum.
RegisterNetEvent('checkD')
AddEventHandler('checkD', function()
local xPlayer = ESX.GetPlayerFromId(source)
local meth = xPlayer.getInventoryItem('meth_pooch').count -----------------------------------------> 173. satır
local coke = xPlayer.getInventoryItem('coke_pooch').count
local weed = xPlayer.getInventoryItem('weed_pooch').count
local opium = xPlayer.getInventoryItem('opium_pooch').count
if meth >= 1 or coke >= 1 or weed >= 1 or opium >= 1 then
TriggerClientEvent("checkR", source, true)
else
TriggerClientEvent("checkR", source, false)
end
end)
RegisterServerEvent("esx_trunk_inventory:getOwnedVehicule")
AddEventHandler(
"esx_trunk_inventory:getOwnedVehicule",
function()
local vehicules = {}
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
MySQL.Async.fetchAll(
"SELECT * FROM owned_vehicles WHERE owner = @owner",
{
["@owner"] = xPlayer.identifier ----------------------------------------> 30. SATIR
},
function(result)
if result ~= nil and #result > 0 then
for _, v in pairs(result) do
local vehicle = json.decode(v.vehicle)
table.insert(vehicules, {plate = vehicle.plate})
end
end
TriggerClientEvent("esx_trunk_inventory:setOwnedVehicule", _source, vehicules)
end
)
end
)
AddEventHandler('onMySQLReady', function ()
local result = MySQL.Sync.fetchAll('SELECT * FROM addon_account')
for i=1, #result, 1 do
local name = result[i].name
local label = result[i].label
local shared = result[i].shared
local result2 = MySQL.Sync.fetchAll(
'SELECT * FROM addon_account_data WHERE account_name = @account_name',
{
['@account_name'] = name
}
)
if shared == 0 then
table.insert(AccountsIndex, name)
Accounts[name] = {}
for j=1, #result2, 1 do
local addonAccount = CreateAddonAccount(name, result2[j].owner, result2[j].money)
table.insert(Accounts[name], addonAccount)
end
else
local money = nil
if #result2 == 0 then
MySQL.Sync.execute(
'INSERT INTO addon_account_data (account_name, money, owner) VALUES (@account_name, @money, NULL)',
{ -----------------------------------------------------------------------------------------------------------> 47. SATIR
['@account_name'] = name,
['@money'] = 0
}
)
money = 0
else
money = result2[1].money
end
local addonAccount = CreateAddonAccount(name, nil, money)
SharedAccounts[name] = addonAccount
end
end
end)
mysql-async yi güncelle
Maalesef yine çözüm olmadı aynı hataları tekrardan alıyorum. Bunuda burdan indirdim:async yi güncellemeyi denermisin?
Forumdan daha fazla yararlanmak için giriş yapın veya kayıt olun!