-
Posts
245 -
Joined
-
Last visited
Everything posted by Turbesz
-
thank youuuu working fine, many-many thanks
-
I'd like to save only the objects created by the local player, not all of them, that's why i want use client side or i can do this on server side?
-
Thank you Btw, how can i save several objects to XML file? I tried this way, working, but only with 1 object datas: client: function saveObjects(x, y, z, int, dim, owner) local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "objekt") end if (x ~= "") then local XNode = xmlFindChild (xml_save_log_File, "X", 0) if not XNode then XNode = xmlCreateChild(xml_save_log_File, "X") end xmlNodeSetValue (XNode, tostring(x)) end if (y ~= "") then local YNode = xmlFindChild (xml_save_log_File, "y", 0) if not YNode then YNode = xmlCreateChild(xml_save_log_File, "y") end xmlNodeSetValue (YNode, tostring(y)) end if (z ~= "") then local ZNode = xmlFindChild (xml_save_log_File, "z", 0) if not ZNode then ZNode = xmlCreateChild(xml_save_log_File, "z") end xmlNodeSetValue (ZNode, tostring(z)) end if (int ~= "") then local IntNode = xmlFindChild (xml_save_log_File, "int", 0) if not IntNode then IntNode = xmlCreateChild(xml_save_log_File, "int") end xmlNodeSetValue (IntNode, tostring(int)) end if (dim ~= "") then local DimNode = xmlFindChild (xml_save_log_File, "dim", 0) if not DimNode then DimNode = xmlCreateChild(xml_save_log_File, "dim") end xmlNodeSetValue (DimNode, tostring(dim)) end if (owner ~= "") then local OwnerNode = xmlFindChild (xml_save_log_File, "owner", 0) if not OwnerNode then OwnerNode = xmlCreateChild(xml_save_log_File, "owner") end xmlNodeSetValue (OwnerNode, tostring(owner)) end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("saveObjects", true) addEventHandler("saveObjects", getRootElement(), saveObjects) server: function teszt(thePlayer) local object=getElementsByType("object") for k, v in ipairs(object) do if getElementData(v,"owner") == thePlayer then local x,y,z = getElementPosition(v) local id = getElementModel(v) local owner = getElementData(v,"owner") or getAccountName(theAcc) local int = getElementInterior(v) local dim = getElementDimension(v) outputChatBox(x.." | "..y.." | ".. z .. " | "..id.." | "..owner.. " | "..int.." | "..dim) triggerClientEvent(thePlayer,"saveObjects",thePlayer,x,y,z,int,dim,owner) end end end addCommandHandler("save",teszt)
-
i create object and save it, and if i load from xml more than 1x then create many object at same pos, so i want can be loaded only 1x
-
and how can i get that object is there? because if i save objects and load it, then spawn objects again the same position
-
I created objects on server side, and i want save to XML and load from XML file on client side. I tried many way to do this, but unsuccessfully Anyone can show me an example of this?
-
hmm, i tried save the data to XML, but does not create the xml file: function teszt(player) local loadFile = xmlLoadFile("objektek.xml", "root") if not (loadFile) then loadFile = xmlCreateFile("objektek.xml", "root") end local object = getElementsByType("object") for k, v in ipairs(object) do local createChild = xmlCreateChild(loadFile, "object") if getElementData(v,"owner") == player then local x,y,z = getElementPosition(v) local model = getElementModel(v) outputChatBox("saved") xmlNodeSetAttribute(createChild, "x", x) xmlNodeSetAttribute(createChild, "y", y) xmlNodeSetAttribute(createChild, "z", z) xmlNodeSetAttribute(createChild, "id", model) end end end addCommandHandler("teszt",teszt)
-
i fixed that meanwhile, thank you the help btw how can i save the objects? because if i restart the server or the script, the objects are deleted (but if i reconnect then no)
-
this: if getElementData(element, "owner") == player and getElementData(element, "mozgathato") then in the bindkey func
-
oh i fixed, now working fine, thank youu but the debugscript flood this: bad argument @ 'getElementData' [Expected element at argument 1] why?
-
ups, my bad. now all object moving if i press arrow_up key
-
because i don't know can i do this in the onElementClicked func with a key
-
i just want move the object which the player clicked with the bindkey func
-
if i add moveObject func in clickfunc then i can't move the object with my bindKey, no?
-
Yes, but i tried add the move object function: function clickfunc ( button, state, player ) if button == "left" and state == "down" then if getElementType (source ) == "object" and getElementData(source,"owner") == player then local x, y, z = getElementPosition(source) local model = getElementModel(source) bindKey(player,"arrow_u","down",mozgatas) setElementData(source,"mozgathato",true) end end end function mozgatas(player) if getElementData(targy,"owner") == player and getElementData(targy,"mozgathato") == true then local x,y,z = getElementPosition(targy) setElementPosition(targy,x,y-0.5,z) end end i always can move only the new one with this, no matter if i click the old one
-
Yes, but i cannot interact the old one, just with the newly created object
-
Yes
-
this works, but i need the table thing, because i want that if a player create more than 1 object, then he can interact with just one of them, if he click on the object
-
uf, my bad but i got this error now: attempt to index field '?' (a userdata value)
-
Like this? local targy = {} function lerakja(thePlayer) local x, y, z = getElementPosition(thePlayer) table[thePlayer] = createObject(2167, x+1, y+1, z-1) setElementData(table[thePlayer], "owner", thePlayer) end addCommandHandler("obj",lerakja) function clickfunc ( button, state, player ) if button == "left" and state == "down" then if table[player][1] == source then local x, y, z = getElementPosition(table[player][1]) outputChatBox(x.." | "..y.." | "..z) end end end addEventHandler ( "onElementClicked", root, clickfunc )
-
i got the same error with this, but if it had worked, then the table would be emptied, and if i try change "local targy = {}" to "local targy[source] = {}" out of the function, i got another error
-
I got the same error
-
attempt to get length of field '?' (a nil value) targy[player][tonumber(#targy[player]) + 1] = createObject(2167, x+1, y+1, z-1) if i add this line without tonumber, i got the same error
-
i tried this, but if i create a new object, the old one does not respond to click
-
I want get data from table, to use a object (move, etc.), but i don't know how to do this. I tried this method: local targy = {} local cp = {} function lerakja(thePlayer) local x, y, z = getElementPosition(thePlayer) targy[thePlayer] = createObject(2167, x+1, y+1, z-1) setElementData(targy[thePlayer], "owner", thePlayer) end addCommandHandler("obj",lerakja) function clickfunc ( button, state, player ) if button == "left" and state == "down" then if getElementType ( targy[player] ) == "object" and getElementData(targy[player],"owner") == player then local x, y, z = getElementPosition(targy[player]) outputChatBox("you are use now this object: ID: "..#targy[player]) cp[player]= createMarker(x, y-0.2, z+2.5, "arrow", 0.7, 255, 181, 64, 250) end end end addEventHandler ( "onElementClicked", root, clickfunc ) The object spawn fine, and the cp spawn fine too above my object after i click. But if i spawn another object, the cp spawn above my object too again. This is fine, but i want to get data from that object which one I clicked to remove the previous cp from the previous object. How can i get data from my table to know how to do it this? (Sorry for my very bad english:/)
