Jump to content

spawnPlayer: Bad Argument


Recommended Posts

I have this array at the top of my server script:

hiddenSpawn = {1093, -358, 74, 0} 

and then I have function which is called in my onPlayerJoin hook:

function startNewRound() 
    roundStatus = 2 
  
    currentHidden = getRandomPlayer() 
    setPlayerTeam(currentHidden, hiddenTeam) 
  
    for loopIndex, playerID in ipairs(getElementsByType("player")) do 
        if playerID == currentHidden then 
            spawnPlayer(playerID, hiddenSpawn[0], hiddenSpawn[1], hiddenSpawn[2], hiddenSpawn[3], 0) 
  
            addPedClothes(playerID, "glasses04dark", "glasses04", 15) 
            addPedClothes(playerID, "croupier", "valet", 17) 
        else 
            local randomSpawn = math.random(#defenderSpawns) 
            spawnPlayer(playerID, defenderSpawns[randomSpawn][0], defenderSpawns[randomSpawn][1], defenderSpawns[randomSpawn][2], defenderSpawns[randomSpawn][3], 179) 
  
            setPlayerTeam(playerID, defenderTeam) 
        end 
  
        setCameraTarget(playerID) 
    end 
end 

When I spawn, I'm getting the following warning:

hidden\hidden_server.lua:54: Bad argument @ 'spawnPlayer' 

Line 54 is:

spawnPlayer(playerID, hiddenSpawn[0], hiddenSpawn[1], hiddenSpawn[2], hiddenSpawn[3], 0) 

When I used outputChatBox on the values, they printed out fine but I got the same warning on outputChatBox. I also tried changing the values to 0 and it worked fine so it's a problem with the variables. I'm new to MTA, coming from another online GTA:SA modification, and I'm stuck on this little problem. I would appreciate it if somebody could guide me through this issue.

Thanks,

Ricky Phelps

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