[Help] ProxDetectorS - Easy
#1

My question is, how do I call a "callback" and use the "ProxDetectorS" to send a message to the closest player?

Example:

Код:
CALLBACK: test1(playerid)
{
	new jName = INVALID_PLAYER_ID;
        if(ProxDetectorS(3,playerid,jName))
		{
                     Mensaje(jNombre,-1,"closest player message.");
		}
       Mensaje(playerid, -1, "i use the callback");
	return 1;
}
With this code I get the message "i use the callback" but not send the message to the nearest player "closest player message."

What i doing wrong?
Reply
#2

Show your ProxDetectorS function. Also CALLBACK: could be anything(though it's likely just a macro for forward and public). You can call it directly using test1(playerid); where you want to call it. You probably don't need callbacks for this though, you can probably make this a function(just remove the CALLBACK:).
Reply
#3

I use the callback to a timer

Код:
SetTimerEx("test1", 90000, true, "i", playerid);
then

Код:
CALLBACK: test1(playerid)
{
	new jName = INVALID_PLAYER_ID;
        if(ProxDetectorS(3,playerid,jName))
		{
                     Mensaje(jNombre,-1,"closest player message.");
		}
       Mensaje(playerid, -1, "i use the callback");
	return 1;
}
So, i can use a function to a timer?

Код:
stock ProxDetectorS(Float:radi, playerid, targetid)
{
    if(IsPlayerConnected(playerid) && IsPlayerConnected(targetid))
	{
		new Float:posx, Float:posy, Float:posz;
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		GetPlayerPos(targetid, posx, posy, posz);
		tempposx = (oldposx -posx);
		tempposy = (oldposy -posy);
		tempposz = (oldposz -posz);
		if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}
Reply
#4

Quote:
Originally Posted by Doniczzz
Посмотреть сообщение
I use the callback to a timer

Код:
SetTimerEx("test1", 90000, true, "i", playerid);
then

Код:
CALLBACK: test1(playerid)
{
	new jName = INVALID_PLAYER_ID;
        if(ProxDetectorS(3,playerid,jName))
		{
                     Mensaje(jNombre,-1,"closest player message.");
		}
       Mensaje(playerid, -1, "i use the callback");
	return 1;
}
So, i can use a function to a timer?

Код:
stock ProxDetectorS(Float:radi, playerid, targetid)
{
    if(IsPlayerConnected(playerid) && IsPlayerConnected(targetid))
	{
		new Float:posx, Float:posy, Float:posz;
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		GetPlayerPos(targetid, posx, posy, posz);
		tempposx = (oldposx -posx);
		tempposy = (oldposy -posy);
		tempposz = (oldposz -posz);
		if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}
No, you have to use a callback for a timer. I am not exactly sure what you're trying to do, it seems the point of the ProxDetectorS function is to check if two players are in a certain radius of each other, but jName(targetid in the ProxDetector function) is INVALID_PLAYER_ID.
Reply
#5

I'm just trying when, i use the "timer" send a message a nearest player.

Because this "timer" don't have any command, i put this timer on "OnPlayerConnect"
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)