SA-MP Forums Archive
Looping a command 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)
+--- Thread: Looping a command problem (/showthread.php?tid=489535)



Looping a command problem - AnonScripter - 23.01.2014

can somebody tell me how to make this work ? it doesn't sent the message and i want it to make the command works faster instead of (/heal [playerid])

pawn Код:
CMD:heal(playerid, params[])
{
    if(PlayerTeam[playerid] == TEAM_MEDIC)
    {
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && i != playerid)
            {
                if(GetDistanceBetweenPlayers(playerid,i) > AVAILABLE_DISTANCE) return SendClientMessage(playerid, COLOR_WHITE, "{FF0000}Error: {FFFFFF}There are no players close enough to heal.");
            }
        }
    }



Re: Looping a command problem - Jefff - 23.01.2014

You can't use return inside loop in this case


Re: Looping a command problem - AnonScripter - 23.01.2014

explain more please


Re: Looping a command problem - Jefff - 23.01.2014

pawn Код:
CMD:heal(playerid, params[])
{
    if(PlayerTeam[playerid] == TEAM_MEDIC)
    {
        new bool:PlayerFounded;
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && i != playerid)
            {
                if(GetDistanceBetweenPlayers(playerid,i) < AVAILABLE_DISTANCE)
                {
                    PlayerFounded = true;
                }
            }
        }
        if(!PlayerFounded)
            SendClientMessage(playerid, COLOR_WHITE, "{FF0000}Error: {FFFFFF}There are no players close enough to heal.");
    }