SA-MP Forums Archive
Set player team from Filterscript - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Set player team from Filterscript (/showthread.php?tid=155417)



Set player team from Filterscript - VirSpectorX - 18.06.2010

I am scripting a Filterscript for a server, it's not my server, but i am just a scripter of some of the filterscripts.

And then, i tried using SetPlayerTeam, but when i enter the server, the SetPlayerTeam doesn't works, i still have my old team. Are there anything that i can do with it?


Re: Set player team from Filterscript - VirSpectorX - 18.06.2010

anybody?


Re: Set player team from Filterscript - KDlivest954 - 18.06.2010

did u take any previous SetPlayerTeam stuff out of the GM itself?


Re: Set player team from Filterscript - park4bmx - 18.06.2010

is it like this
pawn Код:
SetPlayerTeam(playerid, 1);
_________________________________________________
(playerid, 1);
[b][1] is what team NUMBER u put the player in


Re: Set player team from Filterscript - TTJJ - 18.06.2010

Hi VirSpectorX,

If you are having trouble using SetPlayerTeam you could try using your own variables.

eg.

Код:
//Top of script
new Team[MAX_PLAYERS];
//OnPlayerConnect
Team[playerid] = -1;
//Loading stats / OnPlayerSpawn
Team[playerid] = TEAM VARIABLE HERE
//And to reference:
if(Team[playerid] == TEAM VARIABLE HERE)
I have found this the easiest way to track player teams. Give it a go.

Cheers,

TJ


Re: Set player team from Filterscript - VirSpectorX - 20.06.2010

No, in the game mode, there already a Team system.

Now, i tried to use SetPlayerTeam(playerid, #teamid#); in a filterscript but it doesn't works...

(#teamid# is the id of the team i set in the filtersript)


Re: Set player team from Filterscript - VirSpectorX - 20.06.2010

Quote:
Originally Posted by KDlivest954
did u take any previous SetPlayerTeam stuff out of the GM itself?
Yes


Re: Set player team from Filterscript - DJDhan - 20.06.2010

Use PVar.

In your GM
Код:
SetPvarInt(playerid,"Team",Teamid);
Now when you try to get the team of the player in your FS, you'll do :

Код:
new teamid[MAX_PLAYERS];
teamid[playerid]=GetPVarInt(playerid,"Team");
There you have the team id.


Re: Set player team from Filterscript - VirSpectorX - 20.06.2010

Quote:
Originally Posted by DJDhan
Use PVar.

In your GM
Код:
SetPvarInt(playerid,"Team",Teamid);
Now when you try to get the team of the player in your FS, you'll do :

Код:
new teamid[MAX_PLAYERS];
teamid[playerid]=GetPVarInt(playerid,"Team");
There you have the team id.
No, what i want is, to set the Player Team, not to get the player team...


Re: Set player team from Filterscript - DJDhan - 20.06.2010

The above code would let you check for a player's team in any of your FSs.

To set a player's team
Код:
#define TEAM_ONE 1
#define TEAM_TWO 2
new gTeam[MAX_PLAYERS];
Then under OnPlayerRequestClass
Call a function to set the player's team like so:
Код:
SetPlayerTeamFromClass(playerid,classid);
Код:
forward SetPlayerTeamFromClass(playerid,classid);
public SetPlyerTeamFromClass(playerid,classid)
{
if(classid==0) gTeam[playerid] = TEAM_ONE;
if(classid==1) gTeam[playerid] = TEAM_TWO;
return 1;
}
Under OnPlayerSpawn
Код:
SetPlayerTeam(playerid,gTeam[playerid]);
I've answered a topic similar to yours, please search.