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

Wysłany: 2017-03-19, 14:00


Allansso







Wiek: 24
Na forum: 3938 dni
Posty: 386

Piwa: 1537

Respekt: 180
Respekt: 180Respekt: 180

Ostrzeżeń: 100%
Witam posiadam tu kod od ironman czy jakos tak i gdy pisz? /pojazd ID NICK, czyli np /pojazd 588 Allansso to sie respi ale gdy chce zrespic graczowi pojazd to pisze /pojazd 600 krystian to zamiast jego to mi sie respi pojazd co tu nie dziala?

Kod:



--Skrypt by Irons--
--Mo?esz u?ywa? tego kodu, i go edytowa?.. ale wspomnij gdzie? o autorze ;)


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)




Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-03-19, 16:52


R3fr3Sh







Wiek: 27
Na forum: 4800 dni
Posty: 70

Piwa: 60

Respekt: 150
Respekt: 150Respekt: 150

Pojazd ten warpuje admina do pojazdu, ale pojazd w bazie jest przypisany na gracza. Musia?by? u?y? getPlayerFromName aby pobra? gracza i go warpowa?.

Postaw piwo autorowi tego posta
 

 
Tagi: prywatnymi :: pojazdami :: nie :: dziala
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Prywatnymi Pojazdami - Nie Dziala 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