Parent Directory | Revision Log
Revision 1 - (view) (download)
1 : | ian | 1 | #include <amxmodx> |
2 : | |||
3 : | public plugin_init() | ||
4 : | { | ||
5 : | register_plugin("callfunc test", "1.0", "BAILOPAN") | ||
6 : | |||
7 : | register_srvcmd("test_callfunc", "Command_Callfunc") | ||
8 : | } | ||
9 : | |||
10 : | public OnCallfuncReceived(num, str[], &val, array[], array2[], size, hello2[1]) | ||
11 : | { | ||
12 : | server_print("num = %d (expected: %d)", num, 5) | ||
13 : | server_print("str[] = ^"%s^" (expected: %s)", str, "Gaben") | ||
14 : | |||
15 : | server_print("val = %d (expected %d, setting to %d)", val, 62, 15) | ||
16 : | val = 15 | ||
17 : | server_print("printing %d elements of array[] (expected: %d)", size, 6) | ||
18 : | for (new i=0; i<size; i++) | ||
19 : | { | ||
20 : | server_print("array[%d] = %d (expected: %d)", i, array[i], i) | ||
21 : | } | ||
22 : | for (new i=0; i<size; i++) | ||
23 : | { | ||
24 : | server_print("array2[%d] = %d (expected: %d)", i, array[i], i) | ||
25 : | } | ||
26 : | array[0] = 5 | ||
27 : | array2[1] = 6 | ||
28 : | hello2[0] = 25 | ||
29 : | } | ||
30 : | |||
31 : | public Command_Callfunc() | ||
32 : | { | ||
33 : | new a = 62 | ||
34 : | new hello[] = {0,1,2,3,4,5} | ||
35 : | new hello2[] = {9} | ||
36 : | new pm = 6 | ||
37 : | new err | ||
38 : | |||
39 : | if ((err=callfunc_begin("OnCallfuncReceived")) < 1) | ||
40 : | { | ||
41 : | server_print("Failed to call callfunc_begin()! Error: %d", err) | ||
42 : | |||
43 : | return PLUGIN_HANDLED | ||
44 : | } | ||
45 : | callfunc_push_int(5) | ||
46 : | callfunc_push_str("Gaben") | ||
47 : | callfunc_push_intrf(a) | ||
48 : | callfunc_push_array(hello, pm) | ||
49 : | callfunc_push_array(hello, pm) | ||
50 : | callfunc_push_int(pm) | ||
51 : | callfunc_push_array(hello2, 1, false) | ||
52 : | callfunc_end() | ||
53 : | |||
54 : | server_print("a = %d (expected: %d)", a, 15) | ||
55 : | server_print("hello[0] = %d (expected: %d)", hello[0], 5) | ||
56 : | server_print("hello[1] = %d (expected: %d)", hello[1], 6) | ||
57 : | server_print("hello2[0] = %d (expected: %d)", hello2[0], 9) | ||
58 : | |||
59 : | return PLUGIN_HANDLED | ||
60 : | } |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |