SA-MP Forums Archive
Problem with (!IsPlayerInRangeOfPoint) - 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: Problem with (!IsPlayerInRangeOfPoint) (/showthread.php?tid=282645)



Problem with (!IsPlayerInRangeOfPoint) - rangerxxll - 11.09.2011

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.


Re: Problem with (!IsPlayerInRangeOfPoint) - =WoR=G4M3Ov3r - 11.09.2011

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.


Re: Problem with (!IsPlayerInRangeOfPoint) - Emmet_ - 12.09.2011

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



Re: Problem with (!IsPlayerInRangeOfPoint) - skullmuncher1337 - 12.09.2011

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?


Re: Problem with (!IsPlayerInRangeOfPoint) - [M]onsieur - 12.09.2011

Try change distance 7.0 to 20.0 :d


Re: Problem with (!IsPlayerInRangeOfPoint) - rangerxxll - 12.09.2011

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.