If a player is Close
#1

I want to detect if the player (playerid) has about any player, in order to disable this command if you have someone close
heres is my code =B
Код:
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++)
  {
  	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;
	  }
	  else
		{
			return 0;
	  }
	}
}
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/sf", cmdtext, true, 10) == 0)
	{
		if (IsPlayerClose(playerid,10)==0)
		{
			Teleport(playerid,80,-1977.1107,285.8831,35.1719,0,0);
			Announcecmd(playerid,": a ido hacia /sf","asd",1,COLOR_AZUL,3);
 		}
		return 1;
	}
	return 0;
}
but when i compile show this error
Quote:
Originally Posted by MDFK ERROR
gamemodes\ChrisDM.pwn(190) : warning 209: function "IsPlayerClose" should return a value
Reply
#2

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


Forum Jump:


Users browsing this thread: 1 Guest(s)