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

Wysłany: 2020-12-15, 20:57


DawidekD







Wiek: 31
Na forum: 2372 dni
Posty: 22



Respekt: 50

Witam problem wygl?da tak chce dodac na sw?j serwer warianty i nie dziala ...
oto kod z pystories-vehicle z zapisywania pojazd?w

Kod:

--///////////////////////////////////// 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 rent=getElementData(vehicle,"vehicle:rent") or ''
local player=getElementData(vehicle,"vehicle:ownedPlayer")
local group=getElementData(vehicle,"vehicle:ownedGroup")
local blokada=getElementData(vehicle,"vehicle:block")
local h1,h2,h3=getVehicleHeadLightColor(vehicle)
local paintjob=getVehiclePaintjob(vehicle)
local mask=getElementData(vehicle,"vehicle:masked") or 0
local neon=getElementData(vehicle,"neony")
local rear="Brak"
local frozen= isElementFrozen(vehicle) and 1 or 0
local wariant=getVehicleVariant(vehicle)
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', blokada='%s , wariant='%d', 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), wariant, id))
if (type(rent) == "table") then
local rr = string.format("%s", table.concat(rent, ',') )
local query2= exports['pystories-db']:dbSet("UPDATE pystories_vehicles SET rent=? WHERE id=?",rr,id)
end
end
end

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


Tutaj ss z bazy danych z pystories-vehicle



Tutaj ss z gry z debuga:



Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-15, 21:34


TheSebaPL

Mod-team






Wiek: 21
Na forum: 3098 dni
Posty: 964

Piwa: 3102

Respekt: 640,5
Respekt: 640,5Respekt: 640,5

DawidekD, podaj linijk?: 54 tak?e 60

Tak?e dobrze by by?o jak by? wczytywanie tak?e pokaza? a nie sam zapis.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-15, 21:44


DawidekD







Wiek: 31
Na forum: 2372 dni
Posty: 22



Respekt: 50

"TheSebaPL" napisał/a:

DawidekD, podaj linijk?: 54 tak?e 60

Tak?e dobrze by by?o jak by? wczytywanie tak?e pokaza? a nie sam zapis.


tutaj linijka od 54 do 60

Kod:

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



tutaj caly zapis i wczytywanie


Kod:

--///////////////////////////////////// WCZYTYWANIE POJAZD?“W /////////////////////////////////
function onRespawnVehicles(_,id,poss,buyed,player)
-- 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])
if buyed then
warpPedIntoVehicle(player,veh)
end
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("PL "..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", false)
setElementData(veh,"vehicle:mileage", vehicle["mileage"])
setElementData(veh,"vehicle:driver", vehicle["driver"])
setElementData(veh,"vehicle:ownedGroup", vehicle["ownedGroup"])
setElementData(veh,"vehicle:ownedPlayer", vehicle["ownedPlayer"])
setElementData(veh, "vehicle:pojemnosc", vehicle["pojemnosc_silnika"])


if getElementData(veh, "vehicle:pojemnosc") > 11 then
setElementData(veh, "vehicle:pojemnosc", 11)
end

if getElementData(veh, "vehicle:pojemnosc") == 1 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "1.2")
setVehicleHandling(veh, "engineAcceleration", acceleration+1.3)
elseif getElementData(veh, "vehicle:pojemnosc") == 2 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "1.6")
setVehicleHandling(veh, "engineAcceleration", acceleration+1.5)
elseif getElementData(veh, "vehicle:pojemnosc") == 3 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "1.8")
setVehicleHandling(veh, "maxVelocity", velocity+3)
setVehicleHandling(veh, "engineAcceleration", acceleration+1.8)
elseif getElementData(veh, "vehicle:pojemnosc") == 4 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "2.0")
setVehicleHandling(veh, "maxVelocity", velocity+4)
setVehicleHandling(veh, "engineAcceleration", acceleration+1.9)
elseif getElementData(veh, "vehicle:pojemnosc") == 5 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "2.2")
setVehicleHandling(veh, "maxVelocity", velocity+5)
setVehicleHandling(veh, "engineAcceleration", acceleration+2.0)
elseif getElementData(veh, "vehicle:pojemnosc") == 6 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "2.5")
setVehicleHandling(veh, "maxVelocity", velocity+6)
setVehicleHandling(veh, "engineAcceleration", acceleration+2.2)
elseif getElementData(veh, "vehicle:pojemnosc") == 7 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "2.6")
setVehicleHandling(veh, "maxVelocity", velocity+7)
setVehicleHandling(veh, "engineAcceleration", acceleration+2.4)
elseif getElementData(veh, "vehicle:pojemnosc") == 8 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "2.7")
setVehicleHandling(veh, "maxVelocity", velocity+8)
setVehicleHandling(veh, "engineAcceleration", acceleration+2.5)
elseif getElementData(veh, "vehicle:pojemnosc") == 9 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "2.8")
setVehicleHandling(veh, "maxVelocity", velocity+12)
setVehicleHandling(veh, "engineAcceleration", acceleration+2.6)
elseif getElementData(veh, "vehicle:pojemnosc") == 10 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "2.9")
setVehicleHandling(veh, "maxVelocity", velocity+13)
setVehicleHandling(veh, "engineAcceleration", acceleration+2.7)
elseif getElementData(veh, "vehicle:pojemnosc") == 11 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "3.0")
setVehicleHandling(veh, "maxVelocity", velocity+18)
setVehicleHandling(veh, "engineAcceleration", acceleration+5)
end
local mk1 = vehicle['mk1']
if tonumber(mk1) ~= 0 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setVehicleHandling(veh,"engineAcceleration", acceleration+2)
setVehicleHandling(veh,"maxVelocity", velocity+6)
end
local mk2 = vehicle['mk2']
if tonumber(mk2) ~= 0 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setVehicleHandling(veh,"engineAcceleration", acceleration+4)
setVehicleHandling(veh,"maxVelocity", velocity+8)
end
local mk3 = vehicle['mk3']
if tonumber(mk3) ~= 0 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setVehicleHandling(veh,"engineAcceleration", acceleration+4)
setVehicleHandling(veh,"maxVelocity", velocity+8)
end
local turbo = vehicle['turbo']
if tonumber(turbo) ~= 0 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setVehicleHandling(veh,"engineAcceleration", acceleration+12)
--setVehicleHandling(veh,"maxVelocity", velocity+8)
end
local drift = vehicle['drift']
if tonumber(drift) ~= 0 then
setVehicleHandling(veh,"driveType","rwd")
setVehicleHandling(veh,"dragCoeff",1.59)
end
local naped = vehicle['naped']
if tonumber(naped) ~= 0 then
setVehicleHandling(veh,"driveType","awd")
end
local mask = vehicle['masked']
if tonumber(mask) ~= 0 then
setElementData(veh,"vehicle:masked",vehicle['masked'])
end
local wariant = getElementModel(veh)
if wariant == 429 then
setVehicleVariant(veh, 2, 2)
end
if wariant == 562 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 415 then
setVehicleVariant(veh, 4, 4)
end
if wariant == 477 then
setVehicleVariant(veh, 0, 1)
end
if wariant == 480 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 579 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 559 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 411 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 561 then
setVehicleVariant(veh, 0, 0)
end
setElementData(veh,"neony", vehicle["neon"])
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

if vehicle["blokada"] == "true" then
setElementData(veh,"vehicle:block", true)
setVehicleWheelStates(veh, 2, 2, 2, 2)
else
setElementData(veh,"vehicle:block", false)
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)
end

outputDebugString("[pystories_vehicles] Loaded "..vehicles.." vehicles.")
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 rent=getElementData(vehicle,"vehicle:rent") or ''
local player=getElementData(vehicle,"vehicle:ownedPlayer")
local group=getElementData(vehicle,"vehicle:ownedGroup")
local blokada=getElementData(vehicle,"vehicle:block")
local h1,h2,h3=getVehicleHeadLightColor(vehicle)
local paintjob=getVehiclePaintjob(vehicle)
local mask=getElementData(vehicle,"vehicle:masked") or 0
local neon=getElementData(vehicle,"neony")
local rear="Brak"
local frozen= isElementFrozen(vehicle) and 1 or 0
local wariant=getVehicleVariant(vehicle)
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', blokada='%s , wariant='%d', 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), wariant, id))
if (type(rent) == "table") then
local rr = string.format("%s", table.concat(rent, ',') )
local query2= exports['pystories-db']:dbSet("UPDATE pystories_vehicles SET rent=? WHERE id=?",rr,id)
end
end
end

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


[ Dodano: 2020-12-16, 10:50 ]
TheSebaPL, jeste? ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-16, 11:08


Matikmontana

Modern Stories






Wiek: 22
Na forum: 2473 dni
Posty: 423
Nick w MP: Mazeusz*

Piwa: 1015

Respekt: 130
Respekt: 130

Ostrzeżeń: 60%
Zapisz wariant tak
 v1,v2 getVehicleVariant(vehicle


export do bazy
v1='%d'v2='%d'


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-16, 15:06


DawidekD







Wiek: 31
Na forum: 2372 dni
Posty: 22



Respekt: 50

"Matikmontana" napisał/a:

Zapisz wariant tak
 v1,v2 getVehicleVariant(vehicle


export do bazy
v1='%d'v2='%d'


Pozmieniamy fragment tak jak mi m?wi?e?

Kod:

local blokada=getElementData(vehicle,"vehicle:block")
local h1,h2,h3=getVehicleHeadLightColor(vehicle)
local paintjob=getVehiclePaintjob(vehicle)
local mask=getElementData(vehicle,"vehicle:masked") or 0
local neon=getElementData(vehicle,"neony")
local rear="Brak"
local frozen= isElementFrozen(vehicle) and 1 or 0
v1,v2 = getVehicleVariant(vehicle)
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', blokada='%s, v1='%d', v2='%d', 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), v1, v2, id))
if (type(rent) == "table") then
local rr = string.format("%s", table.concat(rent, ',') )
local query2= exports['pystories-db']:dbSet("UPDATE pystories_vehicles SET rent=? WHERE id=?",rr,id)
end
end
end


ss z bazy danych:



ss z mta z debug 3:



Ca?y kod od wczytywania do zapisywania:

Kod:

--///////////////////////////////////// WCZYTYWANIE POJAZD?“W /////////////////////////////////
function onRespawnVehicles(_,id,poss,buyed,player)
-- 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])
if buyed then
warpPedIntoVehicle(player,veh)
end
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("PL "..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", false)
setElementData(veh,"vehicle:mileage", vehicle["mileage"])
setElementData(veh,"vehicle:driver", vehicle["driver"])
setElementData(veh,"vehicle:ownedGroup", vehicle["ownedGroup"])
setElementData(veh,"vehicle:ownedPlayer", vehicle["ownedPlayer"])
setElementData(veh, "vehicle:pojemnosc", vehicle["pojemnosc_silnika"])


if getElementData(veh, "vehicle:pojemnosc") > 11 then
setElementData(veh, "vehicle:pojemnosc", 11)
end

if getElementData(veh, "vehicle:pojemnosc") == 1 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "1.2")
setVehicleHandling(veh, "engineAcceleration", acceleration+1.3)
elseif getElementData(veh, "vehicle:pojemnosc") == 2 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "1.6")
setVehicleHandling(veh, "engineAcceleration", acceleration+1.5)
elseif getElementData(veh, "vehicle:pojemnosc") == 3 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "1.8")
setVehicleHandling(veh, "maxVelocity", velocity+3)
setVehicleHandling(veh, "engineAcceleration", acceleration+1.8)
elseif getElementData(veh, "vehicle:pojemnosc") == 4 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "2.0")
setVehicleHandling(veh, "maxVelocity", velocity+4)
setVehicleHandling(veh, "engineAcceleration", acceleration+1.9)
elseif getElementData(veh, "vehicle:pojemnosc") == 5 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "2.2")
setVehicleHandling(veh, "maxVelocity", velocity+5)
setVehicleHandling(veh, "engineAcceleration", acceleration+2.0)
elseif getElementData(veh, "vehicle:pojemnosc") == 6 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "2.5")
setVehicleHandling(veh, "maxVelocity", velocity+6)
setVehicleHandling(veh, "engineAcceleration", acceleration+2.2)
elseif getElementData(veh, "vehicle:pojemnosc") == 7 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "2.6")
setVehicleHandling(veh, "maxVelocity", velocity+7)
setVehicleHandling(veh, "engineAcceleration", acceleration+2.4)
elseif getElementData(veh, "vehicle:pojemnosc") == 8 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "2.7")
setVehicleHandling(veh, "maxVelocity", velocity+8)
setVehicleHandling(veh, "engineAcceleration", acceleration+2.5)
elseif getElementData(veh, "vehicle:pojemnosc") == 9 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "2.8")
setVehicleHandling(veh, "maxVelocity", velocity+12)
setVehicleHandling(veh, "engineAcceleration", acceleration+2.6)
elseif getElementData(veh, "vehicle:pojemnosc") == 10 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "2.9")
setVehicleHandling(veh, "maxVelocity", velocity+13)
setVehicleHandling(veh, "engineAcceleration", acceleration+2.7)
elseif getElementData(veh, "vehicle:pojemnosc") == 11 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setElementData(veh, "vehicle:poj", "3.0")
setVehicleHandling(veh, "maxVelocity", velocity+18)
setVehicleHandling(veh, "engineAcceleration", acceleration+5)
end
local mk1 = vehicle['mk1']
if tonumber(mk1) ~= 0 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setVehicleHandling(veh,"engineAcceleration", acceleration+2)
setVehicleHandling(veh,"maxVelocity", velocity+6)
end
local mk2 = vehicle['mk2']
if tonumber(mk2) ~= 0 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setVehicleHandling(veh,"engineAcceleration", acceleration+4)
setVehicleHandling(veh,"maxVelocity", velocity+8)
end
local mk3 = vehicle['mk3']
if tonumber(mk3) ~= 0 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setVehicleHandling(veh,"engineAcceleration", acceleration+4)
setVehicleHandling(veh,"maxVelocity", velocity+8)
end
local turbo = vehicle['turbo']
if tonumber(turbo) ~= 0 then
local acceleration = getVehicleHandling(veh).engineAcceleration
local velocity = getVehicleHandling(veh).maxVelocity
setVehicleHandling(veh,"engineAcceleration", acceleration+12)
--setVehicleHandling(veh,"maxVelocity", velocity+8)
end
local drift = vehicle['drift']
if tonumber(drift) ~= 0 then
setVehicleHandling(veh,"driveType","rwd")
setVehicleHandling(veh,"dragCoeff",1.59)
end
local naped = vehicle['naped']
if tonumber(naped) ~= 0 then
setVehicleHandling(veh,"driveType","awd")
end
local mask = vehicle['masked']
if tonumber(mask) ~= 0 then
setElementData(veh,"vehicle:masked",vehicle['masked'])
end
local wariant = getElementModel(veh)
if wariant == 429 then
setVehicleVariant(veh, 2, 2)
end
if wariant == 562 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 415 then
setVehicleVariant(veh, 4, 4)
end
if wariant == 477 then
setVehicleVariant(veh, 0, 1)
end
if wariant == 480 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 579 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 559 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 411 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 561 then
setVehicleVariant(veh, 0, 0)
end
setElementData(veh,"neony", vehicle["neon"])
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

if vehicle["blokada"] == "true" then
setElementData(veh,"vehicle:block", true)
setVehicleWheelStates(veh, 2, 2, 2, 2)
else
setElementData(veh,"vehicle:block", false)
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)
end

outputDebugString("[pystories_vehicles] Loaded "..vehicles.." vehicles.")
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 rent=getElementData(vehicle,"vehicle:rent") or ''
local player=getElementData(vehicle,"vehicle:ownedPlayer")
local group=getElementData(vehicle,"vehicle:ownedGroup")
local blokada=getElementData(vehicle,"vehicle:block")
local h1,h2,h3=getVehicleHeadLightColor(vehicle)
local paintjob=getVehiclePaintjob(vehicle)
local mask=getElementData(vehicle,"vehicle:masked") or 0
local neon=getElementData(vehicle,"neony")
local rear="Brak"
local frozen= isElementFrozen(vehicle) and 1 or 0
v1,v2 = getVehicleVariant(vehicle)
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', blokada='%s, v1='%d', v2='%d', 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), v1, v2, id))
if (type(rent) == "table") then
local rr = string.format("%s", table.concat(rent, ',') )
local query2= exports['pystories-db']:dbSet("UPDATE pystories_vehicles SET rent=? WHERE id=?",rr,id)
end
end
end

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


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-16, 15:49


Matikmontana

Modern Stories






Wiek: 22
Na forum: 2473 dni
Posty: 423
Nick w MP: Mazeusz*

Piwa: 1015

Respekt: 130
Respekt: 130

Ostrzeżeń: 60%
W respie zrob
setVehicleVariant(veh, vehicle["v1"], vehicle["v2"])
a w zapisie
local v1,v2 = getVehicleVariant(vehicle)



Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-16, 16:10


DawidekD







Wiek: 31
Na forum: 2372 dni
Posty: 22



Respekt: 50

"Matikmontana" napisał/a:

W respie zrob
setVehicleVariant(veh, vehicle["v1"], vehicle["v2"])
a w zapisie
local v1,v2 = getVehicleVariant(vehicle)

Obrazek


no to teraz taki b??d:



Postaw piwo autorowi tego posta
 

 
Tagi: warianty :: paczce :: psrpg
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Warianty na paczce PSRPG Odpowiedz do tematu

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