IsPlayerInRangeOfPoint -
AlfaSufaIndo - 20.10.2018
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(playerid, 2, HouseData[i][houseX], HouseData[i][houseY], HouseData[i][houseZ]))
{
SetPlayerCheckpoint(playerid, HouseData[i][houseX], HouseData[i][houseY], HouseData[i][houseZ], 2);
}
else
{
DisablePlayerCheckpoint(playerid);
}
Re: IsPlayerInRangeOfPoint -
Calisthenics - 20.10.2018
You are trying to achieve what streamer plugin already does.
Re: IsPlayerInRangeOfPoint -
AlfaSufaIndo - 20.10.2018
Quote:
Originally Posted by Calisthenics
You are trying to achieve what streamer plugin already does.
|
Then what should I do?
Re: IsPlayerInRangeOfPoint -
Calisthenics - 20.10.2018
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)
Re: IsPlayerInRangeOfPoint -
AlfaSufaIndo - 20.10.2018
Quote:
Originally Posted by Calisthenics
|
Can you give an example of how it works for me?
Re: IsPlayerInRangeOfPoint -
Calisthenics - 20.10.2018
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;
}
Re: IsPlayerInRangeOfPoint -
Kane - 20.10.2018
Use areas instead. CP set on enter, clear on exit.
Re: IsPlayerInRangeOfPoint -
AlfaSufaIndo - 20.10.2018
Quote:
Originally Posted by Calisthenics
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