SA-MP Forums Archive
SendPlayerMessage - 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: SendPlayerMessage (/showthread.php?tid=68983)



SendPlayerMessage - Jason_Larson - 15.03.2009

Hey All,

I'm trying to do something where if a player goes over a set co-ordinance it sends them a message on their screen. I know this is a very noobish question but I'd greatly appreciate some help.

I've tried a few different ways but I think I may be putting it in the wrong area in my script, anyhelp?


Re: SendPlayerMessage - Grim_ - 15.03.2009

This is not tested, but it might work...

//top of script
pawn Код:
forward AreaCheck();
//somewhere below 'main()'
pawn Код:
public AreaCheck()
{
 for(new i = 0; i<MAX_PLAYERS; i++)
 {
   new Float:Pos[3];
   GetPlayerPos(i, Pos[0], Pos[1], Pos[2]);
   if(PlayerToPoint(1, i, thex, they, thez)) //replace "thex, they, thez" with the coordinates of the place
   {
    GameTextForPlayer(i, "You are at the special spot", 5000, 5); //or whatever message you want displayed
   }
 }
 return 1;
}
//under OnGameModeInit
pawn Код:
SetTimer("AreaCheck", 1000, 1);



Re: SendPlayerMessage - Jason_Larson - 15.03.2009

If I want to add more than one position, can I just do??

GetPlayerPos(i, Pos[0], Pos[1], Pos[2]);
GetPlayerPos(i, Pos[0], Pos[1], Pos[2]);


Re: SendPlayerMessage - Grim_ - 15.03.2009

You could just add on to the code. For example, just add another line
pawn Код:
if(PlayerToPoint(1, i, theotherx, theothery, theotherz))



Re: SendPlayerMessage - Jason_Larson - 15.03.2009

You'll have to excuse me, but I'm very grateful for your help! However I've tried adding if but I think I'm doing it in the wrong way/area, as I get 26 errors lol. Could you put it in the code please. Thanks!


Re: SendPlayerMessage - Grim_ - 15.03.2009

Sure..try this

pawn Код:
public AreaCheck()
{
  for(new i = 0; i<MAX_PLAYERS; i++)
  {
   new Float:Pos[3];
   GetPlayerPos(i, Pos[0], Pos[1], Pos[2]);
   if(PlayerToPoint(1, i, thex, they, thez)) //replace "thex, they, thez" with the coordinates of the place
   {
     GameTextForPlayer(i, "You are at the special spot", 5000, 5); //or whatever message you want displayed
   }
   if(PlayerToPoint(1, i, theotherx, theothery, theotherz))
   {
     GameTextForPlayer(i, "You are at the other special spot", 5000, 5);
   }
  }
  return 1;
}



Re: SendPlayerMessage - Jason_Larson - 15.03.2009

Worked excellent, thank you so very much!!!!!