Wysłany: 2014-03-30, 18:55
TheTroll
Pan Majster
Wiek: 38 Na forum: 4764 dni Posty: 219
Nick w MP: TheTroll
Piwa : 1114
Witam. Pisze skrypt na prywatne pojazdy kt?re zapisuj? si? w pliku xml. Ale mam ma?y problem. Polega on na tym ?e kiedy wybieram pojazd z gridlisty i klikam stw?rz to po stronie serwera dodaje si? wszystko do pliku xml ale pojazd si? nie tworzy.
Kod po stronie klienta w kt?rym dodaje pojazdy do gridlisty i potem pobieram pojazd do stworzenia.
Kod: function pokazPanel()
guiSetInputEnabled(true)
guiSetVisible(GUIEditor.tabpanel[1],true)
showCursor(true)
for i = 0, 211 do
if ( getVehicleNameFromModel ( 400 + i ) ~= "" ) then
local row = guiGridListAddRow(GUIEditor.gridlist[2])
guiGridListSetItemText (GUIEditor.gridlist[2], row,1, getVehicleNameFromModel(400+i), false, false )
guiGridListSetItemText (GUIEditor.gridlist[2], row,2, 400+i, false, false )
end
end
end
addEvent("Panel:Pokaz_Osobowe",true)
addEventHandler("Panel:Pokaz_Osobowe",getRootElement(),pokazPanel)
function AutaClientTworz()
local nazwa = guiGridListGetItemText ( GUIEditor.gridlist[2], guiGridListGetSelectedItem ( GUIEditor.gridlist[2] ), 2 )
if nazwa ~= "" then
triggerServerEvent("AutaServer:Tworz",getLocalPlayer(),getLocalPlayer(),nazwa)
else
outputChatBox("*Musisz wybra? pojazd z listy!", source, 255, 255, 255)
end
end
addEventHandler("onClientGUIClick",GUIEditor.button[1],AutaClientTworz,false)
I kod po stronie serwera w kt?rym dodaje pojazd do pliku xml i tworze go.
Kod: function AutaServerTworz(nazwa)
if (not isPedInVehicle(source)) then
if (hasObjectPermissionTo (source,"command.aexec",false)) then
local x,y,z = getElementPosition (source)
local PojazdCount = tonumber(getPojazdCount())
local root = xmlLoadFile ("auta.xml")
local PojazdRoot = xmlFindChild (root,"autka",0)
local newPojazd = xmlCreateChild (PojazdRoot,"auta")
xmlNodeSetAttribute (newPojazd,"x",x)
xmlNodeSetAttribute (newPojazd,"y",y)
xmlNodeSetAttribute (newPojazd,"z",z)
xmlNodeSetAttribute (newPojazd,"model",nazwa)
xmlNodeSetAttribute (newPojazd,"owner","")
pojazd = createVehicle (nazwa, x, y+5, z)
outputChatBox ("* Pomy?lnie stworzono pojazd prywanty. ID pojazdu: "..PojazdCount,source,255,255,255,false)
xmlSaveFile (root)
xmlUnloadFile (root)
setTimer ( onStart, 2000, 1 )
else
outputChatBox ("* Nie posiadasz dost?pu do stawiania aut!",source,255,255,255,false)
end
else
outputChatBox ("* Musisz wyj?? z pojazdu!",thePlayer,255,255,255,false)
end
end
addEvent("AutaServer:Tworz", true)
addEventHandler("AutaServer:Tworz", root, AutaServerTworz)
Prosz? o pomoc.
Wysłany: 2014-03-30, 20:02
Jacob
Głupiomądry
Wiek: 28 Na forum: 5502 dni Posty: 967
Nick w MP: Jacob
Piwa : 786
Server
function AutaServerTworz ( nazwa )
if ( not isPedInVehicle ( source )) then
if ( hasObjectPermissionTo ( source , "command.aexec" , false )) then
local x , y , z = getElementPosition ( source )
local PojazdCount = tonumber ( getPojazdCount ())
local root = xmlLoadFile ( "auta.xml" )
local PojazdRoot = xmlFindChild ( root , "autka" , 0 )
local newPojazd = xmlCreateChild ( PojazdRoot , "auta" )
xmlNodeSetAttribute ( newPojazd , "x" , x )
xmlNodeSetAttribute ( newPojazd , "y" , y )
xmlNodeSetAttribute ( newPojazd , "z" , z )
xmlNodeSetAttribute ( newPojazd , "model" , nazwa )
xmlNodeSetAttribute ( newPojazd , "owner" , "" )
pojazd = createVehicle ( getVehicleModelFromName ( nazwa ), x , y + 5 , z )
outputChatBox ( "* Pomy?lnie stworzono pojazd prywanty. ID pojazdu: " .. PojazdCount , source , 255 , 255 , 255 , false )
xmlSaveFile ( root )
xmlUnloadFile ( root )
setTimer ( onStart , 2000 , 1 )
else
outputChatBox ( "* Nie posiadasz dost?pu do stawiania aut!" , source , 255 , 255 , 255 , false )
end
else
outputChatBox ( "* Musisz wyj?? z pojazdu!" , thePlayer , 255 , 255 , 255 , false )
end
end
addEvent ( "AutaServer:Tworz" , true )
addEventHandler ( "AutaServer:Tworz" , root , AutaServerTworz )
Wysłany: 2014-03-30, 20:16
TheTroll
Pan Majster
Wiek: 38 Na forum: 4764 dni Posty: 219
Nick w MP: TheTroll
Piwa : 1114
Niestety dalej to samo.
Takie b??dy wyskakuj? podczas tworzenia pojazdu:
Bad argument @ 'createVehicle'[Expected a number at argument 1, got boolean]
[ Dodano : 2014-03-30, 20:18 ]
Aha wyskakuje jeszcze b??d Bad argument @ 'getVehicleModelFromName'
Tagi: system :: prywatnych :: pojazdów
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: