[Half-Life AMXX] / include / amxmodx.inc Repository:
ViewVC logotype

Annotation of /include/amxmodx.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (view) (download)

1 : ian 1 /* AMX Mod X functions
2 :     *
3 :     * by the AMX Mod X Development Team
4 :     * originally developed by OLO
5 :     *
6 :     * This file is provided as is (no warranties).
7 :     */
8 :    
9 :     #if defined _amxmodx_included
10 :     #endinput
11 :     #endif
12 :     #define _amxmodx_included
13 :    
14 :     #include <core>
15 :     #include <float>
16 :     #include <amxconst>
17 :     #include <string>
18 :     #include <file>
19 :     #include <vault>
20 :     #include <lang>
21 :     #include <messages>
22 :     #include <vector>
23 :     #include <sorting>
24 : ian 17 #include <cellarray>
25 :     #include <newmenus>
26 : ian 1
27 :     /* Function is called just after server activation.
28 :     * Good place for configuration loading, commands and cvars registration. */
29 :     forward plugin_init();
30 :    
31 :     /* Called when the plugin is paused. */
32 :     forward plugin_pause();
33 :    
34 :     /* Called when the plugin is unpaused. */
35 :     forward plugin_unpause();
36 :    
37 :     /* Called when the mod tries to change the map. */
38 :     forward server_changelevel(map[]);
39 :    
40 :     /* Function is called when all plugin_init from plugins
41 :     * were called, so all commmands and cvars should be already registered. */
42 :     forward plugin_cfg();
43 :    
44 :     /* Function called before plugin unloading (server deactivation) */
45 :     forward plugin_end();
46 :    
47 :     /* Called on log message. */
48 :     forward plugin_log();
49 :    
50 :     /* Use here model_precache() and sound_precache() functions. */
51 :     forward plugin_precache();
52 :    
53 :     /* Whenever player info is changed, this function is called. */
54 :     forward client_infochanged(id);
55 :    
56 :     /* Called on client connection. */
57 :     forward client_connect(id);
58 :    
59 :     /* Called when client gets valid STEAM id (usually
60 :     * between client_connect() and client_putinserver()). */
61 :     forward client_authorized(id);
62 :    
63 :     /* Called when client is disconnecting from server. */
64 :     forward client_disconnect(id);
65 :    
66 :     /* Called when client is sending command. */
67 :     forward client_command(id);
68 :    
69 :     /* Called when client is entering to a game. */
70 :     forward client_putinserver(id);
71 :    
72 :     /* Sets informations about plugin. Returns the plugin id of the calling plugin. */
73 :     native register_plugin(const plugin_name[],const version[],const author[]);
74 :    
75 :     /* Precache model. Can be used only in plugin_precache() function.*/
76 :     native precache_model(const name[]);
77 :    
78 :     /* Precache sound. Can be used only in plugin_precache() function.*/
79 :     native precache_sound(const name[]);
80 :    
81 :     /* Precaches any file. */
82 :     native precache_generic(const szFile[]);
83 :    
84 :     /* Sets info for player. */
85 :     native set_user_info(index,const info[],const value[]);
86 :    
87 :     /* Gets info from player. */
88 :     native get_user_info(index,const info[],output[],len);
89 :    
90 :     /* Sets info for server. */
91 :     native set_localinfo(const info[],const value[]);
92 :    
93 :     /* Gets info from server. */
94 :     native get_localinfo(const info[],output[],len);
95 :    
96 :     /* Shows text in MOTD window. When there is no header, the MOTD title
97 :     * will be the name of server. If message is filename, then a contents
98 :     * of this file will be displayed as MOTD. */
99 :     native show_motd(player,const message[],const header[]="");
100 :    
101 :     /* Sends message to player. Set index to 0 to send text globaly. */
102 : ian 17 native client_print(index,type,const message[],any:...);
103 : ian 1
104 :     /* Sends message to player by engine. Set index to 0 to send text globaly. */
105 : ian 17 native engclient_print(player,type,const message[],any:...);
106 : ian 1
107 :     /* Sends message to console. */
108 : ian 17 native console_print(id,const message[],any:...);
109 : ian 1
110 :     /* Sends command to console. */
111 : ian 17 native console_cmd(id,const cmd[],any:...);
112 : ian 1
113 :     /* Registers event on which a given function will be called
114 :     * Flags:
115 :     * "a" - global event.
116 :     * "b" - specified.
117 :     * "c" - send only once when repeated to other players.
118 :     * "d" - call if is send to dead player.
119 :     * "e" - to alive.
120 : ian 17 * NOTE: Due to a long-standing bug that would break compatibility with old plugins,
121 :     * the client id should be checked for alive/dead state if you use d or e.
122 : ian 1 * Examples for conditions:
123 :     * "2=c4" - 2nd parameter of message must be sting "c4".
124 :     * "3>10" - 3rd parameter must be greater then 10.
125 :     * "3!4" - 3rd must be different from 4.
126 :     * "2&Buy" - 2nd parameter of message must contain "Buy" substring.
127 :     * "2!Buy" - 2nd parameter of message can't contain "Buy" substring. */
128 :     native register_event(const event[],const function[],const flags[],const cond[]="", ... );
129 :    
130 :     /* Registers log event on which the given function will be called
131 :     * Examples for conditions:
132 :     * "0=World triggered" "1=Game_Commencing"
133 :     * "1=say"
134 :     * "3=Terrorists_Win"
135 :     * "1=entered the game"
136 :     * "0=Server cvar"
137 :     */
138 :     native register_logevent(const function[], argsnum, ... );
139 :    
140 :     /**
141 :     * Sets format for hudmessage.
142 :     * Note - as of AMX Mod X 1.61, setting the channel to -1
143 :     * will automatically choose the next available HUD channel for a player.
144 :     */
145 :     native set_hudmessage(red=200, green=100, blue=0, Float:x=-1.0, Float:y=0.35, effects=0, Float:fxtime=6.0, Float:holdtime=12.0, Float:fadeintime=0.1, Float:fadeouttime=0.2,channel=4);
146 :    
147 :     /* Displays HUD message to given player. */
148 : ian 17 native show_hudmessage(index,const message[],any:...);
149 : ian 1
150 :     /* Displays menu. Keys have bit values (key 1 is (1<<0), key 5 is (1<<4) etc.). */
151 :     native show_menu(index,keys,const menu[], time = -1, const title[] = "");
152 :    
153 :     /* Gets value from client messages.
154 :     * When you are asking for string the array and length is needed (read_data(2,name,len)).
155 :     * Integer is returned by function (new me = read_data(3)).
156 :     * Float is set in second parameter (read_data(3,value)). */
157 : ian 17 native read_data(value, any:... );
158 : ian 1
159 :     /* Returns number of values in client message. */
160 :     native read_datanum();
161 :    
162 :     /* Gets log message. Can be called only in plugin_log() forward function. */
163 :     native read_logdata(output[],len);
164 :    
165 :     /* Returns number of log arguments.
166 :     * Can be called only in plugin_log() forward function. */
167 :     native read_logargc();
168 :    
169 :     /* Gets log argument indexed from 0.
170 :     * Can be called only in plugin_log() forward function. */
171 :     native read_logargv(id,output[],len);
172 :    
173 :     /* Parse log data about user ( "Butcher<5><BOT><TERRORIST>" etc. ). */
174 :     native parse_loguser(const text[], name[], nlen, &userid = -2, authid[] = "", alen = 0, team[]="", tlen=0);
175 :    
176 :     /* Prints message to server console.
177 :     * You may use text formating (f.e. server_print("%-32s %.2f!","hello",7.345)) */
178 : ian 17 native server_print(const message[], any:...);
179 : ian 1
180 :     /* Returns 1 or 0. */
181 :     native is_map_valid(const mapname[]);
182 :    
183 :     /* Returns 1 or 0. */
184 :     native is_user_bot(index);
185 :    
186 :     /* Returns 1 or 0. */
187 :     native is_user_hltv(index);
188 :    
189 :     /* Returns 1 or 0. */
190 :     native is_user_connected(index);
191 :    
192 :     /* Returns 1 or 0. */
193 :     native is_user_connecting(index);
194 :    
195 :     /* Returns 1 or 0. */
196 :     native is_user_alive(index);
197 :    
198 :     /* Returns 1 or 0. */
199 :     native is_dedicated_server();
200 :    
201 :     /* Returns 1 or 0. */
202 :     native is_linux_server();
203 :    
204 :     /* Returns 1 or 0. */
205 :     native is_jit_enabled();
206 :    
207 :     /* Returns AMXX's version string of the current gameserver */
208 :     native get_amxx_verstring(buffer[], length);
209 :    
210 :     /* If player is not attacked function returns 0, in other
211 :     * case returns index of attacking player. On second and third
212 :     * parameter you may get info about weapon and body hit place.
213 :     * As of 1.75, get_user_attacker can return a non-player index if the player was attacked by a non-player entity.
214 :     */
215 :     native get_user_attacker(index,...);
216 :    
217 :     /* If player doesn't hit at anything function returns 0.0,
218 :     * in other case the distance between hit point and player is returned.
219 :     * If player is aiming at another player then the id and part of body are set. */
220 :     native Float:get_user_aiming(index,&id,&body,dist=9999);
221 :    
222 :     /* Returns player frags. */
223 :     native get_user_frags(index);
224 :    
225 :     /* Returns player armor. */
226 :     native get_user_armor(index);
227 :    
228 :     /* Returns player deaths. */
229 :     native get_user_deaths(index);
230 :    
231 :     /* Returns player health. */
232 :     native get_user_health(index);
233 :    
234 :     /* Returns index. */
235 :     native get_user_index(const name[]);
236 :    
237 :     /* Returns ip. */
238 :     native get_user_ip(index,ip[],len, without_port = 0);
239 :    
240 :     /* Returns if the player has the weapon or not in their pev->weapons field.
241 :     set "setweapon" to 0 to turn the bit off, set to 1 to turn it on. */
242 :     native user_has_weapon(index,weapon,setweapon=-1);
243 :    
244 :     /* Returns id of currently carried weapon. Gets also
245 :     * ammount of ammo in clip and backpack. */
246 : ian 17 native get_user_weapon(index,&clip=0,&ammo=0);
247 : ian 1
248 :     /* Gets ammo and clip from current weapon. */
249 :     native get_user_ammo(index,weapon,&clip,&ammo);
250 :    
251 :     /* Converts numbers from range 0 - 999 to words. */
252 :     native num_to_word(num,output[],len);
253 :    
254 :     /* Returns team id. When length is greater then 0
255 :     * then a name of team is set. */
256 :     native get_user_team(index, team[]="", len = 0);
257 :    
258 :     /* Returns player playing time in seconds.
259 :     * If flag is set then result is without connection time. */
260 :     native get_user_time(index, flag = 0);
261 :    
262 :     /* Gets ping and loss at current time. */
263 :     native get_user_ping(index, &ping, &loss);
264 :    
265 :     /* Gets origin from player.
266 :     * Modes:
267 :     * 0 - current position.
268 :     * 1 - position from eyes (weapon aiming).
269 :     * 2 - end position from player position.
270 :     * 3 - end position from eyes (hit point for weapon).
271 :     * 4 - position of last bullet hit (only CS). */
272 :     native get_user_origin(index, origin[3], mode = 0);
273 :    
274 :     /* Returns all carried weapons as bit sum. Gets
275 :     * also theirs indexes.
276 :     * Note that num is incremental - if you pass 0, you get
277 :     * 32 weapons towards the total. Afterwards, num will
278 :     * will contain the number of weapons retrieved.
279 :     * However, subsequent calls to get_user_weapons() will
280 :     * return the next batch of weapons, in case the mod
281 :     * supports more than 32 weapons.
282 :     * This means to call get_user_weapons() on the same
283 :     * inputs twice, you must reset num to 0 to get the
284 :     * original output again.
285 :     */
286 :     native get_user_weapons(index,weapons[32],&num);
287 :    
288 :     /* Returns weapon name. */
289 :     native get_weaponname(id,weapon[],len);
290 :    
291 :     /* Returns player name. */
292 :     native get_user_name(index,name[],len);
293 :    
294 :     /* Gets player authid. */
295 :     native get_user_authid(index, authid[] ,len);
296 :    
297 :     /* Returns player userid. */
298 :     native get_user_userid(index);
299 :    
300 :     /* Slaps player with given power. */
301 :     native user_slap(index,power,rnddir=1);
302 :    
303 :     /* Kills player. When flag is set to 1 then death won't decrase frags. */
304 :     native user_kill(index,flag=0);
305 :    
306 :     /* Logs something into the current amx logfile
307 :     * Parameters:
308 :     * string[] - format string
309 :     * ... - optional parameters
310 :     * Return value:
311 :     * always 0 */
312 : ian 17 native log_amx(const string[], any:...);
313 : ian 1
314 :     /* Sends message to standard HL logs. */
315 : ian 17 native log_message(const message[],any:...);
316 : ian 1
317 :     /* Sends log message to specified file. */
318 : ian 17 native log_to_file(const file[],const message[],any:...);
319 : ian 1
320 :     /* Returns number of players put in server.
321 :     * If flag is set then also connecting are counted. */
322 :     native get_playersnum(flag=0);
323 :    
324 :     /* Sets indexes of players.
325 :     * Flags:
326 :     * "a" - don't collect dead players.
327 :     * "b" - don't collect alive players.
328 :     * "c" - skip bots.
329 :     * "d" - skip real players.
330 :     * "e" - match with team.
331 :     * "f" - match with part of name.
332 :     * "g" - ignore case sensitivity.
333 :     * "h" - skip HLTV.
334 :     * Example: Get all alive CTs: get_players(players,num,"ae","CT") */
335 :     native get_players(players[32], &num ,const flags[]="", const team[]="");
336 :    
337 :     /* Gets argument from command. */
338 :     native read_argv(id,output[],len);
339 :    
340 :     /* Gets line of all arguments. */
341 :     native read_args(output[],len);
342 :    
343 :     /* Returns number of arguments (+ one as command). */
344 :     native read_argc();
345 :    
346 :     /* Converts string to sum of bits.
347 :     * Example: "abcd" is a sum of 1, 2, 4 and 8. */
348 :     native read_flags(const flags[]);
349 :    
350 :     /* Converts sum of bits to string.
351 :     * Example: 3 will return "ab". */
352 :     native get_flags(flags,output[],len);
353 :    
354 :     /* Find player.
355 :     * Flags:
356 :     * "a" - with given name.
357 :     * "b" - with given part of name.
358 :     * "c" - with given authid.
359 :     * "d" - with given ip.
360 :     * "e" - with given team name.
361 :     * "f" - don't look in dead players.
362 :     * "g" - don't look in alive players.
363 :     * "h" - skip bots.
364 :     * "i" - skip real players.
365 :     * "j" - return index of last found player.
366 :     * "k" - with given userid.
367 :     * "l" - ignore case sensitivity. */
368 :     native find_player(const flags[], ... );
369 :    
370 :     /* Removes quotes from sentence. */
371 :     native remove_quotes(text[]);
372 :    
373 :     /* Executes command on player. */
374 : ian 17 native client_cmd(index,const command[],any:...);
375 : ian 1
376 :     /* This is an emulation of a client command (commands aren't send to client!).
377 :     * It allows to execute some commands on players and bots.
378 :     * Function is excellent for forcing to do an action related to a game (not settings!).
379 :     * The command must stand alone but in arguments you can use spaces. */
380 :     native engclient_cmd(index,const command[],const arg1[]="",const arg2[]="");
381 :    
382 :     /* Executes command on a server console. */
383 : ian 17 native server_cmd(const command[],any:...);
384 : ian 1
385 :     /* Sets a cvar to given value. */
386 :     native set_cvar_string(const cvar[],const value[]);
387 :    
388 :     /* If a cvar exists returns 1, in other case 0 */
389 :     native cvar_exists(const cvar[]);
390 :    
391 :     /* Removes a cvar flags (not allowed for amx_version,
392 :     * fun_version and sv_cheats cvars). */
393 :     native remove_cvar_flags(const cvar[],flags = -1);
394 :    
395 :     /* Sets a cvar flags (not allowed for amx_version,
396 :     * fun_version and sv_cheats cvars). */
397 :     native set_cvar_flags(const cvar[],flags);
398 :    
399 :     /* Returns a cvar flags. */
400 :     native get_cvar_flags(const cvar[]);
401 :    
402 :     /* Sets a cvar to given float. */
403 :     native set_cvar_float(const cvar[],Float:value);
404 :    
405 :     /* Gets a cvar float. */
406 :     native Float:get_cvar_float(const cvarname[]);
407 :    
408 :     /* Gets a cvar integer value. */
409 :     native get_cvar_num(const cvarname[]);
410 :    
411 :     /* Sets a cvar with integer value. */
412 :     native set_cvar_num(const cvarname[],value);
413 :    
414 :     /* Reads a cvar value. */
415 :     native get_cvar_string(const cvarname[],output[],iLen);
416 :    
417 :     /* Returns a name of currently played map. */
418 :     native get_mapname(name[],len);
419 :    
420 :     /* Returns time remaining on map in seconds. */
421 :     native get_timeleft();
422 :    
423 :     /* Returns a game time. */
424 :     native Float:get_gametime();
425 :    
426 :     /* Returns maxplayers setting. */
427 :     native get_maxplayers();
428 :    
429 :     /* Returns a name of currently played mod. */
430 :     native get_modname(name[],len);
431 :    
432 :     /* Returns time in given format. The most popular is: "%m/%d/%Y - %H:%M:%S". */
433 :     native get_time(const format[],output[],len);
434 :    
435 :     /* Returns time in given format. The most popular is: "%m/%d/%Y - %H:%M:%S".
436 :     * Last parameter sets time to format. */
437 :     native format_time(output[],len, const format[],time = -1);
438 :    
439 :     /* Returns system time in seconds elapsed since 00:00:00 on January 1, 1970.
440 :     * Offset is given in seconds.*/
441 :     native get_systime(offset = 0);
442 :    
443 :     /* Returns time in input and additionaly fills missing information
444 :     * with current time and date. If time is different than -1 then parsed
445 :     * time is added to given time.
446 :     * Example:
447 :     * parset_time( "10:32:54 04/02/2003", "%H:%M:%S %m:%d:%Y" )
448 :     * For more information see strptime(...) function from C libraries. */
449 :     native parse_time(const input[],const format[], time = -1);
450 :    
451 :     /* Calls function on specified time.
452 :     * Flags:
453 :     * "a" - repeat.
454 :     * "b" - loop task.
455 :     * "c" - do task on time after a map timeleft.
456 :     * "d" - do task on time before a map timelimit. */
457 :     native set_task(Float:time,const function[],id = 0,const parameter[]="",len = 0,const flags[]="", repeat = 0);
458 :    
459 :     /* Removes all tasks with given id. If outside var is
460 :     * set then a task can be removed also when
461 :     * was set in another plugin. */
462 :     native remove_task(id = 0, outside = 0);
463 :    
464 :     /* Changes the time of a task */
465 :     native change_task(id = 0, Float:newTime=1.0, outside = 0);
466 :    
467 :     /* Returns 1 if task under given id exists. */
468 :     native task_exists(id = 0, outside = 0);
469 :    
470 : ian 17 /* Sets the users flags with the assignment by bitwise OR operator. */
471 : ian 1 native set_user_flags(index,flags=-1,id=0);
472 :    
473 :     /* Gets flags from player. Set index to 0 if you want to read flags from server. */
474 :     native get_user_flags(index,id=0);
475 :    
476 :     /* Removes flags for player. */
477 :     native remove_user_flags(index,flags=-1,id=0);
478 :    
479 :     /* Registers function which will be called from client console.
480 : ian 17 * Set FlagManager to 1 to make FlagManager always include this command
481 :     * Set FlagManager to 0 to make FlagManager never include this command
482 : ian 1 * Returns the command ID.
483 :     */
484 : ian 17 native register_clcmd(const client_cmd[],const function[],flags=-1, const info[]="", FlagManager=-1);
485 : ian 1
486 :     /* Registers function which will be called from any console.
487 : ian 17 * Set FlagManager to 1 to make FlagManager always include this command
488 :     * Set FlagManager to 0 to make FlagManager never include this command
489 : ian 1 * Returns the command ID.
490 :     */
491 : ian 17 native register_concmd(const cmd[],const function[],flags=-1, const info[]="", FlagManager=-1);
492 : ian 1
493 :     /* Registers function which will be called from server console.
494 :     * Returns the command ID.
495 :     */
496 :     native register_srvcmd(const server_cmd[],const function[],flags=-1, const info[]="");
497 :    
498 :     /* Gets info about client command. */
499 :     native get_clcmd(index, command[], len1, &flags, info[], len2, flag);
500 :    
501 :     /* Returns number of registered client commands. */
502 :     native get_clcmdsnum(flag);
503 :    
504 :     /* Gets info about server command. */
505 :     native get_srvcmd(index,server_cmd[],len1,&flags, info[],len2, flag);
506 :    
507 :     /* Returns number of registered server commands. */
508 :     native get_srvcmdsnum(flag);
509 :    
510 :     /* Gets info about console command. If id is set to 0,
511 :     then function returns only server cmds, if positive then
512 :     returns only client cmds. in other case returns all console commands. */
513 :     native get_concmd(index,cmd[],len1,&flags, info[],len2, flag, id = -1);
514 :    
515 :     /* Gets the parent plugin id of a console command. */
516 :     native get_concmd_plid(cid, flag_mask, id_type);
517 :    
518 :     /* Returns number of registered console commands. */
519 :     native get_concmdsnum(flag,id = -1);
520 :    
521 :     /* Returns the number of plugin-registered cvars. */
522 :     native get_plugins_cvarsnum();
523 :    
524 :     /* Returns information about a plugin-registered cvar. */
525 :     native get_plugins_cvar(num, name[], namelen, &flags=0, &plugin_id=0, &pcvar_handle=0);
526 :    
527 :     /* Gets unique id of menu. Outside set to 1 allows
528 :     * to catch menus outside a plugin where register_menuid is called. */
529 :     native register_menuid(const menu[], outside=0 );
530 :    
531 :     /* Calls function when player uses specified menu and proper keys. */
532 :     native register_menucmd(menuid,keys, const function[] );
533 :    
534 :     /* Gets what menu the player is watching and what keys for menu he have.
535 :     * When there is no menu the index is 0. If the id is negative then the menu
536 :     * is VGUI in other case the id is from register_menuid() function. */
537 :     native get_user_menu(index,&id,&keys);
538 :    
539 :     /* Forces server to execute sent server command at current time.
540 :     * Very useful for map changes, setting cvars and other activities. */
541 :     native server_exec();
542 :    
543 :     /* Emits sound. Sample must be precached. */
544 :     native emit_sound(index, channel, const sample[], Float:vol, Float:att,flags, pitch);
545 :    
546 :     /* Registers new cvar for HL engine.
547 :     * Returns the cvar pointer for get/set_pcvar functions.
548 :     */
549 :     native register_cvar(const name[],const string[],flags = 0,Float:fvalue = 0.0);
550 :    
551 :     /* Generates random floating point number from a to b. */
552 :     native Float:random_float(Float:a,Float:b);
553 :    
554 :     /* Generates random integer from a to b. */
555 :     native random_num(a,b);
556 :    
557 :     /* Returns id of client message.
558 :     * Example: get_user_msgid("TextMsg"). */
559 :     native get_user_msgid(const name[]);
560 :    
561 :     /* Gets name of client message index. Return value is number of
562 :     * characters copied into name. Returns 0 on invalid msgid. */
563 :     native get_user_msgname(msgid, name[], len);
564 :    
565 :     /* Checks if public variable with given name exists in loaded plugins. */
566 :     native xvar_exists( const name[] );
567 :    
568 :     /* Returns an unique id for public variable specified by name. If such
569 :     * variable doesn't exist then returned value is -1. */
570 :     native get_xvar_id( const name[] );
571 :    
572 :     /* Returns an integer value of a public variable. Id is a value
573 :     * returned by get_xvar_id(...) native. */
574 :     native get_xvar_num( id );
575 :    
576 :     /* Returns a float value of a public variable. Id is a value
577 :     * returned by get_xvar_id(...) native. */
578 :     native Float:get_xvar_float( id );
579 :    
580 :     /* Sets a value of a public variable. Id is a value
581 :     * returned by get_xvar_id(...) native. */
582 :     native set_xvar_num( id, value = 0 );
583 :    
584 :     /* Sets a float value of a public variable. Id is a value
585 :     * returned by get_xvar_id(...) native. */
586 :     native set_xvar_float( id, Float:value = 0.0 );
587 :    
588 :     /* Checks whether a module is loaded. If it is not, the return value is -1, otherwise
589 :     * the return value is the module id. The function is case insensitive. */
590 :     native is_module_loaded(const name[]);
591 :    
592 :     /* Gets info about a module.
593 :     * Parameters:
594 :     * id - the id of the module
595 :     * name[] - The name of the module will be stored here
596 :     * nameLen - maximal length of the name
597 :     * author[] - the author will be stored here
598 :     * authorLen - maximal length of the author
599 :     * version[] - the version of the module will be stored here
600 :     * versionLen - maximal length of the version
601 :     * status - the status of the module will be stored here
602 :     * Return value:
603 :     * id - success
604 :     * -1 - module not found */
605 :     native get_module(id, name[], nameLen, author[], authorLen, version[], versionLen, &status);
606 :    
607 :     /* Returns number of currently registered modules */
608 :     native get_modulesnum();
609 :    
610 : ian 17 /**
611 :     * Checks whether a plugin is loaded by the given registered name (such as "Admin Base"), or, optionally
612 :     * the given filename ("admin.amxx").
613 :     *
614 :     * @param name Either the plugin name to lookup, or the plugin filename to lookup.
615 :     * @param usefilename Set to true if you want to search for the plugin by the filename, false to search
616 :     * by the plugin's registered name.
617 :     *
618 :     * @return Plugin ID of the matching plugin on a successful search, -1 on a failed search.
619 :     *
620 :     * @note Prior to 1.8, this function would only search for plugins registered names, not
621 :     * the filename.
622 :     *
623 :     * @note The plugin registered name search is a case insensitive search, however, the plugin
624 :     * filename search is case sensitive.
625 :     */
626 :     native is_plugin_loaded(const name[], bool:usefilename=false);
627 : ian 1
628 :     /* Gets info about plugin by given index.
629 :     * Function returns -1 if plugin doesn't exist with given index.
630 :     * Note: the [...] portion should not be used, and is only for backward compatibility.
631 :     * Use index of -1 to use the calling plugin's ID.
632 :     */
633 : ian 17 native get_plugin(index,filename[]="",len1=0,name[]="",len2=0,version[]="",len3=0,author[]="",len4=0,status[]="",len5=0,...);
634 : ian 1
635 :     /* Returns number of all loaded plugins. */
636 :     native get_pluginsnum();
637 :    
638 :     /* Pauses function or plugin so it won't be executed.
639 :     * In most cases param1 is name of function and
640 :     * param2 name of plugin (all depends on flags).
641 :     * Flags:
642 :     * "a" - pause whole plugin.
643 :     * "c" - look outside the plugin (by given plugin name).
644 :     * "d" - set "stopped" status when pausing whole plugin.
645 :     * In this status plugin is unpauseable.
646 :     * Example: pause("ac","myplugin.amxx")
647 :     *
648 :     * Note: There used to be the b and e flags as well,
649 :     * which have been deprecated and are no longer used.
650 :     */
651 :     native pause(const flag[], const param1[]="",const param2[]="");
652 :    
653 :     /* Unpauses function or plugin.
654 :     * Flags:
655 :     * "a" - unpause whole plugin.
656 :     * "c" - look outside the plugin (by given plugin name). */
657 :     native unpause(const flag[], const param1[]="",const param2[]="");
658 :    
659 :     /* Call a function in this / an another plugin by name.
660 :     * Parameters:
661 :     * plugin - plugin filename; if "", the caller plugin is used.
662 :     * If specified, it has to be the exact filename (for example stats.amxx)
663 :     * func - function name
664 :     * Return value:
665 :     * 1 - Success
666 :     * 0 - Runtime error
667 :     * -1 - Plugin not found
668 :     * -2 - Function not found */
669 :     native callfunc_begin(const func[], const plugin[]="");
670 :    
671 :     /* Call a function in this / an another plugin by id.
672 :     * Parameters:
673 :     * plugin - plugin id; the id you would pass to get_plugin
674 :     * If < 0, the current plugin is taken
675 :     * func - function id
676 :     * Return value:
677 :     * 1 - Success
678 :     * -1 - Plugin not found
679 :     * -2 - Function not executable */
680 :     native callfunc_begin_i(func, plugin = -1);
681 :    
682 :     /* Get a function id (for callfunc_begin_i)
683 :     To get the plugin id, use the find_plugin stock
684 :     */
685 :     native get_func_id(const funcName[], pluginId = -1);
686 :    
687 :     /* Push a parameter (integer, string, float)
688 :     * Note that none of these values are const.
689 :     * Anything pushed by intrf, floatrf, array, or str
690 :     * can be modified by the called function.
691 :     */
692 :     native callfunc_push_int(value);
693 :     native callfunc_push_float(Float: value);
694 :     native callfunc_push_intrf(&value);
695 :     native callfunc_push_floatrf(& Float: value);
696 :    
697 :     /* If copyback is 1 (default), any changes are copied back.
698 :     * Note that this will defy the 'const' specifier for push_str(),
699 :     * which is only kept for special backwards compatibility.
700 :     */
701 :     native callfunc_push_str(const VALUE[], bool:copyback=true);
702 :     native callfunc_push_array(const VALUE[], array_size, bool:copyback=true);
703 :    
704 :     /* Make the actual call.
705 :     * Return value of the function called. */
706 :     native callfunc_end();
707 :    
708 :     /* Called on inconsistent file. You can put any text
709 :     * into reason to change an original message. */
710 :     forward inconsistent_file(id,const filename[], reason[64] );
711 :    
712 :     /* Forces the client and server to be running with the same
713 :     * version of the specified file ( e.g., a player model ). */
714 :     native force_unmodified(force_type, const mins[3] , const maxs[3], const filename[]);
715 :    
716 :     /* Calculates the md5 keysum of a string */
717 :     native md5(const szString[], md5buffer[34]);
718 :    
719 :     /* Calculates the md5 keysum of a file */
720 :     native md5_file(const file[], md5buffer[34]);
721 :    
722 : ian 17 /* Returns the internal flags set on the plugin's state
723 : ian 1 * If hdr is 1, it will return the pcode flags rather than state flags.
724 : ian 17 *
725 :     * Use a plid of -1 to get the flags for the calling plugin.
726 : ian 1 */
727 : ian 17 native plugin_flags(hdr=0, plid=-1);
728 : ian 1
729 : ian 17 /**
730 :     * @deprecated
731 :     * Do not use!
732 :     */
733 : ian 1 forward plugin_modules();
734 :    
735 :     native require_module(const module[]);
736 :    
737 :     native is_amd64_server();
738 :    
739 :     /* Returns plugin id searched by file/name. Returns INVALID_PLUGIN_ID on failure. */
740 :     native find_plugin_byfile(const filename[], ignoreCase=1);
741 :    
742 :     /* This is called before plugin_init and allows you to register natives. */
743 :     forward plugin_natives();
744 :    
745 :     /* Registers a NATIVE. When a plugin uses your native (you should distribute a .inc),
746 :     * the handler will be called with two parameters: the calling plugin id, and the
747 :     * number of parameters.
748 :     * If you set style=1, the method of parameter passing is a tad more efficient.
749 :     * Instead of "id, numParams", you label the native exactly as how the parameters
750 :     * should, in theory, be sent. Then for each byreference parameter, you call
751 :     * param_convert(num). This is theoretically more efficient but quite hacky.
752 :     * The method was discovered by dJeyL, props to him!
753 :     */
754 :     native register_native(const name[], const handler[], style=0);
755 :    
756 : ian 17 /* Registers a library. To mark a library as required, place the following
757 :     * in your include file:
758 :     * #pragma reqlib <name>
759 :     * #if !defined AMXMODX_NOAUTOLOAD
760 :     * #pragma loadlib <name>
761 :     * #endif
762 : ian 1 */
763 :     native register_library(const library[]);
764 :    
765 :     /* Logs an error in your native, and breaks into the debugger.
766 :     * Acts as if the calling plugin had the error.
767 :     */
768 : ian 17 native log_error(error, const fmt[], any:...);
769 : ian 1
770 :     // More Dynamic Native System Stuff
771 :     // Each of these natives affects one of the parameters sent to your native.
772 :     // Parameters go from 1 to n, just like in modules, and it is important to
773 :     // remember two things: The parameters are actually coming from another plugin
774 :     // (and just like modules, you must use these special natives).
775 :     // two: you CANNOT call your native from inside your native. This is very bad.
776 :    
777 :     //This function should only be called if you registered with style=1
778 :     //You only need to use it on by-reference parameters.
779 :     native param_convert(num);
780 :    
781 :     // Gets a string from the calling plugin
782 :     native get_string(param, dest[], maxlen);
783 :    
784 :     // Sets a string in the calling plugin
785 :     native set_string(param, dest[], maxlen);
786 :    
787 :     // Gets a normal int or float parameter
788 :     native get_param(param);
789 :     native Float:get_param_f(param);
790 :    
791 :     // Gets/Sets a float or int parameter by reference
792 :     native get_param_byref(param);
793 :     native Float:get_float_byref(param);
794 :     native set_param_byref(param, value);
795 :     native set_float_byref(param, Float:value);
796 :    
797 :     // Copies an array either from the calling plugin to you
798 :     // Or copies an array from you to the calling plugin
799 :     native get_array(param, dest[], size);
800 :     native get_array_f(param, Float:dest[], size);
801 :     native set_array(param, const source[], size);
802 :     native set_array_f(param, const Float:source[], size);
803 :    
804 :     // Dispatches a client cvar query
805 :     // id: Player id
806 :     // cvar: cvar name
807 :     // resultFunc: public handler function
808 :     // paramLen + params: optional array parameter
809 :     // resultFunc looks like:
810 :     // public callbackCvarValue(id, const cvar[], const value[])
811 :     // or if you use the optional parameter:
812 :     // public callbackCvarValue(id, const cvar[], const value[], const param[])
813 :     native query_client_cvar(id, const cvar[], const resultFunc[], paramlen=0, const params[] = "");
814 :    
815 :    
816 :     /**
817 :     * Allows you to trap error messages that occur in your plugin.
818 :     * You can use this to override the debug messages that occur when your plugin
819 :     * causes some sort of runtime error. Your handler will be called in this style:
820 :     *
821 :     * public error_filter(error_code, bool:debugging, message[])
822 :     * error_code is the AMX_ERR code. debugging is whether or not the plugin is in debug mode.
823 :     * message[] is any message that was sent along with the error.
824 :     * Return PLUGIN_CONTINUE to let the error pass through the filter.
825 :     * Return PLUGIN_HANDLED to block the error from displaying.
826 :     */
827 :     native set_error_filter(const handler[]);
828 :    
829 :     /**
830 :     * Gets a trace handle for the item at the top of the traced call stack.
831 :     * Returns 0 if no debugging information is available.
832 :     */
833 :     native dbg_trace_begin();
834 :    
835 :     /**
836 :     * Gets the next item in a traced call stack. Returns 0 if no more traces exist.
837 :     */
838 :     native dbg_trace_next(trace);
839 :    
840 :     /**
841 :     * Gets the call stack info for a trace.
842 :     */
843 :     native dbg_trace_info(trace, &line, function[], maxLength1, file[], maxLength2);
844 :    
845 :     /**
846 :     * Gets the formatted error string, which looks like "Run time error X: (description)"
847 :     */
848 :     native dbg_fmt_error(buffer[], maxLength);
849 :    
850 :     /**
851 :     * The following two natives are useful for creating cross-mod plugins
852 :     * where instead of #define flags to compile separate versions, you can
853 :     * filter out the natives and modules depending on the current mod.
854 :     * Examples of this usage are in plmenu.sma, which filters out the cstrike module.
855 :     */
856 :    
857 :     /**
858 :     * Sets a native filter. This must be first set in plugin_natives(), but future calls will
859 :     * simply set a new filter.
860 :     * This filter will allow your plugin to load even if its modules aren't loaded. For example,
861 :     * if Fun isn't loaded and you use set_user_frags, your plugin will still load. However, if you
862 :     * attempt to call this native, your filter will intercept it with these parameters:
863 :     *
864 :     * public function native_filter(const name[], index)
865 :     * native - name of native
866 :     * index - index of native
867 :     * trap - 0 if native couldn't be found, 1 if native use was attempted
868 :     *
869 :     * If you return PLUGIN_HANDLED, no error is thrown. If you return PLUGIN_CONTINUE,
870 :     * your plugin will have a run-time-error. To print your own error, or change the default,
871 :     * you can return PLUGIN_HANDLED or return PLUGIN_CONTINUE and use set_error_filter.
872 :     * If you return PLUGIN_CONTINUE when trap is 0, the plugin will ABORT AND FAIL TO LOAD!
873 :     * When trap is 0, it is unsafe to use natives that modify the server or use other plugins.
874 :     */
875 :     native set_native_filter(const handler[]);
876 :    
877 :     /**
878 :     * This function sets a module/library filter. It will let you intercept the automatic requirement
879 :     * of a module and return PLUGIN_CONTINUE to fail load or PLUGIN_HANDLED to imply that load
880 :     * can continue even without the module.
881 :     *
882 :     * This is the most unforgiving of the filter functions. You can ONLY call it during plugin_natives,
883 :     * and any error that occurs is not filtered -- instead your plugin will fail to load as if you
884 :     * returned PLUGIN_CONTINUE.
885 :     *
886 :     * Your handler will be called with this prototype:
887 :     *
888 :     * public module_filter(const library[], LibType:type);
889 :     * library - library or class name of the module that is required
890 :     * libtype - The type of requirement being checked (library/module or class).
891 :     *
892 :     *
893 :     * set_module_filter() returns 0 on success (unlike most natives).
894 :     */
895 :     native set_module_filter(const handler[]);
896 :    
897 :     /**
898 :     * Aborts execution of the current callback. Your script will throw a run time error.
899 :     * You can also specify an optional message.
900 :     * You should NOT call this function inside:
901 :     * - Error or module filters (native filters are safe if trap is 1)
902 :     * - plugin_natives()
903 :     * Note that the plugin's filename is prepending to your message:
904 :     * [myplugin.amxx] MESSAGE
905 :     */
906 : ian 17 native abort(error, const fmt[]="", any:...);
907 : ian 1
908 :     /**
909 :     * Checks if a specific module is loaded. This is the exact same method AMX Mod X
910 :     * uses to see if a module is required by a plugin. For example:
911 :     * module_exists("cstrike")
912 :     * module_exists("dbi")
913 :     */
914 :     native module_exists(const logtag[]);
915 :    
916 :     /**
917 :     * Checks if a library/class is loaded. This is the newer version of module_exists.
918 :     */
919 :     native LibraryExists(const library[], LibType:type);
920 :    
921 :     /**
922 :     * Returns the next valid hudchannel for a user, from 1-4.
923 :     */
924 :     native next_hudchannel(player);
925 :    
926 :     /**
927 :     * Creates a HUD Synchronization Object. Create one of these
928 :     * for each section of the screen that contains overlapping HUD messages.
929 :     * For example, if you use both sides of the screen to display three messages
930 :     * that can potentially overlap, each side counts as a synchronizable area.
931 :     * You can then use ShowSyncHudMsg() to correctly synchronize displaying the
932 :     * HUD message with any other messages potentially in its class. Note that this
933 :     * does not yet do anything like reserve screen area, its sole purpose is to be
934 :     * able to wipe an old message on an auto-channel and ensure that it will not
935 :     * clear a message from another plugin.
936 :     * The parameters are kept blank for future use.
937 :     */
938 :     native CreateHudSyncObj(num=0, ...);
939 :    
940 :     /**
941 :     * Displays a synchronized HUD message. This will check that your
942 :     * HUD object has its previous display on the screen cleared before
943 :     * it proceeds to write another. It will only do this in the case
944 :     * of that channel not having been cleared already.
945 :     * Target can be 0 for all players or 1-get_maxplayers().
946 :     * You must use set_hudmessage, although the channel parameter is
947 :     * entirely ignored.
948 :     */
949 : ian 17 native ShowSyncHudMsg(target, syncObj, const fmt[], any:...);
950 : ian 1
951 :     /**
952 :     * Clears the display on a HudSync Object. This is essentially the same
953 :     * thing as: ShowSyncHudMsg(x, y, ""), except doing that would send
954 :     * out two messages and use up another channel. This re-uses the last
955 :     * channel and clears it at the same time.
956 :     * Note: for this you do not have to use set_hudmessage().
957 :     * Note: target can be 0 for all players.
958 :     */
959 :     native ClearSyncHud(target, syncObj);
960 :    
961 :     //no
962 :     native int3();
963 :    
964 :     //Sets your plugin to a failed/error state.
965 :     //If you use this, your plugin will cease operating.
966 :     //This is a good idea to fatally, but gracefully, handle errors.
967 :     //You can set a failed error message.
968 :     native set_fail_state(const err_msg[]);
969 :    
970 :     //Returns the reference address of the variable passed in.
971 :     //This address is local to the plugin, and not a full CPU address
972 :     //pass the variable as the first parameter
973 : ian 17 native get_var_addr(any:...);
974 : ian 1
975 :     //Returns the value of an address. This dereferences something returned by
976 :     // get_var_addr(). Attempting to pass in a value beyond stack or heap limits
977 :     // will result in AMX_ERR_MEMACCESS.
978 :     native get_addr_val(addr);
979 :    
980 :     //Sets the value of an address. same as above, essentially
981 :     native set_addr_val(addr, val);
982 :    
983 :    
984 :     /**
985 :     * Creates a multi-plugin forward.
986 :     * Stop type must be one of the ET_ values in amxconst.inc
987 :     * results will be > 0 for success
988 :     */
989 :     native CreateMultiForward(const name[], stop_type, ...);
990 :    
991 :     /**
992 :     * Creates a multi-forward plugin that can filter between old/new plugins.
993 :     * Old plugins are used by the AMX Mod backwards compatibility layer.
994 :     * Stop type must be one of the ET_ values in amxconst.inc
995 :     * Forward type must be one of the FORWARD_ values in amxconst.inc.
996 :     */
997 :     native CreateMultiForwardEx(const name[], stop_type, forward_type, ...);
998 :    
999 :     /**
1000 :     * Creates a forward for one plugin.
1001 :     * Results will be > 0 for success.
1002 :     * id should be an id such as returned by find_plugin_byfile.
1003 :     * Unlike get_plugin(), negative numbers will not work.
1004 :     */
1005 :     native CreateOneForward(plugin_id, const name[], ...);
1006 :    
1007 :     /**
1008 :     * prepares an array. use this and pass the result into
1009 :     * ExecuteForward() instead of the array itself.
1010 :     */
1011 :     native PrepareArray(const array[], size, copyback=0);
1012 :    
1013 :     /**
1014 :     * executes a forward. returns result in ret.
1015 :     * returns 1 for success, 0 for failure.
1016 :     */
1017 : ian 17 native ExecuteForward(forward_handle, &ret, any:...);
1018 : ian 1
1019 :     /**
1020 :     * Destroys/deallocates any type of forward
1021 :     */
1022 :     native DestroyForward(forward_handle);
1023 :    
1024 :    
1025 :     /* CVAR Pointer natives. Use these for
1026 :     * more optimized CVAR usage.
1027 :     * register_cvar() returns a pointer you can use.
1028 :     */
1029 :    
1030 :     /**
1031 :     * Get a cvar pointer. Returns 0 if not found.
1032 :     */
1033 :     native get_cvar_pointer(const cvar[]);
1034 :    
1035 :     native get_pcvar_flags(pcvar);
1036 :     native set_pcvar_flags(pcvar, flags);
1037 :     native get_pcvar_num(pcvar);
1038 :     native set_pcvar_num(pcvar, num);
1039 :     native Float:get_pcvar_float(pcvar);
1040 :     native set_pcvar_float(pcvar, Float:num);
1041 :     native get_pcvar_string(pcvar, string[], maxlen);
1042 : ian 17 native set_pcvar_string(pcvar, const string[]);
1043 : ian 1
1044 :     /**
1045 :     * Sets a whole array to a certain value.
1046 :     */
1047 :     native arrayset(array[], value, size);
1048 :    
1049 :     /**
1050 :     * Returns the weapon id, otherwise 0 when no id found.
1051 :     * The weapon name is case sensitive, and has the weapon_* form.
1052 :     */
1053 :     native get_weaponid(const name[]);
1054 :    
1055 : ian 17 /**
1056 :     * Adds an admin to the dynamic admin storage
1057 :     * for lookup at a later time
1058 :     */
1059 :     native admins_push(const AuthData[], const Password[], Access, Flags);
1060 :    
1061 :     /**
1062 :     * Gets the number of admins in the dynamic admin
1063 :     * storage list
1064 :     */
1065 :     native admins_num();
1066 :    
1067 :     /**
1068 :     * Gets information about a dynamically stored admin
1069 :     * Use the enum AdminProp
1070 :     * Returns an integer value: AdminProp_Access, AdminProp_Flags
1071 :     * Sets the buffer string: AdminProp_Auth, AdminProp_Password
1072 :     */
1073 :     native admins_lookup(num, AdminProp:Property, Buffer[]="", BufferSize=0);
1074 :    
1075 :     /**
1076 :     * Clears the list of dynamically stored admins
1077 :     */
1078 :     native admins_flush();
1079 : ian 1 // Keep this always at the bottom of this file
1080 :     #include <message_stocks>

Contact
ViewVC Help
Powered by ViewVC 1.0.4