SendPlayerMessage
#1

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?
Reply
#2

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);
Reply
#3

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]);
Reply
#4

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

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!
Reply
#6

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;
}
Reply
#7

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


Forum Jump:


Users browsing this thread: 2 Guest(s)