Cze??,
Posiadam dashboard i jest tam opcja "Pojazdy"
i gdy klikniemy to wy?wietlaj? nam si? jakie auta kupione posiadamy, jest te? zrobiona funkcja na lokalizacje auta ale chyba nie dzia?aj?ca, gdy? pisze N/A, nawet je?li auto jest wyj?te lub jest w przechowywalni, co musz? zrobi? aby to naprawi??
W kodzie chcesz, aby po podj?ciu warto?? logiczn? zrobi? dane dzia?anie... lecz skrypt nie wie co skrywa si? pod warto?ci? v.parking. Dlatego oddaje Ci N/A, bo tak jest domy?lnie ustawione przez Ciebie.
Musisz pokaza? pe?ny skrypt, brakuje mi tu kod. R?wnie? jakby? m?g? pokaza? przynajmniej jedn? p?l danych w MySQL. (Z t? kt?r? si? ??czy i s? zapisywane dane)
Dzia?a, po podmienieniu tej linijki w twoj?, gdy pojazd jest w przechowywalni, pisze ?e auta tam s?. Jednak?e nadal gdy auto jest wyj?te z przecho i jest gdziekolwiek, nie ma lokalizacji
Kod z ogrpg-vehicles:
local pozwolone = {[453] = true, [509] = true, [481] = true, [510] = true}
local nlIDX = {3962, 2113, 1784, 2054, 2428, 2352}
local nlOffsets = {
[411] = {-1,0,-0.6}, -- infernus
[470] = {-1,0,-0.4}, -- patriot
[541] = {-0.9,0,-0.4}, -- bulelt
[549] = {-0.9,0,-0.4}, -- tampa
[587] = {-1,0,-0.5}, -- euros
}
function onRespawnVehicles(_, id, position, player, warpTo)
if id then result = exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_vehicles WHERE parking=1 and not(police=1) AND id=?", id) query = exports["ogrpg-db"]:dbSet("UPDATE ogrpg_vehicles SET parking=0 WHERE id=?", id) else result = exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_vehicles WHERE parking=0 and not(police=1)") end
for k,vehicle in pairs(result) do
if id then pos = {position[1], position[2], position[3], position[4], position[5], position[6]} else pos = split(vehicle["pos"], ",") end
local color = split(vehicle["color"], ",")
local lights = split(vehicle["headlights"], ",")
local veh = Vehicle(vehicle["model"], pos[1], pos[2], pos[3], pos[4], pos[5], pos[6])
veh:setColor(color[1], color[2], color[3], color[4],color[5], color[6], color[7], color[8],color[9], color[10], color[11], color[12])
if vehicle["plateText"] ~= "" then veh.plateText = vehicle["plateText"] else veh.plateText = tostring("SA "..vehicle["id"]) end
if vehicle["paintjob"] ~= 3 then setVehiclePaintjob(veh, vehicle["paintjob"]) end
veh:setHeadLightColor(lights[1], lights[2], lights[3])
veh.frozen = ((vehicle["frozen"]) > 0)
veh.dimension = 0
veh.health = vehicle["health"]
veh:setData("vehicle:spawn", true)
veh:setData("vehicle:id", vehicle["id"])
veh:setData("vehicle:fuel", vehicle["fuel"])
--veh:setData("vehicle:desc", vehicle["text"] or false)
if string.len(vehicle["text"]) > 1 then
exports["iyw_vehtexts"]:add3DTextForElement(veh,{0,0,0},tostring(vehicle["text"]),{255,255,255,255},"czcionka4",1.0,30,1)
end
veh:setData("vehicle:mileage", vehicle["mileage"])
veh:setData("vehicle:driver", vehicle["driver"])
veh:setData("vehicle:ownedGroup", vehicle["ownedGroup"])
veh:setData("vehicle:ownedPlayer", vehicle["ownedPlayer"])
veh:setData("vehicle:engine_upgrade_one", vehicle["mk1"])
veh:setData("vehicle:engine_upgrade_two", vehicle["mk2"])
veh:setData("vehicle:suspension", vehicle["rh"])
veh:setData("vehicle:drive", vehicle["naped"])
veh:setData("vehicle:capacity", vehicle["capacity"])
local mk1 = vehicle["mk1"]
local mk2 = vehicle["mk2"]
local xfour = vehicle["naped"]
local model = vehicle["model"]
if getElementData(veh, "vehicle:capacity") == "1.2" then
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+0)
elseif getElementData(veh, "vehicle:capacity") == "1.4" then
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+0.1)
elseif getElementData(veh, "vehicle:capacity") == "1.6" then
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+0.2)
elseif getElementData(veh, "vehicle:capacity") == "1.8" then
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+0.3)
elseif getElementData(veh, "vehicle:capacity") == "2.0" then
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+0.4)
elseif getElementData(veh, "vehicle:capacity") == "2.2" then
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+0.5)
elseif getElementData(veh, "vehicle:capacity") == "2.4" then
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+0.6)
elseif getElementData(veh, "vehicle:capacity") == "2.6" then
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+0.7)
elseif getElementData(veh, "vehicle:capacity") == "2.8" then
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+0.8)
elseif getElementData(veh, "vehicle:capacity") == "3.0" then
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+0.9)
elseif getElementData(veh, "vehicle:capacity") == "3.2" then
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+1.1)
elseif getElementData(veh, "vehicle:capacity") == "3.4" then
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+1.2)
elseif getElementData(veh, "vehicle:capacity") == "3.6" then
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+1.3)
elseif getElementData(veh, "vehicle:capacity") == "3.8" then
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+1.4)
end
if tonumber(xfour) == 1 then
setVehicleHandling(veh, "driveType", "awd")
end
if tonumber(mk1) ~= 0 then
local handling = getModelHandling(tonumber(model))
local fast = handling["engineAcceleration"]
local maxfast = handling["maxVelocity"]
setVehicleHandling(veh, "engineAcceleration", fast+2.5)
setVehicleHandling(veh, "maxVelocity", maxfast+20)
end
if tonumber(mk2) ~= 0 then
local handling = getModelHandling(tonumber(model))
local fast = handling["engineAcceleration"]
local maxfast = handling["maxVelocity"]
setVehicleHandling(veh, "engineAcceleration", fast+5)
setVehicleHandling(veh, "maxVelocity", maxfast+40)
end
if (type(vehicle["rent"]) == "string") then
local tabelka = {}
if tonumber(vehicle["removehood"]) == 1 then veh:setData("vehicle:bonnet", true) end
if tonumber(vehicle["masked"]) ~= 0 then veh:setData("vehicle:masked", vehicle["masked"]) end
for k,v in ipairs(split(vehicle["rent"], ",")) do
tabelka[#tabelka+1] = v
end
veh:setData("vehicle:rent", tabelka or false)
else
veh:setData("vehicle:rent",0)
end
veh:setData("neony", vehicle["neon"])
for i,v in ipairs(split(vehicle["tuning"], ",")) do veh:addUpgrade(v) end
for i,v in ipairs(split(vehicle["panelstates"], ",")) do setVehiclePanelState(veh, i, tonumber(v)) end
setVehicleFuelTankExplodable(veh, false)
veh.damageProof = true
if warpTo then
fadeCamera(player, false, 1, 0, 0, 0)
setTimer(function()
warpPedIntoVehicle(player, veh)
end, 1500, 1)
setTimer(fadeCamera, 2000, 1, player, true, 1)
end
end
end
function onSaveVehicle(vehicle)
if vehicle and vehicle:getData("vehicle:spawn") then
local model = vehicle.model
local health = vehicle.health
local x,y,z = getElementPosition(vehicle)
local rx,ry,rz = getElementRotation(vehicle)
local desc = exports["iyw_vehtexts"]:get3DTextForElement(vehicle) or ""
local id = vehicle:getData("vehicle:id")
local fuel = vehicle:getData("vehicle:fuel")
local mileage = vehicle:getData("vehicle:mileage")
local c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12 = vehicle:getColor(true)
local driver= vehicle:getData("vehicle:driver") or ""
local rent = vehicle:getData("vehicle:rent")
local player = vehicle:getData("vehicle:ownedPlayer")
local blokada = vehicle:getData("vehicle:block")
local neon = vehicle:getData("neony")
local h1,h2,h3 = vehicle:getHeadLightColor()
local paintjob = vehicle.paintjob
local mask = vehicle:getData("vehicle:masked") or 0
local mk1 = vehicle:getData("vehicle:engine_upgrade_one")
local mk2 = vehicle:getData("vehicle:engine_upgrade_two")
local naped = vehicle:getData("vehicle:suspension")
local rh = vehicle:getData("vehicle:drive")
local capacity = vehicle:getData("vehicle:capacity")
local frozen = vehicle.frozen and 1 or 0
local rear = "Brak"
local panelstates = {}
local upgrades = vehicle.upgrades
for i=0,6 do panelstates[#panelstates+1] = vehicle:getPanelState(i) end
panelstates = table.concat(panelstates,",")
if not upgrades then upgrades = {} end
upgrades = table.concat(upgrades, ",")
local query = exports["ogrpg-db"]:dbSet(string.format("UPDATE ogrpg_vehicles SET model='%d', pos='%.2f,%.2f,%.2f,%.2f,%.2f,%.2f', rent='%d',text='%s', masked='%d', health='%d', fuel='%d', mileage='%d', frozen='%d', driver='%s', color='%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d', panelstates='%s', paintjob='%d', tuning='%s', headlights='%d,%d,%d', ownedPlayer='%d', neon='%d', blokada='%s', mk1='%d', mk2='%d', naped='%d', rh='%d', capacity='%s' WHERE id=%d", model, x,y,z, rx,ry,rz, "0",desc, mask,health, fuel, mileage, frozen, driver, c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12, panelstates, paintjob, upgrades, h1,h2,h3, player, neon, tostring(blokada), mk1, mk2, naped, rh, capacity, id))
if (type(rent) == "table") then
local query2= exports["ogrpg-db"]:dbSet("UPDATE ogrpg_vehicles SET rent=? WHERE id=?", string.format("%s", table.concat(rent, ",")), id)
end
end
end
addEventHandler("onResourceStart", resourceRoot, function()
onRespawnVehicles(_, false)
end)
function onParkVehicle(vehicle)
local query = exports["ogrpg-db"]:dbSet("UPDATE ogrpg_vehicles SET parking=1 WHERE id=?", vehicle:getData("vehicle:id"))
if query then
local zneony = vehicle:getData("zneony")
if zneony and type(zneony) == "table" then
zneony[1]:destroy()
zneony[2]:destroy()
vehicle:removeData("zneony")
end
vehicle:destroy()
end
end
addEventHandler("onVehicleExit", root, function(plr, seat)
if not source or seat ~= 0 then return false end
if source:getData("vehicle:masked") then
plr.name = plr:getData("player:old:nick")
end
onSaveVehicle(source)
source.engineState = false
source.damageProof = true
unbindKey(plr, "h", "down", bindHoron4)
end)
addEventHandler("onPlayerQuit", root, function()
local vehicle = source.vehicle
if vehicle then
source.damageProof = true
onSaveVehicle(vehicle)
end
end)
addEventHandler("onResourceStop", resourceRoot, function()
for i,v in ipairs(Element.getAllByType("vehicle")) do
onSaveVehicle(v)
local zneony = v:getData("zneony")
if zneony and type(zneony) == "table" then
zneony[1]:destroy()
zneony[2]:destroy()
v:removeData("zneony")
end
end
end)
addEventHandler("onVehicleEnter", root, function(plr, seat)
if not source or seat ~= 0 then return false end
if source:getData("vehicle:masked") then
plr:setData("player:old:nick", plr.name)
plr.name = string.format("#040707%s", string.gsub(plr.name, "#%x%x%x%x%x%x", ""))
end
source.engineState = false
source:setData("vehicle:driver", plr.name)
if source:getData("neony") and source:getData("neony") ~= 0 then
triggerClientEvent(plr, "onClientAddNotification", plr, "Posiadasz neony w poje?dzie, mo?esz w??czy? i wy?aczyc je za pomoc? przycisku H.", "info")
bindKey(plr, "h", "down", bindHoron4, plr)
end
end)
addEventHandler("onVehicleStartEnter", root, function(plr, seat, jacked)
if source.health < 302 then source.health = 302 end
if jacked then
if source:getData("vehicle:ownedPlayer") == plr:getData("player:uid") then return false end
cancelEvent()
end
if seat == 0 then
if source:getData("spawnowany") then
if not plr:getData("player:admin") then
cancelEvent()
end
end
if not pozwolone[source.model] then
if categoryA[source.model] then
if exports["ogrpg-prace-settings"]:getVehicleLicense(plr, "A") then
cancelEvent()
end
elseif categoryB[source.model] then
if exports["ogrpg-prace-settings"]:getVehicleLicense(plr, "B") then
cancelEvent()
end
elseif categoryC[source.model] then
if exports["ogrpg-prace-settings"]:getVehicleLicense(plr, "C") then
cancelEvent()
end
end
end
local rent = source:getData("vehicle:rent")
local group = source:getData("vehicle:ownedGroup")
local player = source:getData("vehicle:ownedPlayer")
if group == "0" then group = "Brak" end
if getAdmin2(plr, 4) then return end
if rent and (type(rent) == "table") then
for i,s in pairs(rent) do
if tonumber(s) == plr:getData("player:uid") then return end
end
end
local plrgroup = plr:getData("player:organization")
if plrgroup then if getSettings(plr, false, "organization") == group then return end end
if player and player ~= getSettings(plr, false, "owner") then
triggerClientEvent(plr, "onClientAddNotification", plr, "Ten pojazd nie nale?y do Ciebie!", "error")
cancelEvent()
end
end
end)
addEvent("neonfix",true)
addEventHandler("neonfix", resourceRoot, function(vehicle, distance)
if not vehicle then return end
if not distance then return end
montujneony(vehicle, distance)
end)
function hasNeon(vehicle)
if not vehicle then return end
if vehicle:getData("zneony") then
return true
else
return false
end
end
function montujneony(vehicle, distance)
local rodzajneonu = tonumber(vehicle:getData("neony"))
if not vehicle or not distance or not rodzajneonu or hasNeon(vehicle) then return false end
if rodzajneonu == 0 then
return plr:outputChat("* Brak Neonow.", 255, 0 ,0)
end
local zDis = distance
local position = {getElementPosition(vehicle)}
local rotation = {getElementRotation(vehicle)}
local rDis = getVehicleHandling(vehicle).suspensionLowerLimit
local neon1 = Object(nlIDX[rodzajneonu], position[1], position[2], position[3])
local neon2 = Object(nlIDX[rodzajneonu], position[1], position[2], position[3])
setElementRotation(neon1, rotation[1], rotation[2], rotation[3])
setElementRotation(neon2, rotation[1], rotation[2], rotation[3])
neon1:attach(vehicle, 0.8, 0, -(zDis+rDis))
neon2:attach(vehicle, -0.8, 0, -(zDis+rDis))
vehicle:setData("zneony", {neon1, neon2})
end
function bindHoron4(plr)
local vehicle = plr.vehicle
local rodzajneonu = tonumber(vehicle:getData("neony"))
if not vehicle or not rodzajneonu then return false end
if rodzajneonu == 0 then
return outputChatBox('* Brak Neonow.', plr, 255, 0 ,0)
end
local zneony = vehicle:getData("zneony")
if (zneony and type(zneony) == "table") then
zneony[1]:destroy()
zneony[2]:destroy()
vehicle:removeData("zneony")
else
triggerClientEvent(plr, "neonfix", resourceRoot)
end
end
addEventHandler("onElementDestroy", root, function()
if source.type == "vehicle" then
local zneony = source:getData("zneony")
if zneony and type(zneony) == "table" then
zneony[1]:destroy()
zneony[2]:destroy()
v:removeData("zneony")
end
if source:getData("vehicle:masked") then
for i,v in pairs(source.occupants) do
v.name = v:getData("player:old:nick")
end
end
end
end)
addEventHandler("onVehicleStartEnter", root, function(plr,seat,jacked)
if seat ~= 0 or source:getData("multiseat") or pozwolone[source.model] then return end
if not categoryL[source.model] then
local result = exports["ogrpg-db"]:pobierzWyniki(string.format("SELECT * FROM ogrpg_punish WHERE type=%q AND active=1 AND serial=%q AND time>NOW() LIMIT 1","prawko", plr.serial))
if result then
triggerClientEvent(plr, "onClientAddNotification", plr, "Posiadasz zawieszone prawo jazdy do\n"..result["time"].." za "..result["reason"], "error")
cancelEvent()
else
exports["ogrpg-db"]:dbSet("DELETE FROM ogrpg_punish WHERE type=? AND active=1 AND serial=?", "prawko", plr.serial)
end
else
local result = exports["ogrpg-db"]:pobierzWyniki(string.format("SELECT * FROM ogrpg_punish WHERE type=%q AND active=1 AND serial=%q AND time>NOW() LIMIT 1","L", plr.serial))
if result then
triggerClientEvent(plr, "onClientAddNotification", plr, "Posiadasz zawieszon? licencj? lotnicz? do\n"..result["time"].." za "..result["reason"], "error")
cancelEvent()
else
exports["ogrpg-db"]:dbSet("DELETE FROM ogrpg_punish WHERE type=? AND active=1 AND serial=?", "L", plr.serial)
end
end
end, true, "low-1")
addEventHandler("onVehicleEnter", root, function(plr,seat,jacked)
if seat ~= 0 or source:getData("mutiseat") or pozwolone[source.model] then return end
if not categoryL[source.model] then
local result = exports["ogrpg-db"]:pobierzWyniki(string.format("SELECT * FROM ogrpg_punish WHERE type=%q AND active=1 AND serial=%q AND time>NOW() LIMIT 1","prawko", plr.serial))
if result then
Timer(setControlState, 800, 1, plr, "enter_exit", true)
Timer(setControlState, 1800, 1, plr, "enter_exit", false)
triggerClientEvent(plr, "onClientAddNotification", plr, "Posiadasz zawieszone prawo jazdy do\n"..result["time"].." za "..result["reason"], "error")
else
exports["ogrpg-db"]:dbSet("DELETE FROM ogrpg_punish WHERE type=? AND active=1 AND serial=?", "prawko", plr.serial)
end
else
local result = exports["ogrpg-db"]:pobierzWyniki(string.format("SELECT * FROM ogrpg_punish WHERE type=%q AND active=1 AND serial=%q AND time>NOW() LIMIT 1","L", plr.serial))
if result then
Timer(setControlState, 800, 1, plr, "enter_exit", true)
Timer(setControlState, 1800, 1, plr, "enter_exit", false)
triggerClientEvent(plr, "onClientAddNotification", plr, "Posiadasz zawieszon? licencj? lotnicz? do\n"..result["time"].." za "..result["reason"], "error")
else
exports["ogrpg-db"]:dbSet("DELETE FROM ogrpg_punish WHERE type=? AND active=1 AND serial=?", "L", plr.serial)
end
end
end, true, "low-1")
Bo to efekt sklejania pierdyliarda serwer?w w jeden. Nie zgadzaj? si? dan? z tabeli, kt?r? pobierasz a tym co chcesz sprawdzi?. Mo?e by? przeanalizowa? kod (nie napisz?, ?e 'sw?j') i dowiedzia? si? jak on po kolei dzia?a.
Dzi?kuje, dla ciebie.
Nadal pr?buj? si? nauczy? lua ale te? chce naprawi? pozosta?e skrypty w kt?rych jest b??d a je?li w?a?nie tego nie umiem to pisz? tutaj
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach