SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 15/06/2009, 10:17 AM   #1
JoeDaDude
Gangsta
 
Join Date: Apr 2008
Posts: 673
Reputation: 6
Default PlayerToPoint Help

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 Code:
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;
}
JoeDaDude is offline  
Old 15/06/2009, 10:36 AM   #2
Blacklite
Huge Clucker
 
Join Date: Mar 2009
Location: am kiwi
Posts: 412
Reputation: 45
Default Re: PlayerToPoint Help

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.
__________________

Blacklite is offline  
Old 15/06/2009, 10:39 AM   #3
JoeDaDude
Gangsta
 
Join Date: Apr 2008
Posts: 673
Reputation: 6
Default Re: PlayerToPoint Help

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 Code:
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;
}
JoeDaDude is offline  
Old 15/06/2009, 08:51 PM   #4
Blacklite
Huge Clucker
 
Join Date: Mar 2009
Location: am kiwi
Posts: 412
Reputation: 45
Default Re: PlayerToPoint Help

pawn Code:
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.
__________________

Blacklite is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[DUV]PlayerToPoint m0ta Português/Portuguese 4 05/01/2010 01:46 PM
HELP WITH PLAyertopoint while in a car mike_bisko Help Archive 3 19/05/2009 07:43 AM
Help me with PlayerToPoint Derksen123 Help Archive 11 15/05/2009 07:38 PM
Need help with PlayerToPoint Cabby Help Archive 1 22/04/2009 09:49 AM
PlayerToPoint Klutty Help Archive 6 22/04/2009 09:43 AM


All times are GMT. The time now is 01:59 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.