Module Creation FAQ

From ASSS Wiki
Revision as of 18:56, 10 January 2005 by Dr Brain (talk | contribs) (Initial Creation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

What module and function do I use to send messages to players?

The chat interface, Ichat, is defined in chat.h and is used to send messages of all kinds.

Most of the chat interface functions use printf like syntax in their strings.

NOTE: You must get the I_CHAT interface from the ASSS Module Manager before using it, just like you must on every other interface.

To send a green message to a single player, you should use code similar to one of the following:

chat->SendMessage(p, "This is a message");
chat->SendMessage(p, "This is a message that displays an int. %i", someInt);
chat->SendMessage(p, "This is a message that displays a char array. %s", charArray);

To send a message to an entire arena, one should use code similar to one of the following:

chat->SendArenaMessage(p, "This is an arena-wide message");
chat->SendArenaMessage(p, "This is an arena-wide message that displays an int. %i", someInt);
chat->SendArenaMessage(p, "This is an arena-wide message that displays a char array. %s", charArray);

How do I log events?

The log manager's interface, Ilogman, is defined in logman.h and aids in debugging and notifying zone staff of unusual activity.

There are three log functions that are defined. Log, LogP and LogA. All three have printf like syntaxes (just like the chat interfaces's functions) for easy addition of variable values to add in debugging.

LogP is the most commonly used logging function. It should be used when you have access to a player pointer and the event relates to that player's actions.

lm->LogP(L_DEBUG, "my_module_name", p, "a log message attached to Player *p");

LogA is attached to an arena rather than a player. This should be used whenever an event happens inside an arena but is tied to no specific player.

lm->LogA(L_DEBUG, "my_module_name", arena, "a log message attached to Arena *arena");

I'm still typing...