Super! Dzia?a! jednak mam jeszcze pare innych funkcji na identycznej zasadzie. Je?li zmienna "kt" ju? jest zdefiniowana to wystarczy tylko doda? "=getAccountName(kt)" [...] i b?dzie git?
marcin778, Drogi Marcinie, nie da si? ukry?, ?e wszystko rzetelnie i zrozumiale wyt?umaczy?e?. Jednak u?ywaj?c podanego przez ciebie wy?ej przyk?adu komendy "stworzauto" niestety nie tworzy ona pojazdu na nazw? konta. Nie dzieje si? nic.
Aby unikn?? niedopowiedze? podaj? ci ca?y kod z komendami dla skryptu:
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),function()
local q=dbQuery(db,"SELECT * FROM `Save`")
local x=dbPoll(q,-1)
dbFree(q)
for _,v in ipairs(x)do
local car=createVehicle(v.Model,v.x,v.y,v.z)
setVehicleColor(car,v.c1,v.c2,v.c3,v.c4,v.c5,v.c6)
setElementData(car,"owner",v.owner)
setElementData(car,"przeb",v.przebieg)
setElementData(car,"fuel",v.paliwo)
setElementData(car,"v:id",v.ID)
setElementHealth(car,v.hp)
setElementData(car,"x",v.x)
setElementData(car,"y",v.y)
setElementData(car,"z",v.z)
setElementData(car,"rot",v.rot)
setVehicleRotation(car,0,0,v.rot)
setVehicleHandling(car,"driveType",v.driveType)
setVehicleHandling(car,"numberOfGears",v.numberOfGears)
setVehicleHandling(car,"maxVelocity",v.maxVelocity)
setVehicleHandling(car,"engineAcceleration",v.engineAcceleration)
setVehicleHandling(car,"steeringLock",v.steeringLock)
tuning=fromJSON(v.tuning)
for _,value in ipairs(tuning)do
addVehicleUpgrade(car,value)
end
end
end)
addCommandHandler("stworzauto",function(plr,cmd,model)
if isObjectInACLGroup("user."..getPlayerName(plr),aclGetGroup("Admin")) then
if not model then return end
local kt = getPlayerAccount(plr)
local x,y,z=getElementPosition(plr)
local v=createVehicle(model,x,y,z)
local _,_,rot=getVehicleRotation(v)
setElementPosition(plr,x,y,z+2)
setVehicleRotation(plr,0,0,rot)
setElementData(v,"owner",getAccountName(kt))
setElementData(v,"przeb",0)
executeCommandHandler("save",plr)
end
end)
addCommandHandler("zaparkuj",function(plr)
if getPedOccupiedVehicle(plr) then
local kt = getPlayerAccount(plr)
if kt then
if getElementData(getPedOccupiedVehicle(plr),"owner")==getAccountName(kt) then
local x,y,z=getElementPosition(getPedOccupiedVehicle(plr))
local _,_,rot1=getVehicleRotation(getPedOccupiedVehicle(plr))
setElementData(getPedOccupiedVehicle(plr),"x",x)
setElementData(getPedOccupiedVehicle(plr),"y",y)
setElementData(getPedOccupiedVehicle(plr),"z",z)
setElementData(getPedOccupiedVehicle(plr),"rot",rot)
outputChatBox("*Tw?j pojazd zosta? zaparkowany.",plr,255,255,255)
executeCommandHandler("save",plr)
end
end
end
end)
addCommandHandler("przepiszpojazd",function(plr,cmd,nick)
if getPedOccupiedVehicle(plr) then
if getElementData(getPedOccupiedVehicle(plr),"owner")==getPlayerName(plr) then
local auto=getPedOccupiedVehicle(plr)
local gracz=getPlayerFromName(nick)
if not gracz then return outputChatBox("*Nie znaleziono takiego gracza.",plr,255,255,255) end
setElementData(auto,"owner",nick)
executeCommandHandler("save",plr)
outputChatBox("*Pomy?lne przepisanie pojazdu.",plr,255,255,255)
outputChatBox("*Otrzymujesz pojazd : "..getVehicleName(auto).." od gracza : "..getPlayerName(plr).."!",gracz,255,255,255)
end
end
end)
addEventHandler("onVehicleStartEnter",root,function(plr,seat)
if seat==0 then
local own=getElementData(source,"owner")
if own then
if own~=getPlayerName(plr) then
cancelEvent()
outputChatBox("*To auto nale?y do innego gracza.",plr,255,255,255)
end
end
end
end)
((Wst?p kodu czyli ??czenie si? z baz? danych, formaty zapisu itp pozwoli?em sobie pomin??, bo i tak w tej sprawie jest to bezu?yteczne.))
Nie wina przyk?adu, tylko nie istniej?cej funkcji 'setVehicleRotation'. Wpisz /debugscript 3 na chacie b?d? konsoli i wyskoczy ci debugowanie wszystkich zasob?w, tam zawsze pojawiaj? si? b??dy czy te? ostrze?enia odno?nie b??d?w w skrypcie, wszystko jest tam napisane w jakiej linijce jest b??d oraz na czym on polega. Co do problemu rozwi?zanie jest proste nie istnieje co? takiego jak setVehicleRotation tylko
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),function()
local q=dbQuery(db,"SELECT * FROM `Save`")
local x=dbPoll(q,-1)
dbFree(q)
for _,v in ipairs(x)do
local car=createVehicle(v.Model,v.x,v.y,v.z)
setVehicleColor(car,v.c1,v.c2,v.c3,v.c4,v.c5,v.c6)
setElementData(car,"owner",v.owner)
setElementData(car,"przeb",v.przebieg)
setElementData(car,"fuel",v.paliwo)
setElementData(car,"v:id",v.ID)
setElementHealth(car,v.hp)
setElementData(car,"x",v.x)
setElementData(car,"y",v.y)
setElementData(car,"z",v.z)
setElementData(car,"rot",v.rot)
setElementRotation(car,0,0,v.rot)
setVehicleHandling(car,"driveType",v.driveType)
setVehicleHandling(car,"numberOfGears",v.numberOfGears)
setVehicleHandling(car,"maxVelocity",v.maxVelocity)
setVehicleHandling(car,"engineAcceleration",v.engineAcceleration)
setVehicleHandling(car,"steeringLock",v.steeringLock)
tuning=fromJSON(v.tuning)
for _,value in ipairs(tuning)do
addVehicleUpgrade(car,value)
end
end
end)
addCommandHandler("stworzauto",function(plr,cmd,model)
if isObjectInACLGroup("user."..getPlayerName(plr),aclGetGroup("Admin")) then
if not model then return end
local kt = getPlayerAccount(plr)
local x,y,z=getElementPosition(plr)
local v=createVehicle(model,x,y,z)
local _,_,rot=getVehicleRotation(v)
setElementPosition(plr,x,y,z+2)
setElementRotation(plr,0,0,rot)
setElementData(v,"owner",getAccountName(kt))
setElementData(v,"przeb",0)
executeCommandHandler("save",plr)
end
end)
addCommandHandler("zaparkuj",function(plr)
if getPedOccupiedVehicle(plr) then
local kt = getPlayerAccount(plr)
if kt then
if getElementData(getPedOccupiedVehicle(plr),"owner")==getAccountName(kt) then
local x,y,z=getElementPosition(getPedOccupiedVehicle(plr))
local _,_,rot1=getVehicleRotation(getPedOccupiedVehicle(plr))
setElementData(getPedOccupiedVehicle(plr),"x",x)
setElementData(getPedOccupiedVehicle(plr),"y",y)
setElementData(getPedOccupiedVehicle(plr),"z",z)
setElementData(getPedOccupiedVehicle(plr),"rot",rot)
outputChatBox("*Tw?j pojazd zosta? zaparkowany.",plr,255,255,255)
executeCommandHandler("save",plr)
end
end
end
end)
addCommandHandler("przepiszpojazd",function(plr,cmd,nick)
if getPedOccupiedVehicle(plr) then
if getElementData(getPedOccupiedVehicle(plr),"owner")==getPlayerName(plr) then
local auto=getPedOccupiedVehicle(plr)
local gracz=getPlayerFromName(nick)
if not gracz then return outputChatBox("*Nie znaleziono takiego gracza.",plr,255,255,255) end
setElementData(auto,"owner",nick)
executeCommandHandler("save",plr)
outputChatBox("*Pomy?lne przepisanie pojazdu.",plr,255,255,255)
outputChatBox("*Otrzymujesz pojazd : "..getVehicleName(auto).." od gracza : "..getPlayerName(plr).."!",gracz,255,255,255)
end
end
end)
addEventHandler("onVehicleStartEnter",root,function(plr,seat)
if seat==0 then
local own=getElementData(source,"owner")
if own then
if own~=getPlayerName(plr) then
cancelEvent()
outputChatBox("*To auto nale?y do innego gracza.",plr,255,255,255)
end
end
end
end)
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