Multiply IsPlayerInRangeOfPoint
#1

Hello,

I have a little question, I'm sure the answer is simple, but I'm searching for a few days now to find a solution.
I made a /buy menu where you can buy stuff ingame, I'm using the following line's to make it able to open this menu in multiply places:

Code:
if(!strcmp("/buy",cmdtext))
{
  if(IsPlayerInRangeOfPoint(playerid, 7.0, 2695.6880, -1704.6300, 11.8438))
  {
    "Open buymenu"
  }
  if(IsPlayerInRangeOfPoint(playerid, 7.0, 1695.5674, -5434.6300, 44.8438))
  {
    "Open buymenu"
  }
  if(IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438))
  {
    "Open buymenu"
  }
  else{
  SendClientMessage(playerid,0xFFFFFFFF,"You are not near a buy point!");
  }
  return 1;
}
There must be a more easy way to add multiply IsPlayerInRangeOfPoints, but how?

I tryd somethign like:

Code:
if(IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438) || IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438) || IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438))
But that also didn't work, I hope somebody can help me.

Thanks for reading!
Reply
#2

Are you sure if(bla || bla) doesn't work? I never had that before.
Reply
#3

pawn Code:
if(IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438 || IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438 || IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438))
Try that
Reply
#4

Quote:
Originally Posted by Joe Torran C
pawn Code:
if(IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438 || IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438 || IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438))
Try that
You are missing some ")"...

Correct version:

Code:
if(!strcmp("/buy",cmdtext))
{
	if(IsPlayerInRangeOfPoint(playerid, 7.0, 2695.6880, -1704.6300, 11.8438) || IsPlayerInRangeOfPoint(playerid, 7.0, 1695.5674, -5434.6300, 44.8438) || IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438))
	{
			"Open buymenu"
  	}
  	else return SendClientMessage(playerid,0xFFFFFFFF,"You are not near a buy point!");
  	return 1;
}
(Intendations are made using space...)
Reply
#5

If you want to use this

pawn Code:
if(!strcmp("/buy",cmdtext))
{
  if(IsPlayerInRangeOfPoint(playerid, 7.0, 2695.6880, -1704.6300, 11.8438))
  {
    "Open buymenu"
  }
  if(IsPlayerInRangeOfPoint(playerid, 7.0, 1695.5674, -5434.6300, 44.8438))
  {
    "Open buymenu"
  }
  if(IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438))
  {
    "Open buymenu"
  }
  else{
  SendClientMessage(playerid,0xFFFFFFFF,"You are not near a buy point!");
  }
  return 1;
}
then GOD next time remember to use else if

correct version
pawn Code:
if(!strcmp("/buy",cmdtext))
{
  if(IsPlayerInRangeOfPoint(playerid, 7.0, 2695.6880, -1704.6300, 11.8438))
  {
    "Open buymenu"
  }
  else if(IsPlayerInRangeOfPoint(playerid, 7.0, 1695.5674, -5434.6300, 44.8438))
  {
    "Open buymenu"
  }
  else if(IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438))
  {
    "Open buymenu"
  }
  else{
  SendClientMessage(playerid,0xFFFFFFFF,"You are not near a buy point!");
  }
  return 1;
}
but ofc.

Assyrias version is WAY better
pawn Code:
if(IsPlayerInRangeOfPoint(playerid, 7.0, 2695.6880, -1704.6300, 11.8438) || IsPlayerInRangeOfPoint(playerid, 7.0, 1695.5674, -5434.6300, 44.8438) || IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438))
    {
            "Open buymenu"
    }
    else return SendClientMessage(playerid,0xFFFFFFFF,"You are not near a buy point!");
Because the first one is a shitload of space thats not needed.
Reply
#6

Quote:
Originally Posted by Assyria
Quote:
Originally Posted by Joe Torran C
pawn Code:
if(IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438 || IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438 || IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438))
Try that
You are missing some ")"...

Correct version:

Code:
if(!strcmp("/buy",cmdtext))
{
	if(IsPlayerInRangeOfPoint(playerid, 7.0, 2695.6880, -1704.6300, 11.8438) || IsPlayerInRangeOfPoint(playerid, 7.0, 1695.5674, -5434.6300, 44.8438) || IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438))
	{
			"Open buymenu"
  	}
  	else return SendClientMessage(playerid,0xFFFFFFFF,"You are not near a buy point!");
  	return 1;
}
(Intendations are made using space...)
I know i missed ) because with his code/you code it dosent work.
Reply
#7

pawn Code:
if(!strcmp("/buy",cmdtext))
{
  if( IsPlayerInRangeOfPoint(playerid, 7.0, 2695.6880, -1704.6300, 11.8438) ||
    IsPlayerInRangeOfPoint(playerid, 7.0, 1695.5674, -5434.6300, 44.8438) ||
    IsPlayerInRangeOfPoint(playerid, 7.0, 3455.6880, -2345.6300, 523.8438))
  {
    "Open buymenu"

    return 1;
  }

  return SendClientMessage(playerid, 0xFFFFFFFF, "You are not near a buy point!");
}
You don't need to have them all in a row if you don't like the width of the code line.

Not that any of the posts above wouldn't work or if this method would be faster and/or better, just wanted to throw this in.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)