Frequently Asked Questions (FAQ) about SMAUG server.
Summary | How to add more questions to the SMAUG login sequence |
---|---|
Question | I want to add a "roll stats" to the original character creation. 
 
I have found a couple of snippets but none of them work even after following their instructions. 
 
I have written a C++ program that generates random numbers but when I try to "plug it in" to your code I get several errors. 
 
One problem I know of, is "#include <iostream.h>" ... for some reason it's acting like it doesn't see this at all, my cout, cin, << etc. do not work at all. 
 
Any insight you could offer would be greatly appreciated. |
Answer | Well, for one thing the files are .C files and not .CPP which means they are C and not C++. Thus things like cout, and << will not work. Second, using "cout" is wrong anyway because all that would do is display something on the screen of the server which is hardly what you want - you want the stats to go to the player. What you need to do to change the login sequence, is to change the way "nanny" works in comm.c. Remember, the server is handling multiple players doing things all the time, so it is not a simple matter of asking a question and expecting an answer. eg.
This would fail for a number of reasons, for one thing, printf would only go to the terminal of the server, and the gets would hang the server until you reply, which means all the other players would have a "dead" server. Each player has a descriptor, which stores its state, and in that is a thing called "connected" which is how far they have got through the connection sequence. This is a "switch" that checks the state, like this:
To send a message to the player you use "write_to_buffer" like this:
Here are the states, from mud.h:
You would need to:
Now you are back into the original login sequence. |
Enter a word or phrase in the box below to narrow the list down to those that match.
Leave blank to show all FAQs.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.