Legacy GM issue calling script

E

EZTALES

Guest
hey yall,
i don't know if im doing this right but when i want to call my script it gives me a malformed if statement. heres the code below. Whats suppose to happen is when i press enter i want the script to open and replace the other one.
Code:
SCR_BMENU
///placeholder
switch (mpos)
{

case 0:
{// ATTACK
script_execute(scr_attack);
break;
}

case 1:
{// SPELLS

break;
}

case 2:
{// INFO

break;
}}
THX
 

samspade

Member
hey yall,
i don't know if im doing this right but when i want to call my script it gives me a malformed if statement. heres the code below. Whats suppose to happen is when i press enter i want the script to open and replace the other one.
Code:
SCR_BMENU
///placeholder
switch (mpos)
{

    case 0:
    {// ATTACK
        script_execute(scr_attack);
        break;
    }

    case 1:
    {// SPELLS

        break;
    }

    case 2:
    {// INFO

        break;
    }
}
THX
There's nothing inherently wrong with the code you posted. There's also no if statement. Are you sure this is the code with the issue?

Also, your question is a little confusing. You say 'malformed if statement' but don't post an if statement. You say 'when i press enter' but none of that is reflected in the code you posted. Is it in the step event, an enter specific gm event, something else? You say 'i want the script to open and replace the other one'. Which script is supposed to open? Why would it open. You haven't posted that code. Which script is the 'other one' and why would it be replaced? You haven't posted that code.

In other words, you probably need to reask the question to more clearly state what you want answered.
 
I

immortalx

Guest
Check if you put a semicolon by accident after the if statement
Code:
if (condition); // This is wrong. Remove this semicolon
 
You do not need the curly brackets for the cases in a switch statement:
Code:
switch (mpos) {
  case 0:
    // ATTACK
    script_execute(scr_attack);
  break;
  case 1:
    // SPELLS
  break;
  case 2:
    // INFO
  break;
}
 
when i want to call my script it gives me a malformed if statement.
Try showing us the actual error you are getting, as that will normally tell you exactly where the error is. As has been already mentioned, there is no if anywhere in that code you showed, so the problem must be inside your script where you have incorrectly set up an if statement.
 
E

EZTALES

Guest
Try showing us the actual error you are getting, as that will normally tell you exactly where the error is. As has been already mentioned, there is no if anywhere in that code you showed, so the problem must be inside your script where you have incorrectly set up an if statement.
whoops! wrong code sent out, heres the problem one:
Code:
///placeholder
switch (mpos)
{

case 0:
{// ATTACK
if keyboard_check_pressed(vk_enter);
{script_execute(scr_attack)};
break;
}

case 1:
{// SPELLS

break;
}

case 2:
{// INFO

break;
}}
what i want it to do is open the menu.
 
E

EZTALES

Guest
i just don't want to make multiple rooms for each fight. its a turn base rpg
 
E

EZTALES

Guest
You have a ; at the end of the line. That is not how you do an if statement. Get rid of the ;
If you ever get a "malformed..." type of error it is usually because you have done this.
heres a look at what its suppose to do in my menu. for now, i ended up making a few rooms for different menus. that will be temporary though, i just wanted to see what it would look like.
 
Top