SA-MP Forums Archive
Players in groups - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Players in groups (/showthread.php?tid=425582)



Players in groups - arjanforgames - 26.03.2013

Hello,

I want to have 2 "groups" witch are in this case: group_one and group_two.
I got a timer that has a callback function and I need to have in the callback function a script that will put the player in either team_one or team_two. (Prefer auto asign)
So not on PlayerRequestClass or something but on my callback.

All things I want to happen after the countdown are listed in this callback:

pawn Код:
forward CountdownMechanics();
public CountdownMechanics()
Also I need something so I can see if someone is in team_one or team_two like:

pawn Код:
If(pTeam[playerid] == team_one)
{
    return 1;
}
Or something.

I've tried so much things but can't get the teams working.
Please help me if possible.


Re: Players in groups - RajatPawar - 26.03.2013

I didn't get what you want, for groups you can use y_groups, however.


Re: Players in groups - Babul - 26.03.2013

you should define a value to each team, like
pawn Код:
#define team_none 0
#define team_one 1
#define team_two 2
...then your if(pTeam[playerid])==team_one) check works already.
a player, freshly joined, has 0 in his pTeam[] cell, thats why its clever to check if a player is NOt assigned to a team yet similar to yours:
pawn Код:
if(pTeam[playerid])==team_none)
{
pTeam[playerid]=team_one;
}
...this would put any player into teamone. in order to balance it, its a good idea to simply count all players' teams, and chose the side with less players. if its equal, chose a random team ( random(2)+1 ).


Re: Players in groups - arjanforgames - 26.03.2013

Quote:
Originally Posted by Babul
Посмотреть сообщение
you should define a value to each team, like
pawn Код:
#define team_none 0
#define team_one 1
#define team_two 2
...then your if(pTeam[playerid])==team_one) check works already.
a player, freshly joined, has 0 in his pTeam[] cell, thats why its clever to check if a player is NOt assigned to a team yet similar to yours:
pawn Код:
if(pTeam[playerid])==team_none)
{
pTeam[playerid]=team_one;
}
...this would put any player into teamone. in order to balance it, its a good idea to simply count all players' teams, and chose the side with less players. if its equal, chose a random team ( random(2)+1 ).
Could you give an example on the balance? I tried some things but it didnt work out well.