IsPlayerInRangeOfPoint
#1

So I want to make it so that if the player approaches a certain area it will make a checkpoint, and if the player moves away from that area it will automatically delete the checkpoint. I've tried to make it but it doesn't work well. Checkpoint is not lost even though the player has moved away from the area

PHP Code:
if(IsPlayerInRangeOfPoint(playerid2HouseData[i][houseX], HouseData[i][houseY], HouseData[i][houseZ]))
{
    
SetPlayerCheckpoint(playeridHouseData[i][houseX], HouseData[i][houseY], HouseData[i][houseZ], 2);
}
else
{
    
DisablePlayerCheckpoint(playerid);

Reply
#2

You are trying to achieve what streamer plugin already does.
Reply
#3

Quote:
Originally Posted by Calisthenics
View Post
You are trying to achieve what streamer plugin already does.
Then what should I do?
Reply
#4

Use dynamic checkpoints. It disables the checkpoint when the distance is longer than stream distance specified (2.0 in your case).

https://github.com/samp-incognito/sa...-(Checkpoints)
Reply
#5

Quote:
Originally Posted by Calisthenics
View Post
Use dynamic checkpoints. It disables the checkpoint when the distance is longer than stream distance specified (2.0 in your case).

https://github.com/samp-incognito/sa...s-(Checkpoints)
Can you give an example of how it works for me?
Reply
#6

I fixed the link on the github wiki.

You create the dynamic checkpoints once, when you load the houses. Add a variable to store the checkpoint id in your `HouseData` array.
pawn Code:
// loading data of each house
HouseData[i][houseCP] = CreateDynamicCP(HouseData[i][houseX], HouseData[i][houseY], HouseData[i][houseZ], size_of_checkpoint, .streamdistance = 2.0);
When player will be streamed, it will show the checkpoint or disable if not. The callback when enter one is
pawn Code:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
Streamer provides an extra id and can be used to skip loops if you set an offset.
pawn Code:
#define HOUSES_OFFSET 50000
pawn Code:
// loading data of each house
HouseData[i][houseCP] = CreateDynamicCP(HouseData[i][houseX], HouseData[i][houseY], HouseData[i][houseZ], size_of_checkpoint, .streamdistance = 2.0);
Streamer_SetIntData(STREAMER_TYPE_CP, HouseData[i][houseCP], E_STREAMER_EXTRA_ID, HOUSES_OFFSET + i);
When a player enters a dynamic checkpoint, you subtract the offset and expect it to be in a certain range. If none was set, it is by default 0 so the result would be a negative number.
pawn Code:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    new house_id = Streamer_GetIntData(STREAMER_TYPE_CP, HouseData[i][houseCP], E_STREAMER_EXTRA_ID) - HOUSES_OFFSET;

    if (house_id >= 0)
    {
        // player entered checkpoint at position:
        //HouseData[house_id][houseX], HouseData[house_id][houseY], HouseData[house_id][houseZ]
    }
    return 1;
}
Reply
#7

Use areas instead. CP set on enter, clear on exit.
Reply
#8

Quote:
Originally Posted by Calisthenics
View Post
I fixed the link on the github wiki.

You create the dynamic checkpoints once, when you load the houses. Add a variable to store the checkpoint id in your `HouseData` array.
pawn Code:
// loading data of each house
HouseData[i][houseCP] = CreateDynamicCP(HouseData[i][houseX], HouseData[i][houseY], HouseData[i][houseZ], size_of_checkpoint, .streamdistance = 2.0);
When player will be streamed, it will show the checkpoint or disable if not. The callback when enter one is
pawn Code:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
Streamer provides an extra id and can be used to skip loops if you set an offset.
pawn Code:
#define HOUSES_OFFSET 50000
pawn Code:
// loading data of each house
HouseData[i][houseCP] = CreateDynamicCP(HouseData[i][houseX], HouseData[i][houseY], HouseData[i][houseZ], size_of_checkpoint, .streamdistance = 2.0);
Streamer_SetIntData(STREAMER_TYPE_CP, HouseData[i][houseCP], E_STREAMER_EXTRA_ID, HOUSES_OFFSET + i);
When a player enters a dynamic checkpoint, you subtract the offset and expect it to be in a certain range. If none was set, it is by default 0 so the result would be a negative number.
pawn Code:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    new house_id = Streamer_GetIntData(STREAMER_TYPE_CP, HouseData[i][houseCP], E_STREAMER_EXTRA_ID) - HOUSES_OFFSET;

    if (house_id >= 0)
    {
        // player entered checkpoint at position:
        //HouseData[house_id][houseX], HouseData[house_id][houseY], HouseData[house_id][houseZ]
    }
    return 1;
}
OMG!! Thats work!! Thanks bro
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)