20.06.2015, 09:36
I have seen in servers that if you come closer to certain locations, a small red checkpoint pops up and if you walk inside it a dialog opens.
Anyone knows how to do this?
Anyone knows how to do this?
First you need to detect if the player is near the desired location, use this under a callback like OnPlayerPosChange (not a SAMP function but can be found here: https://sampforum.blast.hk/showthread.php?tid=573961)
https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint Now when the player is near, use this: https://sampwiki.blast.hk/wiki/Function:SetPlayerCheckpoint To make a dialog open up whenever the player enters the CP, use this callback: https://sampwiki.blast.hk/wiki/OnPlayerEnterCheckpoint Or Streamer plugin may help you: https://sampforum.blast.hk/showthread.php?tid=102865 |
public OnPlayerPosChange(playerid, Float:newx, Float:newy, Float:newz, Float:oldx, Float:oldy, Float:oldz) { return 1; }
Looks great, can you just show me how to use
Код:
public OnPlayerPosChange(playerid, Float:newx, Float:newy, Float:newz, Float:oldx, Float:oldy, Float:oldz) { return 1; } |
public OnPlayerPosChange(playerid, Float:newx, Float:newy, Float:newz, Float:oldx, Float:oldy, Float:oldz)
{
if(IsPlayerInRangeOfPoint(playerid, 50.0, x, y, z))
{
SetPlayerCheckpoint(playerid, x, y, z);
}
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
{
ShowPlayerDialog(playerid, ...);
}
return 1;
}
It's pretty simple, i already gave you the link to IsPlayerInRangeOfPoint. So simply check if the player is near to the coordinates and create a checkpoint.
For example: pawn Код:
Now when the player is in range of the point (x, y, z), a checkpoint appears. To show dialog: pawn Код:
|