SA-MP Forums Archive
PlayerToPoint Help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: PlayerToPoint Help (/showthread.php?tid=81958)



PlayerToPoint Help - JoeDaDude - 15.06.2009

My PlayerToPoint isent working, It lets me type the command anywhere,
But its only supposed to let me type the command in certain place,

pawn Код:
forward PlayerToPoint (Float:radi, playerid, Float:x, Float:y, Float:z);

    if (strcmp("/buyc4", cmdtext, true) == 0)
    {
      if(PlayerToPoint(1.0,playerid,-2044.0804,149.9467,28.8359))
      {
        if (C4BUY[playerid] == 1) return SendClientMessage(playerid, 0xFF0000AA, "You already have C4");
        else
        {
        SendClientMessage(playerid, 0xFF0000AA, "You have purchased C4");
        C4BUY[playerid] = 1;
        }
        }
        return 1;
    }



public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
  new Float:oldposx, Float:oldposy, Float:oldposz;
  new Float:tempposx, Float:tempposy, Float:tempposz;
  GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  tempposx = (oldposx -x);
  tempposy = (oldposy -y);
  tempposz = (oldposz -z);
  //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 1;
  }
  return 0;
}



Re: PlayerToPoint Help - Blacklite - 15.06.2009

You can't just forward a function that doesn't exist.

Please learn how to code at least a little bit, before asking silly questions on here.

Also, PlayerToPoint doesn't need to be a public function.


Re: PlayerToPoint Help - JoeDaDude - 15.06.2009

Quote:
Originally Posted by Blacklite
You can't just forward a function that doesn't exist.

Please learn how to code at least a little bit, before asking silly questions on here.

Also, PlayerToPoint doesn't need to be a public function.
Dude make sure you read it properly before posting,
Scroll down and you see the PlayerToPoint
Its right here look infront of your eyes,
If you was to scrolldown on the code provided on the first post,
You would realise that

pawn Код:
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
  new Float:oldposx, Float:oldposy, Float:oldposz;
  new Float:tempposx, Float:tempposy, Float:tempposz;
  GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  tempposx = (oldposx -x);
  tempposy = (oldposy -y);
  tempposz = (oldposz -z);
  //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 1;
  }
  return 0;
}



Re: PlayerToPoint Help - Blacklite - 15.06.2009

pawn Код:
if (strcmp("/buyc4", cmdtext, true) == 0)
{
  if(PlayerToPoint(1.0,playerid,-2044.0804,149.9467,28.8359))
  {
    if (C4BUY[playerid]) return SendClientMessage(playerid, 0xFF0000AA, "You already have C4");
    else
    {
      C4BUY[playerid] = 1;
      return SendClientMessage(playerid, 0xFF0000AA, "You have purchased C4");
    }
  }
  SendClientMessage(playerid, 0xFF0000AA, "You are not at the right location to purchase C4");
  return 1;
}

PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
  if(IsPlayerConnected(playerid))
  {
    new Float:oldposx, Float:oldposy, Float:oldposz;
    new Float:tempposx, Float:tempposy, Float:tempposz;
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
    tempposx = (oldposx -x);
    tempposy = (oldposy -y);
    tempposz = (oldposz -z);
    if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
    {
      return 1;
    }
  }
  return 0;
}
There should be nothing wrong with that. Also, you don't need 5 lines to tell me that I forgot to scroll down.

And there is no need to make PlayerToPoint a public function.