SA-MP Forums Archive
error 030: compound statement not closed at the end of file - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: error 030: compound statement not closed at the end of file (/showthread.php?tid=413015)



error 030: compound statement not closed at the end of file - RStyle - 03.02.2013

Well guys, i need a little help in my Filterscript, that i can't solve anyway.

Well, there is the codes:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/lift1d", true))
    {
 	MoveObject(uss1, -779.39, 3196.35, 9.69, 15000);
}else{

 if(!strcmp(cmdtext, "/lift2d", true))
	{
	MoveObject(uss2, -821.67, 3181.70, 9.89, 15000);
	 	    
}else{

	if(!strcmp(cmdtext, "/lift1u", true))
	{
	MoveObject(uss1, -779.39, 3196.35, 16.80, 15000);
	    }else{

	if(!strcmp(cmdtext, "/lift2u", true))  < This is the line 42
	{
	MoveObject(uss2, -821.67, 3181.70, 17.03, 15000);
    return 0;
}
#endif
Now the error:

Код:
C:\SA-MP\filterscripts\sacarrier.pwn(48) : error 030: compound statement not closed at the end of file (started at line 42)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
I Can't reveal all the code, because it's a surprise to Map Sections


Re: error 030: compound statement not closed at the end of file - Vince - 03.02.2013

Your code, properly indented, looks like this:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/lift1d", true))
    {
        MoveObject(uss1, -779.39, 3196.35, 9.69, 15000);
    }
    else
    {
        if(!strcmp(cmdtext, "/lift2d", true))
        {
            MoveObject(uss2, -821.67, 3181.70, 9.89, 15000);
        }
        else
        {
            if(!strcmp(cmdtext, "/lift1u", true))
            {
                MoveObject(uss1, -779.39, 3196.35, 16.80, 15000);
            }
            else
            {
                if(!strcmp(cmdtext, "/lift2u", true))  < This is the line 42
                {
                    MoveObject(uss2, -821.67, 3181.70, 17.03, 15000);
    return 0;
}
Which makes it very clear that you are missing loads of brackets. Not to mention the rather questionable structure of the callback as a whole.


Re: error 030: compound statement not closed at the end of file - RStyle - 03.02.2013

Well, what i can do?


Re: error 030: compound statement not closed at the end of file - RStyle - 03.02.2013

Bump?


Re: error 030: compound statement not closed at the end of file - u3ber - 03.02.2013

add the braces!

https://sampforum.blast.hk/showthread.php?tid=406343


Re: error 030: compound statement not closed at the end of file - RStyle - 03.02.2013

I'm sorry, but i don't understood, i'm a newbie in pawn, and i need that ready ASAP


Re: error 030: compound statement not closed at the end of file - u3ber - 03.02.2013

Quote:
Originally Posted by RStyle
Посмотреть сообщение
I'm sorry, but i don't understood, i'm a newbie in pawn, and i need that ready ASAP
read the link in my previous post, along with indentation it briefly explains scope and code-blocks.


Re: error 030: compound statement not closed at the end of file - RStyle - 03.02.2013

arbit, i swear that i read that a lot of times, but i still not understanding, i don't know what to do next, i really need help here.


Re: error 030: compound statement not closed at the end of file - MP2 - 04.02.2013

A callback is an 'event'. When something happens, the code between the brackets/braces is executed:

pawn Код:
public OnPlayerSpawn(playerid)
{ // START OF THE CALLBACK.
    // Code between the { and } is executed when a player spawns
} // END OF THE CALLBACK.
This also applies for if() statements etc.:

pawn Код:
if(something)
{
    // do something
}
You need to END the 'compound block' ('piece of code' I guess).

Plus your if-else structure is questionable.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{ // When a player types a command the code from this point will be executed
    if(!strcmp(cmdtext, "/lift1d", true)) // If they typed /lift1d
    { // Start of code that will be executed when typing /lift1d
        MoveObject(uss1, -779.39, 3196.35, 9.69, 15000); // Move the object
    } // End of code that will be executed when typing /lift1d
    else if(!strcmp(cmdtext, "/lift2d", true))
    {
        MoveObject(uss2, -821.67, 3181.70, 9.89, 15000);
    }
    else if(!strcmp(cmdtext, "/lift1u", true))
    {
        MoveObject(uss1, -779.39, 3196.35, 16.80, 15000);
    }
    else if(!strcmp(cmdtext, "/lift2u", true))
    {
        MoveObject(uss2, -821.67, 3181.70, 17.03, 15000);
    }
    return 0;
}
I added comments to the first one for you.