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 ➜ Adding Togglemurder, getting errors :(

Adding Togglemurder, getting errors :(

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


Pages: 1 2  

Posted by Mopop   (115 posts)  Bio
Date Thu 24 Nov 2005 03:12 AM (UTC)

Amended on Thu 24 Nov 2005 05:15 AM (UTC) by Nick Gammon

Message
Trying to add a togglemurder function so players do not kill if they dont want to, for free pk fights or player events. Its been giving me a little problem but here is what I got.

the code.

void toggle_murder(CHAR_DATA *ch, char *argument)
{
   char *victim;

   set_char_color( AT_RED, ch );
   ch_printf( ch, "You are set to %s.\n\are.", xIS_SET( ch->act, PLR_MURDER ) ? "stun" : "murder" );
   if( !xIS_SET( ch->act, PLR_MURDER )
    2053->  xSET_BIT( ch->act, PLR_MURDER );
   else 
      xREMOVE_BIT( ch->act, PLR_MURDER );
   if( !IS_NPC( victim ) && xIS_SET( ch->act, PLR_MURDER ) && victim->hit < 1 )
  {
      victim->hit = 0;
      ch_printf( ch, "You spare your victim!" );
      act( AT_RED, "$n's life has been spared!", victim, NULL, NULL, TO_ROOM );
      act( AT_RED, "Your life has been spared, this time.", victim, NULL, NULL, TO_CHAR );
   }
   return;
}


the errors

player.c: In function `toggle_murder':
player.c:2053: called object is not a function
player.c:2053: parse error before ';' token
player.c:2056: request for member `act' in something not a structure or union
player.c:2056: request for member `hit' in something not a structure or union
player.c:2058: request for member `hit' in something not a structure or union
cc1: warnings being treated as errors
player.c:2060: warning: passing arg 3 of `act' from incompatible pointer type
player.c:2061: warning: passing arg 3 of `act' from incompatible pointer type
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #1 on Thu 24 Nov 2005 03:31 AM (UTC)
Message
 char *victim;

That's the problem. Needs to be:
 CHAR_DATA *victim;

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Mopop   (115 posts)  Bio
Date Reply #2 on Thu 24 Nov 2005 03:43 AM (UTC)
Message
Awesome! now I only got these 2 errors

player.c: In function `toggle_murder':
player.c:2053: called object is not a function
player.c:2053: parse error before ';' token

gettin' close :-D
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #3 on Thu 24 Nov 2005 03:47 AM (UTC)

Amended on Thu 24 Nov 2005 03:58 AM (UTC) by Zeno

Message
Could you edit the first post and point out what those lines are? Also, remember to use the code tag.

[EDIT] Okay wait, this function seems odd. victim isn't even initialized. It's just declared. Unless I'm missing something.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #4 on Thu 24 Nov 2005 05:17 AM (UTC)
Message

if( !xIS_SET( ch->act, PLR_MURDER )


You are missing a bracket. You have 2 LH brackets, and 1 RH bracket.

- Nick Gammon

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

Posted by Mopop   (115 posts)  Bio
Date Reply #5 on Thu 24 Nov 2005 05:29 AM (UTC)
Message
Eh? Come again? Sorry still new at this :P
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #6 on Thu 24 Nov 2005 05:41 AM (UTC)
Message
Putting aside other possible problems, like the fact that you are using "victim" without initialising it, the syntax error is because you are a bracket short. It should read:

if( !xIS_SET( ch->act, PLR_MURDER ) )

- Nick Gammon

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

Posted by Mopop   (115 posts)  Bio
Date Reply #7 on Thu 24 Nov 2005 05:44 AM (UTC)

Amended on Thu 24 Nov 2005 05:47 AM (UTC) by Mopop

Message
Ah thanks, So I heard I wasnt quite sure how to intialize it :( I got a little help making this...

I compiled fixing what you said and got these errors.

o/tables.o(.text+0x4670): In function `skill_function':
//tables.c:1115: undefined reference to `do_toggle_murder'
o/tables.o(.text+0x75b3): In function `skill_name':
//tables.c:2237: undefined reference to `do_toggle_murder'
collect2: ld returned 1 exit status
smaug: No such file or directory
smaug: No such file or directory
Done compiling mud.
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #8 on Thu 24 Nov 2005 03:08 PM (UTC)
Message
Just a typo.
void toggle_murder(CHAR_DATA *ch, char *argument)

There's no "do_" in there.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Mopop   (115 posts)  Bio
Date Reply #9 on Thu 24 Nov 2005 03:59 PM (UTC)
Message
Sweet that works now if I only knew why It was crashing the mud when I use it.
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #10 on Thu 24 Nov 2005 08:40 PM (UTC)
Message
Like we said, victim isn't initialized. Basically this means that you declared space for it be defined, you use it (such as the !IS_NPC check) but it's never actually defined. It's still null.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Mopop   (115 posts)  Bio
Date Reply #11 on Fri 25 Nov 2005 12:18 AM (UTC)
Message
isnt that what CHAR_DATA victim* is doing?

Here is the current code


void do_toggle_murder(CHAR_DATA *ch, char *argument)
{
   CHAR_DATA *victim;

   set_char_color( AT_RED, ch );
   ch_printf( ch, "You are set to %s.\n\r", xIS_SET( ch->act, PLR_MURDER ) ? "stun" : "murder" );
   if( !xIS_SET( ch->act, PLR_MURDER ))
      xSET_BIT( ch->act, PLR_MURDER );
   else
      xREMOVE_BIT( ch->act, PLR_MURDER );
   if( !IS_NPC( victim ) && xIS_SET( ch->act, PLR_MURDER ) && victim->hit < 1 )
  {
      victim->hit = 0;
      ch_printf( ch, "You spare your victim!" );
      act( AT_RED, "$n's life has been spared!", victim, NULL, NULL, TO_ROOM );
      act( AT_RED, "Your life has been spared, this time.", victim, NULL, NULL, TO_CHAR );
   }
   return;
}


and this is what my core file is saying when I check it.

#0 0x08148d2f in do_toggle_murder (ch=0x85c5fb0, argument=0xb54b4a4c "") at player.c:2056
#1 0x0810d05d in interpret (ch=0x85c5fb0, argument=0xb54b4a4c "") at interp.c:543
#2 0x080d2840 in game_loop () at comm.c:881
#3 0x080d1e67 in main (argc=5, argv=0xb54b4ed4) at comm.c:551
#4 0x4b9ced06 in __libc_start_main () from /lib/libc.so.6
(gdb) frame 0
#0 0x08148d2f in do_toggle_murder (ch=0x85c5fb0, argument=0xb54b4a4c "") at player.c:2056
2056 in player.c
(gdb) list
2051 in player.c

maybe you guys can get an understaning of it better than I can :P
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #12 on Fri 25 Nov 2005 02:26 AM (UTC)
Message
No, CHAR_DATA is declaring it, and that's it.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Mopop   (115 posts)  Bio
Date Reply #13 on Fri 25 Nov 2005 03:11 AM (UTC)
Message
Well like I said earlier excuse my ignorance how would I define it, I tried looking for examples in other code and kinda drew blank, this is one of the first things I (kinda) wrote on my own. So sorry for the newbness.
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #14 on Fri 25 Nov 2005 03:36 AM (UTC)
Message
Well my question is why is there a victim in the first place? Isn't that command only meant to toggle the setting?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
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.


62,677 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

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.