Jump to content

weird bug


Castillo

Recommended Posts

Posted

hey i have a strange bug on my friend server, after some time when players are playing all gets fucked up :o 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.

Posted
  
-- 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 
  

Posted

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 

Posted

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?

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...