/W ? fails
#1

pawn Code:
CMD:w(playerid,params[])
    {
        new string[128], Player[MAX_PLAYER_NAME];
        new Float:x, Float:y, Float:z;
        GetPlayerName(playerid, Player, MAX_PLAYER_NAME);
        GetPlayerPos(playerid, x, y, z);
        format(string, 128, "[WHISPER] %s: %s", Player, params);
        for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerInRangeOfPoint(playerid, 15.0, x, y, z)) SendClientMessage(i, COLOR_WHITE, string);
        return 1;
    }
Everyone can hear this, not only the player that is in range of 15
Reply
#2

Quote:
Originally Posted by Mean
View Post
pawn Code:
CMD:w(playerid,params[])
    {
        new string[128], Player[MAX_PLAYER_NAME];
        new Float:x, Float:y, Float:z;
        GetPlayerName(playerid, Player, MAX_PLAYER_NAME);
        GetPlayerPos(playerid, x, y, z);
        format(string, 128, "[WHISPER] %s: %s", Player, params);
        for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerInRangeOfPoint(playerid, 15.0, x, y, z)) SendClientMessage(i, COLOR_WHITE, string);
        return 1;
    }
Everyone can hear this, not only the player that is in range of 15
In the for-loop you once mixed up 'i' and 'playerid' when checking the range.
Reply
#3

So how to fix?
EDIT:Found it
Reply
#4

pawn Code:
CMD:w(playerid,params[])
    {
        new string[128], Player[MAX_PLAYER_NAME];
        new Float:x, Float:y, Float:z;
        GetPlayerName(playerid, Player, MAX_PLAYER_NAME);
        GetPlayerPos(playerid, x, y, z);
        format(string, 128, "[WHISPER] %s: %s", Player, params);
        for(new i=0; i<MAX_PLAYERS; i++)
        {
                  if(IsPlayerInRangeOfPoint(i, 15.0, x, y, z)) return SendClientMessage(i, COLOR_WHITE, string);
        }        
        return 1;
    }
Reply
#5

ty will!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)