loop problem - 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: loop problem (
/showthread.php?tid=251939)
loop problem -
fissekarl - 29.04.2011
Hello. When I put some messages under a loop , the message gets send twice if 2 players are online? Why?
Re: loop problem -
MadeMan - 29.04.2011
Because you have scripted it like that.
Re: loop problem -
JaTochNietDan - 29.04.2011
Well, that sounds like you're using the function SendClientMessageToAll in a loop, in which case why are you using a loop? If you want to send a message to everyone, just use SendClientMessageToAll on its own.
Re: loop problem -
fissekarl - 29.04.2011
That was a nice answer MadeMan.
And yes JaTochNietDan
but how in this case?
pawn Код:
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(gTeam[i] == 1)
{
SendClientMessageToTeam(team1,teamcolor, "....");
}
if(gTeam[i] == 2)
{
SendClientMessageToTeam(team2,teamcolor2, "....");
}
}
}
Re: loop problem -
MadeMan - 29.04.2011
Quote:
Originally Posted by fissekarl
That was a nice answer MadeMan.
|
It was a nice question too.
Re: loop problem -
fissekarl - 29.04.2011
ok MadeMan....
So how could I do that with gteam?
Should I do it outside a loop?
Re: loop problem -
MadeMan - 29.04.2011
What are you trying to do?
Re: loop problem -
fissekarl - 29.04.2011
This is why I want to use the loop
pawn Код:
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(gTeam[i] == 1)
{
SetTeamPos(1, X , Y , Z);
SetPlayerFacingAngle(i, angle);
SetCameraBehindPlayer(i);
SendClientMessageToTeam(team1,teamcolor, "....");
}
if(gTeam[i] == 2)
{
SetTeamPos(2, X , Y , Z);
SetPlayerFacingAngle(i, angle);
SetCameraBehindPlayer(i);
SendClientMessageToTeam(team2,teamcolor2, "....");");
}
}
}
but is the loop needed?
Re: loop problem -
MadeMan - 29.04.2011
What does SetTeamPos do?
Re: loop problem -
fissekarl - 29.04.2011
It sets all players from Team 1's pos to X,Y,Z