Castillo Posted November 3, 2010 Share Posted November 3, 2010 hey i have a strange bug on my friend server, after some time when players are playing all gets fucked up i have no clue why this is happening i have tryed many things and nothing worked, function playerSpawn() local playerTeam = getElementData(source, "team") local playerSkin = getElementData(source, "skin") check(source) local xmlFile = xmlLoadFile("Spawns.xml") player = xmlFindChild(xmlFile, "skin", playerSkin-1) positionX = xmlNodeGetAttribute(player,"x") positionY = xmlNodeGetAttribute(player,"y") positionZ = xmlNodeGetAttribute(player,"z") spawnPlayer(source, positionX, positionY, positionZ, 0) id = xmlNodeGetAttribute(player,"id") setElementModel(source, id) I = 0 while (xmlFindChild(player, "weapon", I)) do local weapon = xmlFindChild(player, "weapon", I) local weaponAttributes = xmlNodeGetAttributes(weapon) giveWeapon(source, weaponAttributes.name, weaponAttributes.amount) I = I + 1 end end addEvent("spawnHim",true) addEventHandler("spawnHim", getRootElement(), playerSpawn) errors: bad argument xmlNodeGetAttribute from line positionX = xmlNodeGetAttribute(player,"x") to 36 bad argument spawnPlayer (this is because attributes aren't working) bad argument while xmlFindChild line (xmlFindChild(player, "weapon", I)) do i hope someone can give me a hand, thanks in advance. Link to comment
dzek (varez) Posted November 3, 2010 Share Posted November 3, 2010 -- this isn't local. in some extreme cases (two or more players death at same time) - it can go crazy. player = xmlFindChild(xmlFile, "skin", playerSkin-1) -- also be sure if playerSkin have valid value. -- maybe it's nil or something? -- try: outputDebugString("player skin from element data: "..tostring(playerSkin)) -- put this before this line -- check(source) -- and put this: outputDebugString("child found: "..tostring(player)) -- just after line with xmlFindChild -- -- you can also put this outputDebugString("doing this for player: "..getPlayerName(source)) -- on function beginning Link to comment
Castillo Posted November 4, 2010 Author Share Posted November 4, 2010 it keeps making same bug any other ideas? Link to comment
dzek (varez) Posted November 4, 2010 Share Posted November 4, 2010 eh.. what it says in debug? (while problem start to happening) Link to comment
Castillo Posted November 4, 2010 Author Share Posted November 4, 2010 this is the outputs: [18:10:33] INFO: player skin from element data: 41 [18:10:33] INFO: child found: false [18:10:33] WARNING: rpg.lua: Bad argument @ 'xmlNodeGetAttribute' - Line: 34 [18:10:33] WARNING: rpg.lua: Bad argument @ 'xmlNodeGetAttribute' - Line: 35 [18:10:33] WARNING: rpg.lua: Bad argument @ 'xmlNodeGetAttribute' - Line: 36 [18:10:33] WARNING: rpg.lua: Bad argument @ 'spawnPlayer' - Line: 37 [18:10:33] WARNING: rpg.lua: Bad argument @ 'xmlNodeGetAttribute' - Line: 38 [18:10:33] WARNING: rpg.lua: Bad argument @ 'setElementModel' - Line: 39 [18:10:33] WARNING: rpg.lua: Bad argument @ 'xmlNodeFindChild' - Line: 41 Link to comment
dzek (varez) Posted November 4, 2010 Share Posted November 4, 2010 isn't it clear? children element is not found post your xml file. is doing xmlLoadFile needed every respawn? maybe do it once on resource start if possible.. are you writing something somewhere to this xml? Link to comment
Castillo Posted November 4, 2010 Author Share Posted November 4, 2010 but why it works and then stops working? i have changed xmlLoadFile to getResourceConfig. Link to comment
dzek (varez) Posted November 5, 2010 Share Posted November 5, 2010 can you post xml? -- try: local xmlFile = xmlLoadFile("Spawns.xml") outputDebugString("loading of xml: "..tostring(xmlFile)) -- to check if xml loading is ok. and you didn't reply to my questions Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now