Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2020-01-06, 19:46


krixpl







Wiek: 24
Na forum: 2957 dni
Posty: 83
Nick w MP: Krix

Piwa: 656

Respekt: 36,3

Witam.Przychodz? dzi? do was z ma?ym problemem.A chodzi tu o system pojazd?w kt?ry nie dzia?a poprawnie.My?la?em ?e sam si? z tym uporam ale po 2 godzinach sobie odpu?ci?em bo ju? nie mia?em pomys??w. Screen z db3 : https://imgur.com/a/G5yzuXi

A tutaj dorzucam system pojazd?w :
Kod:

vehicles=0
root=getRootElement()
resourceRoot=getResourceRootElement(getThisResource())

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
}

local nlIDX={
3962,2113,1784,2054,2428,2352
}
function getAdmin2(plr,level)
if level then
local result=exports["pystories-db"]:dbGet("SELECT * from pystories_admins WHERE serial=? AND level=?", getPlayerSerial(plr), level)
if result and #result > 0 then
return true
else
return false
end
else
local result=exports["pystories-db"]:dbGet("SELECT * from pystories_admins WHERE serial=?", getPlayerSerial(plr))
if result and #result > 0 then
return true
else
return false
end
end
end
--///////////////////////////////////// WCZYTYWANIE POJAZD?W /////////////////////////////////
function getVehicleHandlingProperty ( element, property )
if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then
local handlingTable = getVehicleHandling ( element )
local value = handlingTable[property]

if value then
return value
end
end

return false
end

function onRespawnVehicles(_,id,poss)
-- Settings (QUERY)
if id then
result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_vehicles WHERE parking=1 AND id=?", id)
query=exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET parking=0 WHERE id=?", id)
else
result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_vehicles WHERE parking=0")
end

-- Pairs
for ile,vehicle in pairs(result) do
vehicles=ile

if id then pos={poss[1], poss[2], poss[3], poss[4], poss[5], poss[6]}
else pos=split(vehicle["pos"], ",") end

local color=split(vehicle["color"], ",")
local lights=split(vehicle["headlights"], ",")

local veh=createVehicle(vehicle["model"], pos[1], pos[2], pos[3], pos[4], pos[5], pos[6])
setVehicleColor(veh, color[1], color[2], color[3], color[4],color[5], color[6], color[7], color[8],color[9], color[10], color[11], color[12])
setVehicleHeadLightColor(veh, lights[1], lights[2], lights[3])
if vehicle["plateText"] ~= "" then
setVehiclePlateText(veh, vehicle["plateText"])
else
setVehiclePlateText(veh, tostring("SA "..vehicle["id"]))
end
setElementFrozen(veh, (vehicle["frozen"]) > 0)
if vehicle["paintjob"] ~= 3 then
setVehiclePaintjob(veh, vehicle["paintjob"])
end
setElementHealth(veh, vehicle["health"])
setElementData(veh,"vehicle:spawn",true)
setElementData(veh,"vehicle:id", vehicle["id"])
setElementData(veh,"vehicle:fuel", vehicle["fuel"])
setElementData(veh,"vehicle:desc", vehicle["text"] or false)
setElementData(veh,"vehicle:mileage", vehicle["mileage"])
setElementData(veh,"vehicle:driver", vehicle["driver"])
setElementData(veh,"vehicle:ownedGroup", vehicle["ownedGroup"])
setElementData(veh,"vehicle:komis", vehicle["komis"])
setElementData(veh,"vehicle:ownedPlayer", vehicle["ownedPlayer"])
setElementData(veh,"vehicle:LPG", vehicle["gaz"])
setElementData(veh,"Zamontowane:LPG", vehicle["GazZamont"])
setElementData(veh,"licznik:kolor", vehicle["licznik"])
setElementData(veh,"Zawieszenie:Pneumatyczne", vehicle["zawieszenie"])
setElementData(veh,"vehicle:drzwidogury", vehicle["drzwi"])
setElementData(veh,"vehicle:tempomat", vehicle["tempomat"])
setElementData(veh,"vehicle:cb", vehicle["cb"])
setElementData(veh,"vehicle:ogranicznik", vehicle["ogranicznik"])
setElementData(veh,"vehicle:rodzaj", vehicle["rodzaj"])
setElementData(veh,"Pojemnosc:silnika", vehicle["silnik"])
setElementData(veh, "vehicle:bak", vehicle["bak"])
setElementData(veh, "vehicle:up1", vehicle["up1"])
setElementData(veh, "vehicle:up2", vehicle["up2"])
setElementData(veh, "vehicle:up3", vehicle["up3"])
setElementData(veh, "vehicle:naped", vehicle["naped"])
local Pojemnosc = getElementData(veh,"Pojemnosc:silnika") or "1.6"
local silnik12 = vehicle['silnik']
local silnik14 = vehicle['silnik']
local silnik16 = vehicle['silnik']
local silnik18 = vehicle['silnik']
local silnik20 = vehicle['silnik']
local silnik22 = vehicle['silnik']
local silnik24 = vehicle['silnik']

if (silnik12) == '1.2' then
local fast = getVehicleHandlingProperty(veh,"engineAcceleration")
local maxfast = getVehicleHandlingProperty(veh,"maxVelocity")
setVehicleHandling(veh,"engineAcceleration",fast -0.5)
setVehicleHandling(veh,"maxVelocity",maxfast -20)
end

if (silnik14) == '1.4' then
local fast = getVehicleHandlingProperty(veh,"engineAcceleration")
local maxfast = getVehicleHandlingProperty(veh,"maxVelocity")
setVehicleHandling(veh,"engineAcceleration",fast -0.3)
setVehicleHandling(veh,"maxVelocity",maxfast -15)
end

if (silnik16) == '1.6' then
local fast = getVehicleHandlingProperty(veh,"engineAcceleration")
local maxfast = getVehicleHandlingProperty(veh,"maxVelocity")
setVehicleHandling(veh,"engineAcceleration",fast +0.01)
setVehicleHandling(veh,"maxVelocity",maxfast +0.01)
end

if (silnik18) == '1.8' then
local fast = getVehicleHandlingProperty(veh,"engineAcceleration")
local maxfast = getVehicleHandlingProperty(veh,"maxVelocity")
setVehicleHandling(veh,"engineAcceleration",fast +2.5)
setVehicleHandling(veh,"maxVelocity",maxfast +15)
end

if (silnik20) == '2.0' then
local fast = getVehicleHandlingProperty(veh,"engineAcceleration")
local maxfast = getVehicleHandlingProperty(veh,"maxVelocity")
setVehicleHandling(veh,"engineAcceleration",fast +3.0)
setVehicleHandling(veh,"maxVelocity",maxfast +16)
end

if (silnik22) == '2.2' then
local fast = getVehicleHandlingProperty(veh,"engineAcceleration")
local maxfast = getVehicleHandlingProperty(veh,"maxVelocity")
setVehicleHandling(veh,"engineAcceleration",fast +3.5)
setVehicleHandling(veh,"maxVelocity",maxfast +17)
end

if (silnik24) == '2.4' then
local fast = getVehicleHandlingProperty(veh,"engineAcceleration")
local maxfast = getVehicleHandlingProperty(veh,"maxVelocity")
setVehicleHandling(veh,"engineAcceleration",fast +4.0)
setVehicleHandling(veh,"maxVelocity",maxfast +19)
end
if getElementData(veh, "vehicle:up1") and getElementData(veh, "vehicle:up1") == 1 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setVehicleHandling(veh, "engineAcceleration", acceleration+2)
setVehicleHandling(veh, "maxVelocity", velocity+10)
end
if getElementData(veh, "vehicle:up2") and getElementData(veh, "vehicle:up2") == 1 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setVehicleHandling(veh, "engineAcceleration", acceleration+3)
setVehicleHandling(veh, "maxVelocity", velocity+15)
end
if getElementData(veh, "vehicle:up3") and getElementData(veh, "vehicle:up3") == 1 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setVehicleHandling(veh, "engineAcceleration", acceleration+4)
setVehicleHandling(veh, "maxVelocity", velocity+20)
end
if getElementData(veh,"vehicle:rodzaj") == "Elektryk" then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
local steering = getVehicleHandling(veh).steeringLock
local drag = getVehicleHandling(veh).dragCoeff
if getElementModel(veh) == 411 then
setVehicleHandling(veh, "engineAcceleration", nil)
setVehicleHandling(veh, "maxVelocity", nil)
setVehicleHandling(veh, "steeringLock", nil)
setVehicleHandling(veh, "dragCoeff", nil)
setVehicleHandling(veh, "engineAcceleration", acceleration+20)
setVehicleHandling(veh, "maxVelocity", velocity-19)
setVehicleHandling(veh, "steeringLock", steering+40)
setVehicleHandling(veh, "dragCoeff", drag-0.15)
elseif getElementModel(veh) == 533 then
setVehicleHandling(veh, "engineAcceleration", nil)
setVehicleHandling(veh, "maxVelocity", nil)
setVehicleHandling(veh, "steeringLock", nil)
setVehicleHandling(veh, "dragCoeff", nil)
setVehicleHandling(veh, "engineAcceleration", acceleration+20)
setVehicleHandling(veh, "maxVelocity", velocity-19)
setVehicleHandling(veh, "steeringLock", steering+20)
setVehicleHandling(veh, "dragCoeff", drag-0.55)
elseif getElementModel(veh) == 426 then
setVehicleHandling(veh, "engineAcceleration", nil)
setVehicleHandling(veh, "maxVelocity", nil)
setVehicleHandling(veh, "steeringLock", nil)
setVehicleHandling(veh, "dragCoeff", nil)
setVehicleHandling(veh, "engineAcceleration", acceleration+20)
setVehicleHandling(veh, "maxVelocity", velocity-11)
setVehicleHandling(veh, "steeringLock", steering+20)
setVehicleHandling(veh, "dragCoeff", drag-0.55)
elseif getElementModel(veh) == 555 then
setVehicleHandling(veh, "engineAcceleration", nil)
setVehicleHandling(veh, "maxVelocity", nil)
setVehicleHandling(veh, "steeringLock", nil)
setVehicleHandling(veh, "dragCoeff", nil)
setVehicleHandling(veh, "engineAcceleration", acceleration+20)
setVehicleHandling(veh, "maxVelocity", velocity-10)
setVehicleHandling(veh, "steeringLock", steering+20)
setVehicleHandling(veh, "dragCoeff", drag-0.55)
end
end
--[[
if getElementData(veh,"vehicle:up1") == 1 then
setVehicleHandling(veh, "engineAcceleration", przysp+2)
setVehicleHandling(veh, "maxVelocity", fast+10)
setVehicleHandling(veh, "steeringLock", 40)
end ]]
if getElementData(veh, "vehicle:naped") == "AWD" then
setVehicleHandling(veh, "driveType", "awd")
elseif getElementData(veh, "vehicle:naped") == "RWD" then
setVehicleHandling(veh, "driveType", "rwd")
elseif getElementData(veh, "vehicle:naped") == "FWD" then
setVehicleHandling(veh, "driveType", "fwd")
end

if getElementData(veh, "vehicle:rodzaj") == "LPG" then
setVehicleHandling(veh, "maxVelocity", getVehicleHandling(veh).maxVelocity-5)
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+1)
setVehicleHandling(veh, "engineType", "electric")
elseif getElementData(veh, "vehicle:rodzaj") == "Diesel" then
setVehicleHandling(veh, "maxVelocity", getVehicleHandling(veh).maxVelocity+5)
setVehicleHandling(veh, "engineAcceleration", getVehicleHandling(veh).engineAcceleration+1.5)
setVehicleHandling(veh, "engineType", "diesel")
elseif getElementData(veh, "vehicle:rodzaj") == "Benzyna" then
setVehicleHandling(veh, "engineType", "petrol")
end

local drziwdogora = getElementData(veh,"vehicle:drzwidogury")
if drziwdogora == 'Tak' then
setElementData(veh, "tuning.lsdDoor", true)
end
if (type(vehicle['rent']) == "string") then
local tabelka = {}
local rente = split(vehicle['rent'], ',')
for k,v in ipairs(rente) do
table.insert(tabelka,v)
end
setElementData(veh,"vehicle:rent", tabelka or false)
else
setElementData(veh,"vehicle:rent",0)
end
--[[ if vehicle["rearlights"] ~= "" then
setElementData(veh,"vehicle:light", vehicle["rearlights"])
else
setElementData(veh,"vehicle:light", "High Quality")
end]]--
local mask = vehicle['masked']
if tonumber(mask) ~= 0 then
setElementData(veh,"vehicle:masked",vehicle['masked'])
end
setElementData(veh,"neony", vehicle["neon"])
if vehicle["blokada"] == "true" then
setElementData(veh,"vehicle:block", true)
setVehicleWheelStates(veh, 2, 2, 2, 2)
else
setElementData(veh,"vehicle:block", false)
end
local rodzajneonu=tonumber(getElementData(veh,"neony"))
if getElementData(veh,"neony") ~= 0 then
local m = getElementModel(veh)
local of
if not nlOffsets[m] then
of={-1,0,-0.5}
else
of=nlOffsets[m]
end
neon1=createObject(nlIDX[rodzajneonu],0,0,0)
neon2=createObject(nlIDX[rodzajneonu],0,0,0)
setElementData(veh,"zneony", {neon1, neon2})
attachElements(neon1,veh,of[1],of[2],of[3])
attachElements(neon2,veh,-of[1],of[2],of[3])
end

for i,v in ipairs(split(vehicle["tuning"], ",")) do addVehicleUpgrade(veh, v) end
for i,v in ipairs(split(vehicle["panelstates"], ",")) do setVehiclePanelState(veh, i, tonumber(v)) end
setVehicleDamageProof(veh, true)
setElementData(veh, "vehicle:BezynaWloczone", true)
setElementFrozen(veh,false)
end
outputDebugString("[og-vehicles] Wczytano "..vehicles.." pojazdow.")
end

--///////////////////////////////////// ZAPISYWANIE POJAZD?W /////////////////////////////////
function onSaveVehicle(vehicle)
if getElementData(vehicle,"vehicle:spawn") then
-- Setting
local panelstates={}
local model=getElementModel(vehicle)
local health=getElementHealth(vehicle)
local x,y,z=getElementPosition(vehicle)
local rx,ry,rz=getElementRotation(vehicle)
local desc=getElementData(vehicle,"vehicle:desc") or ""
local id=getElementData(vehicle,"vehicle:id")
local fuel=getElementData(vehicle,"vehicle:fuel")
local mileage=getElementData(vehicle,"vehicle:mileage")
local c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12=getVehicleColor(vehicle, true)
local driver=getElementData(vehicle,"vehicle:driver") or ""
local gaz=getElementData(vehicle,"vehicle:LPG")
local silnik=getElementData(vehicle,"Pojemnosc:silnika") or "1.6"
local licznik=getElementData(vehicle,"licznik:kolor") or "Zwykly"
local GazZamont=getElementData(vehicle,"Zamontowane:LPG") or "Brak"
local zawieszenie=getElementData(vehicle,"Zawieszenie:Pneumatyczne") or "Brak"
local drzwi=getElementData(vehicle,"vehicle:drzwidogury") or "Nie"
local tempomat=getElementData(vehicle,"vehicle:tempomat") or "0"
local cb=getElementData(vehicle,"vehicle:cb") or "0"
local ogranicznik=getElementData(vehicle,"vehicle:ogranicznik") or "0"
local rodzaj=getElementData(vehicle,"vehicle:rodzaj")
local rent=getElementData(vehicle,"vehicle:rent")
local player=getElementData(vehicle,"vehicle:ownedPlayer")
-- local group=getElementData(vehicle,"vehicle:ownedGroup")
local blokada=getElementData(vehicle,"vehicle:block")
local neon=getElementData(vehicle,"neony")
local h1,h2,h3=getVehicleHeadLightColor(vehicle)
local paintjob=getVehiclePaintjob(vehicle)
local rear="Brak"
local mask=getElementData(vehicle,"vehicle:masked") or 0
local frozen= isElementFrozen(vehicle) and 1 or 0
for i=0,6 do table.insert(panelstates, getVehiclePanelState(vehicle,i)) end
panelstates=table.concat(panelstates,",")
upgrades=getVehicleUpgrades(vehicle)
if not upgrades then upgrades={} end
upgrades=table.concat(upgrades, ",")
-- Query
local query = exports["pystories-db"]:dbSet(string.format("UPDATE pystories_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', silnik='%s', gaz='%d', GazZamont='%s', zawieszenie='%s', drzwi='%s',tempomat='%d',cb='%d',ogranicznik='%d',rodzaj='%s', licznik='%s', blokada='%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, silnik, gaz, GazZamont, zawieszenie, drzwi,tempomat,cb,ogranicznik,rodzaj, licznik, tostring(blokada), id))
if (type(rent) == "table") then
local rr = string.format("%s", table.concat(rent, ',') )
-- outputDebugString(rr)
local query2= exports['pystories-db']:dbSet("UPDATE pystories_vehicles SET rent=? WHERE id=?",rr,id)
end
end
end

function createNewVehicle(id)
local query= exports["pystories-db"]:dbGet("SELECT * FROM pystories_vehicles WHERE id=?", id)
--local veh = onRespawnVehicles(query[1])
--return veh
end

--////////////////DALSZE USTAWIENIA ///////////////////


function onParkVehicle(vehicle)
local query=exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET parking=1 WHERE id=?", getElementData(vehicle,"vehicle:id"))
if query then
local zneony=getElementData(vehicle,"zneony")
if (zneony and type(zneony)=="table") then
destroyElement(zneony[1])
destroyElement(zneony[2])
removeElementData(vehicle,"zneony")
end
destroyElement(vehicle)
end
end
--///////////////////////////////////// SPRAWDZANIE USTAWIE? /////////////////////////////////
function getSettings(plr,code,value)
local sid=getElementData(plr,"player:sid")
if not sid then return end
if value == "faction" then
local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_factions WHERE code=? AND sid=?", code, sid)
if result and #result > 0 then
return result[1].code
else
return false
end
end
if value == "organization" then
local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_organizations WHERE sid=?",sid)
if result and #result > 0 then
return result[1].code
else
return false
end
end
if value == "owner" then
local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_users WHERE id=?", sid)
if result and #result > 0 then
return result[1].id
else
return false
end
end
end

--///////////////////////////////////// INNE USTAWIENIA /////////////////////////////////
addEventHandler("onVehicleExit", root, function(plr,seat)
if seat ~= 0 then return end
onSaveVehicle(source)
setVehicleDamageProof(source, true)
unbindKey(plr, 'h', 'down', bindHoron4)
end)

addEventHandler("onPlayerQuit", root, function()
local veh=getPedOccupiedVehicle(source)
if veh then
setVehicleDamageProof(source, true)
onSaveVehicle(veh)
end
end)

addEventHandler("onResourceStop", resourceRoot, function()
for i,v in ipairs(getElementsByType("vehicle")) do
onSaveVehicle(v)
local zneony=getElementData(v,"zneony")
if (zneony and type(zneony)=="table") then
destroyElement(zneony[1])
destroyElement(zneony[2])
removeElementData(v,"zneony")
end
end
outputDebugString("[NightRPG-pojazdy] Zapisano wszystkie auta!")
end)

addEventHandler("onVehicleEnter", root, function(plr,seat)
if seat ~= 0 then return end
local zawiesze = getElementData(source,"Zawieszenie:Pneumatyczne")
if zawiesze == 'Tak' then
outputChatBox("* Posiadasz zawieszenie pneumatyczne, mo?esz je regulowa? komend? /zawieszenie 1-5", plr, 255,255,255)
return
end
end)

addCommandHandler("zawieszenie", function(player, command, level)
if getPedOccupiedVehicle(player) then
local vehicle = getPedOccupiedVehicle(player)
if getVehicleOccupant(vehicle) == player then
zawiesze = getElementData(vehicle,"Zawieszenie:Pneumatyczne")
if not zawiesze == 'Tak' then
outputChatBox("* Nie posiadasz zamontowanego zawieszenia pneumatyczego!", player, 255,0,0)
return
end
if zawiesze == 'Tak' then
if tonumber(level) >= 0 and tonumber(level) <= 5 then
if isTimer(airRideActive) then
return
end

-- triggerClientEvent(player, "playAirRideSound", player, vehicle)
setElementFrozen(vehicle, true)

airRideActive = setTimer(function()
if tonumber(level) == 0 then
setVehicleHandling(vehicle, "suspensionLowerLimit", getOriginalHandling(getElementModel(vehicle))["suspensionLowerLimit"])
elseif tonumber(level) == 1 then
setVehicleHandling(vehicle, "suspensionLowerLimit", 0.01)
elseif tonumber(level) == 2 then
setVehicleHandling(vehicle, "suspensionLowerLimit", -0.1)
elseif tonumber(level) == 3 then
setVehicleHandling(vehicle, "suspensionLowerLimit", -0.2)
elseif tonumber(level) == 4 then
setVehicleHandling(vehicle, "suspensionLowerLimit", -0.3)
elseif tonumber(level) == 5 then
setVehicleHandling(vehicle, "suspensionLowerLimit", -0.45)
end

setElementFrozen(vehicle, false)
end, 3000, 1)
end
end
end
end
end)

addEventHandler("onVehicleEnter", root, function(plr,seat)
if seat ~= 0 then return end
setElementData(source,"vehicle:driver",getPlayerName(plr))
if getElementData(source,"neony") and getElementData(source,"neony") ~= 0 then
triggerClientEvent(plr,"addNotification",root,"* Posiadasz neony w pojezdzie, mo?esz wl?czy? i wylaczyc je za pomoc? przycisku H.","info")
bindKey(plr, 'h', 'down', bindHoron4, plr)
end
end)
--///////////////////////////////////// SPRAWDZENIE W?A?CICIELA /////////////////////////////////---[[
addEventHandler("onVehicleStartEnter", resourceRoot, function(plr,seat,jacked)
if seat == 0 then
local rent=getElementData(source, "vehicle:rent")
local group=getElementData(source, "vehicle:ownedGroup")
if group == "0" then group = "Brak" end
local player=getElementData(source, "vehicle:ownedPlayer")
if getAdmin2(plr, 3) then
return
end
if rent and (type(rent) == "table") then
for i,s in pairs(rent) do
if tonumber(s) == getElementData(plr,"player:sid") then
return end
end
end

local plrgroup = getElementData(plr,"player:organization")
if plrgroup then
--outputDebugString(group)
if getSettings(plr,false,"organization") == group then return end
end
if player and player ~= getSettings(plr,false,"owner") then
triggerClientEvent(plr,"addNotification",root,"* Nie masz kluczyk?w do tego pojazdu.","error")
cancelEvent()
end
end
end)


addEventHandler("onVehicleStartEnter", root, function(plr,seat,jacked)
if seat == 0 then
if getElementData(source,"spawnowany")== true then
if getElementData(plr,"player:admin")== false then
cancelEvent()
end
end
end
end)

addEventHandler("onElementDestroy", getRootElement(), function ()
if getElementType(source) == "vehicle" then
local zneony=getElementData(source,"zneony")
if (zneony and type(zneony)=="table") then
destroyElement(zneony[1])
destroyElement(zneony[2])
removeElementData(source,"zneony")
end
end
end)


addEventHandler("onResourceStart", resourceRoot, function() onRespawnVehicles(_,false) end)

function shuffle(t)
local n = #t

while n >= 2 do
-- n is now the last pertinent index
local k = math.random(n) -- 1 <= k <= n
-- Quick swap
t[n], t[k] = t[k], t[n]
n = n - 1
end
return t
end

local function vr()

local pojazdy=getElementsByType("vehicle")

if (#pojazdy<1) then return end

local pojazdwoda={}
for _,pojazd in ipairs(pojazdy) do
if isElementInWater(pojazd) and not getVehicleController(pojazd) then
local x,y,z=getElementPosition(pojazd)
if (z<-1) then
table.insert(pojazdwoda,pojazd)
end
end
end
if (#pojazdwoda<1) then return end

outputDebugString("Pojazdow w wodzie/pod mapa: " .. #pojazdwoda)

shuffle(pojazdwoda)

local pojazd=pojazdwoda[1]
if getElementData(pojazd, "vehicle:spawn") then
onParkVehicle(pojazd)
else
respawnVehicle(pojazd)
end
end
setTimer(vr, 35000, 0)

--//////////////////////////////////////////////////////// Licencje

local categoryA={[463] = true,[462] = true,[461] = true,[581] = true,[448] = true,[468] = true,[471] = true,[521] = true,[522] = true,[523] = true}
local categoryB={[602] = true,[545] = true,[496] = true,[517] = true,[401] = true,[410] = true,[518] = true,[600] = true,[527] = true,[436] = true,[589] = true,[580] = true,[419] = true,[439] = true,[533] = true,[549] = true,[526] = true,[491] = true,[474] = true,[445] = true,[467] = true,[604] = true,[426] = true,[507] = true,[547] = true,[585] = true,[405] = true,[587] = true,[409] = true,[466] = true,[550] = true,[492] = true,[566] = true,[546] = true,[540] = true,[551] = true,[421] = true,[516] = true,[529] = true,[488] = true,[460] = true,
[469] = true,[487] = true,[510] = true,[509] = true,[481] = true,[586] = true,[472] = true,[473] = true,[493] = true,[595] = true,[484] = true,[430] = true,[453] = true,[452] = true,[446] = true,[454] = true,[485] = true,[552] = true,
[438] = true,[574] = true,[420] = true,[525] = true,[408] = true,[596] = true,[597] = true,[427] = true,[599] = true,[490] = true,[432] = true,[528] = true,[601] = true,[407] = true,[544] = true,[470] = true,[598] = true,[588] = true,
[532] = true,[443] = true,[486] = true,[531] = true,[543] = true,[422] = true,[583] = true,[478] = true,[605] = true,[554] = true,[530] = true,[418] = true,[572] = true,[582] = true,[536] = true,[575] = true,[534] = true,
[567] = true,[535] = true,[576] = true,[412] = true,[402] = true,[542] = true,[603] = true,[475] = true,[449] = true,[537] = true,[570] = true,[441] = true,[464] = true,[501] = true,[465] = true,[564] = true,[568] = true,[557] = true,[424] = true,[504] = true,[495] = true,[457] = true,[539] = true,[483] = true,[571] = true,[500] = true,
[444] = true,[556] = true,[429] = true,[411] = true,[541] = true,[559] = true,[415] = true,[561] = true,[480] = true,[560] = true,[562] = true,[506] = true,[565] = true,[451] = true,[434] = true,[558] = true,[494] = true,[555] = true,[502] = true,[477] = true,[503] = true,[579] = true,[400] = true,[404] = true,[489] = true,[505] = true,[479] = true,[442] = true,[458] = true,
[606] = true,[607] = true,[610] = true,[590] = true,[569] = true,[611] = true,[584] = true,[608] = true,[435] = true,[450] = true,[591] = true,[594] = true}
local categoryC={[403] = true,[406] = true,[413] = true,[414] = true,[416] = true,[423] = true,[428] = true,[431] = true,[433] = true,[437] = true,[440] = true,[455] = true,[456] = true,[459] = true,[482] = true,[498] = true,[499] = true,[508] = true,[514] = true,[515] = true,[524] = true,[538] = true,[573] = true}

addEventHandler("onVehicleStartEnter", resourceRoot, function(plr,seat,jacked)
if seat == 0 then
if categoryA[getElementModel(source)] then
if exports["pystories-ustawienia-prac"]:getVehicleLicense(plr,"A", "prawa jazdy kat.", "Twoje prawo jazdy jest zawieszone", "je w urz?dzie miasta") then
cancelEvent()
end
elseif categoryB[getElementModel(source)] then
if exports["pystories-ustawienia-prac"]:getVehicleLicense(plr,"B", "prawa jazdy kat.", "Twoje prawo jazdy jest zawieszone", "je w urz?dzie miasta") then
cancelEvent()
end
elseif categoryC[getElementModel(source)] then
if exports["pystories-ustawienia-prac"]:getVehicleLicense(plr,"C", "prawa jazdy kat.", "Twoje prawo jazdy jest zawieszone", "je w urz?dzie miasta") then
cancelEvent()
end
elseif categoryL[getElementModel(source)] then
if exports["pystories-ustawienia-prac"]:getVehicleLicense(plr,"L", "licencji lotniczej", "Twoja licencja lotnicza jest zawieszona", "j? na opuszczonym lotnisku LV") then
cancelEvent()
end
end
end
end)


addEventHandler("onVehicleEnter", getRootElement(), function(plr,seat,jacked)
if seat ~= 0 then return end
if getElementData(source, "vehicle:id") and getElementData(source, "vehicle:spawn") then
local up2 = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND up2=?",getElementData(source, "vehicle:id"), "1")
local up1 = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND up1=?",getElementData(source, "vehicle:id"), "1")
local zawieszenie = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND zawieszenie=?",getElementData(source, "vehicle:id"), "1")
local naped = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND naped=?",getElementData(source, "vehicle:id"), "1")
end
end)


local categoryL={592,553,577,488,511,497,548,563,512,476,593,447,425,519,520,460,417,469,487,513}

-- Tutaj dalsza cze?c kodu
addEventHandler("onVehicleStartEnter", getRootElement(), function(plr,seat,jacked)
if seat ~= 0 then return end
local queryA=string.format("SELECT * FROM pystories_punish WHERE type=%q AND active=1 AND serial=%q AND time>NOW() LIMIT 1","A", getPlayerSerial(plr))
local resultA=exports["DB2"]:pobierzWyniki(queryA)
if (resultA) then
cancelEvent()
outputChatBox("* Posiadasz zawieszone prawo jazdy do "..resultA["time"]..", za: "..resultA["reason"], plr, 255, 0, 0)
else
exports["pystories-db"]:dbSet("DELETE FROM pystories_punish WHERE type=? AND active=1 AND serial=?", "A", getPlayerSerial(plr))
end
end)

addEventHandler("onVehicleEnter", getRootElement(), function(plr,seat,jacked)
if seat ~= 0 then return end
local queryA=string.format("SELECT * FROM pystories_punish WHERE type=%q AND active=1 AND serial=%q AND time>NOW() LIMIT 1","A", getPlayerSerial(plr))
local resultA=exports["DB2"]:pobierzWyniki(queryA)
if (resultA) then
setControlState ( plr, "enter_exit", true )
setTimer(toggleControl, 3000, 1, plr,"enter_exit", true)
outputChatBox("* Posiadasz zawieszone prawo jazdy do "..resultA["time"]..", za: "..resultA["reason"], plr, 255, 0, 0)
else
exports["pystories-db"]:dbSet("DELETE FROM pystories_punish WHERE type=? AND active=1 AND serial=?", "A", getPlayerSerial(plr))
end
end)


Z g?ry dzi?kuj?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-01-06, 19:52


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Wska? t? linijk?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-01-06, 21:27


krixpl







Wiek: 24
Na forum: 2957 dni
Posty: 83
Nick w MP: Krix

Piwa: 656

Respekt: 36,3

"Wilq" napisał/a:

Wska? t? linijk?.


Kod:

local query = exports["pystories-db"]:dbSet(string.format("UPDATE pystories_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', silnik='%s', gaz='%d', GazZamont='%s', zawieszenie='%s', drzwi='%s',tempomat='%d',cb='%d',ogranicznik='%d',rodzaj='%s', licznik='%s', blokada='%s' WHERE id=%d",


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-01-06, 21:32


xyzzzikk

.gg






Wiek: 18
Na forum: 2774 dni
Posty: 175
Nick w MP: aspyk

Piwa: 6499

Respekt: 30,5

"krixpl" napisał/a:

"Wilq" napisał/a:

Wska? t? linijk?.


Kod:

local query = exports["pystories-db"]:dbSet(string.format("UPDATE pystories_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', silnik='%s', gaz='%d', GazZamont='%s', zawieszenie='%s', drzwi='%s',tempomat='%d',cb='%d',ogranicznik='%d',rodzaj='%s', licznik='%s', blokada='%s' WHERE id=%d",


Kolego, co ty spodziewa?e? si? po PYSie? Pys by?, i b?dzie zbugowany. Mo?e powiedz o co chodzi wgl?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-01-07, 20:29


krixpl







Wiek: 24
Na forum: 2957 dni
Posty: 83
Nick w MP: Krix

Piwa: 656

Respekt: 36,3

Poda?em co jest zepsute

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-01-07, 22:22


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Problem ze zmienn? licznik. Zobaccz szybko w runcode co masz pod elementDat? "licznik:kolor".
Skrypt oczekuje tekstu, a prawdopodobnie ustawiasz true / false.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-01-09, 08:22


krixpl







Wiek: 24
Na forum: 2957 dni
Posty: 83
Nick w MP: Krix

Piwa: 656

Respekt: 36,3

Dobra naprawi?em. Do zamkni?cia.

Postaw piwo autorowi tego posta
 

 
Tagi: system :: pojazdów :: nie :: działa :: poprawnie
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

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
Dodaj temat do Ulubionych
Wersja do druku