SA-MP Forums Archive
Random teams. - 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: Random teams. (/showthread.php?tid=340841)



Random teams. - Blunt - 08.05.2012

Alright so recently I tried making some random teams, but couldn't get my mind round it.
I got some errors which will be posted below, and I need a new code or someone to tell me how and what to do, to make it run smoothly.

So this is what I come up with.

Код:
new Float:RandomTeams[][] =
{
	{TEAM_OFFENSE},
	{TEAM_DEFENSE}
};
Код:
CMD:randomteam(playerid, params[])
{
        new RandomTeam = random(sizeof(RandomTeams));
	SetPlayerTeam(playerid, RandomTeam[RandomTeam][0]);
	return 1;
}
I go to compile and I get these errors.

Код:
C:\Users\Mike\Desktop\Scripting\gamemodes\PRTDM.pwn(2580) : error 028: invalid subscript (not an array or too many subscripts): "RandomTeam"
C:\Users\Mike\Desktop\Scripting\gamemodes\PRTDM.pwn(2580) : warning 215: expression has no effect
C:\Users\Mike\Desktop\Scripting\gamemodes\PRTDM.pwn(2580) : error 001: expected token: ";", but found "]"
C:\Users\Mike\Desktop\Scripting\gamemodes\PRTDM.pwn(2580) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Scripting\gamemodes\PRTDM.pwn(2580) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.



Re: Random teams. - Ballu Miaa - 08.05.2012

Replace this with yours and compile again. Tell me what you get?

pawn Код:
new RandomTeams[][] =
{
    {TEAM_OFFENSE},
    {TEAM_DEFENSE}
};



Re: Random teams. - Blunt - 08.05.2012

Works fine, thank you.