What's wrong with this loop?
#1

I haven't made that many loops before, and the loops I've made has been pretty simple.

pawn Code:
for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(strfind(result, NameTagInfo[playerid][nFirstName], true) != -1 || strfind(result, NameTagInfo[playerid][nLastName], true) != -1)
        {
            while(GetDistanceBetweenPlayers(playerid, i) < 10)
            {
                if(NameTagInfo[i][nFriend1] == 0)
                {
                    NameTagInfo[i][nFriend1] = PlayerInfo[playerid][pSQLID];
                    SaveFriends(i);
                }
                else if(NameTagInfo[i][nFriend2] == 0)
                {
                    SendClientMessage(i, COLOR_YELLOW, "It didn't work");
                    SendClientMessage(playerid, COLOR_YELLOW, "It didn't work");
                }
            }
            SendClientMessage(playerid, COLOR_YELLOW, "It worked!");
            return 1;
        }
    }
    return true;
I does work, but it also affects the players that types the command, and I want it to only affect the players around the player who types in the command.

It's just something I made for fun I guess, a piece where a player have to type in their name, and then the other players in range, can see his name.
Reply


Messages In This Thread
What's wrong with this loop? - by Knappen - 07.11.2011, 15:03
Re: What's wrong with this loop? - by Scarred - 07.11.2011, 15:08
Re: What's wrong with this loop? - by Knappen - 07.11.2011, 15:51

Forum Jump:


Users browsing this thread: 1 Guest(s)