SA-MP Forums Archive
[Help] ProxDetectorS - Easy - 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)
+--- Thread: [Help] ProxDetectorS - Easy (/showthread.php?tid=622599)



[Help] ProxDetectorS - Easy - Doniczzz - 24.11.2016

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?


Re: [Help] ProxDetectorS - Easy - Abagail - 24.11.2016

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:).


Respuesta: [Help] ProxDetectorS - Easy - Doniczzz - 24.11.2016

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



Re: Respuesta: [Help] ProxDetectorS - Easy - Abagail - 24.11.2016

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.


Respuesta: [Help] ProxDetectorS - Easy - Doniczzz - 24.11.2016

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"