19.09.2009, 03:54
Here's the code I'm using to see if a player is near.
This command should only be used if no player is near, but always detects that a player is close but not there no player connected.
I'm using the wrong code?, Or because it does not work, any idea.
Thanks for your answers =D
pawn Код:
stock IsPlayerClose(playerid, Float:radi)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
new Float:otherx, Float:othery, Float:otherz;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
GetPlayerPos(i, otherx, othery, otherz);
tempposx = (oldposx -otherx);
tempposy = (oldposy -othery);
tempposz = (oldposz -otherz);
if(((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
}
}
return 0;
}
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/sf", cmdtext, true, 10) == 0)
{
if (IsPlayerClose(playerid,5.00) == 0)
{
Teleport(playerid,80,-1977.1107,285.8831,35.1719,0,0);
Announcecmd(playerid,": a ido hacia /sf","asd",1,COLOR_AZUL,3);
}
else
{
SendClientMessage(playerid,COLOR_ROJO,"AVISO: Hay un jugador cerca no puedes usar este comando.");
}
return 1;
}
return 0;
}
Thanks for your answers =D