If player in pos - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: If player in pos (
/showthread.php?tid=84260)
If player in pos -
Sal_Kings - 29.06.2009
how do i make something so if a player is in a certain position a action will happen
explain in depth plz i am a noob
Re: If player in pos -
James_Alex - 29.06.2009
you have to set a timer in nGameMdeInit
then use the PlayerToPoint function
then do your action
example
pawn Код:
public OnGameModeInit()
{
SetTimer("MyAction", 100, true);
return 1;
}
forward MyAction();
public MyAction()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(PlayerToPoint(Float:Radi, playerid, PosX, PosX, PosZ))
{
//The Action
}
}
}
for more info visit
https://sampwiki.blast.hk/
Re: If player in pos -
dice7 - 29.06.2009
Use this function
pawn Код:
stock IsPlayerInArea(playerid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(X <= max_x && X >= min_x && Y <= max_y && Y >= min_y) return 1;
return 0;
}
You do it like
pawn Код:
if(IsPlayerInArea(playerid, max x, min x, max y, min y)
and if he is in the area, the code in the if statement will execute. And as stated above, you would need a timer to check of the players in the area