Looping a command problem
#1

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.");
            }
        }
    }
Reply
#2

You can't use return inside loop in this case
Reply
#3

explain more please
Reply
#4

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.");
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)