im not near all the time
#1

hello, i made a command (/break) and you have to be near the person to execute the command but it seems that it tells me im never near the person.
pawn Код:
CMD:break(playerid, params[])
{
    new id, idcar, string[128], string2[128];
    if(gTeam[playerid] == MECHANIC)
    {
        if(PlayersDistance(playerid, id) > 5)
        {
            if(sscanf(params,"u",id)) return SendClientMessage(playerid, -1, "USAGE: /break <id/name>");
            idcar = GetPlayerVehicleID(id);
            SetVehicleHealth(idcar, 20);
            format(string, sizeof(string), "You have broken %s car by filling it with sand", PlayerName(id));
            format(string2, sizeof(string2), "%s has filled your engine with sand! get out!", PlayerName(playerid));
            SendClientMessage(playerid, -1, string);
            SendClientMessage(id, -1, string2);
            SetPlayerWantedLevel(playerid, 4);
            if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "This player is not connected");
            if(id == playerid) return SendClientMessage(playerid, -1, "You cant use this command on youself");
            return 1;
        }
        else if(PlayersDistance(playerid, id) < 5)
        {
            new string3[128];
            format(string3, sizeof(string3), "You are not close enough to %s", PlayerName(id));
            SendClientMessage(playerid, -1, string3);
            return 1;
        }
    }
    return 1;
}
Reply
#2

You made an exact opposite...
pawn Код:
if(PlayersDistance(playerid, id) > 5)
Distance is GREATER than 5.

pawn Код:
else if(PlayersDistance(playerid, id) < 5)
        {
            new string3[128];
            format(string3, sizeof(string3), "You are not close enough to %s", PlayerName(id));
            SendClientMessage(playerid, -1, string3);
            return 1;
        }
Distance is smaller than 5.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)