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

Wysłany: 2015-05-31, 00:51


PsychOTV

LUA Skrypter






Wiek: 26
Na forum: 4252 dni
Posty: 10
Nick w MP: Tom.

Piwa: 1

Respekt: 50

Prosz? ?eby kto? zrobi? tak ?ebym tylko musia? uzupe?ni? dane do bazy tutaj daje kod.

Kod:

function saveallvehicles(modelID)
executeSQLDropTable ( "vehiclesaver" )
executeSQLCreateTable ( "vehiclesaver", "VehicleID INTEGER, px REAL, py REAL, pz REAL, rx REAL, ry REAL, rz REAL, Color1 INTEGER, Color2 INTEGER, Health REAL, upgrades TEXT, paintjob INTEGER, Hood INTEGER, Trunk INTEGER, FrontLeft INTEGER, FrontRight INTEGER,RearLeft INEGER, RearRight INEGER, FrontLeftPanel INTEGER, FrontRightPanel Integer, RearLeftPanel Integer, RearRightPanel Integer,Windscreen Integer,FrontBumper Integer, RearBumper Integer,FLL Integer,FRL Integer,RLL Integer, RRL Integer, VehOvL Integer, HR Real,TR Real,FLR Real,FRR Real, RLR Real, RRR Real,WFL Integer, WRL Intger, WFR Integer, WRR Integer, VehSirena Integer, EngineState Integer, XTUR Real, YTUR Real" )
local vehicles = (getElementsByType("vehicle"))
for i, vehicle in pairs (vehicles) do
local id = (getElementModel(vehicle))
if id == 602 or id == 545 or id == 496 or id == 517 or id == 401 or id == 410 or id == 518 or id == 600 or id == 527 or id == 436
or id == 589 or id == 580 or id == 419 or id == 439 or id == 533 or id == 549 or id == 526 or id == 491 or id == 474 or id == 445
or id == 467 or id == 604 or id == 426 or id == 507 or id == 547 or id == 585 or id == 405 or id == 587 or id == 409 or id == 466
or id == 550 or id == 492 or id == 566 or id == 546 or id == 540 or id == 551 or id == 421 or id == 516 or id == 529 or id == 581
or id == 510 or id == 509 or id == 522 or id == 481 or id == 461 or id == 462 or id == 448 or id == 521 or id == 468 or id == 463
or id == 586 or id == 459 or id == 543 or id == 422 or id == 583 or id == 482 or id == 478 or id == 605 or id == 554 or id == 530
or id == 418 or id == 572 or id == 582 or id == 413 or id == 440 or id == 536 or id == 575 or id == 534 or id == 567 or id == 535
or id == 576 or id == 412 or id == 402 or id == 542 or id == 603 or id == 475 or id == 429 or id == 411 or id == 541 or id == 559
or id == 415 or id == 561 or id == 480 or id == 560 or id == 562 or id == 506 or id == 565 or id == 451 or id == 434 or id == 558
or id == 494 or id == 555 or id == 502 or id == 477 or id == 503 or id == 579 or id == 400 or id == 404 or id == 489 or id == 505
or id == 479 or id == 442 or id == 458 then
local px, py, pz = getElementPosition(vehicle)
local rx, ry, rz = getElementRotation(vehicle)
local color1, color2, color3, color4 = getVehicleColor(vehicle)
local model = getElementModel(vehicle)
local health = getElementHealth (vehicle)
local tableUpgrades = getVehicleUpgrades(vehicle)
local upgrades = table.concat(tableUpgrades, ",")
local paintjob = getVehiclePaintjob(vehicle)
local hood = getVehicleDoorState(vehicle,0)
local trunk = getVehicleDoorState(vehicle,1)
local frontleft = getVehicleDoorState(vehicle,2)
local frontright = getVehicleDoorState(vehicle,3)
local rearleft = getVehicleDoorState(vehicle,4)
local rearright = getVehicleDoorState(vehicle,5)
local frontleftpanel = getVehiclePanelState(vehicle,0)
local frontrightpanel = getVehiclePanelState(vehicle,1)
local rearleftpanel = getVehiclePanelState(vehicle,2)
local rearrightpanel = getVehiclePanelState(vehicle,3)
local windscreen = getVehiclePanelState(vehicle,4)
local frontbumper = getVehiclePanelState(vehicle,5)
local rearbumper = getVehiclePanelState(vehicle,6)

local fll = tostring(getVehicleLightState(vehicle, 0))
local frl = tostring(getVehicleLightState(vehicle, 1))
local rll = tostring(getVehicleLightState(vehicle, 2))
local rrl = tostring( getVehicleLightState(vehicle, 3))
local VehOvL = getVehicleOverrideLights(vehicle)
local hr = getVehicleDoorOpenRatio(vehicle,0)
local tr = getVehicleDoorOpenRatio(vehicle,1)
local flr = getVehicleDoorOpenRatio(vehicle,2)
local frr = getVehicleDoorOpenRatio(vehicle,3)
local rlr = getVehicleDoorOpenRatio(vehicle,4)
local rrr = getVehicleDoorOpenRatio(vehicle,5)
local wfl, wrl, wfr, wrr = getVehicleWheelStates ( vehicle )
if getVehicleSirensOn(vehicle)==true then getsirena=1 elseif getVehicleSirensOn(vehicle)==false then getsirena=0 else getsirena=2 end
local sirena = getsirena
if getVehicleEngineState ( vehicle )==true then estate=1 else estate=0 end
local tengine=estate
local xtur, ytur = getVehicleTurretPosition ( vehicle )


--Insert into SQL Database
executeSQLInsert ( "vehiclesaver", "'"..model.."','"..px.."','"..py.."','"..pz.."','"..rx.."','"..ry.."','"..rz.."','"..color1.."','"..color2.."','"..health.."','"..upgrades.."','"..paintjob.."','"..hood.."','"..trunk.."','"..frontleft.."','"..frontright.."','"..rearleft.."','"..rearright.."','"..frontleftpanel.."','"..frontrightpanel.."','"..rearleftpanel.."','"..rearrightpanel.."','"..windscreen.."','"..frontbumper.."','"..rearbumper.."','"..fll.."','"..frl.."','"..rll.."','"..rrl.."','"..VehOvL.."','"..hr.."','"..tr.."','"..flr.."','"..frr.."','"..rlr.."','"..rrr.."','"..wfl.."','"..wrl.."','"..wfr.."','"..wrr.."','"..sirena.."','"..tengine.."','"..xtur.."','"..ytur.."'" )
end
end

end
addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), saveallvehicles)

period=get("0_vehiclesaver.Period")
if (period > 0) then
setTimer(saveallvehicles,period,0)
end

function createDatabase()
executeSQLCreateTable ( "vehiclesaver", "VehicleID INTEGER, px REAL, py REAL, pz REAL, rx REAL, ry REAL, rz REAL, Color1 INTEGER, Color2 INTEGER, Health REAL, upgrades TEXT, paintjob INTEGER, Hood INTEGER, Trunk INTEGER, FrontLeft INTEGER, FrontRight INTEGER,RearLeft INEGER, RearRight INEGER, FrontLeftPanel INTEGER, FrontRightPanel Integer, RearLeftPanel Integer, RearRightPanel Integer,Windscreen Integer,FrontBumper Integer, RearBumper Integer,FLL Integer,FRL Integer,RLL Integer, RRL Integer, VehOvL Integer, HR Real,TR Real,FLR Real,FRR Real, RLR Real, RRR Real,WFL Integer, WRL Intger, WFR Integer, WRR Integer,VehSirena Integer,EngineState Integer, XTUR Real, YTUR Real" )

--Getting datas
local vehicles = executeSQLQuery("SELECT * FROM vehiclesaver")

--Spawning the vehicles
for i, v in pairs (vehicles) do
local vehicle = createVehicle( v.VehicleID, v.px, v.py, v.pz, v.rx, v.ry, v.rz )
setElementHealth ( vehicle, v.Health )

setVehicleColor ( vehicle, v.Color1, v.Color2, 0, 0 )
if ( v.paintjob ) then
setVehiclePaintjob( vehicle, v.paintjob )
end
local upgrades = split( v.upgrades, 44 )
for index, upgrade in pairs (upgrades) do
addVehicleUpgrade( vehicle, upgrade )
end
setVehicleDoorState ( vehicle, 0, v.Hood )
setVehicleDoorState ( vehicle, 1, v.Trunk )
setVehicleDoorState ( vehicle, 2, v.FrontLeft )
setVehicleDoorState ( vehicle, 3, v.FrontRight )
setVehicleDoorState ( vehicle, 4, v.RearLeft )
setVehicleDoorState ( vehicle, 5, v.RearRight )

setVehiclePanelState (vehicle,0,v.FrontLeftPanel)
setVehiclePanelState (vehicle,1,v.FrontRightPanel)
setVehiclePanelState (vehicle,2,v.RearLeftPanel)
setVehiclePanelState (vehicle,3,v.RearRightPanel)
setVehiclePanelState (vehicle,4,v.Windscreen)
setVehiclePanelState (vehicle,5,v.FrontBumper)
setVehiclePanelState (vehicle,6,v.RearBumper)

setVehicleLightState (vehicle,0,v.FLL)
setVehicleLightState (vehicle,1,v.FRL)
setVehicleLightState (vehicle,2,v.RLL)
setVehicleLightState (vehicle,3,v.RRL)
setVehicleOverrideLights(vehicle, v.VehOvL)
setVehicleDoorOpenRatio (vehicle,0,v.HR,0)
setVehicleDoorOpenRatio (vehicle,1,v.TR,0)
setVehicleDoorOpenRatio (vehicle,2,v.FLR,0)
setVehicleDoorOpenRatio (vehicle,3,v.FRR,0)
setVehicleDoorOpenRatio (vehicle,4,v.RLR,0)
setVehicleDoorOpenRatio (vehicle,5,v.RRR,0)
setVehicleWheelStates ( vehicle, v.WFL, v.WRL, v.WFR, v.WRR )

if v.VehSirena==1 then vsirena=true elseif v.VehSirena==0 then vsirena=false end

if (v.VehSirena~=2) then
setVehicleSirensOn(vehicle,vsirena)
end
if v.EngineState==1 then setVehicleEngineState(vehicle,true) else setVehicleEngineState(vehicle,false) end
setVehicleTurretPosition ( vehicle, v.XTUR, v.YTUR )

end
outputChatBox( #vehicles.." vehicles were created by vehiclesaver", getRootElement(), 0, 255, 0 )
outputDebugString ( #vehicles.." vehicles were created by vehiclesaver" )
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), createDatabase)

addCommandHandler("delvehicles", function()
destroyElement(getResourceRootElement())
executeSQLDropTable ( "vehiclesaver" )
end )


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-05-31, 01:02


Loop

Inspektor






Wiek: 27
Na forum: 4289 dni
Posty: 311
Nick w MP: Inspektor

Piwa: 201

Respekt: 130
Respekt: 130

My tylko pamagamy, nie dajemy gotowcow

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-05-31, 01:16


Piorun







Wiek: 32
Na forum: 6712 dni
Posty: 1837
Nick w MP: Piorun

Piwa: 516

Respekt: 480,7
Respekt: 480,7

Hah a? si? forum posypa?o :D ....

Poza tym masz tutaj niedzia?aj?ce ju? funkcje wi?c najpierw ogarnij tak, by dzia?a?o pod SQLite, a wtedy Ci mo?emy przerobi? pod MySQL :) .

Podpis
Możesz mnie znaleźć na: Facebook
Postaw piwo autorowi tego posta
 

 
Tagi: prośba :: zmienienie :: tego :: sql :: mysql
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