EvilXmik
Wiek: 28 Na forum: 3620 dni Posty: 148
Nick w MP: EvilXmik
Piwa : 399
Witam ot?? mam taki problem i? nie tepa mi auta. My?l? ?e ?le podpi??em pod siebie skrypty. M?g? by mi kto? powiedzie? gdzie pope?ni?em b??d? Z g?ry stawiam browarka
addEventHandler ( "onResourceStart" , resourceRoot ,function() -- Funkcja kt ? ra sprawdza czy posiadamy tabel ? w registry . db , je ? li nie to j ? tworzy
local state = executeSQLQuery ( "CREATE TABLE IF NOT EXISTS pojazdy (id INT, model INT, owner TEXT, kolor1 INT, kolor2 INT, kolor3 INT, kolor4 INT, kolor5 INT, kolor6 INT, posx FLOAT, posy FLOAT, posz FLOAT, rotz FLOAT)" )
if state then
outputDebugString ( "* Utworzono tabel?" )
else
outputDebugString ( "* Nie utworzono tabeli" )
end
end )
-- JE ? LI NIE ZNASZ SI ? NA MYSQL / SQL ANI LUA TO NIC NIE EDYTUJ !!!!!!
local auta = {} -- tabela z autami
addCommandHandler ( "pojazd" ,function( plr , cmd , modelid , gracz ) -- komenda / pojazd < id pojazdu > < nick gracza >
if modelid and gracz then -- sprawdzamy czy podalismyy wszystkie argumenty
modelid = tonumber ( modelid )
if modelid then
local x , y , z = getElementPosition ( plr )
local pojazd = createVehicle ( modelid , x , y , z , 0 , 0 , 0 ) -- tworzymy pojazd
if not pojazd then
outputChatBox ( "* Nie uda?o si? utworzy? pojazdu!" , plr ) return end
table . insert ( auta , pojazd )
setElementData ( pojazd , "pojazd:id" , #auta)
local k1 , k2 , k3 , k4 , k5 , k6 = getVehicleColor ( pojazd , true )
local x , y , z = getElementPosition ( pojazd )
local _ , _ , rotacjaz = getElementRotation ( pojazd )
if executeSQLQuery ( "INSERT INTO `pojazdy`(`id`,`model`,`owner`,`kolor1`,`kolor2`,`kolor3`,`kolor4`,`kolor5`,`kolor6`,`posx`,`posy`,`posz`,`rotz`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)" , getElementData ( pojazd , "pojazd:id" ), modelid , gracz , k1 , k2 , k3 , k4 , k5 , k6 , x , y , z , rotacjaz ) then
-- wrzucamy pojazd to tabeli
warpPedIntoVehicle ( plr , pojazd )
setElementData ( pojazd , "pojazd:wlasciciel" , gracz )
outputChatBox ( "* Utworzono pojazd " .. getVehicleName ( pojazd ).. " z ID " .. #auta.."",plr)
setVehiclePlateText ( pojazd , #auta)
else
outputChatBox ( "* Nie uda?o si? utworzy? pojazdu / wpisa? go do bazy!" , plr )
end
else
outputChatBox ( "* Model pojazdu musi by? liczb?!" , plr )
end
else
outputChatBox ( "* Uzupe?nij wszystkie argumenty! /pojazd <model> <gracz>" , plr )
end
end )
function loadVehicle ( vehicle )-- funckja ladujaca pojazd z tabeli 'vehicle'
local pojazd = createVehicle ( vehicle . model , vehicle . posx , vehicle . posy , vehicle . posz )
setElementRotation ( pojazd , 0 , 0 , vehicle . rotz )
setElementData ( pojazd , "pojazd:id" , vehicle . id )
setElementData ( pojazd , "pojazd:wlasciciel" , vehicle . owner )
setVehicleColor ( pojazd , vehicle . kolor1 , vehicle . kolor2 , vehicle . kolor3 , vehicle . kolor4 , vehicle . kolor5 , vehicle . kolor6 )
setVehiclePlateText ( pojazd , getElementData ( pojazd , "pojazd:id" ))
table . insert ( auta , pojazd )
end
function savePojazdy () -- zapisujemy wszystkie pojazdy prywatne
for i , v in ipairs ( getElementsByType ( "vehicle" , resourceRoot )) do
if getElementData ( v , "pojazd:id" ) then
local x , y , z = getElementPosition ( v )
local _ , _ , rotz = getElementRotation ( v )
local k1 , k2 , k3 , k4 , k5 , k6 = getVehicleColor ( v , true )
if executeSQLQuery ( "UPDATE `pojazdy`SET `owner`=?, `kolor1`=?, `kolor2`=?, `kolor3`=?, `kolor4`=?, `kolor5`=?, `kolor6`=?, `posx`=?, `posy`=?, `posz`=?, `rotz`=? WHERE id=?" , getElementData ( v , "pojazd:wlasciciel" ), k1 , k2 , k3 , k4 , k5 , k6 , x , y , z , rotz , getElementData ( v , "pojazd:id" ) ) then
outputDebugString ( "Zapisano pojazd " .. getElementData ( v , "pojazd:id" ).. "" )
end
end
end
end
addEventHandler ( "onVehicleExit" , resourceRoot ,function( plr , seat )
savePojazdy ()
end )
addEventHandler ( "onResourceStart" , resourceRoot ,function() -- jak wlaczamy skrypt to tworzymy auta
local vehiclestable = executeSQLQuery ( "SELECT * FROM `pojazdy`" )
if vehiclestable and #vehiclestable > 0 then
for i , v in ipairs ( vehiclestable ) do
loadVehicle ( v )
end
else
outputDebugString ( "nie znaleziono pojazdow w bazie" )
end
end )
-- addCommandHandler ( "drop" ,function( plr , cmd ) -- ZAKODUJ TO
-- executeSQLQuery ( "DROP TABLE `pojazdy`" )
-- outputChatBox ( "USUNIETO TABELE Z POJAZDAMI" )
-- end )
addEventHandler ( "onVehicleStartEnter" , resourceRoot ,function( plr , seat )
if seat == 0 then
local name = getPlayerName ( plr )
local data = getElementData ( source , "pojazd:wlasciciel" )
if data then
if data == name then return end
end
outputChatBox ( "* Nie jeste? w?a?cicielem tego pojazdu!" , plr )
cancelEvent ()
end
end )
A tutaj skrypt
function ttv ( plr , cmd , id )
local account = getPlayerAccount ( plr )
local name = getAccountName ( account )
if getElementData ( plr , "duty" ) == 3 or getElementData ( plr , "duty" ) == 2 or getElementData ( plr , "duty" ) == 1 then
if id then
local id = tonumber ( id )
local v = znajdzpojazd ( id )
if v then
warpPedIntoVehicle ( plr , v )
outputChatBox ( "Teleportowano do pojazdu o ID: " .. id , plr , 255 , 0 , 0 , true )
else
outputChatBox ( "Nie znaleziono pojazdu o takim ID." , plr , 255 , 0 , 0 , true )
end
else
outputChatBox ( "Nie wpisa?e? ID pojazdu." , plr , 255 , 0 , 0 , true )
end
end
end
addCommandHandler ( "ttv" , ttv )
function ttp ( plr , cmd , id )
local account = getPlayerAccount ( plr )
local name = getAccountName ( account )
if getElementData ( plr , "duty" ) == 3 or getElementData ( plr , "duty" ) == 2 or getElementData ( plr , "duty" ) == 1 then
if id then
local id = tonumber ( id )
local v = znajdzpojazd ( id )
if v then
local x , y , z = getElementPosition ( plr )
setElementPosition ( v , x , y , z )
setElementPosition ( plr , x , y , z + 3 )
outputChatBox ( "Teleportowano pojazd o ID: " .. id , plr , 255 , 0 , 0 , true )
else
outputChatBox ( "Nie znaleziono pojazdu o takim ID." , plr , 255 , 0 , 0 , true )
end
else
outputChatBox ( "Nie wpisa?e? ID pojazdu." , plr , 255 , 0 , 0 , true )
end
end
end
addCommandHandler ( "ttp" , ttp )
function vehowner ( plr , cmd , id )
local account = getPlayerAccount ( plr )
local name = getAccountName ( account )
if getElementData ( plr , "duty" ) == 3 or getElementData ( plr , "duty" ) == 2 or getElementData ( plr , "duty" ) == 1 then
if id then
local id = tonumber ( id )
local v = znajdzpojazd ( id )
if v then
local wlasciciel = getElementData ( v , "pojazd:wlasciciel" )
outputChatBox ( "Pojazd o ID: " .. id .. ", nale?y do gracza: " .. wlasciciel , plr , 255 , 0 , 0 , true )
else
outputChatBox ( "Nie znaleziono pojazdu o takim ID." , plr , 255 , 0 , 0 , true )
end
else
outputChatBox ( "Nie wpisa?e? ID pojazdu." , plr , 255 , 0 , 0 , true )
end
end
end
addCommandHandler ( "vehowner" , vehowner )
function znajdzpojazd ( id )
for i , v in pairs ( getElementsByType ( "vehicle" )) do
if getElementData ( v , "pojazd:id" ) == id then
return v
end
end
end
A na ko?cu pytanko jak zrobi? ?eby zapisywa?o mi te? tuning wizualny auta.