SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 06/12/2009, 05:43 PM   #1
Anthony_Brassi
Big Clucker
 
Join Date: Jun 2009
Posts: 127
Reputation: 0
Default [HELP]compound statement not closed at the end of file

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 Code:
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)
Anthony_Brassi is offline  
Old 06/12/2009, 05:58 PM   #2
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 2,628
Reputation: 136
Default Re: [HELP]compound statement not closed at the end of file

instead of closing brackets, you've opened more .

you have
pawn Code:
if(something) { something; {
it should be
pawn Code:
if(something) { something; }
__________________


NEW: [FS] Simple Cellphones

if( strfind( title, "REP", true ) != -1 )
{________________________________________
Sigh();__________________________
}________________________________________


LarzI is offline  
Old 06/12/2009, 06:02 PM   #3
Martin_M
Big Clucker
 
Martin_M's Avatar
 
Join Date: Oct 2009
Location: Lithuania
Posts: 121
Reputation: 2
Default Re: [HELP]compound statement not closed at the end of file

Make this like that:
Code:
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);
__________________
Martin_M is offline  
Old 06/12/2009, 06:04 PM   #4
Remi-X
Huge Clucker
 
Join Date: Dec 2008
Posts: 296
Reputation: 0
Default Re: [HELP]compound statement not closed at the end of file

And in your case its better to use a Switch, in stead of Else If. A switch is a lot faster.
Code:
switch(pickupid)
{
  case Sniper: return GivePlayerWeapon(playerid, 34, 150);
  case M4: return GivePlayerWeapon(playerid, 32, 250);
  case //And so on
}
Remi-X is offline  
Old 06/12/2009, 06:17 PM   #5
Anthony_Brassi
Big Clucker
 
Join Date: Jun 2009
Posts: 127
Reputation: 0
Default Re: [HELP]compound statement not closed at the end of file

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

you have
pawn Code:
if(something) { something; {
it should be
pawn Code:
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..
Anthony_Brassi is offline  
Old 06/12/2009, 06:24 PM   #6
Remi-X
Huge Clucker
 
Join Date: Dec 2008
Posts: 296
Reputation: 0
Default Re: [HELP]compound statement not closed at the end of file

Code:
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
Remi-X is offline  
Old 06/12/2009, 06:26 PM   #7
Anthony_Brassi
Big Clucker
 
Join Date: Jun 2009
Posts: 127
Reputation: 0
Default Re: [HELP]compound statement not closed at the end of file

Quote:
Originally Posted by Remi-X
Code:
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
Anthony_Brassi is offline  
Old 06/12/2009, 06:40 PM   #8
Remi-X
Huge Clucker
 
Join Date: Dec 2008
Posts: 296
Reputation: 0
Default Re: [HELP]compound statement not closed at the end of file

Hmm, I thought it needs to work. So I don't know the problem at the moment.
Remi-X is offline  
Old 06/12/2009, 09:57 PM   #9
Anthony_Brassi
Big Clucker
 
Join Date: Jun 2009
Posts: 127
Reputation: 0
Default Re: [HELP]compound statement not closed at the end of file

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?
Anthony_Brassi is offline  
Old 07/12/2009, 12:48 AM   #10
Anthony_Brassi
Big Clucker
 
Join Date: Jun 2009
Posts: 127
Reputation: 0
Default Re: [HELP]compound statement not closed at the end of file

sorry for double post but i really need some help
Anthony_Brassi 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
error 030: compound statement not closed at the end of file Sergio Leone Help Archive 7 11/08/2011 03:34 PM
error 030: compound statement not closed at the end of file Ragidon Help Archive 1 04/04/2010 10:10 AM
error 030: compound statement not closed at the end of file (started at line 240 w00tNew Help Archive 4 23/12/2009 08:15 AM
compound statement not closed at the end of file? spiper Help Archive 10 23/09/2009 08:06 PM
compound statement not closed at the end of file Jamould Help Archive 15 03/07/2009 11:29 AM


All times are GMT. The time now is 10:17 PM.


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