SA-MP Forums Archive
im not near all the time - 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: im not near all the time (/showthread.php?tid=361584)



im not near all the time - thefatshizms - 21.07.2012

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;
}



Re: im not near all the time - [XST]O_x - 21.07.2012

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.