[HELP]compound statement not closed at the end of file
#1

I've searched, and asked my friends...i feel awkward asking like this ,but my code is messed and i cant figure it out...It's an easy error to fix...but...I can't figure it out with this code, I've done it a bunch of times
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
if (pickupid == Sniper)
{
GivePlayerWeapon(playerid, 34, 150);
return 1;
}
else if (pickupid == M4)
{
GivePlayerWeapon(playerid, 32, 250);
{
if (pickupid == MP5)
{
GivePlayerWeapon(playerid, 28, 300);
{
if (pickupid == Para)
{
GivePlayerWeapon(playerid, 46, 1337);
{
if (pickupid == Deagle)
{
GivePlayerWeapon(playerid, 24, 125);
{
if (pickupid == ShotGun)
{
GivePlayerWeapon(playerid, 27, 500);// line 66
{
if (pickupid == Grenades)
{
GivePlayerWeapon(playerid, 16, 500);
{
if (pickupid == Melee)
{
GivePlayerWeapon(playerid, 3, 1337);
}
return 1;
}
}
return 0;
}
//line 81

EDIT: Sorry bout messed subject..fixed...also included error

C:\Users\Owner\Desktop\samp03asvr_win32\ArmoryPick ups.pwn(82) : error 030: compound statement not closed at the end of file (started at line 66)
Reply
#2

instead of closing brackets, you've opened more .

you have
pawn Код:
if(something) { something; {
it should be
pawn Код:
if(something) { something; }
Reply
#3

Make this like that:
Код:
if(pickupid == Sniper) return GivePlayerWeapon(playerid, 34, 150);
else if(pickupid == M4) return GivePlayerWeapon(playerid, 32, 250);
else if(pickupid == MP5) return GivePlayerWeapon(playerid, 28, 300);
Reply
#4

And in your case its better to use a Switch, in stead of Else If. A switch is a lot faster.
Код:
switch(pickupid)
{
  case Sniper: return GivePlayerWeapon(playerid, 34, 150);
  case M4: return GivePlayerWeapon(playerid, 32, 250);
  case //And so on
}
Reply
#5

Quote:
Originally Posted by lrZ^ aka LarzI
instead of closing brackets, you've opened more .

you have
pawn Код:
if(something) { something; {
it should be
pawn Код:
if(something) { something; }
thanks for the fast response...but I'm still a little confused , never used a switch

and the quote above really wasn't that helpfull, please explain a little more..I'm sorry


btw doing else if over and over doesn't work, that was my first mistake in this code..
Reply
#6

Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
	switch(pickupid) //We're checking the ID of the pickup
	{
		case Sniper: return GivePlayerWeapon(playerid, 34, 150); //If the pickupid == Sniper, than return to give the player a weapon. 
		case M4: return GivePlayerWeapon(playerid, 32, 250);
		case MP5: return GivePlayerWeapon(playerid, 28, 300);
		case Para: return GivePlayerWeapon(playerid, 46, 1);
		case Deagle: return GivePlayerWeapon(playerid, 24, 125);
		case ShotGun: return GivePlayerWeapon(playerid, 27, 500);
		case Grenades: return GivePlayerWeapon(playerid, 16, 500);
		case Melee: return GivePlayerWeapon(playerid, 3, 1);
	}
	return 0;
}
I've made the callback for you. Just delete that callback you have now, and replace it with this one
Reply
#7

Quote:
Originally Posted by Remi-X
Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
	switch(pickupid) //We're checking the ID of the pickup
	{
		case Sniper: return GivePlayerWeapon(playerid, 34, 150);
		case M4: return GivePlayerWeapon(playerid, 32, 250);
		case MP5: return GivePlayerWeapon(playerid, 28, 300);
		case Para: return GivePlayerWeapon(playerid, 46, 1);
		case Deagle: return GivePlayerWeapon(playerid, 24, 125);
		case ShotGun: return GivePlayerWeapon(playerid, 27, 500);
		case Grenades: return GivePlayerWeapon(playerid, 16, 500);
		case Melee: return GivePlayerWeapon(playerid, 3, 1);
	}
	return 0;
}
I've made the callback for you. Just delete that callback you have now, and replace it with this one
Thanks a bunch for the help, but i get an error on all the case lines
C:\Users\Owner\Desktop\samp03asvr_win32\pawno\Swit chpickups.pwn(46) : error 008: must be a constant expression; assumed zero
C:\Users\Owner\Desktop\samp03asvr_win32\pawno\Swit chpickups.pwn(47) : error 008: must be a constant expression; assumed zero
C:\Users\Owner\Desktop\samp03asvr_win32\pawno\Swit chpickups.pwn(4 : error 008: must be a constant expression; assumed zero
C:\Users\Owner\Desktop\samp03asvr_win32\pawno\Swit chpickups.pwn(49) : error 008: must be a constant expression; assumed zero
C:\Users\Owner\Desktop\samp03asvr_win32\pawno\Swit chpickups.pwn(50) : error 008: must be a constant expression; assumed zero
C:\Users\Owner\Desktop\samp03asvr_win32\pawno\Swit chpickups.pwn(51) : error 008: must be a constant expression; assumed zero
C:\Users\Owner\Desktop\samp03asvr_win32\pawno\Swit chpickups.pwn(52) : error 008: must be a constant expression; assumed zero
C:\Users\Owner\Desktop\samp03asvr_win32\pawno\Swit chpickups.pwn(53) : error 008: must be a constant expression; assumed zero

EDIT:I'm gonna go watch terminator...so I'll be back later, thanks for you're help
Reply
#8

Hmm, I thought it needs to work. So I don't know the problem at the moment.
Reply
#9

Quote:
Originally Posted by Remi-X
Hmm, I thought it needs to work. So I don't know the problem at the moment.
sorry for bump, but its been a while, any suggestions?
Reply
#10

sorry for double post but i really need some help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)