Error with Positions
#1

When I type /docarrest .... its saying You are not at DoC Facilties ...idk why ... I am not seeing any error's


pawn Код:
CMD:docarrest(playerid, params[])
{
    if(IsACop(playerid)) {
        if(!IsPlayerInRangeOfPoint(playerid, 12.0, 1788.3121, -1569.8536, 22.9151) || !IsPlayerInRangeOfPoint(playerid, 12.0, 1760.0992, -1541.9899, 9.3473))
        {
            SendClientMessageEx(playerid, COLOR_GREY, "You're not at DoC Facilities.");
            return 1;
        }
        new giveplayerid;
        if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /docarrest [playerid]");

        if(IsPlayerConnected(giveplayerid))
        {
            if(giveplayerid == playerid) {
                return SendClientMessageEx(playerid, COLOR_GREY, "You can't arrest yourself.");
            }
            if(ProxDetectorS(8.0, playerid, giveplayerid))
            {
                new string[37 + MAX_PLAYER_NAME];
                SetPVarInt(giveplayerid, "IsFrozen", 0);
                format(string, sizeof(string), "* You've brought %s to DoC Facilities.", GetPlayerNameEx(giveplayerid));
                SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
                format(string, sizeof(string), "* %s brought you to DoC Facilities.", GetPlayerNameEx(playerid));
                SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
                GameTextForPlayer(giveplayerid, "~w~Welcome to ~n~~r~DoC Facilities", 5000, 3);
                TogglePlayerControllable(giveplayerid, 1);
                ClearAnimations(giveplayerid);
                PlayerCuffed[giveplayerid] = 0;
                SetPVarInt(giveplayerid, "PlayerCuffed", 0);
                format(PlayerInfo[giveplayerid][pPrisonedBy], 24, "%s", GetPlayerNameEx(playerid));
                format(PlayerInfo[giveplayerid][pPrisonReason], 128, "[IC] Military Apprehension");
                WantedPoints[giveplayerid] = 0;
                PlayerInfo[giveplayerid][pWantedLevel] = 0;
                SetPlayerToTeamColor(giveplayerid);
                SetPlayerWantedLevel(giveplayerid, 0);
                SetPlayerSkin(giveplayerid, 50);
                PlayerInfo[giveplayerid][pJailed] = 2;
                PhoneOnline[giveplayerid] = 1;
                PlayerInfo[giveplayerid][pJailTime] = 3600;
                SetPlayerInterior(giveplayerid, 1);
                PlayerInfo[giveplayerid][pInt] = 1;
                SetPlayerSkin(giveplayerid, 50);
                SetPlayerVirtualWorld(giveplayerid, 0);
                PlayerInfo[giveplayerid][pVW] = 0;
                SetPlayerColor(giveplayerid, TEAM_ORANGE_COLOR);
                GameTextForPlayer(giveplayerid, "Objects loading...", 1000, 5);
                SetPVarInt(giveplayerid, "LoadingObjects", 1);
                SetTimerEx("SafeLoadObjects", 4000, 0, "d", giveplayerid);
                new rand = random(sizeof(ICPrisonSpawns));
                Streamer_UpdateEx(giveplayerid, ICPrisonSpawns[rand][0], ICPrisonSpawns[rand][1], ICPrisonSpawns[rand][2]);
                SetPlayerPos(giveplayerid, ICPrisonSpawns[rand][0], ICPrisonSpawns[rand][1], ICPrisonSpawns[rand][2]);
                ResetPlayerWeaponsEx(giveplayerid);
            }
            else
            {
                SendClientMessageEx(playerid, COLOR_GREY, "That player isn't near you.");
                return 1;
            }
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
            return 1;
        }
    }
    return 1;
}
Reply
#2

Change this line:
pawn Код:
if(!IsPlayerInRangeOfPoint(playerid, 12.0, 1788.3121, -1569.8536, 22.9151) || !IsPlayerInRangeOfPoint(playerid, 12.0, 1760.0992, -1541.9899, 9.3473))
To this:
pawn Код:
if(!IsPlayerInRangeOfPoint(playerid, 12.0, 1788.3121, -1569.8536, 22.9151) && !IsPlayerInRangeOfPoint(playerid, 12.0, 1760.0992, -1541.9899, 9.3473))
They should have both conditions in order to get the message, therefore you use && instead of ||
Reply
#3

thanks bro
Reply
#4

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
pawn Код:
if(!IsPlayerInRangeOfPoint(playerid, 12.0, 1788.3121, -1569.8536, 22.9151) && !IsPlayerInRangeOfPoint(playerid, 12.0, 1760.0992, -1541.9899, 9.3473))
They should have both conditions in order to get the message, therefore you use && instead of ||
That means the player could be in range of one point, but still not be able to use the command because the player isn't in range of the other point. Therefore it should be || and the OP's code is fine.
Reply
#5

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
That means the player could be in range of one point, but still not be able to use the command because the player isn't in range of the other point. Therefore it should be || and the OP's code is fine.
Just the other way around. They are NOT statements so:

if the player is NOT at point A and NOT at point B, then say "NO CAN DO!" else he is at one point so let the code continue. Therefore, your statement is false
Reply
#6

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
That means the player could be in range of one point, but still not be able to use the command because the player isn't in range of the other point. Therefore it should be || and the OP's code is fine.
|| is OR, && is AND.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)