29 Nov, 2011, arholly wrote in the 1st comment:
Votes: 0
Hello all:
I've got two problems and they are related and both probably are a reflection of my lack of coding skills. So, I'm using KaVir's protocol snippet for ROM and I'm hitting two snags. One I know is my lack of knowledge and the other is I have no idea.

Problem 1
OK, I'm trying to code my generation variable so it will display with MSDP. I have done a number of other variables fine, but this one is giving me problems.
MSDPSetNumber( d, eMSDP_GEN, d->character->gen );

I'm basing it off of this:
sprintf(buf, "Your generation is: %d.\n\r", ch->gen);

But when I use mushclient and configure it to show:
if msdp["RACE"] == "Vampire" then
outlined_text (colourGold, score_window, msdp["GEN"]..'th '..msdp["CLAN"]..'', 10, 5, y_offset, score_width)
else
outlined_text (colourGold, score_window, msdp["RACE"]..' ('..msdp["CLAN"]..')', 10, 5, y_offset, score_width)
end – if

I get fun error messages that after putting in some troubleshooting statements tells me that GEN is nil. But for the life of me, I know it's not because even looking at the information in the pfile it says it is 8.
Any thoughts?

Problem 2
The way health is coded is again based on the WoD system, but we display health using this:
sprintf( buf, "Health: %-22s  ", health_string(ch) );
send_to_char( buf, user );

And I'm not sure how to put it in code wise. I have this right now in the update.c file, but I know it's not right.
MSDPSetString( d, eMSDP_HEALTH, health_string(d));


Any help would be appreciated. Thanks in advance.

Arholly
29 Nov, 2011, Tyche wrote in the 2nd comment:
Votes: 0
msdp["RACE"]
It's not a good idea to use pointer to const char as an array subscript.
30 Nov, 2011, JohnnyStarr wrote in the 3rd comment:
Votes: 0
haha
30 Nov, 2011, David Haley wrote in the 4th comment:
Votes: 0
I'm not sure it's great to be laughing at somebody trying to learn how to code. :sad:

What he did would be perfectly appropriate in other languages, or even in C++ for a map. Don't kill him for not realizing you can't do that in C with straight arrays.
30 Nov, 2011, KaVir wrote in the 5th comment:
Votes: 0
Problem 1: Looks fine from the mud side:

<unhurt> get gen
MSDP RECV (GEN) (13) #variable {MSDP_GEN} {13}

The code you posted looks fine as well. So my guess is you just didn't add it to the REPORT
line in the OnPluginTelnetRequest() function in the plugin. You no longer need to send them
all in the same line, either, so if you prefer you could just add another REPORT call below
the first:

SendPkt ("\255\250\69\1REPORT\2GEN\255\240")

Problem 2: The first code section shows health_string() taking a CHAR_DATA* argument, so assuming
that's correct the second should be:

MSDPSetString( d, eMSDP_HEALTH, health_string(d->character));

The variable already seems to be there, but isn't being initialised:

<unhurt> get health
MSDP RECV (HEALTH) () #variable {MSDP_HEALTH} {}

Tyche said:
msdp["RACE"]
It's not a good idea to use pointer to const char as an array subscript.

That section of code is Lua, not C.
30 Nov, 2011, David Haley wrote in the 6th comment:
Votes: 0
Heh. Go figure.
02 Dec, 2011, Tyche wrote in the 7th comment:
Votes: 0
KaVir said:
Problem 1: Looks fine from the mud side:
Tyche said:
msdp["RACE"]
It's not a good idea to use pointer to const char as an array subscript.

That section of code is Lua, not C.

LOL, My bad.
0.0/7