On Fri, 19 Apr 2002, Mike Beasley wrote:
> Hi,
> I'm running Rom2.4b6. I'm making a modern mud with gangs (the old clan
> system) and corperations (a modified copy of the old clan system). On the
> who list, now is shows the level, race, class, gang, corperation then the
> name. If you are not in a gang or corperation, it says:
>
> [ 110 Asian IMP Citizen (NoCorp) ] Tarian
>
> and if you are in a gang but not a corp, or vice versa, it says:
>
> [ 110 Asian IMP Citizen FrstBnk ] Tarian
>
> I would like it so that if you are in either a gang or a corp (you can't be
> in both) to show only that gang or corp name like:
>
> [ 110 Asian IMP FrstBnk ] Tarian
>
> And if in neither a gang nor a corp, to say:
>
> [ 110 Asian IMP PRIVATE ] Tarian
>
> Or something like private. I was wondering if that would be possible and if
> anyone knows how to code that...cuz I cant seem to figure it out right now.
Sorry to be blunt, but if you really are having a lot of trouble
with this part, you shouldn't be trying to code in a mud yet.
After learning just some real basic C (probably the first few chapters
of any decent C book), you should be able to figure out the changes you
want to make (it looks like just modifying some existing stuff and
knowing how to use an if... nothing too complex).
It would help if you would post some code with a question like this.
You said you can't seem to figure it out, so that sounds like you
tried something. If you post what you've tried, we can help you figure
out why it's not doing what you want. At the very least, post the
code you're starting with (It's obviously not stock, so I don't know
exactly what it looks like to be able to give a detailed answer).
> I tried using some of the string operators like ? and :, but that sorta
? and : aren't string operators. They're just plain operators, having
nothing to do with strings. :)
> screwed things up and I realized that I'm going to need to use some if()'s
> and for's...which I suck at...
If I were doing it, I would probably use ? and : in there somewhere,
but since you're apparently new to C, I would suggest sticking to the
ifs, since they're easier for new coders to understand.
If you are having trouble with if's, you really do need to try to
learn how to use them before trying to tackle much more in your mud.
You just have to understand very basic boolean logic (TRUE, FALSE, AND, OR,
and NOT), and be able to make out at least some of the C syntax.
If it's the logic that's giving you problems, you HAVE to learn that
before progressing any further. If it's just the C syntax for it that
is giving you problems, then you just need to try to learn some more C
(try some simpler stuff than the mud code, such as example problems
from a C book or tutorial). ROM uses medium-level C stuff such as
structures and advanced stuff like pointers a ton (such as in the code
you're messing with), so you need to at least know a decent amount
about them to interpret the syntax.
> if anyone knows and could send the format part
> of do_who to me or to this list, it would be great!
> -Tarian
It sounds like you have 3 conditions to test for: If they are in
a gang, if they are in a corporation, or if they are in neither. The
simplest way to do it is something similar to the following pseudocode
(this is the best I can do without seeing any code to start with):
if ( ch->gang != NO_GANG ) {
/* print out the list with the Gang name */
} else if ( ch->corporation != NO_CORPORATION ) {
/* print out the list with the Corporation name */
} else /* neither */
/* print out the list with 'PRIVATE' */
}
Of course, you'd have to replace the psuedocode with the C code that
does each particular test or print. The printing code would be
the printf (or sprintf if I remember right) and any other code
that would be different in any of the 3 cases. Just change the
argument being sent to printf to something like: 'gang_table [ ch->gang ]',
'corporation_table [ ch->corporation ]', or '"PRIVATE"'. And of course
make sure you change the format string being sent to printf to reflect
the appropriate number and types of arguments (it will be the same
for all 3 cases, but not the same as it is now).
Like I said before, that's about as detailed of an answer as I can
give without seeing any code to work off of.
Dennis