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

Wysłany: 2016-11-02, 16:39


maRIoXd1







Wiek: 44
Na forum: 3504 dni
Posty: 1
Nick w MP: TheToker



Respekt: 50

Witam moim problemem jest skrypt zapisu/parkowania samochodu. Gdy pisz? komend? /zaparkuj w aucie frakcyjnym b?d? aucie nieposiadaj?cym rejestracji wszystko jest w porz?dku, lecz gdy pisze t? sam? komend? w aucie kt?re posiada ju? prawo jazdy to nie dzieje si? nic. Prosz? o pomoc nie mam poj?cia co jest ?le.

Kod:



output = false

function getPlayerAccountID(login)
account = getAccount(tostring(login))
if account then
data = getAccountData(account,"ID-Player")
if data then
return data
else
return false
end
else
return false
end
end

function zapiszlog(string)
local file = fileOpen("logs.txt")
if not file then
file = fileCreate("logs.txt")
end
if (file) then
local time = getRealTime()
fileSetPos(file,fileGetSize(file))
local written = fileWrite(file,"\r\n",string.format("-- %02s/%02s/%04s %02s:%02s\r : ",
tostring(time.monthday),
tostring(time.month + 1),
tostring(time.year + 1900),
tostring(time.hour),
tostring(time.minute)),
string,"\r\n")
fileFlush(file)
fileClose(file)

end
end

local panelvip = exports.panelvip
aaa =mysql_connect(get("mysql.host"), get("mysql.user"), get("mysql.pass"), get("mysql.db"), 3306)
if ( not aaa ) then
outputDebugString("Blad polaczenia!-Vehsaver")
end

function makeCaptcha(capNumz)
theC = ""
tCode = { "a","A", "b","B", "c","C", "d","D", "e","E", "f","F", "g","G", "h","H", "j","J", "k","K", "l","L", "m","L", "n","N", "o","O", "p","P", "q","Q", "r","R", "s","S", "t","T", "u","U", "v","V", "x","X", "y","Y", "z","Z", "1", "2", "3", "4", "5", "6", "7", "8", "9" }
for k=1,capNumz or 5 do
randomCode = math.random (#tCode )
theC = ""..theC..""..tCode[randomCode]..""
end
return theC
end


function showBox(player,value,str)
exports.msgboxrpg:showBox(player,value,str)
end



for i,v in ipairs(getElementsByType("player")) do

setElementData(v,"UzylParkowanie",false)

end




function saveallvehicles(thePlayer)

insert = false
insertvip = false

local vehicle = getPedOccupiedVehicle ( thePlayer )
if vehicle then
data = getElementData(vehicle,"PojazdMapa")
if (data==true) then
showBox(thePlayer,"error","Nie mo?na zaprawkowa? tego pojazdu, jest to pojazd frakcyjny.")
else
if getElementData(thePlayer,"UzylParkowanie") == false then
local zarejstrowany = tostring(getElementData(vehicle,"Zarejstrowany"))
if zarejstrowany then
local x = getElementData(vehicle,"Zarejstrowany-Na")
local x2 = getElementData(vehicle,"Zarejstrowany-Na2")
id = getElementData(vehicle,"Zarejstrowany-NaID")
id2 = getElementData(vehicle,"Zarejstrowany-Na2ID")
if tostring(id) == tostring(getPlayerAccountID(getAccountName(getPlayerAccount(thePlayer)))) or tostring(id2) == tostring(getPlayerAccountID(getAccountName(getPlayerAccount(thePlayer)))) then
local px, py, pz = getElementPosition(vehicle)
local rx, ry, rz = getElementRotation(vehicle)
local c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12 = getVehicleColor(vehicle,true)
local color = table.concat({c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12},",")
local model = getElementModel(vehicle)
local health = getElementHealth (vehicle)
local tableUpgrades = getVehicleUpgrades(vehicle)
local upgrades = table.concat(tableUpgrades, ",")
local paintjob = getVehiclePaintjob(vehicle)
local paliwo = tostring(getElementData(vehicle,"fuel"))
local x = getElementData(vehicle,"Zarejstrowany-Na")
local x2 = getElementData(vehicle,"Zarejstrowany-Na2")
local h = getVehicleHandling ( vehicle )
local handlingx = table.concat({h.brakeDeceleration,h.steeringLock,h.mass,h.suspensionDamping,h.suspensionHighSpeedDamping},",")
local gps = getElementData(vehicle,"Have-GPS")
if gps then gps="true" else gps="false" end
local antyr = getElementData(vehicle,"Have-AntyRadar")
if antyr then antyr="true" else antyr="false" end
local przebiegx = getElementData(vehicle,"przebieg")
if x then
na1 = getElementData(vehicle,"Zarejstrowany-Na")
else
na1 = ""
end

if x2 then
na2 = getElementData(vehicle,"Zarejstrowany-Na2")
else
na2 = ""
end

local bx = getElementData(vehicle,"Tabl_Rejstracyjna")
if not bx then
local tabrej = tostring(makeCaptcha(12))
setElementData(vehicle,"Tabl_Rejstracyjna",tabrej)
end

local tablicarejstracyjna = getElementData(vehicle,"Tabl_Rejstracyjna")

q1 = mysql_query(aaa,"SELECT * FROM auta WHERE `NaKogo1ID` = '".. getPlayerAccountID(getAccountName(getPlayerAccount(thePlayer))) .."'")
q2 = mysql_query(aaa,"SELECT * FROM auta WHERE `NaKogo2ID` = '".. getPlayerAccountID(getAccountName(getPlayerAccount(thePlayer))) .."'")
local account = getPlayerAccount(thePlayer)
local login = getAccountName(account)
local accid = getPlayerAccountID(login)
if not panelvip:isPlayerVIP(thePlayer) then
if(mysql_num_rows(q1)+mysql_num_rows(q2) < 3) then
q = mysql_query(aaa,"SELECT * FROM auta WHERE `rejstracja` = '".. tablicarejstracyjna .."'")
if(mysql_num_rows(q) == 0) then
mysql_query( aaa, "INSERT INTO auta SET VehicleID='" .. model .. "', px='" .. px .. "',py='" .. py .. "',pz='" .. pz .. "',rx='" .. rx .. "',ry='" .. ry .. "',rz='" .. rz .. "',Color='" .. color .. "',Health='" .. health .. "',upgrades='" .. upgrades .. "',paintjob='" .. paintjob .. "',PALIWO='" .. paliwo .. "',Zarejstrowany='" .. zarejstrowany .. "',NaKogo1='" .. na1 .. "',NaKogo2='" .. na2 .. "',rejstracja='"..tablicarejstracyjna.."',NaKogo1ID='"..tostring(id).."',NaKogo2ID='"..tostring(id2).."',gps='"..gps.."',antyradar='"..antyr.."',handling='"..handlingx.."',przebieg='"..przebiegx.."'")
if output then outputDebugString("INSERT auta bazy wykonane!") end
showBox(thePlayer,"info","Zaparkowano pomy?lnie!")
setVehicleRespawnPosition ( vehicle, px, py, pz,rx,ry,rz )
insert = true
end
end
if insert == false then
zxc = mysql_query(aaa,"SELECT * FROM auta WHERE `rejstracja` = '".. tablicarejstracyjna .."'")
if(mysql_num_rows(zxc) ~= 0) then
fr = mysql_query ( aaa, "UPDATE `auta` SET VehicleID='" .. model .. "', px='" .. px .. "',py='" .. py .. "',pz='" .. pz .. "',rx='" .. rx .. "',ry='" .. ry .. "',rz='" .. rz .. "',Color='" .. color .. "',Health='" .. health .. "',upgrades='" .. upgrades .. "',paintjob='" .. paintjob .. "',PALIWO='" .. paliwo .. "',Zarejstrowany='" .. zarejstrowany .. "',NaKogo1='" .. na1 .. "',NaKogo2='" .. na2 .. "',NaKogo1ID='"..tostring(id).."',NaKogo2ID='"..tostring(id2).."',rejstracja='"..tablicarejstracyjna.."',gps='"..gps.."',antyradar='"..antyr.."',handling='"..handlingx.."',przebieg='"..przebiegx.."' WHERE `rejstracja` = '".. tablicarejstracyjna .."'")
if output then outputDebugString("UPDATE auta bazy wykonane!") end
showBox(thePlayer,"info","Zaparkowano pomy?lnie!")
setVehicleRespawnPosition ( vehicle, px, py, pz,rx,ry,rz )
else
showBox(thePlayer,"error","Posiadasz maxymaln? liczb? pojazd?w!")
end
end
else
if(mysql_num_rows(q1)+mysql_num_rows(q2) <7) then
q = mysql_query(aaa,"SELECT * FROM auta WHERE `rejstracja` = '".. tablicarejstracyjna .."'")
if(mysql_num_rows(q) == 0) then
mysql_query( aaa, "INSERT INTO auta SET VehicleID='" .. model .. "', px='" .. px .. "',py='" .. py .. "',pz='" .. pz .. "',rx='" .. rx .. "',ry='" .. ry .. "',rz='" .. rz .. "',Color='" .. color .. "',Health='" .. health .. "',upgrades='" .. upgrades .. "',paintjob='" .. paintjob .. "',PALIWO='" .. paliwo .. "',Zarejstrowany='" .. zarejstrowany .. "',NaKogo1='" .. na1 .. "',NaKogo2='" .. na2 .. "',rejstracja='"..tablicarejstracyjna.."',NaKogo1ID='"..tostring(id).."',NaKogo2ID='"..tostring(id2).."',gps='"..gps.."',antyradar='"..antyr.."',handling='"..handlingx.."',przebieg='"..przebiegx.."'")
if output then outputDebugString("INSERT auta bazy wykonane!") end
showBox(thePlayer,"info","Zaparkowano pomy?lnie!")
setVehicleRespawnPosition ( vehicle, px, py, pz,rx,ry,rz )
insertvip = true
end
end
if insertvip == false then
zxc = mysql_query(aaa,"SELECT * FROM auta WHERE `rejstracja` = '".. tablicarejstracyjna .."'")
if(mysql_num_rows(zxc) ~= 0) then
fr = mysql_query ( aaa, "UPDATE `auta` SET VehicleID='" .. model .. "', px='" .. px .. "',py='" .. py .. "',pz='" .. pz .. "',rx='" .. rx .. "',ry='" .. ry .. "',rz='" .. rz .. "',Color='" .. color .. "',Health='" .. health .. "',upgrades='" .. upgrades .. "',paintjob='" .. paintjob .. "',PALIWO='" .. paliwo .. "',Zarejstrowany='" .. zarejstrowany .. "',NaKogo1='" .. na1 .. "',NaKogo2='" .. na2 .. "',NaKogo1ID='"..tostring(id).."',NaKogo2ID='"..tostring(id2).."',rejstracja='"..tablicarejstracyjna.."',gps='"..gps.."',antyradar=',handling='"..handlingx.."'"..antyr.."',przebieg='"..przebiegx.."' WHERE `rejstracja` = '".. tablicarejstracyjna .."'")
if output then outputDebugString("UPDATE auta bazy wykonane!") end
showBox(thePlayer,"info","Zaparkowano pomy?lnie!")
setVehicleRespawnPosition ( vehicle, px, py, pz,rx,ry,rz )
else
showBox(thePlayer,"error","Posiadasz maxymaln? liczb? pojazd?w!")
end
end
end




else
showBox(thePlayer,"error","Ten pojazd nie nalezy do ciebie, nie mozesz go zaparkowa?!")
end
else
showBox(thePlayer,"error","Ten pojazd nie jest zarejstrowany, nie mozesz go zaparkowa?!")
end
setElementData(thePlayer,"UzylParkowanie",false)
triggerClientEvent (thePlayer,"ustawdataTimer", getRootElement(), thePlayer)
else
triggerClientEvent (thePlayer,"pokazdaneTimer", getRootElement(), thePlayer)
end

end
end
end



addCommandHandler("zaparkuj",saveallvehicles)


function sprawdzauto(thePlayer)
local vehicle = getPedOccupiedVehicle ( thePlayer )
if vehicle then
local zarejstrowany = tostring(getElementData(vehicle,"Zarejstrowany"))
if zarejstrowany then
local x2 = getElementData(vehicle,"Zarejstrowany-Na")
local x1 = getElementData(vehicle,"Zarejstrowany-Na2")
local x = getElementData(vehicle,"Tabl_Rejstracyjna")
showBox(thePlayer,"info","Tablica Rejstracyjna: "..x.."\nPosiadacz 1: "..x1.."\nPosiadacz 2: "..x2.."")
outputConsole ( "Rejstracja ID VEH: "..x, thePlayer )
end
else
showBox(thePlayer,"error","Nie masz samochodu!")
end
end
addCommandHandler("sprawdzauto",sprawdzauto)

function createDatabase()

local result = mysql_query(aaa,"SELECT * FROM auta")
if (result) then
while true do
local row = mysql_fetch_row(result)
if (not row) then
break end
if tonumber(row[26])==0 then
local vehicle = createVehicle( tonumber(row[1]), row[2], row[3]+2, row[4], row[5], row[6], row[7] )
setVehicleRespawnPosition ( vehicle, row[2], row[3], row[4], row[5], row[6], row[7])
color_table = split( row[8], 44 )

setElementHealth ( vehicle, 1000 )
local upgrades = split( row[13], 44 )

for index, upgrade in pairs (upgrades) do
addVehicleUpgrade( vehicle, upgrade )
end
if ( row[14] ) then
setVehiclePaintjob( vehicle, row[14] )
end
setVehicleColor ( vehicle, color_table[1],color_table[2],color_table[3],color_table[4],color_table[5],color_table[6],color_table[7],color_table[8],color_table[9],color_table[10],color_table[11],color_table[12] )
setElementData(vehicle,"fuel",row[15])
setElementData(vehicle,"Tabl_Rejstracyjna",row[19])

if row[16] == "brak" then
else
setElementData(vehicle,"Zarejstrowany",row[16])
setElementData(vehicle,"Zarejstrowany-Na2",row[18])
setElementData(vehicle,"Zarejstrowany-Na",row[17])
setElementData(vehicle,"Zarejstrowany-NaID",tostring(row[20]))
setElementData(vehicle,"Zarejstrowany-Na2ID",tostring(row[21]))

end
if row[22] == "true" then
setElementData(vehicle,"Have-GPS",true)
end
if row[23] == "true" then
setElementData(vehicle,"Have-AntyRadar",true)
end
handling = split( row[24], 44 )
setVehicleHandling(vehicle,"brakeDeceleration",tonumber(handling[1]))
setVehicleHandling(vehicle,"steeringLock",tonumber(handling[2]))
setVehicleHandling(vehicle,"mass",tonumber(handling[3]))
setVehicleHandling(vehicle,"suspensionDamping",tonumber(handling[4]))
setVehicleHandling(vehicle,"suspensionHighSpeedDamping",tonumber(handling[5]))
setElementData(vehicle,"przebieg",tonumber(row[25]))
end
end
mysql_free_result(result) -- Free the result
end
end

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), createDatabase)





function pokazblip(gracz)
local login = getAccountName(getPlayerAccount(gracz))
triggerClientEvent (gracz,"BlipCarSchow", getRootElement(), gracz,login)
end
addEvent( "PokazWszystkieBlipy", true )
addEventHandler( "PokazWszystkieBlipy", getRootElement(), pokazblip )

function ublip(gracz)
local login = getAccountName(getPlayerAccount(gracz))
triggerClientEvent (gracz,"BlipCarHide", getRootElement(), gracz,login)
end
addEvent( "UsunWszystkieBlipy", true )
addEventHandler( "UsunWszystkieBlipy", getRootElement(), ublip )


function uzupelnij(gracz)

local login = getAccountName(getPlayerAccount(gracz))
if panelvip:isPlayerVIP(gracz) then
tekst = 7
else
tekst = 3
end

hmm = mysql_query(aaa,"SELECT * FROM auta WHERE `NaKogo1ID` = '".. getPlayerAccountID(login) .."'")
hmm2 = mysql_query(aaa,"SELECT * FROM auta WHERE `NaKogo2ID` = '".. getPlayerAccountID(login) .."'")
if(mysql_num_rows(hmm)+mysql_num_rows(hmm2) == 0) then

else

if (hmm) then
while true do
local row = mysql_fetch_row(hmm)
if (not row) then
break end
local nazwa = getVehicleNameFromModel ( row[1] )
if tonumber(row[26])==1 then aktywny="Zholowany" else aktywny="Aktywny" end
triggerClientEvent (gracz,"ustawAuta", getRootElement(),nazwa,row[19],tekst,aktywny )


end
end

if (hmm2) then
while true do
local row = mysql_fetch_row(hmm2)
if (not row) then
break end
local nazwa = getVehicleNameFromModel ( row[1] )
if tonumber(row[26])==1 then aktywny="Zholowany" else aktywny="Aktywny" end
triggerClientEvent (gracz,"ustawAuta", getRootElement(),nazwa,row[19],tekst,aktywny )


end
end


end


end




function pokazoknoauta(gracz)
triggerClientEvent (gracz,"pokazAuta", getRootElement() )
uzupelnij(gracz)
end
addCommandHandler("pokazauta",pokazoknoauta)




function wyrejstruj(rejstracja,gracz)
for i,v in ipairs(getElementsByType("vehicle")) do
if getElementData(v,"Tabl_Rejstracyjna") == rejstracja then

local free = mysql_query( aaa, "DELETE FROM auta WHERE rejstracja='"..rejstracja.."'")
mysql_free_result( free )


setElementData(v,"Zarejstrowany",false)
setElementData(v,"Zarejstrowany-Na2",false)
setElementData(v,"Zarejstrowany-Na",false)
setElementData(v,"Tabl_Rejstracyjna",false)
triggerClientEvent (gracz,"czyscicgrd", getRootElement() )
uzupelnij(gracz)
showBox(gracz,"info","Wyrejstrowa?e? pojazd!")
end
end
end
addEvent( "WyrejstrujAuto", true )
addEventHandler( "WyrejstrujAuto", getRootElement(), wyrejstruj )

function destroyautos ()
local x = getElementData(source,"Tabl_Rejstracyjna")
local x2 = getElementData(source,"TruckerAuto")
if not x2 then
if x then
setTimer(respawnVehicle, 60000, 1, source)
else
setTimer(destroyElement, 60000, 1, source)
end
end
end
addEventHandler ("onVehicleExplode", getRootElement(), destroyautos )

function dstid(thePlayer,cmd,id)
if isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "Admin" ) ) or
isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "SuperModerator" ) ) or
isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "Moderator" ) ) then

hmm = mysql_query(aaa,"SELECT * FROM auta WHERE `rejstracja` = '".. id .."'")
if(mysql_num_rows(hmm) == 0) then
showBox(thePlayer,"error","Brak pojazdu o rejstracji: "..id)
else

for i,v in ipairs(getElementsByType("vehicle")) do
if getElementData(v, "Tabl_Rejstracyjna") == id then
destroyElement(v)
local free = mysql_query( aaa, "DELETE FROM auta WHERE rejstracja='"..id.."'")
showBox(thePlayer,"info","Usunieto z bazy danych pojazd o id: "..id)
end
end
mysql_free_result( free )
end



else
showBox(thePlayer,"error","BRAK PRAW!")
end
end
addCommandHandler("destroyid",dstid)


function dstpass(thePlayer)
if isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "Admin" ) ) or
isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "SuperModerator" ) ) or
isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "Moderator" ) ) then

local theVehicle = getPedOccupiedVehicle ( thePlayer )
local x = getElementData(theVehicle,"Tabl_Rejstracyjna")
if x then
local free = mysql_query ( aaa, "UPDATE `auta` SET blokadapd='1' WHERE `rejstracja` = '".. x .."'")
destroyElement(theVehicle)
showBox(thePlayer,"info","Auto o ID: "..x.." zosta?o zatrzymane i usuni?te z serwera")
mysql_free_result( free )
end


else
showBox(thePlayer,"error","BRAK PRAW!")
end
end
addCommandHandler("destroypass",dstpass)

function saveVehicle(vehicle)
if vehicle then
id = getElementData(vehicle, "Tabl_Rejstracyjna")
if id then
save = mysql_query(aaa,"SELECT * FROM auta WHERE `rejstracja` = '".. id .."'")
if(mysql_num_rows(save) > 0) then
local c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12 = getVehicleColor(vehicle,true)
local color = table.concat({c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12},",")
local health = getElementHealth (vehicle)
local tableUpgrades = getVehicleUpgrades(vehicle)
local upgrades = table.concat(tableUpgrades, ",")
local paintjob = getVehiclePaintjob(vehicle)
local paliwo = tostring(getElementData(vehicle,"fuel"))
local h = getVehicleHandling ( vehicle )
local handlingx = table.concat({h.brakeDeceleration,h.steeringLock,h.mass,h.suspensionDamping,h.suspensionHighSpeedDamping},",")
local gps = tostring(getElementData(vehicle,"Have-GPS"))
local antyr = tostring(getElementData(vehicle,"Have-AntyRadar"))
local przebiegx = getElementData(vehicle,"przebieg")
mysql_query ( aaa, "UPDATE `auta` SET Color='" .. color .. "',Health='" .. health .. "',upgrades='" .. upgrades .. "',paintjob='" .. paintjob .. "',PALIWO='" .. paliwo .. "',gps='"..gps.."',antyradar='"..antyr.."',handling='"..handlingx.."',przebieg='"..przebiegx.."' WHERE `rejstracja` = '".. id .."'")

end
end
end
end


function SaveOnExit ( thePlayer, seat, jacked )
if seat==0 then
saveVehicle(thePlayer)
end
end
--addEventHandler ( "onVehicleExit", getRootElement(), SaveOnExit )




Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-11-05, 00:19


amited







Wiek: 26
Na forum: 3714 dni
Posty: 1233
Nick w MP: Amited

Piwa: 512

Respekt: 466
Respekt: 466

auto kt?re posiada prawo jazdy? i co ta komenda /zaparkuj robi oraz co to za kod i po co on jest tutaj potrzebny

Podpis
"amited" napisał/a:
Postaw piwo autorowi tego posta
 

 
Tagi: czy :: mógłby :: ktoś :: pomóc :: naprawie :: skryptu
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