Sziasztok, a gate systemmel lenne egy kis probléma hogyha elindítom a scriptet akkor ugye lekéne kérje a kapukat sql-ből, de ez nem sikerül neki mert bedob ilyen errort: attempt to index field \'defaultState\' (a nil value) jelen esetben 20.sor
function loadAllGate()
gates = {}
local queryHandler = dbQuery(connection, \"SELECT * FROM gates\")
local result, numAffectedRows, errorMsg = dbPoll(queryHandler, -1)
if numAffectedRows > 0 then
for key, row in ipairs(result) do
local gateId = tonumber(row[\"id\"])
gates[key] = {}
gates[key][\"sqlId\"] = gateId
gates[key][\"modelId\"] = tonumber(row[\"modelId\"])
gates[key][\"lockState\"] = true
gates[key][\"defaultState\"] = fromJSON(row[\"defaultState\"])
gates[key][\"changeState\"] = fromJSON(row[\"changeState\"])
gates[key][\"createRotation\"] = fromJSON(row[\"createRotation\"])
gates[key][\"gate\"] = createObject(gates[key][\"modelId\"], gates[key][\"defaultState\"][1], gates[key][\"defaultState\"][2], gates[key][\"defaultState\"][3], gates[key][\"defaultState\"][4], gates[key][\"defaultState\"][5], gates[key][\"defaultState\"][6])
setElementRotation(gates[key][\"gate\"], gates[key][\"createRotation\"][1], gates[key][\"createRotation\"][2], gates[key][\"createRotation\"][3])
end
end
outputDebugString(gates .. \" gate(s) loaded\")
end
addEventHandler(\"onResourceStart\", resourceRoot, loadAllGate)
hogyha pedig /gate parancsot beírom akkor ilyen errort dob: attempt to compare nil with number jelen esetben a 11.sorban
function getClosestGate(p1)
local x, y, z = getElementPosition(p1)
local dis = 99999
local dis2 = 0
local gate = false
for key, value in ipairs(gates) do
local x2, y2, z2 = getElementPosition(gates[key][\"gate\"])
dis2 = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2)
if tonumber(dis2) < tonumber(dis) and tonumber(dis2) <= 9 then
dis = dis2
gate = key
end
end
return gate
end