IsPlayerInRangeOfPoint problem...
#1

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
Reply
#2

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!");
}
Reply
#3

It works! I never thought of that, thank you very much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)