Author Topic: Syntax errors with a script  (Read 991 times)

I'm getting a syntax error in this scipt when trying to execute.
Code: [Select]
//Warning: This is specific to my A10
package A10shootOnClick_Pack
{
//Next seat => switch weapons
function serverCmdNextSeat(%client)
{

%p = %client.player;
if(!isobject(%p.getobjectmount()))
return Parent::serverCmdNextSeat(%client);

if(%p.getobjectmount().getdatablock() == A10vehicle.getid())
{


%jet = %p.getobjectmount();
                                //applies the settings for each weapon
                                switch (%jet.weaponi)
                                        {
                                        case 1:
                                        %jet.weaponi = 0;
                                        %jet.weapon = "GAU-8/A Minigun";
                                        case 0:
                                        %jet.weaponi = 1;
                                        %jet.weapon = "6x LAU-10 Rocket Pod <color:0000FF>" @ %jet.ammo[%jet.weaponi] @ "/12";
                                }
                                else
                                {       
                                Parent::serverCmdNextSeat(%client);
                                }       



}
//Deploy flares
function serverCmdPrevSeat(%client)
{

if(isObject(%client.player))
{
%p = %client.player;

if(%p.getobjectmount())
{


if(%p.getobjectmount().getdatablock() == A10vehicle.getid())
{
if($Sim::Time<%client.flaredelay)
{
return;
No, this isn't the original code, its edited. This isn't the full code either, it contains the snippet thats broken.

You're missing a closing bracket for the switch statement


What you have:
Code: [Select]
if(condition)
{
    switch(condition)
    {
        stuff

}
else
{
    stuff
}
There is a missing one of these }
Hint: it goes on the only blank line

You're confusing me here.

Look, you've matched up your brackets for your if statement, but not for your switch.
Code: [Select]
if(condition)
{
    switch(condition)
    {
        stuff
    }
}
else
{
    stuff
}

Code: [Select]
//Warning: This is specific to my A10
package A10shootOnClick_Pack
{
//Next seat => switch weapons
function serverCmdNextSeat(%client)
{

%p = %client.player;
if(!isobject(%p.getobjectmount()))
return Parent::serverCmdNextSeat(%client);

if(%p.getobjectmount().getdatablock() == A10vehicle.getid())
{

}
%jet = %p.getobjectmount();
                                //applies the settings for each weapon
                                switch (%jet.weaponi)
                                        {
                                        case 1:
                                        %jet.weaponi = 0;
                                        %jet.weapon = "GAU-8/A Minigun";
                                        case 0:
                                        %jet.weaponi = 1;
                                        %jet.weapon = "6x LAU-10 Rocket Pod <color:0000FF>" @ %jet.ammo[%jet.weaponi] @ "/12";
                                }
                                else
                                {       
                                Parent::serverCmdNextSeat(%client);
                                }       
Fixed?

You fixed it, but you also broke it again by adding a random bracket
Fix your formatting, spotting missing brackets is a lot easier with proper indenting

Can someone just fix this for me? :U

Can someone just fix this for me? :U
yes.

are we going to?
no

this is "coding help" not "coding for you"
Fix your formatting
« Last Edit: November 13, 2012, 11:24:27 PM by Lugnut »

Can someone just fix this for me? :U
Match your braces with each other in pairs, it's not difficult. If you have a good code editor, most of this should be automatic.


Once you format your code properly then it's easy to avoid bracket nightmares like that.