Problem with (!IsPlayerInRangeOfPoint)
#1

Hello, I'm trying to make it so if you're not at the position and do /work It will
pawn Код:
SendClientMessage(playerid, COLOR_RED, "You're not in range of the job"
This is my current code:

pawn Код:
COMMAND:work(playerid, cmdtext) //You can edit this
{
    if (!IsPlayerInRangeOfPoint(playerid, 7.0, -64.1551,-1120.6709,1.0781))
    {
   
    SendClientMessage(playerid, blue, "Welcome to work!"); //You can edit this
    SendClientMessage(playerid, yellow, "Please drive to the checkpoint to recieve your reward."); //You can edit this
    new thevehicle = CreateVehicle(498, -79.2382, -1128.1711, 1.0781, 0.0, 0, 0, 5000);
    PutPlayerInVehicle(playerid, thevehicle, 0);
    SetPlayerCheckpoint(playerid, 1827.8311,-1075.7113,23.9317, 4.0);
    }
    return 1;
}
Do I do:
pawn Код:
COMMAND:work(playerid, cmdtext) //You can edit this
{
    if (!IsPlayerInRangeOfPoint(playerid, 7.0, -64.1551,-1120.6709,1.0781))
    {
        {
            else SendClientMessage(playerid, COLOR_RED, "You're not in range of the job");
        }
   
    SendClientMessage(playerid, blue, "Welcome to work!"); //You can edit this
    SendClientMessage(playerid, yellow, "Please drive to the checkpoint to recieve your reward."); //You can edit this
    new thevehicle = CreateVehicle(498, -79.2382, -1128.1711, 1.0781, 0.0, 0, 0, 5000);
    PutPlayerInVehicle(playerid, thevehicle, 0);
    SetPlayerCheckpoint(playerid, 1827.8311,-1075.7113,23.9317, 4.0);
    }
    return 1;
}
I don't know if that would work. Any help would be appreciated.
Reply
#2

No it won't, first you added an additional bracket at first and use return instead of else, and you didn't return under SetPlayerCheckpoint.
Reply
#3

You were trying to check if the player was not near the position, therefore it would execute the command. Try this code.

pawn Код:
COMMAND:work(playerid, cmdtext) //You can edit this
{
    if (!IsPlayerInRangeOfPoint(playerid, 7.0, -64.1551,-1120.6709,1.0781))
    {
        return SendClientMessage(playerid, COLOR_RED, "You're not in range of the job");
    }
    SendClientMessage(playerid, blue, "Welcome to work!"); //You can edit this
    SendClientMessage(playerid, yellow, "Please drive to the checkpoint to recieve your reward."); //You can edit this
    new thevehicle = CreateVehicle(498, -79.2382, -1128.1711, 1.0781, 0.0, 0, 0, 5000);
    PutPlayerInVehicle(playerid, thevehicle, 0);
    SetPlayerCheckpoint(playerid, 1827.8311,-1075.7113,23.9317, 4.0);
    return 1;
}
Reply
#4

pawn Код:
COMMAND:work(playerid, cmdtext) //You can edit this
{
    if(IsPlayerInRangeOfPoint(playerid, 7.0, -64.1551,-1120.6709,1.0781))
    {
        SendClientMessage(playerid, blue, "Welcome to work!"); //You can edit this
        SendClientMessage(playerid, yellow, "Please drive to the checkpoint to recieve your reward."); //You can edit this
        new thevehicle = CreateVehicle(498, -79.2382, -1128.1711, 1.0781, 0.0, 0, 0, 5000);
        PutPlayerInVehicle(playerid, thevehicle, 0);
        SetPlayerCheckpoint(playerid, 1827.8311,-1075.7113,23.9317, 4.0);
    }
    else SendClientMessage(playerid, COLOR_RED, "You're not in range of the job");
    return 1;
}
Try this possibly?
Reply
#5

Try change distance 7.0 to 20.0 :d
Reply
#6

Quote:
Originally Posted by Emmet_
Посмотреть сообщение
You were trying to check if the player was not near the position, therefore it would execute the command. Try this code.

pawn Код:
COMMAND:work(playerid, cmdtext) //You can edit this
{
    if (!IsPlayerInRangeOfPoint(playerid, 7.0, -64.1551,-1120.6709,1.0781))
    {
        return SendClientMessage(playerid, COLOR_RED, "You're not in range of the job");
    }
    SendClientMessage(playerid, blue, "Welcome to work!"); //You can edit this
    SendClientMessage(playerid, yellow, "Please drive to the checkpoint to recieve your reward."); //You can edit this
    new thevehicle = CreateVehicle(498, -79.2382, -1128.1711, 1.0781, 0.0, 0, 0, 5000);
    PutPlayerInVehicle(playerid, thevehicle, 0);
    SetPlayerCheckpoint(playerid, 1827.8311,-1075.7113,23.9317, 4.0);
    return 1;
}
Helped, thank you very much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)