IsPlayerInRange problem -
PrivatioBoni - 10.09.2013
I haven't coded in a while and I've became very rusty even making the most basic of scripts. This script returns no errors on Pawn but in-game, it allows me to go on duty if I'm pPD 1, but it puts me on duty no matter where I am, but also returns the error: "ERROR: Unknown command".
The below is the relevant code, I think I've only made a minor mistake. I seem to remember coding this successfully before but I've forgotten how to properly do it.
pawn Код:
if (strcmp("/duty", cmdtext, true, 5) == 0)
{
if(PlayerInfo[playerid][pPD] < 1)
return SendClientMessage(playerid, COLOR_ERROR,"ERROR.");
if(IsPlayerInRangeOfPoint(playerid, 5.0,-2500.2500,250.2500,5.2500))
SendClientMessage(playerid, COLOR_ERROR,"ERROR.");
else
SendClientMessage(playerid, COLOR_WHITE, "Police duty");
SetPlayerHealth(playerid, 100.100);
SetPlayerArmour(playerid, 100.100);
SetPlayerColor(playerid, COLOR_WHITE);
return 0;
}
I've tried many combinations but to no avail.
Any help would be appreciated.
Thanks.
Re: IsPlayerInRange problem -
Areax - 10.09.2013
pawn Код:
if(!IsPlayerInRangeOfPoint(playerid, 5.0,-2500.2500,250.2500,5.2500))
Re: IsPlayerInRange problem -
PrivatioBoni - 10.09.2013
That's helped slightly, but my problem is still occurring. It still lets me go on duty but now it says the "ERROR" thing -- it still says "ERROR: Unknown command" though. Before, it said "Police duty" and the "ERROR: Unknown command" error.
I think I've messed up slightly.
Re: IsPlayerInRange problem -
Areax - 10.09.2013
pawn Код:
if(strcmp("/duty", cmdtext, true, 5) == 0)
{
if(PlayerInfo[playerid][pPD] < 1)
return SendClientMessage(playerid, COLOR_ERROR,"ERROR.");
if(IsPlayerInRangeOfPoint(playerid, 5.0,-2500.2500,250.2500,5.2500))
SendClientMessage(playerid, COLOR_ERROR,"ERROR.");
else
SendClientMessage(playerid, COLOR_WHITE, "Police duty");
SetPlayerHealth(playerid, 100.100);
SetPlayerArmour(playerid, 100.100);
SetPlayerColor(playerid, COLOR_WHITE);
return 1;
}
Re: IsPlayerInRange problem -
PrivatioBoni - 10.09.2013
With the code above, it puts me on duty, says 'Police duty' and there's no unknown command error, but it now completely ignores the IsPlayerInRangeOfPoint.
Thanks for your help though, but further help is appreciated!
Re: IsPlayerInRange problem -
Konstantinos - 10.09.2013
It depends on what you want.
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 5.0,-2500.2500,250.2500,5.2500))
SendClientMessage(playerid, COLOR_ERROR,"ERROR.");
else
SendClientMessage(playerid, COLOR_WHITE, "Police duty");
This code sends the message "ERROR" if you're in range of those coordinates. If you're not, then it sends the message "Police duty".
In case you want the opposite, do what Areax said at his first post.
Also, if you want the health, armour and colour when they're on police duty, you need to use it inside a block { }.
pawn Код:
else
{
SendClientMessage(playerid, COLOR_WHITE, "Police duty");
SetPlayerHealth(playerid, 100.100);
SetPlayerArmour(playerid, 100.100);
SetPlayerColor(playerid, COLOR_WHITE);
}
Re: IsPlayerInRange problem -
Areax - 10.09.2013
pawn Код:
if(strcmp("/duty", cmdtext, true, 5) == 0)
{
if(PlayerInfo[playerid][pPD] < 1)
return SendClientMessage(playerid, COLOR_ERROR,"ERROR.");
if(!IsPlayerInRangeOfPoint(playerid, 5.0,-2500.2500,250.2500,5.2500))
SendClientMessage(playerid, COLOR_ERROR,"ERROR.");
else
SendClientMessage(playerid, COLOR_WHITE, "Police duty");
SetPlayerHealth(playerid, 100.100);
SetPlayerArmour(playerid, 100.100);
SetPlayerColor(playerid, COLOR_WHITE);
return 1;
}
My bad :P I forgot "
!"
Re: IsPlayerInRange problem -
PrivatioBoni - 10.09.2013
We fixed it!
Thanks Areax and Konstantinos, you've both received + reps.
(Well, I approved your posts. I don't think you got a plus rep but whatever :P)