Jump to content

weird bug


Castillo

Recommended Posts

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.

Link to comment
  
-- 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

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

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