Parent Directory | Revision Log
Revision 44 - (view) (download)
1 : | ian | 1 | /* Messaging functions (now part of Core) |
2 : | * | ||
3 : | * by the AMX Mod X Development Team | ||
4 : | * | ||
5 : | * This file is provided as is (no warranties). | ||
6 : | */ | ||
7 : | |||
8 : | #if defined _coremsg_included | ||
9 : | #endinput | ||
10 : | #endif | ||
11 : | #define _coremsg_included | ||
12 : | |||
13 : | #include <message_const> | ||
14 : | |||
15 : | /* These functinos are used to generate client messages. | ||
16 : | * You may generate menu, smoke, shockwaves, thunderlights, | ||
17 : | * intermission and many many others messages. | ||
18 : | * See HL SDK for more examples. */ | ||
19 : | native message_begin(dest, msg_type, const origin[3] = {0,0,0}, player = 0); | ||
20 : | native message_end(); | ||
21 : | native write_byte(x); | ||
22 : | native write_char(x); | ||
23 : | native write_short(x); | ||
24 : | native write_long(x); | ||
25 : | native write_entity(x); | ||
26 : | native write_angle(x); | ||
27 : | native write_coord(x); | ||
28 : | native write_string(const x[]); | ||
29 : | |||
30 : | /* These are the same as above, except that the messages sent | ||
31 : | * are also sent to all other plugins and Metamod plugins. | ||
32 : | * This means that if you send one of these messages, other plugins will | ||
33 : | * be notified, which was previously impossible. | ||
34 : | * BE CAREFUL! Using these incorrectly, or not for their intended purpose, | ||
35 : | * could cause infinite recursion or something just as bad. | ||
36 : | * NOTE! These natives are experimental. | ||
37 : | */ | ||
38 : | native emessage_begin(dest, msg_type, const origin[3] = {0,0,0}, player = 0); | ||
39 : | native emessage_end(); | ||
40 : | native ewrite_byte(x); | ||
41 : | native ewrite_char(x); | ||
42 : | native ewrite_short(x); | ||
43 : | native ewrite_long(x); | ||
44 : | native ewrite_entity(x); | ||
45 : | native ewrite_angle(x); | ||
46 : | native ewrite_coord(x); | ||
47 : | native ewrite_string(const x[]); | ||
48 : | |||
49 : | /* Sets/Gets what engine messages are blocked. */ | ||
50 : | native set_msg_block(iMessage, iMessageFlags); | ||
51 : | native get_msg_block(iMessage); | ||
52 : | |||
53 : | /* Lets you directly hook a message in the engine! | ||
54 : | * You can overwrite the message before anything happens and either let the message continue | ||
55 : | * or fully block it. Here is how it works: | ||
56 : | * If you hook a message, the message is stored but not sent. You have the opportunity to | ||
57 : | * not only execute code, but to get/set the contents of the message, before you choose to | ||
58 : | ian | 44 | * either block it or let it go on its way. The hooked function will be passed a msg_id, msg_dest, and entity index. |
59 : | * The return value can be passed to unregister_message() to stop the message from being hooked */ | ||
60 : | ian | 1 | native register_message(iMsgId, const szFunction[]); |
61 : | |||
62 : | ian | 44 | /* Unregisters a message hook previously created with register_message |
63 : | * You must pass the proper message id, and return value from the message to unregister the message successfully. */ | ||
64 : | native unregister_message(iMsgId, registeredmsg); | ||
65 : | |||
66 : | |||
67 : | ian | 1 | /* The get/set _msg commands will fail if used outside a hooked message scope. |
68 : | * They should never be used unless inside a registered message function. | ||
69 : | * There are eight different ways of sending a message, five are ints, two are floats, and one is string. | ||
70 : | * These are denoted by iArgType. argn is the number | ||
71 : | * of the argument. Exceeding the bounds of 1 to get_msg_args() is a bad idea. | ||
72 : | * As of AMX Mod X 1.5, the middle parameter of set_* no longer does anything. | ||
73 : | * You cannot change the message argument type (as this would crash the mod anyway) | ||
74 : | */ | ||
75 : | |||
76 : | /* Gets number of arguments that were passed to this message */ | ||
77 : | native get_msg_args(); | ||
78 : | |||
79 : | /* Gets the argument type of argument argn */ | ||
80 : | native get_msg_argtype(argn); | ||
81 : | |||
82 : | /* Gets the value of argn. */ | ||
83 : | native get_msg_arg_int(argn); | ||
84 : | native Float:get_msg_arg_float(argn); | ||
85 : | native get_msg_arg_string(argn, szReturn[], iLength); | ||
86 : | |||
87 : | /* sets the value of argn. */ | ||
88 : | native set_msg_arg_int(argn, argtype, iValue); | ||
89 : | native set_msg_arg_float(argn, argtype, Float:fValue); | ||
90 : | native set_msg_arg_string(argn, const szString[]); | ||
91 : | |||
92 : | /* Gets the origin of a message */ | ||
93 : | native get_msg_origin(const Float:_Origin[3]); |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |