forward ProxDetectorS(Float:radi, playerid, targetid);
public 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);
//radi = 2.0; //Trigger Radius
GetPlayerPos(targetid, posx, posy, posz);
tempposx = (oldposx -posx);
tempposy = (oldposy -posy);
tempposz = (oldposz -posz);
//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return true;
}
}
return 0;
}
Eg.:
Using a command or a function
if (ProxDetectorS(8.0, playerid, plr))
{
SendClientMessage(playerid, -1, "The player is near you!");
}
else
{
SendClientMessage(playerid, -1, " The character is far from You!");
return true;
}
That and an example, will not try to put it this way to be, and this is an example!
Any bug, post it here
Thank's