GetPlayerDistanceFromPlayer
#1

Hi,
When I try to compile that under OnPlayerGiveDamage:
Код:
	 case 25:
	 {
		if (PlayerData[playerid][pBeanBag]) damage = 0;
		else
		{
			if (GetPlayerDistanceFromPlayer(playerid, damagedid) < 10)
			{
				if (bodypart == 9) damage = 85;
				else damage = 70;
			}
			if (GetPlayerDistanceFromPlayer(playerid, damagedid) == 10.1..20) //line 15974
			{
				if (bodypart == 9) damage = 60;
				else damage = 45;
			}
			if (GetPlayerDistanceFromPlayer(playerid, damagedid) == 20.1..30)
			{
				if (bodypart == 9) damage = 45;
				else damage = 30;
			}
			if (GetPlayerDistanceFromPlayer(playerid, damagedid) > 30.1)
			{
				if (bodypart == 9) damage = 35;
				else damage = 25;
			}
		}	
	}
I get these errors:

Код:
(15974) : error 001: expected token: ")", but found ".."
(15974) : error 029: invalid expression, assumed zero
(15974) : warning 215: expression has no effect
(15974) : error 001: expected token: ";", but found ")"
(15974) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
What's wrong with it? The damage is supposed to be 70 if distance is 10 or less, if distance is 10.1 to 20 then the damage would be 60 and so on.
Reply
#2

Using ".." is invalid and you can't check if something is equal to more than 1 value. ".." is used in switch for integers only. Also you keep calling GetPlayerDistanceFromPlayer function. Store what distance returned to a local variable and then check if for example "distance >= 10.1 && distance <= 20.0".
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Using ".." is invalid and you can't check if something is equal to more than 1 value. ".." is used in switch for integers only. Also you keep calling GetPlayerDistanceFromPlayer function. Store what distance returned to a local variable and then check if for example "distance >= 10.1 && distance <= 20.0".
Thanks, I changed it to:
Код:
new distance;
under OnPlayerGiveDamage and
Код:
	case 25:
	{
		if (PlayerData[playerid][pBeanBag]) damage = 0;
		else
		{
		        distance = GetPlayerDistanceFromPlayer(playerid, damagedid); //line 15970
			if (distance <= 10)
			{
				if (bodypart == 9) damage = 85;
				else damage = 70;
			}
			if (distance >= 10.1 && distance <= 20.0)
			{
				if (bodypart == 9) damage = 65;
				else damage = 45;
			}
			if (distance == 20.1 && distance <= 30.0)
			{
				if (bodypart == 9) damage = 45;
				else damage = 30;
				}
			if (distance >= 30.1)
			{
				if (bodypart == 9) damage = 35;
				else damage = 25;
			}
		}	
	}
Looks good, but I get this warning:
Код:
(15970) : warning 213: tag mismatch
Reply
#4

Add Float: tag to "distance" when you declare it.

Better declare it inside the else statement by the way.
Reply
#5

The variable should be a Float and not an integer since GetPlayerDistanceFromPlayer returns a Float value.

Edit: Too late :v
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Add Float: tag to "distance" when you declare it.

Better declare it inside the else statement by the way.
Thank you!

Quote:
Originally Posted by Sjn
Посмотреть сообщение
The variable should be a Float and not an integer since GetPlayerDistanceFromPlayer returns a Float value.

Edit: Too late :v
You, too.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)