/
amxmodx.inc
executable file
·3322 lines (3092 loc) · 115 KB
/
amxmodx.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#if defined _amxmodx_included
#endinput
#endif
#define _amxmodx_included
#include <core>
#include <float>
#include <amxconst>
#include <string>
#include <file>
#include <vault>
#include <lang>
#include <messages>
#include <vector>
#include <sorting>
#include <cellarray>
#include <cellstack>
#include <celltrie>
#include <datapack>
#include <newmenus>
#include <textparse_smc>
#include <textparse_ini>
#include <cvars>
#include <gameconfig>
/**
* Called just after server activation.
*
* @note Good place to initialize most of the plugin, such as registering
* cvars, commands or forwards, creating data structures for later use, or
* generating and loading other required configurations.
*
* @noreturn
*/
forward plugin_init();
/**
* Called just before the plugin is paused from execution.
*
* @noreturn
*/
forward plugin_pause();
/**
* Called just after the plugin is unpaused.
*
* @noreturn
*/
forward plugin_unpause();
/**
* Called when the mod tries to change the map.
*
* @note This is *only* called if the mod itself handles the map change. The
* server command "changelevel", which is used by many plugins, will not
* trigger this forward. Unfortunately, this means that in practice this
* forward can be unreliable and will not be called in many situations.
* @note AMXX 1.8.3 has added the engine_changelevel() function, which will utilize
* the correct engine function to change the map, and therefore trigger
* this forward.
*
* @param map Map that the mod tries to change to
*
* @return PLUGIN_CONTINUE to let the mod change the map
* PLUGIN_HANDLED or higher to prevent the map change
*/
forward server_changelevel(map[]);
/**
* Called when all plugins went through plugin_init()
*
* @note When this forward is called, most plugins should have registered their
* cvars and commands already.
*
* @noreturn
*/
forward plugin_cfg();
/**
* Called just before server deactivation and subsequent unloading of the
* plugin.
*
* @note The plugin is required to manually free Handles it has acquired, such
* as those from dynamic data structures. Failing to do that will result
* in the plugin and AMXX leaking memory.
*
* @noreturn
*/
forward plugin_end();
/**
* Called when a message is about to be logged.
*
* @note Message data and information can be retrieved using the read_log* set
* of functions.
*
* @return PLUGIN_CONTINUE to let the log message through
* PLUGIN_HANDLED or higher to stop the log message
*/
forward plugin_log();
/**
* This forward allows plugins to add models, sounds and generic files to the
* precache tables using the precache_* set of functions.
*
* @note Adding files to the precaching tables will trigger the client to
* download them to its local filesystem.
* @note There is a hard upper limit of entries in the precaching tables for
* every game, this limit is 512 in most cases. The entries will be filled
* and indexed incrementally. Going over this limit will crash the server.
*
* @noreturn
*/
forward plugin_precache();
/**
* Called when a clients info has changed.
*
* @param id Client index
*
* @noreturn
*/
forward client_infochanged(id);
/**
* Called when a client is connecting.
*
* @note This forward is called too early to do anything that directly affects
* the client.
*
* @param id Client index
*
* @noreturn
*/
forward client_connect(id);
/**
* Called when a client is connecting.
*
* @note This forward is called too early to do anything that directly affects
* the client.
*
* @param id Client index
* @param name Client name
* @param ip Client ip address with port
* @param reason A reason that will be displayed when player gets rejected (can be overwritten)
*
* @return PLUGIN_CONTINUE to let a client join to the server
* PLUGIN_HANDLED or higher to prevent a client to join
*/
forward client_connectex(id, const name[], const ip[], reason[128]);
/**
* Called when the client gets a valid SteamID.
*
* @note This may occur before or after client_putinserver has been called.
* @note This is called for bots, and the SteamID will be "BOT".
*
* @param id Client index
* @param authid Client auth
*
* @noreturn
*/
forward client_authorized(id, const authid[]);
/**
* @deprecated This function does not catch all cases.
*/
#pragma deprecated Use client_disconnected() instead.
forward client_disconnect(id);
/**
* Called when a client is disconnected from the server.
*
* @note This will be called in some additional cases that client_disconnect doesn't cover,
* most notably when a client aborts the connection process. It is guaranteed to pair
* with the client_connect() forward.
* @note When this fires the player entity is still valid (e.g. is_user_connected(id) will
* return true), but no networked commands will reach the client.
*
* @param id Client index
* @param drop If true, the game has explicitly dropped the client
* @param message If drop is true, a writable buffer containing the disconnect info message
* @param maxlen Maximum size of buffer
*
* @noreturn
*/
forward client_disconnected(id, bool:drop, message[], maxlen);
/**
* Called when a client entity has been removed from the server.
*
* @note This fires after the client_disconnected() forward, when the player entity has been
* removed (e.g. is_user_connected(id) will return false).
*
* @param id Client index
* @param drop If true, the game has explicitly dropped the client
* @param message If drop is true, contains the disconnect info message
*
* @noreturn
*/
forward client_remove(id, bool:drop, const message[]);
/**
* Called when a client attempts to execute a command.
*
* @note The command and its arguments can be read using the read_arg* set of
* functions.
*
* @param id Client index
*
* @return PLUGIN_CONTINUE to let the client execute the command
* PLUGIN_HANDLED or higher to stop the command
*/
forward client_command(id);
/**
* Called when a client is entering the game.
*
* @note It is not defined whether the client already has a SteamID when this
* forward is called. client_authorized may occur either before or after
* this.
*
* @param id Client index
*
* @noreturn
*/
forward client_putinserver(id);
/**
* Sets informations about the calling plugin.
*
* @param plugin_name Name of the plugin
* @param version Version of the plugin
* @param author Author of the plugin
*
* @return Plugin id of the calling plugin
*/
native register_plugin(const plugin_name[], const version[], const author[]);
/**
* Precaches a model file.
*
* @note Can only be used inside of the plugin_precache() forward.
*
* @param name Path to the model file
*
* @return Unique cache id of the model
* @error If called outside of the plugin_precache() forward, an error is
* thrown.
*/
native precache_model(const name[]);
/**
* Precaches a sound file.
*
* @note Can only be used inside of the plugin_precache() forward.
* @note The filepath is always relative to the "sound" folder, and the file has
* to be a wav file. Precaching a file with this will add it to the engine
* sound table, making it available for usage in emit_sound() for example.
* @note Precaching other filetypes (such as mp3 music), optionally in different
* locations, has to be done with precache_generic()
*
* @param name Path to the sound file
*
* @return Unique cache id of the sound
* @error If called outside of the plugin_precache() forward, an error is
* thrown.
*/
native precache_sound(const name[]);
/**
* Precaches a generic file.
*
* @note Can only be used inside of the plugin_precache() forward.
* @note Precaching sounds with this will not add them to the engine sound table.
*
* @param szFile Path to the file
*
* @return Unique cache id of the file
* @error If called outside of the plugin_precache() forward, an error
* is thrown.
*/
native precache_generic(const szFile[]);
/**
* Precaches an event file.
*
* @note The event type should always be 1.
* @note Contrary to the other precache_* natives, this can be used outside of
* the plugin_precache() forward, e.g. in plugin_init() or plugin_cfg().
* A bug in some clients makes this necessary, as plugin_precache() is
* called before the mod has precached its own, default event files. This
* can cause the event table to be misaligned on the client, leading to
* visual and audio bugs that are hard to diagnose.
*
* @param type Event type
* @param Name Formatting rules, path to the event file
* @param ... Variable number of formatting parameters
*
* @return Unique cache id of the event
*/
native precache_event(type, const Name[], any:...);
/**
* Changes the map.
*
* @note This calls the pfnChangelLevel engine function.
* @note This has the same behavior as using the "changelevel" server command,
* but will also trigger the server_changelevel() forward in AMXX
* plugins. It will also notify any Metamod plugins that are hooking
* the pfnChangeLevel function.
*
* @param map Map name to change to
*
* @noreturn
*/
native engine_changelevel(const map[]);
/**
* Sets info on the client.
*
* @param index Client index
* @param info Info key
* @param value New value
*
* @noreturn
* @error If the index is not within the range of 1 to MaxClients or
* the client is not connected, an error will be thrown.
*/
native set_user_info(index, const info[], const value[]);
/**
* Gets info from the client.
*
* @param index Client index
* @param info Info key
* @param output Buffer to copy value to
* @param len Maximum size of the buffer
*
* @return Number of cells written to buffer
* @error If the index is not within the range of 1 to MaxClients or
* the client is not connected, an error will be thrown.
*/
native get_user_info(index, const info[], output[], len);
/**
* Sets info on the server.
*
* @param info Info key
* @param value New value
*
* @noreturn
*/
native set_localinfo(const info[], const value[]);
/**
* Gets info from the server.
*
* @param info Info key
* @param output Buffer to copy value to
* @param len Maximum size of the buffer
*
* @return Number of cells written to buffer
*/
native get_localinfo(const info[], output[], len);
/**
* Shows text or a file in MOTD window.
*
* @param player Client index, use 0 to display to all clients
* @param message Message to display inside the MOTD window, if this is a
* filename the contents of this file will be displayed
* @param header Text for the MOTD header, if empty the servers hostname will
* be displayed instead
*
* @noreturn
*/
native show_motd(player, const message[], const header[] = "");
/**
* Sends a message to the client.
*
* @note This functions return value behaves differently depending on what is
* used as the client index: If 0 is specified, then the function will
* return 0 if nothing has been sent (no client connected). If either a
* single client is specified or there is at least one client connected,
* the number of printed characters will refer to the message that is sent
* last, to the client with the highest index.
*
* @param index Client index, use 0 to display to all clients
* @param type Message type, see print_* destination constants in
* amxconst.inc
* @param message Formatting rules
* @param ... Variable number of formatting parameters
*
* @return Number of printed characters
* @error If a single client is specified and the index is not within
* the range of 1 to MaxClients, an error will be thrown.
*/
native client_print(index, type, const message[], any:...);
/**
* Sends colored chat messages to clients.
*
* @note This only works in Counter-Strike 1.6 and Condition Zero.
* @note The colors can be modified inside of the format string using special
* characters. These characters can be included using the escape character
* green x04 ; use location color from this point forward
* red/blue/grey x03 ; use team color from this point forward
* red/blue/grey x02 ; use team color to the end of the client name
* ; This only works at the start of the string,
* ; and precludes using other control characters
* default x01 ; use default color from this point forward
* @note The team color is defined by the sender's index. Alternatively, a
* specific team color can be enforced using the print_team_* constants in
* amxconst.inc
* @note Usage examples:
* client_print_color(id, print_team_red, "^4Green ^3Red ^1Default")
* client_print_color(id, id2, "^4Green ^3id2's team color, ^1Default")
* @note Including colors in ML can be done using the same escaping method:
* EXAMPLE_ML_KEY = ^4Green ^3Team color ^1Default
* @note This functions return value behaves differently depending on what is
* used as the client index: If 0 is specified, then the function will
* return 0 if nothing has been sent (no client connected). If either a
* single client is specified, or there is at least one client connected,
* the number of printed characters will refer to the message that is sent
* last, to the client with the highest index.
*
* @param index Client index, use 0 to display to all clients
* @param sender Client index used as the message sender
* @param fmt Formatting rules
* @param ... Variable number of formatting parameters
*
* @return Number of printed characters
* @error If a single client is specified and the index is not within
* the range of 1 to MaxClients, an error will be thrown.
*/
native client_print_color(index, sender, const message[], any:...);
/**
* Sends a message to the client via the engine.
*
* @note This functions return value behaves differently depending on what is
* used as the client index: If 0 is specified, then the function will
* return 0 if nothing has been sent (no client connected). If either a
* single client is specified, or there is at least one client connected,
* the number of printed characters will refer to the message that is sent
* last, to the client with the highest index.
*
* @param player Client index, use 0 to display to all clients
* @param type Message type, see print_* destination constants in
* amxconst.inc
* @param message Formatting rules
* @param ... Variable number of formatting parameters
*
* @return Number of printed characters
* @error If a single client is specified and the index is not within
* the range of 1 to MaxClients, an error will be thrown.
*/
native engclient_print(player, type, const message[], any:...);
/**
* Sends a message to the console of a client or the server.
*
* @param index Client index, or 0 to print to the server console
* @param message Formatting rules
* @param ... Variable number of formatting parameters
*
* @return Number of printed characters
* @error If a single client is specified and the index is not within
* the range of 1 to MaxClients, an error will be thrown.
*/
native console_print(id, const message[], any:...);
/**
* Executes a command from the specified client or the server console.
*
* @param id Client index, or 0 to execute from the server console
* @param cmd Formatting rules
* @param ... Variable number of formatting parameters
*
* @return Length of the formatted command
*/
native console_cmd(id, const cmd[], any:...);
/**
* Registers a function to be called on a given game event.
*
* @note Examples for event conditions:
* "2=c4" - Second parameter of message must be the string "c4"
* "3>10" - Third parameter of message must be greater than 10
* "3!4" - Third parameter of message must not be equal to 4
* "2&Buy" - Second parameter of message must contain "Buy" substring
* "2!Buy" - Second parameter of message must not equal "Buy"
* @note Due to a long-standing bug that would break compatibility with older
* plugins, the client id should be checked for alive/dead state if using
* flags "d" or "e".
* @note If multiple conditions are specified for a single parameter, only one
* of them has to hold true for the event function to be called.
*
* @param event Name of event that should be hooked
* @param function Name of callback function
* @param flags Flags used for filtering events, the valid flags are:
* "a" - Global event (sent to every client)
* "b" - Event sent to single client
* "c" - Call only once when repeated to multiple clients
* "d" - Call only if sent to dead client
* "e" - Call only if sent to alive client
* "f" - Call only if sent to human client ("b" flag required)
* "g" - Call only if sent to bot ("b" flag required)
* @param cond Condition string used for filtering events, built as:
* "<argument number><comparison operator><value>"
* Argument number is the argument position to be filtered
* The comparison operator may be:
* - "=" for equality comparison (all argument types)
* - "!" for inequality comparison (all argument types)
* - "&" for bitwise and (int argument) or substring
* comparison (string argument)
* - "<" for less than comparison (int/float arguments)
* - ">" for greater than comparison (int/float arguments)
* The argument is compared to the specified value accordingly
* @param ... Any number of additional conditions
*
* @return Event handle
* @error If an invalid event name or callback function is provided,
* an error will be thrown.
*/
native register_event(const event[], const function[], const flags[], const cond[] = "", ...);
/**
* Enables a function hook of a game event which has been previously registered with register_event().
*
* @param handle Value returned from register_event()
*
* @noreturn
* @error If an invalid handle is provided, an error will be thrown.
*/
native enable_event(handle);
/**
* Disables a function hook of a game event which has been previously registered with register_event().
*
* @param handle Value returned from register_event()
*
* @noreturn
* @error If an invalid handle is provided, an error will be thrown.
*/
native disable_event(handle);
/**
* Registers a function to be called on a given log event.
*
* @note Examples for log conditions:
* "0 = World triggered" "1 = Game_Commencing"
* "1 = say"
* "3 = Terrorists_Win"
* "1 = entered the game"
* "0 = Server cvar"
*
* @param function Name of callback function
* @param argsnum Number of arguments of the log event
* @param ... Any number of conditions used for filtering events
* A condition string is built as:
* "<argument number><comparison operator><string>"
* Argument number is the argument position to be filtered
* The comparison operator may be:
* - "=" for equality comparison
* - "&" for substring comparison
* The argument is compared to the specified string accordingly
*
* @return Log event handle
* @error If an invalid callback function is provided, an error will
* be thrown.
*/
native register_logevent(const function[], argsnum, ...);
/**
* Enables a function hook of a game log event which has been previously registered with register_logevent().
*
* @param handle Value returned from register_logevent()
*
* @noreturn
* @error If an invalid handle is provided, an error will be thrown.
*/
native enable_logevent(handle);
/**
* Disables a function hook of a game log event which has been previously registered with register_logevent().
*
* @param handle Value returned from register_logevent()
*
* @noreturn
* @error If an invalid handle is provided, an error will be thrown.
*/
native disable_logevent(handle);
/**
* Sets display parameters for hudmessages.
*
* @note As of AMXX 1.61, setting the channel to -1 will automatically choose
* the next available HUD channel for the client.
* @note There are four different HUD channels available on the client (1-4).
* Sending a hudmessage to a channel will overwrite any existing messages
* already displaying on that channel.
* @note If you plan to create a permanent message, don't forget to specify a
* specific channel to avoid possible flickering due to auto-channeling.
* @note For the hudmessage coordinates x and y, -1.0 will center the message
* on the respective axis.
* @note These parameters stay until the next call to set_hudmessage overwrites
* them. Multiple calls to show_hudmessage will therefore re-use the same
* parameters. The parameters are not stored per-plugin, so other plugins
* can overwrite them.
*
* @param red Red component of hudmessage color
* @param green Green component of hudmessage color
* @param blue Blue component of hudmessage color
* @param x Location of the message on the x axis in percent
* @param y Location of the message on the y axis in percent
* @param effects Display effect
* @param fxtime Duration of the effect
* @param holdtime Time the message stays on screen
* @param fadeintime Time it takes the message to fully appear (fade-in)
* @param fadeouttime Time it takes the message to fully disappear (fade-out)
* @param channel Channel to use on the client
*
* @noreturn
*/
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 = -1);
/**
* Displays a message on the client HUD.
*
* @note Use set_hudmessage to define how the message should look on screen.
* @note This functions return value behaves differently depending on what is
* used as the client index: If 0 is specified, then the function will
* return 0 if nothing has been sent (no client connected). If either a
* single client is specified, or there is at least one client connected,
* the number of printed characters will refer to the message that is sent
* last, to the client with the highest index.
*
* @param index Client index, use 0 to display to all clients
* @param message Formatting rules
* @param ... Variable number of formatting parameters
*
* @return Number of printed characters
* @error If a single client is specified and the index is not within
* the range of 1 to MaxClients, an error will be thrown.
*/
native show_hudmessage(index, const message[], any:...);
/**
* Sets display parameters for director hudmessages.
*
* @note For the hudmessage coordinates x and y, -1.0 will center the message
* on the respective axis.
* @note These parameters stay until the next call to set_dhudmessage overwrites
* them. Multiple calls to show_dhudmessage will therefore re-use the same
* parameters. The parameters are not stored per-plugin, so other plugins
* can overwrite them.
*
* @param red Red component of hudmessage color
* @param green Green component of hudmessage color
* @param blue Blue component of hudmessage color
* @param x Location of the message on the x axis in percent
* @param y Location of the message on the y axis in percent
* @param effects Display effect
* @param fxtime Duration of the effect
* @param holdtime Time the message stays on screen
* @param fadeintime Time it takes the message to fully appear (fade-in)
* @param fadeouttime Time it takes the message to fully disappear (fade-out)
*
* @noreturn
*/
native set_dhudmessage(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);
/**
* Displays a director message on the client HUD.
*
* @note Use set_dhudmessage to define how the message should look on screen.
* @note Unlike the classic HUD message, which is channel-based, director
* messages are stack-based. You can have up to 8 messages displaying at
* once. If more are added, they will be overwritten in the order they were
* sent. There is no way to clear a specific message.
* @note The message has a maximum length of 128 characters which this function
* will automatically enforce.
* @note This functions return value behaves differently depending on what is
* used as the client index: If 0 is specified, then the function will
* return 0 if nothing has been sent (no client connected). If either a
* single client is specified, or there is at least one client connected,
* the number of printed characters will refer to the message that is sent
* last, to the client with the highest index.
*
* @param index Client index, use 0 to display to all clients
* @param message Formatting rules
* @param ... Variable number of formatting parameters
*
* @return Number of printed characters
* @error If a single client is specified and the index is not within
* the range of 1 to MaxClients, an error will be thrown.
*/
native show_dhudmessage(index, const message[], any:...);
/**
* Displays a menu to the client.
*
* @note Keys is a bitflag value that represents which keys the user can press
* on the menu. If you want to display disabled menu options, or skip
* certain number slots, you should exclude that key from the bitflag.
* amxconst.inc provides MENU_KEY_* constants for convenience.
* @note The title parameter is not displayed to the client and is only used for
* identifying menus internally and assigning them to their callbacks.
* The title corresponds to the menu name that you register with
* register_menuid()
*
* @param index Client to display menu to, use 0 to display to all clients
* @param keys Enabled keys
* @param menu Menu body
* @param time Menu timeout in seconds, -1 to disable
* @param title Name of the menu for internal tracking purposes
*
* @return 1 on success, 0 if menu could not be displayed (client not
* connected)
* @error If a single client is specified and the index is not within
* the range of 1 to MaxClients, an error will be thrown.
*/
native show_menu(index, keys, const menu[], time = -1, const title[] = "");
/**
* Retrieves values from a client message.
*
* @note For use within callbacks registered with register_event()
* @note Usage examples:
* value = read_data(1);
* read_data(2, floatvalue);
* written = read_data(3, buffer, buffersize);
*
* @param value Argument number to retrieve value from
* @param ... Changes the native's behavior depending on how many
* additional parameters are provided:
* 0 - Return the argument integer value directly
* 1 - Store the argument float value in the variable passed
* as the second parameter
* 2 - Copy the argument string value to the buffer provided
* in the second parameter, using the third as the
* maximum buffer size
*
* @return Changes depending on how many additional parameters are
* provided:
* 0 - Returns the argument integer value
* 1 - Returns the argument float value, converted
* (truncated) to an integer
* 2 - Returns the number of cells written to the buffer
*/
native read_data(value, any:...);
/**
* Returns the number of values in the client message.
*
* @note For use within callbacks registered with register_event()
*
* @return Number of values in client message
*/
native read_datanum();
/**
* Returns the message id of the client message.
*
* @note For use within callbacks registered with register_event()
*
* @return Message id of the client message
*/
native read_datatype();
/**
* Retrieves current log message.
*
* @note Should only be used inside of the plugin_log() forward.
*
* @param output Buffer to copy log message to
* @param len Maximum buffer size
*
* @return Number of cells written to buffer
*/
native read_logdata(output[], len);
/**
* Returns number of log message arguments.
*
* @note Should only be used inside of the plugin_log() forward.
*
* @return Number of arguments in the log message
*/
native read_logargc();
/**
* Retrieves argument of log message.
*
* @note Should only be used inside of the plugin_log() forward.
*
* @param id Argument index, starting from 0
* @param output Buffer to copy log argument to
* @param len Maximum buffer size
*
* @return Number of cells written to buffer
*/
native read_logargv(id, output[], len);
/**
* Parse log data about client.
*
* @note When client actions are logged, they appear in the the format
* "Name<#userid><SteamID><teamname>", this native extracts the individual
* pieces of information.
*
* @param text String to process
* @param name Buffer to copy client name to
* @param nlen Maximum name buffer size
* @param userid Variable to store userid in
* @param authid Buffer to copy client authid to
* @param alen Maximum auth buffer size
* @param team Buffer to copy client team to
* @param tlen Maximum team buffer size
*
* @noreturn
* @error If the provided string is not valid client log data, an
* error will be thrown.
*/
native parse_loguser(const text[], name[], nlen, &userid =-2, authid[] = "", alen = 0, team[] = "", tlen = 0);
/**
* Sends a message to the console of the server.
*
* @param message Formatting rules
* @param ... Variable number of formatting parameters
*
* @return Number of printed characters
*/
native server_print(const message[], any:...);
/**
* Returns if the given mapname is deemed valid by the engine.
*
* @param mapname Name of the map
*
* @return 1 if the map name is valid, 0 otherwise
*/
native is_map_valid(const mapname[]);
/**
* Returns if the client is a bot.
*
* @param index Client index
*
* @return 1 if client is a bot, 0 otherwise
*/
native is_user_bot(index);
/**
* Returns if the client is a HLTV proxy.
*
* @param index Client index
*
* @return 1 if client is a HLTV proxy, 0 otherwise
*/
native is_user_hltv(index);
/**
* Returns if the client is connected.
*
* @note This does not throw an error if the provided index is out of the
* 1 to MaxClients range. That means you can safely use this native
* without manually verifying that the index is a valid client index.
*
* @param index Client index
*
* @return 1 if client is connected, 0 otherwise
*/
native is_user_connected(index);
/**
* Returns if the client is connecting.
*
* @param index Client index
*
* @return 1 if client is connecting, 0 otherwise
*/
native is_user_connecting(index);
/**
* Returns if the client is alive.
*
* @note This will never return true if a client is not connected. If you need
* to know whether a client is alive, an additional call to
* is_user_connected() is unnecessary.
*
* @param index Client index
*
* @return 1 if client is alive, 0 otherwise
*/
native is_user_alive(index);
/**
* Returns if the server is a dedicated server.
*
* @return 1 if server is a dedicated server, 0 otherwise
*/
native is_dedicated_server();
/**
* Returns if the server is running on Linux.
*
* @return 1 if server is running on Linux, 0 otherwise
*/
native is_linux_server();
/**
* Returns if the AMXX installation has the JIT enabled.
*
* @return 1 if JIT is enabled, 0 otherwise
*/
native is_jit_enabled();
/**
* Retrieves the version string of the AMXX installation.
*
* @param buffer Buffer to copy version to
* @param length Maximum buffer size
*
* @return Number of cells written to the buffer
*/
native get_amxx_verstring(buffer[], length);
/**
* Returns the last known attacker of a client.
*
* @note As of AMXX 1.75 this can return a non-client entity index if the client
* was attacked by a non-client entity.
*
* @param index Client index
* @param ... If provided, the attacker weapon will be stored in an
* optional second parameter, and the body hit place will be
* stored in an optional third parameter
*
* @return Attacker client index, a non-client entity or 0 if no
* attacker was found
* @error If the client index is not within the range of 1 to
* MaxClients, an error will be thrown.
*/
native get_user_attacker(index, ...);
/**
* Traces the client's current aim vector to see if it hits something.
*
* @note If the trace does not hit a client, id and body will be set to 0.
* @note If the trace hits nothing within the specified distance, 0 is returned.
*
* @param index Client index to trace aim from
* @param id Variable to store hit client index (if applicable)
* @param body Variable to store hit client body part (if applicable)
* @param dist Maximum distance of the trace
*
* @return Distance between the trace start and end point
* @error If the client index is not within the range of 1 to
* MaxClients, an error will be thrown.
*/
native Float:get_user_aiming(index, &id, &body, dist = 9999);
/**
* Returns the client's frags.
*
* @note While this is mod-independent, the mod may track frag count differently,
* so it can only be retrieved using another native or other methods.
* @note This will actually return the client's overall score, which may or may
* not be equal to their scored frags depending on the mod.
*
* @param index Client index
*
* @return Frags/Score of the client. Also returns 0 if the client is
* not connected or the index is not within the range of
* 1 to MaxClients
*/
native get_user_frags(index);
/**
* Returns the client's armor value.
*
* @note While this is mod-independent, the mod may track armor data differently,
* so it can only be retrieved using another native or other methods.
*