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 ➜ SMAUG coding ➜ Stupidest question ever!

Stupidest question ever!

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


Posted by Rayze   (9 posts)  Bio
Date Thu 24 Oct 2002 02:38 AM (UTC)
Message
I'm trying to put in the damage snippet, so I go to Fight.c and add in the following code,
else
{
sprintf( buf1, "$n's %s %s $N%c", attack, vp, dam, punct);
sprintf( buf2, "Your %s %s $N%c", attack, vp, dam, punct);
sprintf( buf3, "$n's %s %s you%c", attack, vp, dam, punct);
}

I save, compile, etc...

I keep getting an else error or something...
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 24 Oct 2002 03:01 AM (UTC)
Message
So why did you put "else" there?

- Nick Gammon

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

Posted by Loki   (44 posts)  Bio
Date Reply #2 on Thu 24 Oct 2002 01:26 PM (UTC)
Message
Nope, not the Stupidest Question.

I think I have you beat a million times over.

-LºKi_
Founder
Endless Dreams
Top

Posted by Rayze   (9 posts)  Bio
Date Reply #3 on Thu 24 Oct 2002 08:02 PM (UTC)
Message
When I take out the else I get the following error message though:

C:\source\smaug1.4a\src\fight.c(4257) : error C2449: found '{' at file scope (missing function header?)
C:\source\smaug1.4a\src\fight.c(4261) : error C2059: syntax error : '}'


How do I fix that? I'm a total newbie at this...
Top

Posted by Chris L   USA  (57 posts)  Bio
Date Reply #4 on Thu 24 Oct 2002 09:41 PM (UTC)
Message
like nick i dont see where the else comes into play.. but the code i use for when dt isnt barehand or poison is

sprintf( buf1, "$n's %s %s $N%c (%d)", attack, vp, punct, dam );
sprintf( buf2, "Your %s %s $N%c (%d)", attack, vp, punct, dam );
sprintf( buf3, "$n's %s %s you%c (%d)", attack, vp, punct, dam );

so one problem is that you dont have the %d for your damage. after the ""'s it places the the values from the variables and places them in %s/%c/%d etc., s is string d is for numbers and i would assume c is for charecters like ./,';..

the way you have it set up
sprintf( buf1, "$n's %s %s $N%c", attack, vp, dam, punct);
there is no place for the damage to be placed.. so to follow your layout you would want like
sprintf( buf1, "$n's %s %s $N %d%c", attack, vp, dam, punct);
although then the puncution (.) will be after the damage

this may be part of problem but i would think there is something else wrong to or you would have gotten a different error. id suggest starting with a clean new_dam_message and just replace the 3 of the msgs with new ones, always easy to start over ;)
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 24 Oct 2002 10:04 PM (UTC)
Message
OK, sounds like the code is in the wrong place. The two errors you get (wrong else, or { at file scope), suggests you are "outside" a function.

eg. this would do it.


int myfunction (int a)
  {
  int b;

  b = a * 5;
  return b;

  }  // this is the end of the function

// code below is outside any function

else
  {
  b = 22;
  }


- Nick Gammon

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

Posted by Rayze   (9 posts)  Bio
Date Reply #6 on Sun 27 Oct 2002 04:09 PM (UTC)
Message
Thanks for the help... got it to work.
Top

Posted by Yourdrunkendad   (35 posts)  Bio
Date Reply #7 on Sat 09 Aug 2003 04:57 AM (UTC)
Message
Is this a snippet to show how much damage your dealing/receiving, and if it is where in fight.c do you put it?

Shampoo is for sissies real men use poo*
[werd]thewerd.com "Smacking Your Mom Then Running Away"
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #8 on Sun 10 Aug 2003 05:18 AM (UTC)
Message
Judging by the error messages further up, it would go at around line 4257 (roughly).

- 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.


24,078 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.