From what you're saying here it is very apparent that you need to learn a lot more C before you attempt to tackle a project such as a MUD, however I will attempt to give you some pointers... Brian Juba wrote: > > im trying to create a "deaths' command so that when u type it, it > displays a list of the last 30 pks showing who died and by whom which > is viewable by all players. in fight.c before die(victim) i > created the following code: > > if (!IS_NPC(victim)){ > GET_PK_CNT(ch) += 1; > DLIST(ch) += DLIST(ch) + "%s killed by %s/r/n", > GET_NAME(victim),GET_NAME(ch)); > Hrmmm, alright, assuming that what you want to do is concatenate that string onto the end of DLIST (I'm gonna use buf instead) then what you want is something more like this... sprintf(buf + strlen(buf), "%s killed by %s\r\n", GET_NAME(victim), GET_NAME(ch)); Also note that /r/n is incorrect, you need to use \r\n. > this line dosent compile but i was trying to make it add the next death to > itself. Also in the command in act.info i am not sure how > to make it display the list was thinking maype > sprintf(buf + strlen(buf), "%s\r\n", Dlist(ch)); You used DLIST before, here you use Dlist. Note that C is CASE SENSITIVE. This means that C will see Dlist as being different than DLIST which is also different than dlist and DlIsT. sprintf won't display anything, what sprintf does is it formats a number of variables into a string. If you want to disply the contents of buf then the simple way to do that is... send_to_char(buf, ch); > and need help on how to set a buf to only 30 lines or so. Well, you can't do that. C does not do any tricky behind-the scenes manipulation of its buffers. What I might suggest is an array of 30 buffers and two global integers. One integer stores the index value of the first line to disply, and the other stores the value of the last line, you simply start at the first line and display each line until you reach the last line. If you get to value #30 then start back at #1. When writing an entry you need to increment the last value, if it's = to 30, then set it to 0, then if the first value equals the last increment the first (and set it to 0 if it's 30). Then write to the slot for the last value. And then Brandon Brown asked: > What exactly is DLIST(ch)? And why does it look like you're trying to add > to it like an integer? And Brian Juba responded: > Sorry should of explained that Dlist is just a variable that i tried to > create and defined it in utils.h just as #define DLIST(ch)(pretty sure this > is wrong but just guessed ch should go in there). Didnt know how to add > strings together so figured the += woudld work. You created a MACRO, not a VARIABLE. I suggest that you read up on what the C Preprocessor is and what a macro is to understand this, but rest assured, a macro will NOT work as a variable, at least not in the sense that you think it will. Learn some C, then try it. Regards, Peter +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/10/01 PDT