Increasing Health
#1

Hello! I'm currently working on my gamemode and I've run into a small problem.

I'm trying to script this:
If the player is within a certain distance of a point and presses the [whatever key it may be] key and if they're health is 95% or lower, $2 is taken from them and their health is increased by 5 %.

I have done most of it, but I get 2 errors which are:

C:\Users\Noorie\Desktop\Transporter.pwn(138 : error 017: undefined symbol "IsPlayerInRange"
C:\Users\Noorie\Desktop\Transporter.pwn(1406) : error 030: compound statement not closed at the end of file (started at line 1376)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

2 Errors.

Can someone please help me fix this?

Thanks!.

http://pastebin.com/m331c79c9
Reply
#2

Woooooops!

Sorry to piss you off Seif.. But I was looking at the wrong thing (On wiki..)

Now that thats fixed, can you please tell me how to fix the second error?

I haven't really ever used Keys.
Reply
#3

You forgot to add a close your code.
pawn Код:
}
Reply
#4

Quote:
Originally Posted by lolumadd [cod5server.tk
]
You forgot to add a close your code.
pawn Код:
}
Honestly dude, I'm really tired and shyt :P
I've been studying for exams for like 2 weeks straight now, and I'm exhausted..

Wanna tell me where please?
Reply
#5

From the code in the pastbin there isn't a } missing, it must be wherever the code is.

Also How NOT to check for a key
Reply
#6

Quote:
Originally Posted by mansonh
From the code in the pastbin there isn't a } missing, it must be wherever the code is.

Also How NOT to check for a key
Ou, thanks. I thought It would be " == ".. Anyways, I still haven't found why I'm getting that error
Reply
#7

Well we can't help since it's in your script, not the provided code.
Reply
#8

http://pastebin.com/m331c79c9

Theres the code... The error is somewhere in there. I can't give you any more code because the error isn't anywhere else.
Reply
#9

Anyone?
Reply
#10

It should work like that

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys == KEY_FIRE)
	{
	  if(IsPlayerInRangeOfPoint(playerid, RANGE, CORDX, CORDY, CORDZ))
	  {
			new Float:health;
			GetPlayerHealth(playerid, health);
			if(health <=95)
			{
				SetPlayerHealth(playerid, health + 5);
				GivePlayerMoney(playerid, -2);
		  	SendClientMessage(playerid, COLOR_LIGHTBLUE, "You've bought a drink for $2");
			}
			else
		  {
		    SendClientMessage(playerid, COLOR_RED, "You still have plenty of health left");
			}
			return 1;
		}
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)