Difference between revisions of "Module Creation FAQ"
(Initial Creation) |
|||
Line 1: | Line 1: | ||
+ | I'm still typing (as of 5:57 PM EST 01-10-05). I will remove this message when finished. | ||
+ | |||
+ | |||
== What module and function do I use to send messages to players? == | == What module and function do I use to send messages to players? == | ||
Line 22: | Line 25: | ||
chat->SendArenaMessage(p, "This is an arena-wide message that displays a char array. %s", charArray); | chat->SendArenaMessage(p, "This is an arena-wide message that displays a char array. %s", charArray); | ||
</pre> | </pre> | ||
+ | |||
== How do I log events? == | == How do I log events? == | ||
Line 28: | Line 32: | ||
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. | 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. | ||
+ | |||
+ | There are five log levels that can be used when calling a log function. | ||
+ | |||
+ | <ul> | ||
+ | <li>'''L_DRIVEL''' is for meaningless log entries. Things that no sysop will ever care about. Use this level for printing out statements to help in debugging.</li> | ||
+ | <li>'''L_INFO''' is for things that people might care about.</li> | ||
+ | <li>'''L_MALICIOUS''' is for events that shouldn't happen unless someone is trying to hack/cheat. This is sent to online sysops as soon as it is logged (under default settings).</li> | ||
+ | <li>'''L_WARN''' is for things that probably shouldn't happen, but don't make a big difference.</li> | ||
+ | <li>'''L_ERROR''' is for events that are really bad. It is sent to online sysops as soon as it is logged (under default settings).</li> | ||
+ | </ul> | ||
+ | |||
'''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. | '''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. | ||
<pre> | <pre> | ||
− | lm->LogP( | + | lm->LogP(L_DRIVEL, "my_module_name", p, "A log message attached to Player *p"); |
</pre> | </pre> | ||
Line 38: | Line 53: | ||
<pre> | <pre> | ||
− | lm->LogA( | + | lm->LogA(L_DRIVEL, "my_module_name", arena, "A log message attached to Arena *arena"); |
</pre> | </pre> | ||
− | I' | + | '''Log''' is attached to neither an arena nor a player. |
+ | |||
+ | <pre> | ||
+ | lm->Log(L_DRIVEL, "<my_module_name> A log message"); | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | == How do I warp a player somewhere? == | ||
+ | |||
+ | The game interface, '''Igame''' defines the function '''WarpTo''' that takes a player, an x tile and a y tile. | ||
+ | |||
+ | <pre> | ||
+ | game->WarpTo(p, 512, 512); //will warp a player to the center of the map | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | == How do I give a player prizes? == | ||
+ | |||
+ | The game interface, '''Igame''' defines the function '''GivePrize''' that takes a '''Target''', a prize type and a prize count. | ||
+ | |||
+ | <pre> | ||
+ | Target t; | ||
+ | t.type = T_PLAYER; | ||
+ | t.u.p = p; | ||
+ | |||
+ | game->GivePrize(t, 21, 5); //give Player p 5 repels (prize #21) | ||
+ | </pre> | ||
+ | |||
+ | == How do I set a player's ship? == | ||
+ | |||
+ | == How do I set a player's freq? == | ||
+ | |||
+ | == How do I check when a player has entered a region? == |
Revision as of 18:17, 10 January 2005
I'm still typing (as of 5:57 PM EST 01-10-05). I will remove this message when finished.
Contents
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.
There are five log levels that can be used when calling a log function.
- L_DRIVEL is for meaningless log entries. Things that no sysop will ever care about. Use this level for printing out statements to help in debugging.
- L_INFO is for things that people might care about.
- L_MALICIOUS is for events that shouldn't happen unless someone is trying to hack/cheat. This is sent to online sysops as soon as it is logged (under default settings).
- L_WARN is for things that probably shouldn't happen, but don't make a big difference.
- L_ERROR is for events that are really bad. It is sent to online sysops as soon as it is logged (under default settings).
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_DRIVEL, "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_DRIVEL, "my_module_name", arena, "A log message attached to Arena *arena");
Log is attached to neither an arena nor a player.
lm->Log(L_DRIVEL, "<my_module_name> A log message");
How do I warp a player somewhere?
The game interface, Igame defines the function WarpTo that takes a player, an x tile and a y tile.
game->WarpTo(p, 512, 512); //will warp a player to the center of the map
How do I give a player prizes?
The game interface, Igame defines the function GivePrize that takes a Target, a prize type and a prize count.
Target t; t.type = T_PLAYER; t.u.p = p; game->GivePrize(t, 21, 5); //give Player p 5 repels (prize #21)