IsPlayerInRangeOfPoint problem... - 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: IsPlayerInRangeOfPoint problem... (
/showthread.php?tid=664017)
IsPlayerInRangeOfPoint problem... -
qRazor - 17.02.2019
Hi guys I made a system of roadblocks and I have a problem, look in image.
Image with the problem:
https://imgur.com/a/COGIgyr
My code:
https://pastebin.com/AFEWK7Na
Re: IsPlayerInRangeOfPoint problem... -
Calisthenics - 17.02.2019
You cannot know if a player is in range or not unless the loop is completed.
pawn Code:
IsPlayerInRangeOfRoadBlocks(playerid)
{
for(new i = 0; i < sizeof(RoadBlocks); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, RoadBlocks[i][rbX], RoadBlocks[i][rbY], RoadBlocks[i][rbZ]))
{
return 1;
}
}
return 0;
}
If any point is found, it returns 1. When the loop is completed and the function did not exit, it means no roadblock is in range and it returns 0.
pawn Code:
if (IsPlayerInRangeOfRoadBlocks(playerid))
{
SCM(playerid, COLOR_YELLOW, "[DEBUG]: You're in range of one roadblock!");
}
else
{
SCM(playerid, COLOR_RED, "[DEBUG]: You're not in range of one roadblock!");
}
Re: IsPlayerInRangeOfPoint problem... -
qRazor - 17.02.2019
It works! I never thought of that, thank you very much!