Jump to content

Max players in team


MatXpl

Recommended Posts

Posted

I created this but i have problem :?

if nnnCount == 0 then 
        setPlayerTeam" class="kw6">setPlayerTeam (thePlayer, pnn) 
        outputChatBox ("You are in NeRN", thePlayer, 255, 0, 0, true) 
        setElementPosition (thePlayer, 2021, 1065, 104) 
        setPlayerSkin (thePlayer, 148) 
  
elseif pCount == 1 then 
... 

and in debug script shows:

Bad 'player' pointer @ 'setPlayerTeam'(1) 
Bad 'element' pointer @ 'outputChatBox'(1) 
... 

But i have defined player

function teams (thePlayer) 

Help !

Posted

you cant post a single line that gives error and expect help.

that way people only can help you with syntax errors.

and if you have some function which has some "thePlayer" argument, it doesnt mean its not nil.

where's this function called? what is passed to this function?

Posted

Script:

  
fl = createTeam ( "FL", 0, 10, 200 ) 
nn = createTeam ( "NN", 0, 200, 10 ) 
pCount = countPlayersInTeam ( fl ) 
mCount = countPlayersInTeam ( nn ) 
  
function team (thePlayer) 
    if pCount == 0 then 
        setPlayerTeam" class="kw6">setPlayerTeam (thePlayer, fl) 
        outputChatBox ("Spawned", thePlayer, 255, 10, 0, true) 
        setElementPosition (thePlayer, 1232, 1011, 254) 
        setPlayerSkin (thePlayer, 168) 
    elseif pCount == 1 then 
        setPlayerTeam" class="kw6">setPlayerTeam (thePlayer , nn) 
        setElementPosition (thePlayer, 1510, 120, 113) 
        setPlayerSkin (thePlayer, 166) 
    end 
end 
addEventHandler( "onPlayerLogin", getRootElement(), team ) 
  

Posted

"thePlayer" is not a player element here, it's player's previous account.

use "source" instead.

and i bet you'll need to recount team members when you add a player to the team.

Posted

i have a question, wtf is this?

setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam (thePlayer, fl) 
 

would that also work? and whats the difference?

Posted

lol i uploaded

"setPlayerTeam( thePlayer, fl )" and after writing my post code has changed ... maybe its a bug in the forum?

Here i add code not in code tags:

a = createTeam ( "teamA", 0, 10, 200 )

b = createTeam ( "teamB", 0, 200, 10 )

aCount = countPlayersInTeam ( a )

bCount = countPlayersInTeam ( b )

function team (thePlayer)

if aCount == 0 then

setPlayerTeam (thePlayer, a)

outputChatBox ("A", thePlayer, 255, 0, 0, true)

setElementPosition (thePlayer, 1021, 1120, 142)

setPlayerSkin (thePlayer, 184)

elseif bCount == 1 then

setPlayerTeam (thePlayer , b)

setElementPosition (thePlayer, 100, 100, 100)

setPlayerSkin (thePlayer, 162)

end

end

addEventHandler( "onPlayerLogin", getRootElement(), team )

Posted

put the count players in team functions into onPlayerLogin function, this.

a = createTeam ( "teamA", 0, 10, 200 ) 
b = createTeam ( "teamB", 0, 200, 10 ) 
  
function team (thePlayer) 
aCount = countPlayersInTeam ( a ) 
bCount = countPlayersInTeam ( b ) 
if aCount == 0 then 
setPlayerTeam" class="kw6">setPlayerTeam (thePlayer, a) 
outputChatBox ("A", thePlayer, 255, 0, 0, true) 
setElementPosition (thePlayer, 1021, 1120, 142) 
setPlayerSkin (thePlayer, 184) 
elseif bCount == 1 then 
setPlayerTeam" class="kw6">setPlayerTeam (thePlayer , b) 
setElementPosition (thePlayer, 100, 100, 100) 
setPlayerSkin (thePlayer, 162) 
end 
end 
addEventHandler( "onPlayerLogin", getRootElement(), team ) 

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