Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ Running the server ➜ New code

New code

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Shadoan   Canada  (21 posts)  Bio
Date Mon 30 Apr 2001 09:49 PM (UTC)
Message
Heya can anyone look at the code I just made, whenever I type selfdestruct it gives me Syntax: blabla but when i type selfdestruct ship now or the other option nothing happens. Here's the code:


void do_selfdestruct(CHAR_DATA *ch, char *argument)
{
    SHIP_DATA *ship;

{
  if ( (ship = ship_from_cockpit(ch->in_room->vnum)) == NULL )
  {
    send_to_char("&RYou must be in the cockpit of a ship to do that!\n\r",ch);
    return;
  }
          
  if ( !check_pilot( ch , ship ) )
  {
    send_to_char("This isn't your ship!\n\r" , ch );
    return;
  }
              
  if (ship->shipstate == SHIP_DOCKED)
  {
    send_to_char("&RYour ship is docked!\n\r",ch);    
    return;         
  }
                            
  if (ship->shipstate == SHIP_HYPERSPACE)      
  {
          
    send_to_char("&RYou can only do that in realspace!\n\r",ch);
    return;         
  }
    
  {
    if ( str_cmp( argument, "ship now" )
    &&   str_cmp( argument, "ship now silent" ) )
    
  send_to_char( "Syntax: 'ship now' or 'ship now silent'\n\r", ch );
  return;
    }
    
    if ( str_cmp( argument, "ship now" ) )
  
    send_to_char("Selfdestruct activated!",ch);
      echo_to_ship( AT_YELLOW , ship , "ALERT: Selfdestruct activated...you have one minute to get to minimum safe distance" );
        add_timer ( ch , TIMER_DO_FUN , 60 , do_selfdestruct , 1 );
    }
    
    if ( str_cmp( argument, "ship now silent" ) )
  
      send_to_char( "&RSilent selfdestruct mode activated...\n\r",ch ) ;
            add_timer ( ch , TIMER_DO_FUN , 60 , do_selfdestruct , 1 );
    }
        destroy_ship(ship , NULL);
}

Edge of Darkness MUD and Hosting Service,
Head Administrator(Retired)
All your SWR needs, right here, right now.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 30 Apr 2001 10:20 PM (UTC)
Message
Your braces seem mismatched. For instance, I count 7 opening braces "{" but 8 closing braces "}".

Also, they seem placed in funny spots. For instance in the first four lines:


void do_selfdestruct(CHAR_DATA *ch, char *argument)
{
    SHIP_DATA *ship;
{  // <--- what does this one achieve?



I would closely look at your ifs and braces and make sure that you have them all where you want them.




- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shadoan   Canada  (21 posts)  Bio
Date Reply #2 on Tue 01 May 2001 11:27 PM (UTC)
Message
I added that in because an error popping up and the brace seemed to stop it but now I removed it and it still is error-free...hrm strange. Can you tell me how to make a timer so that right after the ship hears the 'ALERT: blabla'
message a 60 second countdown starts and only AFTER 60 seconds it blows up? I already added a 60 seocnd timer in mud.h so i just need to know how to put in the selfdestruct code.

Edge of Darkness MUD and Hosting Service,
Head Administrator(Retired)
All your SWR needs, right here, right now.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #3 on Tue 01 May 2001 11:46 PM (UTC)

Amended on Tue 01 May 2001 11:47 PM (UTC) by Nick Gammon

Message
Usually an error like that means there is an "if" with a mismatched brace, eg like this:



if (blah)
  do this
  do that
  }   // mismatched brace



Adding another brace somewhere else may make the error go away, but is probably in the wrong spot - ie. in this case the "if" won't behave as expected. You should really check that each brace belongs where it should.

As for how to make it self-destruct - I don't know that, maybe someone else does.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shadoan   Canada  (21 posts)  Bio
Date Reply #4 on Thu 03 May 2001 06:54 PM (UTC)
Message
Sorry, I meant how to put IT(the timer) in the selfdestruct code, the SELFD in the destroy_ship function.
I tried rewriting the last part of the code to make the tiemrs work but to no success here's what I did:

do_selfdestruct(CHAR_DATA *ch, char *argument)
{
char arg[MAX_INPUT_LENGTH];
SHIP_DATA *ship;

blabla IFCHECKS blabla
...
if ( str_cmp( argument, "normal" )
&& str_cmp( argument, "silent" ) )
{
send_to_char( "Syntax: 'normal' or 'silent'\n\r", ch );
return;
}


if ( !str_cmp( arg, "normal" ) )
{
echo_to_ship( AT_YELLOW , ship , "ALERT: Selfdestruct activated...you have one minute to get to minimum safe distance" );
}
add_timer ( ch , TIMER_DO_FUN , 60 , do_selfdestruct , 1 );
ch->dest_buf = str_dup(arg);
return;

if ( !str_cmp( arg, "silent" ) )

add_timer ( ch , TIMER_DO_FUN , 60 , do_selfdestruct , 1 );
ch->dest_buf = str_dup(arg);
return;
{
destroy_ship(ship , NULL);
return;
}
}
Now it doesnt say the ALERT: thing and does nothing.
Thanks in advance because I'll forget to thank you later.


Edge of Darkness MUD and Hosting Service,
Head Administrator(Retired)
All your SWR needs, right here, right now.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 03 May 2001 09:04 PM (UTC)
Message
It still seems to me that your braces are all over the place. You realise, I hope, that the extent of the IF is to affect between the opening brace and closing brace? Yours seem to not be done like that.

I would at least modify it like this, assuming that is what you are trying to do...


if ( !str_cmp( arg, "normal" ) ) 
  { 
  echo_to_ship( AT_YELLOW , ship , "ALERT: Selfdestruct activated...you have one minute to get to minimum safe distance" ); 
  add_timer ( ch , TIMER_DO_FUN , 60 , do_selfdestruct , 1 ); 
  ch->dest_buf = str_dup(arg); 
  return; 
} // <--- move this one here 

if ( !str_cmp( arg, "silent" ) ) 
{ // <--- move this one here 
  add_timer ( ch , TIMER_DO_FUN , 60 , do_selfdestruct , 1 ); 
  ch->dest_buf = str_dup(arg); 
  return; 
  destroy_ship(ship , NULL); 
  return; 
  } 
} 


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


16,975 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.