SA-MP Forums Archive
OnPlayerSpawn, check player team and spam the SendClientMessage if there is - 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: OnPlayerSpawn, check player team and spam the SendClientMessage if there is (/showthread.php?tid=343178)



OnPlayerSpawn, check player team and spam the SendClientMessage if there is - [LvZ]Free - 16.05.2012

Код:
public OnPlayerSpawn ( playerid ) {
    for(new i = 0; i < GetMaxPlayers(); i++)
      {
        if (gTeam[playerid] == TEAM_POLICE){
        new vR = random(sizeof(Vrand));
    	SetPlayerPos(playerid, Vrand[vR][0], Vrand[vR][1], Vrand[vR][2]);
    	SendClientMessage(playerid, 0xFFFFFFFF, "Police!");
        }
        else if (gTeam[playerid] == TEAM_SWAT){
        new vR = random(sizeof(Vrand));
    	SetPlayerPos(playerid, Vrand[vR][0], Vrand[vR][1], Vrand[vR][2]);
    	SendClientMessage(playerid, 0xFFFFFFFF, "SWAT!");
        }
        else if (gTeam[playerid] == TEAM_TERRORISTS){
        new vR = random(sizeof(Vrand));
    	SetPlayerPos(playerid, Vrand[vR][0], Vrand[vR][1], Vrand[vR][2]);
    	SendClientMessage(playerid, 0xFFFFFFFF, "Terrorists!");
        }
        else if (gTeam[playerid] == TEAM_HUNTERS){
        new vR = random(sizeof(Vrand));
    	SetPlayerPos(playerid, Vrand[vR][0], Vrand[vR][1], Vrand[vR][2]);
    	SendClientMessage(playerid, 0xFFFFFFFF, "Hunters!");
        }
      }
}
So this is the code, if i choose team and spawn with it the text EX:
Quote:

SendClientMessage(playerid, 0xFFFFFFFF, "Hunters!");

many times,
Код:
new vR = random(sizeof(Vrand));
    	SetPlayerPos(playerid, Vrand[vR][0], Vrand[vR][1], Vrand[vR][2]);
this code i took from one random spawn tutorial from here.... I don't know why this happening but i need help

// I think is cause of loop
Код:
for(new i = 0; i < GetMaxPlayers(); i++)
It's spammed 30 times = max slots in my server... So.. IDK from here

THx.. for help , i shall rep you (and sorry for bad english)...


Re: OnPlayerSpawn, check player team and spam the SendClientMessage if there is - ViniBorn - 16.05.2012

Delete the loop, you don't need.

pawn Код:
public OnPlayerSpawn ( playerid )
{
    if (gTeam[playerid] == TEAM_POLICE)
        SendClientMessage(playerid, 0xFFFFFFFF, "Police!");
    else if (gTeam[playerid] == TEAM_SWAT)
        SendClientMessage(playerid, 0xFFFFFFFF, "SWAT!");
    else if (gTeam[playerid] == TEAM_TERRORISTS)
        SendClientMessage(playerid, 0xFFFFFFFF, "Terrorists!");
    else if (gTeam[playerid] == TEAM_HUNTERS)
        SendClientMessage(playerid, 0xFFFFFFFF, "Hunters!");

    new vR = random(sizeof(Vrand));
    SetPlayerPos(playerid, Vrand[vR][0], Vrand[vR][1], Vrand[vR][2]);
    return 1;
}



Re: OnPlayerSpawn, check player team and spam the SendClientMessage if there is - Vince - 16.05.2012

Why, Why, Why is that stuff in a loop in the first place?


Re: OnPlayerSpawn, check player team and spam the SendClientMessage if there is - [LvZ]Free - 16.05.2012

a... i don't even know... I look again the tutorial and i don't see it ... it's seems i place this loop for nothing.. and thank u guys