-
Notifications
You must be signed in to change notification settings - Fork 0
/
sampgdk.h
6933 lines (5499 loc) · 217 KB
/
sampgdk.h
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
/* Copyright (C) 2011-2018 Zeex
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SAMPGDK_BOOL_H
#define SAMPGDK_BOOL_H
/* bool */
#if !defined __cplusplus && !defined HAVE_BOOL
/* If HAVE_BOOL is not defined we attempt to detect stdbool.h first,
* then define our own "bool" type.
*/
#if defined __STDC__ && defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L\
|| defined HAVE_STDBOOL_H
/* Have a C99-conformant compiler. */
#include <stdbool.h>
#else
typedef unsigned char bool;
#define true 1
#define false 0
#define __bool_true_false_are_defined
#endif
#else
/* Make sure their "bool" is one byte in size. This is required for binary
* compatibility with C++ code. */
typedef int sizeof_bool_must_be_1[sizeof(bool) == 1 ? 1 : -1];
#endif
#endif /* !SAMPGDK_BOOL_H */
#ifndef SAMPGDK_PLATFORM_H
#define SAMPGDK_PLATFORM_H
#if !defined _M_IX86 && !defined __i386__ && !defined RC_INVOKED
#error Unsupported architecture
#endif
#if (defined __CYGWIN32__ || defined RC_INVOKED) && !defined WIN32
#define WIN32
#endif
#if defined WIN32 || defined _WIN32 || defined __WIN32__
#define SAMPGDK_LINUX 0
#define SAMPGDK_WINDOWS 1
#endif
#if defined __linux__ || defined __linux || defined linux
#if !defined LINUX
#define LINUX
#endif
#define SAMPGDK_LINUX 1
#define SAMPGDK_WINDOWS 0
#endif
#if defined __GNUC__
#define SAMPGDK_DEPRECATED_API(type, rest) \
SAMPGDK_API(type, rest) __attribute__((deprecated))
#elif defined _MSC_VER
#define SAMPGDK_DEPRECATED_API(return_type, rest) \
__declspec(deprecated) SAMPGDK_API(return_type, rest)
#else
#define SAMPGDK_DEPRECATED_API(return_type, rest)
#endif
#if SAMPGDK_WINDOWS
#define SAMPGDK_CDECL __cdecl
#define SAMPGDK_STDCALL __stdcall
#elif SAMPGDK_LINUX
#define SAMPGDK_CDECL __attribute__((cdecl))
#define SAMPGDK_STDCALL __attribute__((stdcall))
#endif
#if SAMPGDK_LINUX && defined IN_SAMPGDK && !defined _GNU_SOURCE
#define _GNU_SOURCE
#endif
#endif /* !SAMPGDK_PLATFORM_H */
#ifndef SAMPGDK_SDK_H
#define SAMPGDK_SDK_H
/* #include <sampgdk/bool.h> */
/* #include <sampgdk/platform.h> */
/* stdint.h */
#if !defined HAVE_STDINT_H
#if (!defined __STDC__ && __STDC_VERSION__ >= 199901L /* C99 or newer */)\
|| (defined _MSC_VER && _MSC_VER >= 1600 /* Visual Studio 2010 and later */)\
|| defined __GNUC__ /* GCC, MinGW, etc */
#define HAVE_STDINT_H 1
#endif
#endif
/* size_t */
#include <stddef.h>
/* alloca() */
#if SAMPGDK_WINDOWS
#undef HAVE_ALLOCA_H
#include <malloc.h> /* for _alloca() */
#if !defined alloca
#define alloca _alloca
#endif
#elif SAMPGDK_LINUX
#if defined __GNUC__
#define HAVE_ALLOCA_H 1
#if !defined alloca
#define alloca __builtin_alloca
#endif
#endif
#endif
#if defined __INTEL_COMPILER
/* ... */
#elif defined __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wignored-attributes"
#elif defined __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes"
#endif
#include "amx/amx.h"
#include "plugincommon.h"
#if defined __INTEL_COMPILER
/* ... */
#elif defined __clang_
#pragma clang diagnostic pop
#elif defined __GNUC__
#pragma GCC diagnostic pop
#endif
/**
* \addtogroup sdk
* @{
*/
/**
* \brief Gets called before Load() to check for compatibility
*
* The Supports() function indicates what possibilities this
* plugin has. The SUPPORTS_VERSION flag is required to check
* for compatibility with the server.
*
* \returns combination of SUPPORTS_* flags
*/
PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports();
/**
* \brief Gets called when the plugin is loaded
*
* The Load() function gets passed on exported functions from
* the SA-MP Server, like the AMX Functions and logprintf().
* Should return true if loading the plugin has succeeded.
*
* \param ppData plugin data
*
* \returns \c true if the plugin has successfully loaded and
* \c false otherwise
*/
PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData);
/**
* \brief Gets called when the plugin is unloaded
*
* The Unload() function is called when the server shuts down,
* meaning this plugin gets shut down with it.
*/
PLUGIN_EXPORT void PLUGIN_CALL Unload();
/**
* \brief Gets called when a new script is loaded
*
* The AmxLoad() function gets called when a new gamemode or
* filterscript gets loaded with the server. In here we register
* the native functions we like to add to the scripts.
*
* \param amx pointer to the script's AMX object
*
* \returns one of AMX error codes
*/
PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx);
/**
* \brief Gets called when a script is unloaded
*
* When a gamemode is over or a filterscript gets unloaded, this
* function gets called. No special actions needed in here.
*
* \param amx pointer to the script's AMX object
*
* \returns one of AMX error codes
*/
PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx);
/**
* \brief Gets called on every server tick
*
* Each tick corresponds to one iteration of the server's internal
* event loop. The interval between ticks depends on many factors,
* but it's possible to set the minimum tick rate via server.cfg
* (default is 5ms).
*/
PLUGIN_EXPORT void PLUGIN_CALL ProcessTick();
/** @} */
#endif /* !SAMPGDK_SDK_H */
#ifndef SAMPGDK_EXPORT_H
#define SAMPGDK_EXPORT_H
/* #include <sampgdk/platform.h> */
/* #include <sampgdk/sdk.h> */
#undef SAMPGDK_EXPORT
#undef SAMPGDK_CALL
#ifdef __cplusplus
#define SAMPGDK_EXTERN_C extern "C"
#else
#define SAMPGDK_EXTERN_C
#endif
#if defined SAMPGDK_STATIC || defined SAMPGDK_AMALGAMATION
#define SAMPGDK_EMBEDDED
#endif
#ifdef SAMPGDK_EMBEDDED
#define SAMPGDK_CALL
#else
#define SAMPGDK_CALL SAMPGDK_CDECL
#endif
#ifdef SAMPGDK_EMBEDDED
#define SAMPGDK_EXPORT SAMPGDK_EXTERN_C
#else
#if SAMPGDK_LINUX
#if defined IN_SAMPGDK
#define SAMPGDK_EXPORT SAMPGDK_EXTERN_C __attribute__((visibility("default")))
#else
#define SAMPGDK_EXPORT SAMPGDK_EXTERN_C
#endif
#elif SAMPGDK_WINDOWS
#if defined IN_SAMPGDK
#define SAMPGDK_EXPORT SAMPGDK_EXTERN_C __declspec(dllexport)
#else
#define SAMPGDK_EXPORT SAMPGDK_EXTERN_C __declspec(dllimport)
#endif
#else
#error Unsupported operating system
#endif
#endif
#define SAMPGDK_API(return_type, rest) \
SAMPGDK_EXPORT return_type SAMPGDK_CALL rest
#undef SAMPGDK_NATIVE_EXPORT
#undef SAMPGDK_NATIVE_CALL
#define SAMPGDK_NATIVE_EXPORT SAMPGDK_EXPORT
#define SAMPGDK_NATIVE_CALL SAMPGDK_CALL
#define SAMPGDK_NATIVE(return_type, rest) \
SAMPGDK_NATIVE_EXPORT return_type SAMPGDK_NATIVE_CALL sampgdk_ ## rest
#undef SAMPGDK_CALLBACK_EXPORT
#undef SAMPGDK_CALLBACK_CALL
#define SAMPGDK_CALLBACK_EXPORT PLUGIN_EXPORT
#define SAMPGDK_CALLBACK_CALL PLUGIN_CALL
#define SAMPGDK_CALLBACK(return_type, rest) \
SAMPGDK_CALLBACK_EXPORT return_type SAMPGDK_CALLBACK_CALL rest
#endif /* !SAMPGDK_EXPORT_H */
#ifndef SAMPGDK_INTEROP_H
#define SAMPGDK_INTEROP_H
#include <stdarg.h>
/* #include <sampgdk/bool.h> */
/* #include <sampgdk/export.h> */
/**
* \addtogroup interop
* @{
*/
/**
* \brief Returns all currently registered native functions
*
* This function can be used to get the names and addresses of all native
* functions that have been registered with amx_Register(), by both the
* server and plugins.
*
* \note The returned array is NULL-terminated.
*
* \param number where to store the number of natives (optional).
*
* \returns pointer to array of registered native functions
*
* \see sampgdk_FindNative()
* \see sampgdk_CallNative()
* \see sampgdk_InvokeNative()
*/
SAMPGDK_API(const AMX_NATIVE_INFO *, sampgdk_GetNatives(int *number));
/**
* \brief Finds a native function by name
*
* Searches for a native function with the specified name and returns its
* address. In order to be found the function must be registered with
* amx_Register() prior to the call.
*
* \param name name of the native function
*
* \returns function's address or \c NULL if not found
*
* \see sampgdk_GetNatives()
* \see sampgdk_CallNative()
* \see sampgdk_InvokeNative()
*/
SAMPGDK_API(AMX_NATIVE, sampgdk_FindNative(const char *name));
/**
* \brief Calls a native function
*
* This function is suitable for calling simple natives that either have only
* value parameters or don't have any parameters at all. If you have to pass
* a reference or a string use sampgdk_InvokeNative() instead.
*
* \note The first element of \p params must contain the number of arguments
* multiplied by \c sizeof(cell).
*
* \param native pointer to the native function
* \param params parameters to be passed to the function as its second argument
*
* \returns function's return value
*
* \see sampgdk_GetNatives()
* \see sampgdk_FindNative()
* \see sampgdk_InvokeNative()
*/
SAMPGDK_API(cell, sampgdk_CallNative(AMX_NATIVE native, cell *params));
/**
* \brief Calls a native function with arguments
*
* Argument types are specified via \p format where each character, or
* *specifier*, corresponds to a single argument. The following format
* specifiers are supported:
*
* Specifier | C/C++ type | Description
* :-------- | :------------ | :------------------------------------------
* i | int | integer value
* d | int | integer value (same as 'i')
* b | bool | boolean value
* f | double | floating-point value
* r | const cell * | const reference (input only)
* R | cell * | non-const reference (both input and output)
* s | const char * | const string (input only)
* S | char * | non-const string (both input and output)
* a | const cell * | const array (input only)
* A | cell * | non-const array (both input and output)
*
* \remarks For the 'S', 'a' and 'A' specifiers you have to specify the size
* of the string/array in square brackets, e.g. "a[100]" (fixed size)
* or s[*2] (size passed via 2nd argument).
*
* \note In Pawn variadic functions always take their variable arguments
* (those represented by "...") by reference. This means that for such
* functions you have to use the 'r' specifier where you would normally
* use 'b', 'i' 'd' or 'f'.
*
* \param native pointer to the native function.
* \param format argument types
* \param ... arguments themselves
*
* \returns function's return value
*
* \see sampgdk_GetNatives()
* \see sampgdk_FindNative()
* \see sampgdk_InvokeNativeV()
* \see sampgdk_InvokeNativeArray()
*/
SAMPGDK_API(cell, sampgdk_InvokeNative(AMX_NATIVE native,
const char *format, ...));
/**
* \brief Calls a native function with arguments
*
* This function is identical to sampgdk_InvokeNative() except it takes
* \c va_list instead of variable arguments.
*
* \see sampgdk_GetNatives()
* \see sampgdk_FindNative()
* \see sampgdk_InvokeNative()
* \see sampgdk_InvokeNativeArray()
*/
SAMPGDK_API(cell, sampgdk_InvokeNativeV(AMX_NATIVE native,
const char *format, va_list args));
/**
* \brief Calls a native function with an array of arguments
*
* This function is similar to sampgdk_InvokeNative() but the arguments
* are passed as an array where each element is a pointer pointing to
* the actual value.
*
* Argument types are specified via \p format where each character, or
* *specifier*, corresponds to a single argument. See sampgdk_InvokeNative()
* for the list of supported format specifiers.
*
* \param native pointer to the native function.
* \param format argument types
* \param args arguments themselves
*
* \returns function's return value
*
* \see sampgdk_GetNatives()
* \see sampgdk_FindNative()
* \see sampgdk_InvokeNative()
*/
SAMPGDK_API(cell, sampgdk_InvokeNativeArray(AMX_NATIVE native,
const char *format, void **args));
/**
* \brief A generic catch-all callback that gets called whenever some
* AMX public function is executed
*
* This is the publics "filter" callback. It is called whenever the
* server calls \c amx_Exec(), which practically means that you can
* use it to hook *any* callback, even those that are called by other
* plugins.
*
* \param amx AMX on which the function is called
* \param name function name
* \param params function arguments as stored on the AMX stack, with
* \c params[0] being set to the number of arguments multiplied
* by \c sizeof(cell)
* \param retval where to store the return value (can be \c NULL)
*
* \returns \c true if the public is allowed to execute
*/
SAMPGDK_CALLBACK(bool, OnPublicCall(AMX *amx, const char *name,
cell *params, cell *retval));
/**
* \brief A generic catch-all callback that gets called whenever some
* AMX public function is executed
*
* This callback is similar to \c OnPublicCall but also allows you to
* stop the call from being propagated to other plugins or the gamemode
* by setting the \c stop parameter to \c true.
*
* \param amx AMX on which the function is called
* \param name function name
* \param params function arguments as stored on the AMX stack, with
* \c params[0] being set to the number of arguments multiplied
* by \c sizeof(cell)
* \param retval where to store the return value (can be \c NULL)
* \param stop whether to stop public call propagation (\c false by default)
*
* \returns \c true if the public is allowed to execute
*/
SAMPGDK_CALLBACK(bool, OnPublicCall2(AMX *amx, const char *name,
cell *params, cell *retval, bool *stop));
/** @} */
#ifdef __cplusplus
namespace sampgdk {
/**
* \addtogroup interop
* @{
*/
/// \brief C++ wrapper around sampgdk_GetNatives()
inline const AMX_NATIVE_INFO *GetNatives(int &number) {
return sampgdk_GetNatives(&number);
}
/// \brief C++ wrapper around sampgdk_GetNatives()
inline const AMX_NATIVE_INFO *GetNatives() {
return sampgdk_GetNatives(0);
}
/// \brief C++ wrapper around sampgdk_FindNative()
inline AMX_NATIVE FindNative(const char *name) {
return sampgdk_FindNative(name);
}
/// \brief C++ wrapper around sampgdk_CallNative()
inline cell CallNative(AMX_NATIVE native, cell *params) {
return sampgdk_CallNative(native, params);
}
/// \brief C++ wrapper around sampgdk_InvokeNative()
inline cell InvokeNative(AMX_NATIVE native, const char *format, ...) {
va_list args;
va_start(args, format);
cell retval = sampgdk_InvokeNativeV(native, format, args);
va_end(args);
return retval;
}
/// \brief C++ wrapper around sampgdk_InvokeNativeV()
inline cell InvokeNativeV(AMX_NATIVE native, const char *format,
va_list args) {
return sampgdk_InvokeNativeV(native, format, args);
}
/// \brief C++ wrapper around sampgdk_InvokeNativeArray()
inline cell InvokeNativeArray(AMX_NATIVE native, const char *format,
void **args) {
return sampgdk_InvokeNativeArray(native, format, args);
}
/** @} */
} // namespace sampgdk
#endif /* __cplusplus */
#endif /* !SAMPGDK_INTEROP_H */
#ifndef SAMPGDK_VERSION_H
#define SAMPGDK_VERSION_H
/* #include <sampgdk/export.h> */
/**
* \addtogroup version
* @{
*/
/**
* \brief Major version
*/
#define SAMPGDK_VERSION_MAJOR 4
/**
* \brief Minor version
*/
#define SAMPGDK_VERSION_MINOR 6
/**
* \brief Patch version
*/
#define SAMPGDK_VERSION_PATCH 1
/**
* \brief Library version number in the form of \c 0xAABBCC00 where
* \c AA, \c BB and \c CC are the major, minor and patch numbers
*/
#define SAMPGDK_VERSION_ID 67502336
/**
* \brief Library version string in the form of \c x.y.z where \c x,
* \c y and \c z are the major, minor and patch numbers
*/
#define SAMPGDK_VERSION_STRING "4.6.1"
/**
* \brief Gets library version number
*
* \returns version number
*
* \see SAMPGDK_VERSION_ID
* \see sampgdk_GetVersionString()
*/
SAMPGDK_API(int, sampgdk_GetVersion(void));
/**
* \brief Gets library version string
*
* \returns version string
*
* \see SAMPGDK_VERSION_STRING
* \see sampgdk_GetVersion()
*/
SAMPGDK_API(const char *, sampgdk_GetVersionString(void));
#ifdef __cplusplus
namespace sampgdk {
/// \brief C++ wrapper around sampgdk_GetVersion()
inline int GetVersion() {
return sampgdk_GetVersion();
}
/// \brief C++ wrapper around sampgdk_GetVersionString()
inline const char *GetVersionString() {
return sampgdk_GetVersionString();
}
} // namespace sampgdk
#endif /* __cplusplus */
/** @} */
#endif /* !SAMPGDK_VERSION_H */
#ifndef SAMPGDK_TYPES_H
#define SAMPGDK_TYPES_H
/* #include <sampgdk/export.h> */
/**
* \brief Defines the signature of a timer callback function
* \ingroup natives
*
* \param timerid timer ID as returned by SetTimer()
* \param param user-supplied data as passed to SetTimer()
*/
typedef void (SAMPGDK_CALL *TimerCallback)(int timerid, void *param);
#endif /* !SAMPGDK_TYPES_H */
#ifndef SAMPGDK_CORE_H
#define SAMPGDK_CORE_H
#include <stdarg.h>
/* #include <sampgdk/bool.h> */
/* #include <sampgdk/export.h> */
/* #include <sampgdk/sdk.h> */
/**
* \defgroup core Core
* \defgroup interop Interop
* \defgroup version Version
* \defgroup sdk SA-MP SDK
* \defgroup natives SA-MP Natives
* \defgroup callbacks SA-MP Callbacks
*/
/**
* \addtogroup core
* @{
*/
/**
* \brief Hidden parameter type, do not use this
*/
typedef int sampgdk_hidden_t;
/**
* \brief Returns supported SDK version
*
* This function always returns SUPPORTS_VERSION. Its sole purpose is to
* make sure that the version of the SDK is compatible with the one that
* was used for building the library.
*
* \code
* PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() {
* return sampgdk_Supports() | SUPPORTS_PROCESS_TICK;
* }
* \endcode
*
* \returns SUPPORTS_VERSION
*/
SAMPGDK_API(unsigned int, sampgdk_Supports(void));
/**
* \brief Initializes the library
*
* Allocates memory for internal data structures and sets everything
* up. Also keeps track of currently loaded plugins and registers the
* calling plugin for callback handling.
*
* This function should be called from Load().
*
* \param ppData pointer to plugin data as passed to Load()
*
* \returns \c true on success and \c false otherwise
*
* \see sampgdk_Unload()
*/
SAMPGDK_API(bool, sampgdk_Load(void **ppData, sampgdk_hidden_t));
/**
* \brief Shuts everything down, opposite of sampgdk_Load()
*
* This function should be called from Unload().
*
* \see sampgdk_Load()
*/
SAMPGDK_API(void, sampgdk_Unload(sampgdk_hidden_t));
/**
* \brief Processes timers created by the calling plugin
*
* Goes through the list of created timers and, if necessary, fires
* them one by one in the order of increasing IDs.
*
* If timer precision is important it's better to call this function
* on every server tick. The plugin's ProcessTick() function might be
* a good place for that.
*/
SAMPGDK_API(void, sampgdk_ProcessTick(sampgdk_hidden_t));
/**
* \brief Prints a message to the server log
*
* \note The resulting message cannot be longer than 1024 characters.
*
* \param format printf-style format string
* \param ... further arguments to logprintf()
*
* \see sampgdk_vlogprintf()
*/
SAMPGDK_API(void, sampgdk_logprintf(const char *format, ...));
/**
* \brief Prints a message to the server log
*
* This function is identica to sampgdk_logprintf() except it takes
* a \c va_list instead of variable arguments.
*
* \param format printf-style format string
* \param args further arguments to logprintf()
*
* \see sampgdk_logprintf()
*/
SAMPGDK_API(void, sampgdk_vlogprintf(const char *format, va_list args));
/** @} */
#define sampgdk_Load(ppData) sampgdk_Load(ppData, 0)
#define sampgdk_Unload() sampgdk_Unload(0)
#define sampgdk_ProcessTick() sampgdk_ProcessTick(0)
#ifdef __cplusplus
/**
* \brief Main namespace
*/
namespace sampgdk {
/**
* \addtogroup core
* @{
*/
/// \brief C++ wrapper around sampgdk_Supports()
inline unsigned int Supports() {
return sampgdk_Supports();
}
/// \brief C++ wrapper around sampgdk_Load()
inline bool Load(void **ppData) {
return sampgdk_Load(ppData);
}
/// \brief C++ wrapper around sampgdk_Unload()
inline void Unload() {
sampgdk_Unload();
}
/// \brief C++ wrapper around sampgdk_ProcessTick()
inline void ProcessTick() {
sampgdk_ProcessTick();
}
/// \brief C++ wrapper around sampgdk_logprintf()
inline void logprintf(const char *format, ...) {
va_list args;
va_start(args, format);
sampgdk_vlogprintf(format, args);
va_end(args);
}
/// \brief C++ wrapper around sampgdk_vlogprintf()
inline void vlogprintf(const char *format, va_list args) {
sampgdk_vlogprintf(format, args);
}
/** @} */
} // namespace sampgdk
#endif /* __cplusplus */
#endif /* !SAMPGDK_CORE_H */
#ifndef SAMPGDK_A_ACTOR_H
#define SAMPGDK_A_ACTOR_H
/* #include <sampgdk/bool.h> */
/* #include <sampgdk/export.h> */
/* #include <sampgdk/types.h> */
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/CreateActor">CreateActor on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(int, CreateActor(int modelid, float x, float y, float z, float rotation));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/DestroyActor">DestroyActor on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(bool, DestroyActor(int actorid));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/IsActorStreamedIn">IsActorStreamedIn on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(bool, IsActorStreamedIn(int actorid, int forplayerid));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/SetActorVirtualWorld">SetActorVirtualWorld on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(bool, SetActorVirtualWorld(int actorid, int vworld));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/GetActorVirtualWorld">GetActorVirtualWorld on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(int, GetActorVirtualWorld(int actorid));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/ApplyActorAnimation">ApplyActorAnimation on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(bool, ApplyActorAnimation(int actorid, const char * animlib, const char * animname, float fDelta, bool loop, bool lockx, bool locky, bool freeze, int time));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/ClearActorAnimations">ClearActorAnimations on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(bool, ClearActorAnimations(int actorid));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/SetActorPos">SetActorPos on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(bool, SetActorPos(int actorid, float x, float y, float z));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/GetActorPos">GetActorPos on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(bool, GetActorPos(int actorid, float * x, float * y, float * z));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/SetActorFacingAngle">SetActorFacingAngle on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(bool, SetActorFacingAngle(int actorid, float angle));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/GetActorFacingAngle">GetActorFacingAngle on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(bool, GetActorFacingAngle(int actorid, float * angle));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/SetActorHealth">SetActorHealth on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(bool, SetActorHealth(int actorid, float health));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/GetActorHealth">GetActorHealth on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(bool, GetActorHealth(int actorid, float * health));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/SetActorInvulnerable">SetActorInvulnerable on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(bool, SetActorInvulnerable(int actorid, bool invulnerable));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/IsActorInvulnerable">IsActorInvulnerable on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(bool, IsActorInvulnerable(int actorid));
/**
* \ingroup natives
* \see <a href="http://wiki.sa-mp.com/wiki/IsValidActor">IsValidActor on SA-MP Wiki</a>
*/
SAMPGDK_NATIVE(bool, IsValidActor(int actorid));
#ifndef DOXYGEN
#if defined SAMPGDK_CPP_WRAPPERS && !defined IN_SAMPGDK
namespace sampgdk {
inline int CreateActor(int modelid, float x, float y, float z, float rotation) {
return sampgdk_CreateActor(modelid, x, y, z, rotation);
}
inline bool DestroyActor(int actorid) {
return sampgdk_DestroyActor(actorid);
}
inline bool IsActorStreamedIn(int actorid, int forplayerid) {
return sampgdk_IsActorStreamedIn(actorid, forplayerid);
}
inline bool SetActorVirtualWorld(int actorid, int vworld) {
return sampgdk_SetActorVirtualWorld(actorid, vworld);
}
inline int GetActorVirtualWorld(int actorid) {
return sampgdk_GetActorVirtualWorld(actorid);
}
inline bool ApplyActorAnimation(int actorid, const char * animlib, const char * animname, float fDelta, bool loop, bool lockx, bool locky, bool freeze, int time) {
return sampgdk_ApplyActorAnimation(actorid, animlib, animname, fDelta, loop, lockx, locky, freeze, time);
}
inline bool ClearActorAnimations(int actorid) {
return sampgdk_ClearActorAnimations(actorid);
}
inline bool SetActorPos(int actorid, float x, float y, float z) {
return sampgdk_SetActorPos(actorid, x, y, z);
}
inline bool GetActorPos(int actorid, float * x, float * y, float * z) {
return sampgdk_GetActorPos(actorid, x, y, z);
}
inline bool SetActorFacingAngle(int actorid, float angle) {
return sampgdk_SetActorFacingAngle(actorid, angle);
}
inline bool GetActorFacingAngle(int actorid, float * angle) {
return sampgdk_GetActorFacingAngle(actorid, angle);
}
inline bool SetActorHealth(int actorid, float health) {
return sampgdk_SetActorHealth(actorid, health);
}
inline bool GetActorHealth(int actorid, float * health) {
return sampgdk_GetActorHealth(actorid, health);
}
inline bool SetActorInvulnerable(int actorid, bool invulnerable = true) {
return sampgdk_SetActorInvulnerable(actorid, invulnerable);
}
inline bool IsActorInvulnerable(int actorid) {
return sampgdk_IsActorInvulnerable(actorid);
}
inline bool IsValidActor(int actorid) {
return sampgdk_IsValidActor(actorid);
}
} // namespace sampgdk
#else /* SAMPGDK_CPP_WRAPPERS && !IN_SAMPGDK */
#undef CreateActor
#define CreateActor sampgdk_CreateActor
#undef DestroyActor
#define DestroyActor sampgdk_DestroyActor
#undef IsActorStreamedIn
#define IsActorStreamedIn sampgdk_IsActorStreamedIn
#undef SetActorVirtualWorld
#define SetActorVirtualWorld sampgdk_SetActorVirtualWorld
#undef GetActorVirtualWorld
#define GetActorVirtualWorld sampgdk_GetActorVirtualWorld
#undef ApplyActorAnimation
#define ApplyActorAnimation sampgdk_ApplyActorAnimation
#undef ClearActorAnimations
#define ClearActorAnimations sampgdk_ClearActorAnimations