[SOLVED] IfPlayerIsInRangeOfPoint - SendClientMessage? How? :(
#1

Hey you all lovely peoples.

I have been playing around with several kind of combinations of codes, but i just can't seem to get this to work.
Everything looks right for me, but nothing happens when i'm in the area.

I currently have this, but doesn't work either.
Код:
forward IsAtScrapyard(playerid);

public IsAtScrapyard(playerid)
{
    new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid,x, y, z);
	if(IsPlayerInRangeOfPoint(playerid,5,-1210.7212,-1061.7201,128.2656))
	SendClientMessage(playerid,COLOR_YELLOW, "Type /buyscrapticket to enter the scrapyard.");
 	return 1;
 	}
It compiles though.
Can anybody tell me what i am doing wrong? Thanks
Reply
#2

You didn't set a timer for IsAtScrapyard.

PS: You might want to place it at OnPlayerUpdate, but as it's a callback which is called a lot of times each second, i'd say no.
Reply
#3

Use a timer and loop through all players and check to pos

https://sampwiki.blast.hk/wiki/SetTimer
Reply
#4

Instead of SendClientMessage, try GameTextForPlayer if you don't want to start making timers and blablabla for it
Reply
#5

As i know of, the GameTextToPlayer is something that shows up in the middle of the screen and then goes away, if i am correct?
Not quite what i need, but thanks


How am i placing a timer and a loop in this code?
I'm not quite familiar with timer or loops yet.

I am appreciating your help guys
Reply
#6

I've been trying to figure this out with timers aswell as loops, but i just dont get it.
Everything i do seems to be wrong.
I re-checked the coordinates, and they perfectly matches.

Any ideas of what i could do or how the code could look like?
Much appreciated, thanks.
Reply
#7

Use Under OnPlayerConnect: SetTimerEx with playerid parameters

and a loop is:
Код:
for(new x; x != MAX_PLAYERS; x++)
use instead playerid, x
But you don't need because you use playerid as parameter.
Reply
#8

This makes no sense to me at all.
I have absolutely no idea of what to do to get this to work.

I've tried everything you have told me to do, but i am doing something wrong that i don't know of.

Can anyone, make a quick overview of, what i am going to do, to get this to work?

All i need is:
If a player is in range of point
then send a message to playerid.

It sounds so easy to me, but seems to be the hardest thing i've tried so far.
I just can't get it to work, and i've played around with more than 20 different combinations of the code now. :/
Reply
#9

pawn Код:
public OnPlayerConnect(playerid)
{
  ...
  SetTimerEx("IsAtScrapyard", time, true, "d", playerid); // change 'time' for the time in milliseconds
  return 1;
}
pawn Код:
forward IsAtScrapyard(playerid);
public IsAtScrapyard(playerid)
{
  new Float:x, Float:y, Float:z;
  GetPlayerPos(playerid, x, y, z);
  if(IsPlayerInRangeOfPoint(playerid, 5, -1210.7212, -1061.7201, 128.2656))
  SendClientMessage(playerid, COLOR_YELLOW, "Type /buyscrapticket to enter the scrapyard.");
  return 1;
}
Reply
#10

You are the best!


Thanks man!
Reply


Forum Jump:


Users browsing this thread: