├── .gitattributes
├── scripting
├── spcomp.exe
├── compile.bat
└── include
│ ├── version_auto.inc
│ ├── adt.inc
│ ├── sdktools_client.inc
│ ├── version.inc
│ ├── sdktools_entinput.inc
│ ├── sdktools_stocks.inc
│ ├── sdktools_engine.inc
│ ├── testing.inc
│ ├── sdktools_variant_t.inc
│ ├── nextmap.inc
│ ├── geoip.inc
│ ├── basecomm.inc
│ ├── commandline.inc
│ ├── handles.inc
│ ├── profiler.inc
│ ├── sdktools_hooks.inc
│ ├── sdktools_entoutput.inc
│ ├── sdktools_voice.inc
│ ├── lang.inc
│ ├── adminmenu.inc
│ ├── logging.inc
│ ├── mapchooser.inc
│ ├── vector.inc
│ ├── sorting.inc
│ ├── commandfilters.inc
│ ├── banning.inc
│ ├── sdktools_stringtables.inc
│ ├── sdktools_gamerules.inc
│ ├── sdktools_tempents.inc
│ ├── datapack.inc
│ ├── helpers.inc
│ ├── chat-processor.inc
│ ├── timers.inc
│ ├── sdktools.inc
│ ├── adt_stack.inc
│ ├── usermessages.inc
│ ├── textparse.inc
│ └── core.inc
├── .vscode
├── settings.json
├── desktop.ini
└── tasks.json
├── plugins
└── chat-processor.smx
├── README.md
└── configs
└── chat_processor.cfg
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/scripting/spcomp.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Drixevel-Archive/Chat-Processor/HEAD/scripting/spcomp.exe
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "sourcepawnLanguageServer.sourcemod_home": "e:/SourcePawn/sm-multitool/scripting/include"
3 | }
--------------------------------------------------------------------------------
/plugins/chat-processor.smx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Drixevel-Archive/Chat-Processor/HEAD/plugins/chat-processor.smx
--------------------------------------------------------------------------------
/scripting/compile.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | IF EXIST "compile.dat" ( del /A compile.dat )
3 | spcomp %~n1.sp -o../plugins/%~n1.smx
4 | PAUSE
--------------------------------------------------------------------------------
/.vscode/desktop.ini:
--------------------------------------------------------------------------------
1 | [.ShellClassInfo]
2 | InfoTip=This folder is shared online.
3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe
4 | IconIndex=16
5 |
--------------------------------------------------------------------------------
/scripting/include/version_auto.inc:
--------------------------------------------------------------------------------
1 |
2 | #if defined _auto_version_included
3 | #endinput
4 | #endif
5 | #define _auto_version_included
6 |
7 | #define SOURCEMOD_V_TAG ""
8 | #define SOURCEMOD_V_CSET "14227c04"
9 | #define SOURCEMOD_V_MAJOR 1
10 | #define SOURCEMOD_V_MINOR 10
11 | #define SOURCEMOD_V_RELEASE 0
12 | #define SOURCEMOD_V_REV 6425
13 |
14 | #define SOURCEMOD_VERSION "1.10.0.6425"
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Chat-Processor
2 |
3 | A Sourcemod plugin which allows other plugins to add and manage chat related features.
4 |
5 | ## Installation
6 |
7 | Place the .smx into the plugins folder and the .cfg into the configs folder.
8 |
9 | ## Usage
10 |
11 | ```C#
12 | public Action CP_OnChatMessage(int& author, ArrayList recipients, char[] flagstring, char[] name, char[] message, bool& processcolors, bool& removecolors)
13 | {
14 | Format(name, MAXLENGTH_NAME, "{red}%s", name);
15 | Format(message, MAXLENGTH_MESSAGE, "{blue}%s", message);
16 | return Plugin_Changed;
17 | }
18 | ```
19 |
20 | ## Contributing
21 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
22 |
23 | Please make sure to update tests as appropriate.
24 |
25 | ## License
26 | [GPL-3.0](https://github.com/Drixevel/Chat-Processor/blob/master/LICENSE.txt)
27 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | // See https://go.microsoft.com/fwlink/?LinkId=733558
3 | // for the documentation about the tasks.json format
4 | "version": "2.0.0",
5 | "tasks": [
6 | {
7 | "label": "Compile plugin",
8 | "type": "shell",
9 |
10 | "presentation": {
11 | "panel": "new"
12 | },
13 |
14 | "windows":{
15 | "command": "${workspaceFolder}\\scripting\\spcomp.exe",
16 | },
17 |
18 | "args": [
19 | "${file}",
20 | "-E",
21 | "-O2",
22 | "-v2",
23 | "-i${workspaceFolder}\\scripting",
24 | "-i${workspaceFolder}\\include",
25 | "-o${workspaceFolder}\\plugins\\${fileBasenameNoExtension}.smx"
26 | ],
27 |
28 | "group": {
29 | "kind": "build",
30 | "isDefault": true
31 | }
32 | }
33 | ]
34 | }
--------------------------------------------------------------------------------
/scripting/include/adt.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _adt_included
34 | #endinput
35 | #endif
36 | #define _adt_included
37 |
38 | #include
39 | #include
40 | #include
41 |
--------------------------------------------------------------------------------
/scripting/include/sdktools_client.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _sdktools_client_included
34 | #endinput
35 | #endif
36 | #define _sdktools_client_included
37 |
38 | /**
39 | * Sets the client to an inactive state waiting for a new map
40 | *
41 | * @param client The client index
42 | */
43 | native void InactivateClient(int client);
44 |
45 | /**
46 | * Reconnect a client without dropping the netchannel
47 | *
48 | * @param client The client index
49 | */
50 | native void ReconnectClient(int client);
51 |
--------------------------------------------------------------------------------
/scripting/include/version.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _version_included
34 | #endinput
35 | #endif
36 | #define _version_included
37 |
38 | #tryinclude
39 |
40 | #if !defined _auto_version_included
41 | #define SOURCEMOD_V_TAG "manual"
42 | #define SOURCEMOD_V_REV 0
43 | #define SOURCEMOD_V_CSET "0"
44 | #define SOURCEMOD_V_MAJOR 1 /**< SourceMod Major version */
45 | #define SOURCEMOD_V_MINOR 10 /**< SourceMod Minor version */
46 | #define SOURCEMOD_V_RELEASE 0 /**< SourceMod Release version */
47 |
48 | #define SOURCEMOD_VERSION "1.10.0-manual" /**< SourceMod version string (major.minor.release-tag) */
49 | #endif
50 |
--------------------------------------------------------------------------------
/scripting/include/sdktools_entinput.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2017 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _sdktools_entinput_included
34 | #endinput
35 | #endif
36 | #define _sdktools_entinput_included
37 |
38 | /**
39 | * Invokes a named input method on an entity.
40 | *
41 | * After completion (successful or not), the current global variant is re-initialized.
42 | *
43 | * @param dest Destination entity index.
44 | * @param input Input action.
45 | * @param activator Entity index which initiated the sequence of actions (-1 for a NULL entity).
46 | * @param caller Entity index from which this event is sent (-1 for a NULL entity).
47 | * @param outputid Unknown.
48 | * @return True if successful otherwise false.
49 | * @error Invalid entity index or no mod support.
50 | */
51 | native bool AcceptEntityInput(int dest, const char[] input, int activator=-1, int caller=-1, int outputid=0);
52 |
--------------------------------------------------------------------------------
/scripting/include/sdktools_stocks.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _sdktools_stocks_included
34 | #endinput
35 | #endif
36 | #define _sdktools_stocks_included
37 |
38 | /**
39 | * Given a partial team name, attempts to find a matching team.
40 | *
41 | * The search is performed case insensitively and only against the
42 | * first N characters of the team names, where N is the number of
43 | * characters in the search pattern.
44 | *
45 | * @param name Partial or full team name.
46 | * @return A valid team index on success.
47 | * -1 if no team matched.
48 | * -2 if more than one team matched.
49 | */
50 | stock int FindTeamByName(const char[] name)
51 | {
52 | int name_len = strlen(name);
53 | int num_teams = GetTeamCount();
54 | char team_name[32];
55 | int found_team = -1;
56 |
57 | for (int i = 0; i < num_teams; i++)
58 | {
59 | GetTeamName(i, team_name, sizeof(team_name));
60 |
61 | if (strncmp(team_name, name, name_len, false) == 0)
62 | {
63 | if (found_team >= 0)
64 | {
65 | return -2;
66 | }
67 | else
68 | {
69 | found_team = i;
70 | }
71 | }
72 | }
73 |
74 | return found_team;
75 | }
76 |
--------------------------------------------------------------------------------
/scripting/include/sdktools_engine.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _sdktools_engine_included
34 | #endinput
35 | #endif
36 | #define _sdktools_engine_included
37 |
38 | #define MAX_LIGHTSTYLES 64
39 |
40 | /**
41 | * Sets a client's "viewing entity."
42 | *
43 | * @param client Client index.
44 | * @param entity Entity index.
45 | * @error Invalid client or entity, lack of mod support, or client not in
46 | * game.
47 | */
48 | native void SetClientViewEntity(int client, int entity);
49 |
50 | /**
51 | * Sets a light style.
52 | *
53 | * @param style Light style (from 0 to MAX_LIGHTSTYLES-1)
54 | * @param value Light value string (see world.cpp/light.cpp in dlls)
55 | * @error Light style index is out of range.
56 | */
57 | native void SetLightStyle(int style, const char[] value);
58 |
59 | /**
60 | * Returns the client's eye position.
61 | *
62 | * @param client Player's index.
63 | * @param pos Destination vector to store the client's eye position.
64 | * @error Invalid client index, client not in game, or no mod support.
65 | */
66 | native void GetClientEyePosition(int client, float pos[3]);
67 |
--------------------------------------------------------------------------------
/scripting/include/testing.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 sw=4 tw=99 noet :
3 | * =============================================================================
4 | * SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | static int TestNumber = 0;
34 | static char TestContext[255];
35 |
36 | stock void SetTestContext(const char[] context)
37 | {
38 | strcopy(TestContext, sizeof(TestContext), context);
39 | }
40 |
41 | stock void AssertEq(const char[] text, int cell1, int cell2)
42 | {
43 | TestNumber++;
44 | if (cell1 == cell2)
45 | {
46 | PrintToServer("[%d] %s: %s == %d OK", TestNumber, TestContext, text, cell2);
47 | }
48 | else
49 | {
50 | PrintToServer("[%d] %s FAIL: %s should be %d, got %d", TestNumber, TestContext, text, cell2, cell1);
51 | ThrowError("test %d (%s in %s) failed", TestNumber, text, TestContext);
52 | }
53 | }
54 |
55 | stock void AssertFalse(const char[] text, bool value)
56 | {
57 | TestNumber++;
58 | if (!value)
59 | {
60 | PrintToServer("[%d] %s: %s == false OK", TestNumber, TestContext, text, value);
61 | }
62 | else
63 | {
64 | PrintToServer("[%d] %s FAIL: %s should be false, got true", TestNumber, TestContext, text);
65 | ThrowError("test %d (%s in %s) failed", TestNumber, text, TestContext);
66 | }
67 | }
68 |
69 | stock void AssertTrue(const char[] text, bool value)
70 | {
71 | TestNumber++;
72 | if (value)
73 | {
74 | PrintToServer("[%d] %s: %s == true OK", TestNumber, TestContext, text, value);
75 | }
76 | else
77 | {
78 | PrintToServer("[%d] %s FAIL: %s should be true, got false", TestNumber, TestContext, text);
79 | ThrowError("test %d (%s in %s) failed", TestNumber, text, TestContext);
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/scripting/include/sdktools_variant_t.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2017 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _sdktools_variant_t_included
34 | #endinput
35 | #endif
36 | #define _sdktools_variant_t_included
37 |
38 | /**
39 | * Sets a bool value in the global variant object.
40 | *
41 | * @param val Input value.
42 | */
43 | native void SetVariantBool(bool val);
44 |
45 | /**
46 | * Sets a string in the global variant object.
47 | *
48 | * @param str Input string.
49 | */
50 | native void SetVariantString(const char[] str);
51 |
52 | /**
53 | * Sets an integer value in the global variant object.
54 | *
55 | * @param val Input value.
56 | */
57 | native void SetVariantInt(int val);
58 |
59 | /**
60 | * Sets a floating point value in the global variant object.
61 | *
62 | * @param val Input value.
63 | */
64 | native void SetVariantFloat(float val);
65 |
66 | /**
67 | * Sets a 3D vector in the global variant object.
68 | *
69 | * @param vec Input vector.
70 | */
71 | native void SetVariantVector3D(const float vec[3]);
72 |
73 | /**
74 | * Sets a 3D position vector in the global variant object.
75 | *
76 | * @param vec Input position vector.
77 | */
78 | native void SetVariantPosVector3D(const float vec[3]);
79 |
80 | /**
81 | * Sets a color in the global variant object.
82 | *
83 | * @param color Input color.
84 | */
85 | native void SetVariantColor(const int color[4]);
86 |
87 | /**
88 | * Sets an entity in the global variant object.
89 | *
90 | * @param entity Entity index.
91 | * @error Invalid entity index.
92 | */
93 | native void SetVariantEntity(int entity);
94 |
--------------------------------------------------------------------------------
/scripting/include/nextmap.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _nextmap_included_
34 | #endinput
35 | #endif
36 | #define _nextmap_included_
37 |
38 | /**
39 | * Sets SourceMod's internal nextmap.
40 | * Equivalent to changing sm_nextmap but with an added validity check.
41 | *
42 | * @param map Next map to set.
43 | * @return True if the nextmap was set, false if map was invalid.
44 | */
45 | native bool SetNextMap(const char[] map);
46 |
47 | /**
48 | * Returns SourceMod's internal nextmap.
49 | *
50 | * @param map Buffer to store the nextmap name.
51 | * @param maxlen Maximum length of the map buffer.
52 | * @return True if a Map was found and copied, false if no nextmap is set (map will be unchanged).
53 | */
54 | native bool GetNextMap(char[] map, int maxlen);
55 |
56 | /**
57 | * Changes the current map and records the reason for the change with maphistory
58 | *
59 | * @param map Map to change to.
60 | * @param reason Reason for change.
61 | */
62 | native void ForceChangeLevel(const char[] map, const char[] reason);
63 |
64 | /**
65 | * Gets the current number of maps in the map history
66 | *
67 | * @return Number of maps.
68 | */
69 | native int GetMapHistorySize();
70 |
71 | /**
72 | * Retrieves a map from the map history list.
73 | *
74 | * @param item Item number. Must be 0 or greater and less than GetMapHistorySize().
75 | * @param map Buffer to store the map name.
76 | * @param mapLen Length of map buffer.
77 | * @param reason Buffer to store the change reason.
78 | * @param reasonLen Length of the reason buffer.
79 | * @param startTime Time the map started.
80 | * @error Invalid item number.
81 | */
82 | native void GetMapHistory(int item, char[] map, int mapLen, char[] reason, int reasonLen, int &startTime);
83 |
--------------------------------------------------------------------------------
/configs/chat_processor.cfg:
--------------------------------------------------------------------------------
1 | "chat-processor"
2 | {
3 | "csgo"
4 | {
5 | "Cstrike_Chat_CT_Loc" "(Counter-Terrorist) {1} : {2}"
6 | "Cstrike_Chat_CT" "(Counter-Terrorist) {1} : {2}"
7 | "Cstrike_Chat_T_Loc" "(Terrorist) {1} : {2}"
8 | "Cstrike_Chat_T" "(Terrorist) {1} : {2}"
9 | "Cstrike_Chat_CT_Dead" "*DEAD*(Counter-Terrorist) {1} : {2}"
10 | "Cstrike_Chat_T_Dead" "*DEAD*(Terrorist) {1} : {2}"
11 | "Cstrike_Chat_Spec" "(Spectator) {1} : {2}"
12 | "Cstrike_Chat_All" "{1} : {2}"
13 | "Cstrike_Chat_AllDead" "*DEAD* {1} : {2}"
14 | "Cstrike_Chat_AllSpec" "*SPEC* {1} : {2}"
15 | }
16 |
17 | "csco"
18 | {
19 | "Cstrike_Chat_CT_Loc" "(Counter-Terrorist) {1} : {2}"
20 | "Cstrike_Chat_CT" "(Counter-Terrorist) {1} : {2}"
21 | "Cstrike_Chat_T_Loc" "(Terrorist) {1} : {2}"
22 | "Cstrike_Chat_T" "(Terrorist) {1} : {2}"
23 | "Cstrike_Chat_CT_Dead" "*DEAD*(Counter-Terrorist) {1} : {2}"
24 | "Cstrike_Chat_T_Dead" "*DEAD*(Terrorist) {1} : {2}"
25 | "Cstrike_Chat_Spec" "(Spectator) {1} : {2}"
26 | "Cstrike_Chat_All" "{1} : {2}"
27 | "Cstrike_Chat_AllDead" "*DEAD* {1} : {2}"
28 | "Cstrike_Chat_AllSpec" "*SPEC* {1} : {2}"
29 | }
30 |
31 | "cstrike"
32 | {
33 | "Cstrike_Chat_CT_Loc" "(Counter-Terrorist) {1}{3} : {2}"
34 | "Cstrike_Chat_CT" "(Counter-Terrorist) {1}{3} : {2}"
35 | "Cstrike_Chat_T_Loc" "(Terrorist) {1}{3} : {2}"
36 | "Cstrike_Chat_T" "(Terrorist) {1}{3} : {2}"
37 | "Cstrike_Chat_CT_Dead" "*DEAD*(Counter-Terrorist) {1}{3} : {2}"
38 | "Cstrike_Chat_T_Dead" "*DEAD*(Terrorist) {1}{3} : {2}"
39 | "Cstrike_Chat_Spec" "(Spectator) {1}{3} : {2}"
40 | "Cstrike_Chat_All" "{1}{3} : {2}"
41 | "Cstrike_Chat_AllDead" "*DEAD* {1}{3} : {2}"
42 | "Cstrike_Chat_AllSpec" "*SPEC* {1}{3} : {2}"
43 | }
44 |
45 | "left4dead"
46 | {
47 | "L4D_Chat_Infected" "(Infected) {1} : {2}"
48 | "L4D_Chat_Survivor" "(Survivor) {1} : {2}"
49 | "L4D_Chat_Infected_Dead" "*DEAD*(Infected) {1} : {2}"
50 | "L4D_Chat_Survivor_Dead" "*DEAD*(Survivor) {1} : {2}"
51 | "L4D_Chat_Spec" "(Spectator) {1} : {2}"
52 | "L4D_Chat_All" "{1} : {2}"
53 | "L4D_Chat_AllDead" "*DEAD* {1} : {2}"
54 | "L4D_Chat_AllSpec" "*SPEC* {1} : {2}"
55 | }
56 |
57 | "left4dead2"
58 | {
59 | "L4D_Chat_Infected" "(Infected) {1} : {2}"
60 | "L4D_Chat_Survivor" "(Survivor) {1} : {2}"
61 | "L4D_Chat_Infected_Dead" "*DEAD*(Infected) {1} : {2}"
62 | "L4D_Chat_Survivor_Dead" "*DEAD*(Survivor) {1} : {2}"
63 | "L4D_Chat_Spec" "(Spectator) {1} : {2}"
64 | "L4D_Chat_All" "{1} : {2}"
65 | "L4D_Chat_AllDead" "*DEAD* {1} : {2}"
66 | "L4D_Chat_AllSpec" "*SPEC* {1} : {2}"
67 | }
68 |
69 | "tf"
70 | {
71 | "TF_Chat_Team_Loc" "(TEAM) {1} : {2}"
72 | "TF_Chat_Team" "(TEAM) {1} : {2}"
73 | "TF_Chat_Team_Dead" "*DEAD*(TEAM) {1} : {2}"
74 | "TF_Chat_Spec" "(Spectator) {1} : {2}"
75 | "TF_Chat_All" "{1} : {2}"
76 | "TF_Chat_AllDead" "*DEAD* {1} : {2}"
77 | "TF_Chat_AllSpec" "*SPEC* {1} : {2}"
78 | "TF_Chat_Coach" "(Coach) {1} : {2}"
79 | }
80 |
81 | "tf2classic"
82 | {
83 | "TF_Chat_Team_Loc" "(TEAM) {1} : {2}"
84 | "TF_Chat_Team" "(TEAM) {1} : {2}"
85 | "TF_Chat_Team_Dead" "*DEAD*(TEAM) {1} : {2}"
86 | "TF_Chat_Spec" "(Spectator) {1} : {2}"
87 | "TF_Chat_All" "{1} : {2}"
88 | "TF_Chat_AllDead" "*DEAD* {1} : {2}"
89 | "TF_Chat_AllSpec" "*SPEC* {1} : {2}"
90 | }
91 |
92 | "hl2mp"
93 | {
94 | "HL2MP_Chat_Team_Loc" "(TEAM) {1} : {2}"
95 | "HL2MP_Chat_Team" "(TEAM) {1} : {2}"
96 | "HL2MP_Chat_Team_Dead" "*DEAD*(TEAM) {1} : {2}"
97 | "HL2MP_Chat_Spec" "(Spectator) {1} : {2}"
98 | "HL2MP_Chat_All" "{1} : {2}"
99 | "HL2MP_Chat_AllDead" "*DEAD* {1} : {2}"
100 | "HL2MP_Chat_AllSpec" "*SPEC* {1} : {2}"
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/scripting/include/geoip.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _geoip_included
34 | #endinput
35 | #endif
36 | #define _geoip_included
37 |
38 | #include
39 |
40 | /**
41 | * @section IP addresses can contain ports, the ports will be stripped out.
42 | */
43 |
44 | /**
45 | * Gets the two character country code from an IP address. (US, CA, etc)
46 | *
47 | * @param ip Ip to determine the country code.
48 | * @param ccode Destination string buffer to store the code.
49 | * @return True on success, false if no country found.
50 | */
51 | native bool GeoipCode2(const char[] ip, char ccode[3]);
52 |
53 | /**
54 | * Gets the three character country code from an IP address. (USA, CAN, etc)
55 | *
56 | * @param ip Ip to determine the country code.
57 | * @param ccode Destination string buffer to store the code.
58 | * @return True on success, false if no country found.
59 | */
60 | native bool GeoipCode3(const char[] ip, char ccode[4]);
61 |
62 | /**
63 | * Gets the full country name. (max length of output string is 45)
64 | *
65 | * @param ip Ip to determine the country code.
66 | * @param name Destination string buffer to store the country name.
67 | * @param maxlength Maximum length of output string buffer.
68 | * @return True on success, false if no country found.
69 | */
70 | native bool GeoipCountry(const char[] ip, char[] name, int maxlength);
71 |
72 | /**
73 | * @endsection
74 | */
75 |
76 | /**
77 | * Do not edit below this line!
78 | */
79 | public Extension __ext_geoip =
80 | {
81 | name = "GeoIP",
82 | file = "geoip.ext",
83 | #if defined AUTOLOAD_EXTENSIONS
84 | autoload = 1,
85 | #else
86 | autoload = 0,
87 | #endif
88 | #if defined REQUIRE_EXTENSIONS
89 | required = 1,
90 | #else
91 | required = 0,
92 | #endif
93 | };
94 |
95 | #if !defined REQUIRE_EXTENSIONS
96 | public void __ext_geoip_SetNTVOptional()
97 | {
98 | MarkNativeAsOptional("GeoipCode2");
99 | MarkNativeAsOptional("GeoipCode3");
100 | MarkNativeAsOptional("GeoipCountry");
101 | }
102 | #endif
103 |
--------------------------------------------------------------------------------
/scripting/include/basecomm.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2011 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _basecomm_included
34 | #endinput
35 | #endif
36 | #define _basecomm_included
37 |
38 | /**
39 | * Called when a client is muted or unmuted
40 | *
41 | * @param client Client index
42 | * @param muteState True if client was muted, false otherwise
43 | */
44 | forward void BaseComm_OnClientMute(int client, bool muteState);
45 |
46 | /**
47 | * Called when a client is gagged or ungagged
48 | *
49 | * @param client Client index
50 | * @param gagState True if client was gaged, false otherwise
51 | */
52 | forward void BaseComm_OnClientGag(int client, bool gagState);
53 |
54 | /**
55 | * Returns whether or not a client is gagged
56 | *
57 | * @param client Client index.
58 | * @return True if client is gagged, false otherwise.
59 | */
60 | native bool BaseComm_IsClientGagged(int client);
61 |
62 | /**
63 | * Returns whether or not a client is muted
64 | *
65 | * @param client Client index.
66 | * @return True if client is muted, false otherwise.
67 | */
68 | native bool BaseComm_IsClientMuted(int client);
69 |
70 | /**
71 | * Sets a client's gag state
72 | *
73 | * @param client Client index.
74 | * @param gagState True to gag client, false to ungag.
75 | * @return True if this caused a change in gag state, false otherwise.
76 | */
77 | native bool BaseComm_SetClientGag(int client, bool gagState);
78 |
79 | /**
80 | * Sets a client's mute state
81 | *
82 | * @param client Client index.
83 | * @param muteState True to mute client, false to unmute.
84 | * @return True if this caused a change in mute state, false otherwise.
85 | */
86 | native bool BaseComm_SetClientMute(int client, bool muteState);
87 |
88 | /* DO NOT EDIT BELOW THIS LINE */
89 |
90 | public SharedPlugin __pl_basecomm =
91 | {
92 | name = "basecomm",
93 | file = "basecomm.smx",
94 | #if defined REQUIRE_PLUGIN
95 | required = 1,
96 | #else
97 | required = 0,
98 | #endif
99 | };
100 |
101 | #if !defined REQUIRE_PLUGIN
102 | public void __pl_basecomm_SetNTVOptional()
103 | {
104 | MarkNativeAsOptional("BaseComm_IsClientGagged");
105 | MarkNativeAsOptional("BaseComm_IsClientMuted");
106 | MarkNativeAsOptional("BaseComm_SetClientGag");
107 | MarkNativeAsOptional("BaseComm_SetClientMute");
108 | }
109 | #endif
110 |
--------------------------------------------------------------------------------
/scripting/include/commandline.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _commandline_included_
34 | #endinput
35 | #endif
36 | #define _commandline_included_
37 |
38 | /**
39 | * Gets the full command line the server was launched with.
40 | *
41 | * @param commandLine Buffer to store the command line in.
42 | * @param maxlen Maximum length of the command line buffer.
43 | * @return True if the command line is valid; otherwise, false.
44 | * @error No command line available, or no mod support.
45 | */
46 | native bool GetCommandLine(char[] commandLine, int maxlen);
47 |
48 | /**
49 | * Gets the value of a command line parameter the server was launched with.
50 | *
51 | * @param param The command line parameter to get the value of.
52 | * @param value Buffer to store the parameter value in.
53 | * @param maxlen Maximum length of the value buffer.
54 | * @param defValue The default value to return if the parameter wasn't specified.
55 | * @error No command line available, or no mod support.
56 | */
57 | native void GetCommandLineParam(const char[] param, char[] value, int maxlen, const char[] defValue="");
58 |
59 | /**
60 | * Gets the value of a command line parameter the server was launched with.
61 | *
62 | * @param param The command line parameter to get the value of.
63 | * @param defValue The default value to return if the parameter wasn't specified.
64 | * @return The integer value of the command line parameter value.
65 | * @error No command line available, or no mod support.
66 | */
67 | native int GetCommandLineParamInt(const char[] param, int defValue=0);
68 |
69 | /**
70 | * Gets the value of a command line parameter the server was launched with.
71 | *
72 | * @param param The command line parameter to get the value of.
73 | * @param defValue The default value to return if the parameter wasn't specified.
74 | * @return The floating point value of the command line parameter value.
75 | * @error No command line available, or no mod support.
76 | */
77 | native float GetCommandLineParamFloat(const char[] param, float defValue=0.0);
78 |
79 | /**
80 | * Determines if a specific command line parameter is present.
81 | *
82 | * @param param The command line parameter to test.
83 | * @return True if the command line parameter is specified; otherwise, false.
84 | * @error No command line available, or no mod support.
85 | */
86 | native bool FindCommandLineParam(const char[] param);
87 |
--------------------------------------------------------------------------------
/scripting/include/handles.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _handles_included
34 | #endinput
35 | #endif
36 | #define _handles_included
37 |
38 | /**
39 | * Preset Handle values.
40 | */
41 | enum Handle // Tag disables introducing "Handle" as a symbol.
42 | {
43 | INVALID_HANDLE = 0
44 | };
45 |
46 |
47 | /**
48 | * Closes a Handle. If the handle has multiple copies open,
49 | * it is not destroyed unless all copies are closed.
50 | *
51 | * @note Closing a Handle has a different meaning for each Handle type. Make
52 | * sure you read the documentation on whatever provided the Handle.
53 | *
54 | * @param hndl Handle to close.
55 | * @error Invalid handles will cause a run time error.
56 | */
57 | native void CloseHandle(Handle hndl);
58 |
59 | /**
60 | * Clones a Handle. When passing handles in between plugins, caching handles
61 | * can result in accidental invalidation when one plugin releases the Handle, or is its owner
62 | * is unloaded from memory. To prevent this, the Handle may be "cloned" with a new owner.
63 | *
64 | * @note Usually, you will be cloning Handles for other plugins. This means that if you clone
65 | * the Handle without specifying the new owner, it will assume the identity of your original
66 | * calling plugin, which is not very useful. You should either specify that the receiving
67 | * plugin should clone the handle on its own, or you should explicitly clone the Handle
68 | * using the receiving plugin's identity Handle.
69 | *
70 | * @param hndl Handle to clone/duplicate.
71 | * @param plugin Optional Handle to another plugin to mark as the new owner.
72 | * If no owner is passed, the owner becomes the calling plugin.
73 | * @return Handle on success, INVALID_HANDLE if not cloneable.
74 | * @error Invalid handles will cause a run time error.
75 | */
76 | native Handle CloneHandle(Handle hndl, Handle plugin=INVALID_HANDLE);
77 |
78 | using __intrinsics__.Handle;
79 |
80 | /**
81 | * Do not use this function. Returns if a Handle and its contents
82 | * are readable, whereas INVALID_HANDLE only checks for the absence
83 | * of a Handle.
84 | *
85 | * This function is intended only for tests where the validity of a
86 | * Handle can absolutely not be known.
87 | *
88 | * Do not use this to check the return values of functions, or to
89 | * check if timers should be closed (except in very rare cases).
90 | * This function is for very specific usage and using it for general
91 | * purpose routines can and will hide very subtle bugs.
92 | *
93 | * @param hndl Handle to test for validity.
94 | * @return True if handle is valid, false otherwise.
95 | * @deprecated Do not use this function.
96 | */
97 | #pragma deprecated Do not use this function.
98 | native bool IsValidHandle(Handle hndl);
99 |
--------------------------------------------------------------------------------
/scripting/include/profiler.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2018 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _profiler_included
34 | #endinput
35 | #endif
36 | #define _profiler_included
37 |
38 | /**
39 | * ONLY AVAILABLE ON WINDOWS RIGHT NOW K.
40 | */
41 |
42 | methodmap Profiler < Handle
43 | {
44 | // Creates a new profile object. The Handle must be freed
45 | // using delete or CloseHandle().
46 | //
47 | // @return A new Profiler Handle.
48 | public native Profiler();
49 |
50 | // Starts a cycle for profiling.
51 | public native void Start();
52 |
53 | // Stops a cycle for profiling.
54 | //
55 | // @error Profiler was never started.
56 | public native void Stop();
57 |
58 | // Returns the amount of high-precision time in seconds
59 | // that passed during the profiler's last start/stop
60 | // cycle.
61 | //
62 | // @return Time elapsed in seconds.
63 | property float Time {
64 | public native get();
65 | }
66 | };
67 |
68 | /**
69 | * Creates a new profile object. The Handle must be freed
70 | * using delete or CloseHandle().
71 | *
72 | * @return Handle to the profiler object.
73 | */
74 | native Profiler CreateProfiler();
75 |
76 | /**
77 | * Starts profiling.
78 | *
79 | * @param prof Profiling object.
80 | * @error Invalid Handle.
81 | */
82 | native void StartProfiling(Handle prof);
83 |
84 | /**
85 | * Stops profiling.
86 | *
87 | * @param prof Profiling object.
88 | * @error Invalid Handle or profiling was never started.
89 | */
90 | native void StopProfiling(Handle prof);
91 |
92 | /**
93 | * Returns the amount of high-precision time in seconds
94 | * that passed during the profiler's last start/stop
95 | * cycle.
96 | *
97 | * @param prof Profiling object.
98 | * @return Time elapsed in seconds.
99 | * @error Invalid Handle.
100 | */
101 | native float GetProfilerTime(Handle prof);
102 |
103 | /**
104 | * Mark the start of a profiling event.
105 | *
106 | * @param group Budget group. This can be "all" for a default, or a short
107 | * description like "Timers" or "Events".
108 | * @param name A name to attribute to this profiling event.
109 | */
110 | native void EnterProfilingEvent(const char[] group, const char[] name);
111 |
112 | /**
113 | * Mark the end of the last profiling event. This must be called in the same
114 | * stack frame as StartProfilingEvent(). Not doing so, or throwing errors,
115 | * will make the resulting profile very wrong.
116 | */
117 | native void LeaveProfilingEvent();
118 |
119 | /**
120 | * Returns true if the global profiler is enabled; false otherwise. It is
121 | * not necessary to call this before Enter/LeaveProfilingEvent.
122 | */
123 | native bool IsProfilingActive();
124 |
--------------------------------------------------------------------------------
/scripting/include/sdktools_hooks.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2009 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _sdktools_hooks_included
34 | #endinput
35 | #endif
36 | #define _sdktools_hooks_included
37 |
38 | #define FEATURECAP_PLAYERRUNCMD_11PARAMS "SDKTools PlayerRunCmd 11Params"
39 |
40 | /**
41 | * Called when a clients movement buttons are being processed
42 | *
43 | * @param client Index of the client.
44 | * @param buttons Copyback buffer containing the current commands (as bitflags - see entity_prop_stocks.inc).
45 | * @param impulse Copyback buffer containing the current impulse command.
46 | * @param vel Players desired velocity.
47 | * @param angles Players desired view angles.
48 | * @param weapon Entity index of the new weapon if player switches weapon, 0 otherwise.
49 | * @param subtype Weapon subtype when selected from a menu.
50 | * @param cmdnum Command number. Increments from the first command sent.
51 | * @param tickcount Tick count. A client's prediction based on the server's GetGameTickCount value.
52 | * @param seed Random seed. Used to determine weapon recoil, spread, and other predicted elements.
53 | * @param mouse Mouse direction (x, y).
54 | * @return Plugin_Handled to block the commands from being processed, Plugin_Continue otherwise.
55 | *
56 | * @note To see if all 11 params are available, use FeatureType_Capability and FEATURECAP_PLAYERRUNCMD_11PARAMS.
57 | */
58 | forward Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2]);
59 |
60 | /**
61 | * Called after a clients movement buttons were processed.
62 | *
63 | * @param client Index of the client.
64 | * @param buttons The current commands (as bitflags - see entity_prop_stocks.inc).
65 | * @param impulse The current impulse command.
66 | * @param vel Players desired velocity.
67 | * @param angles Players desired view angles.
68 | * @param weapon Entity index of the new weapon if player switches weapon, 0 otherwise.
69 | * @param subtype Weapon subtype when selected from a menu.
70 | * @param cmdnum Command number. Increments from the first command sent.
71 | * @param tickcount Tick count. A client's prediction based on the server's GetGameTickCount value.
72 | * @param seed Random seed. Used to determine weapon recoil, spread, and other predicted elements.
73 | * @param mouse Mouse direction (x, y).
74 | */
75 | forward void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float vel[3], const float angles[3], int weapon, int subtype, int cmdnum, int tickcount, int seed, const int mouse[2]);
76 |
77 | /**
78 | * Called when a client requests a file from the server.
79 | *
80 | * @param client Client index.
81 | * @param sFile Requested file path.
82 | *
83 | * @return Plugin_Handled to block the transfer, Plugin_Continue to let it proceed.
84 | */
85 | forward Action OnFileSend(int client, const char[] sFile);
86 |
87 | /**
88 | * Called when a client sends a file to the server.
89 | *
90 | * @param client Client index.
91 | * @param sFile Requested file path.
92 | *
93 | * @return Plugin_Handled to block the transfer, Plugin_Continue to let it proceed.
94 | */
95 | forward Action OnFileReceive(int client, const char[] sFile);
96 |
--------------------------------------------------------------------------------
/scripting/include/sdktools_entoutput.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2017 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _sdktools_entoutput_included
34 | #endinput
35 | #endif
36 | #define _sdktools_entoutput_included
37 |
38 | /**
39 | * Called when an entity output is fired.
40 | *
41 | * @param output Name of the output that fired.
42 | * @param caller Entity index of the caller.
43 | * @param activator Entity index of the activator.
44 | * @param delay Delay in seconds? before the event gets fired.
45 | * @return Anything other than Plugin_Continue will supress this event,
46 | * returning Plugin_Continue will allow it to propagate the results
47 | * of this output to any entity inputs.
48 | */
49 | typeset EntityOutput
50 | {
51 | function void (const char[] output, int caller, int activator, float delay);
52 | function Action (const char[] output, int caller, int activator, float delay);
53 | };
54 |
55 | /**
56 | * Add an entity output hook on a entity classname
57 | *
58 | * @param classname The classname to hook.
59 | * @param output The output name to hook.
60 | * @param callback An EntityOutput function pointer.
61 | * @error Entity Outputs disabled.
62 | */
63 | native void HookEntityOutput(const char[] classname, const char[] output, EntityOutput callback);
64 |
65 | /**
66 | * Remove an entity output hook.
67 | * @param classname The classname to hook.
68 | * @param output The output name to hook.
69 | * @param callback An EntityOutput function pointer.
70 | * @return True on success, false if no valid hook was found.
71 | * @error Entity Outputs disabled.
72 | */
73 | native bool UnhookEntityOutput(const char[] classname, const char[] output, EntityOutput callback);
74 |
75 | /**
76 | * Add an entity output hook on a single entity instance
77 | *
78 | * @param entity The entity on which to add a hook.
79 | * @param output The output name to hook.
80 | * @param callback An EntityOutput function pointer.
81 | * @param once Only fire this hook once and then remove itself.
82 | * @error Entity Outputs disabled or Invalid Entity index.
83 | */
84 | native void HookSingleEntityOutput(int entity, const char[] output, EntityOutput callback, bool once=false);
85 |
86 | /**
87 | * Remove a single entity output hook.
88 | *
89 | * @param entity The entity on which to remove the hook.
90 | * @param output The output name to hook.
91 | * @param callback An EntityOutput function pointer.
92 | * @return True on success, false if no valid hook was found.
93 | * @error Entity Outputs disabled or Invalid Entity index.
94 | */
95 | native bool UnhookSingleEntityOutput(int entity, const char[] output, EntityOutput callback);
96 |
97 | /**
98 | * Fire a named output on an entity.
99 | *
100 | * After completion (successful or not), the current global variant is re-initialized.
101 | *
102 | * @param caller Entity index from where the output is fired.
103 | * @param output Output name.
104 | * @param activator Entity index which initiated the sequence of actions (-1 for a NULL entity).
105 | * @param delay Delay before firing the output.
106 | * @error Invalid entity index or no mod support.
107 | */
108 | native void FireEntityOutput(int caller, const char[] output, int activator=-1, float delay=0.0);
109 |
--------------------------------------------------------------------------------
/scripting/include/sdktools_voice.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _sdktools_voice_included
34 | #endinput
35 | #endif
36 | #define _sdktools_voice_included
37 |
38 | /**
39 | * @section voice flags.
40 | */
41 | #define VOICE_NORMAL 0 /**< Allow the client to listen and speak normally. */
42 | #define VOICE_MUTED 1 /**< Mutes the client from speaking to everyone. */
43 | #define VOICE_SPEAKALL 2 /**< Allow the client to speak to everyone. */
44 | #define VOICE_LISTENALL 4 /**< Allow the client to listen to everyone. */
45 | #define VOICE_TEAM 8 /**< Allow the client to always speak to team, even when dead. */
46 | #define VOICE_LISTENTEAM 16 /**< Allow the client to always hear teammates, including dead ones. */
47 |
48 | /**
49 | * @endsection
50 | */
51 |
52 | enum ListenOverride
53 | {
54 | Listen_Default = 0, /**< Leave it up to the game */
55 | Listen_No, /**< Can't hear */
56 | Listen_Yes /**< Can hear */
57 | };
58 |
59 | /**
60 | * Set the client listening flags.
61 | *
62 | * @param client The client index
63 | * @param flags The voice flags
64 | */
65 | native void SetClientListeningFlags(int client, int flags);
66 |
67 | /**
68 | * Retrieve the client current listening flags.
69 | *
70 | * @param client The client index
71 | * @return The current voice flags
72 | */
73 | native int GetClientListeningFlags(int client);
74 |
75 | /**
76 | * Set the receiver ability to listen to the sender.
77 | *
78 | * @param iReceiver The listener index.
79 | * @param iSender The sender index.
80 | * @param bListen True if the receiver can listen to the sender, false otherwise.
81 | * @return True if successful otherwise false.
82 | * @deprecated Use SetListenOverride() instead.
83 | */
84 | #pragma deprecated Use SetListenOverride() instead
85 | native bool SetClientListening(int iReceiver, int iSender, bool bListen);
86 |
87 | /**
88 | * Retrieves if the receiver can listen to the sender.
89 | *
90 | * @param iReceiver The listener index.
91 | * @param iSender The sender index.
92 | * @return True if successful otherwise false.
93 | * @deprecated GetListenOverride() instead.
94 | */
95 | #pragma deprecated GetListenOverride() instead
96 | native bool GetClientListening(int iReceiver, int iSender);
97 |
98 | /**
99 | * Override the receiver's ability to listen to the sender.
100 | *
101 | * @param iReceiver The listener index.
102 | * @param iSender The sender index.
103 | * @param override The override of the receiver's ability to listen to the sender.
104 | * @return True if successful otherwise false.
105 | */
106 | native bool SetListenOverride(int iReceiver, int iSender, ListenOverride override);
107 |
108 | /**
109 | * Retrieves the override of the receiver's ability to listen to the sender.
110 | *
111 | * @param iReceiver The listener index.
112 | * @param iSender The sender index.
113 | * @return The override value.
114 | */
115 | native ListenOverride GetListenOverride(int iReceiver, int iSender);
116 |
117 | /**
118 | * Retrieves if the muter has muted the mutee.
119 | *
120 | * @param iMuter The muter index.
121 | * @param iMutee The mutee index.
122 | * @return True if muter has muted mutee, false otherwise.
123 | */
124 | native bool IsClientMuted(int iMuter, int iMutee);
125 |
--------------------------------------------------------------------------------
/scripting/include/lang.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _lang_included
34 | #endinput
35 | #endif
36 | #define _lang_included
37 |
38 | #define LANG_SERVER 0 /**< Translate using the server's language */
39 |
40 | /**
41 | * Loads a translation file for the plugin calling this native.
42 | * If no extension is specified, .txt is assumed.
43 | *
44 | * @param file Translation file.
45 | */
46 | native void LoadTranslations(const char[] file);
47 |
48 | /**
49 | * Sets the global language target. This is useful for creating functions
50 | * that will be compatible with the %t format specifier. Note that invalid
51 | * indexes can be specified but the error will occur during translation,
52 | * not during this function call.
53 | *
54 | * @param client Client index or LANG_SERVER.
55 | */
56 | native void SetGlobalTransTarget(int client);
57 |
58 | /**
59 | * Retrieves the language number of a client.
60 | *
61 | * @param client Client index.
62 | * @return Language number client is using.
63 | * @error Invalid client index or client not connected.
64 | */
65 | native int GetClientLanguage(int client);
66 |
67 | /**
68 | * Retrieves the server's language.
69 | *
70 | * @return Language number server is using.
71 | */
72 | native int GetServerLanguage();
73 |
74 | /**
75 | * Returns the number of languages known in languages.cfg.
76 | *
77 | * @return Language count.
78 | */
79 | native int GetLanguageCount();
80 |
81 | /**
82 | * Retrieves info about a given language number.
83 | *
84 | * @param language Language number.
85 | * @param code Language code buffer (2-3 characters usually).
86 | * @param codeLen Maximum length of the language code buffer.
87 | * @param name Language name buffer.
88 | * @param nameLen Maximum length of the language name buffer.
89 | * @error Invalid language number.
90 | */
91 | native void GetLanguageInfo(int language, char[] code="", int codeLen=0, char[] name="", int nameLen=0);
92 |
93 | /**
94 | * Sets the language number of a client.
95 | *
96 | * @param client Client index.
97 | * @param language Language number.
98 | * @error Invalid client index or client not connected.
99 | */
100 | native void SetClientLanguage(int client, int language);
101 |
102 | /**
103 | * Retrieves the language number from a language code.
104 | *
105 | * @param code Language code (2-3 characters usually).
106 | * @return Language number. -1 if not found.
107 | */
108 | native int GetLanguageByCode(const char[] code);
109 |
110 | /**
111 | * Retrieves the language number from a language name.
112 | *
113 | * @param name Language name (case insensitive).
114 | * @return Language number. -1 if not found.
115 | */
116 | native int GetLanguageByName(const char[] name);
117 |
118 | /**
119 | * Determines if the specified phrase exists within the plugin's
120 | * translation cache.
121 | *
122 | * @param phrase Phrase to look for.
123 | * @return True if phrase exists.
124 | */
125 | native bool TranslationPhraseExists(const char[] phrase);
126 |
127 | /**
128 | * Determines if there is a translation for the specified language.
129 | *
130 | * @param phrase Phrase to check.
131 | * @param language Language number.
132 | * @return True if translation exists.
133 | */
134 | native bool IsTranslatedForLanguage(const char[] phrase, int language);
135 |
--------------------------------------------------------------------------------
/scripting/include/adminmenu.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _adminmenu_included
34 | #endinput
35 | #endif
36 | #define _adminmenu_included
37 |
38 | /* Decide whether topmenus should be required */
39 | #if !defined REQUIRE_PLUGIN
40 | #if defined REQUIRE_EXTENSIONS
41 | #define TEMP_REQUIRE_EXTENSIONS
42 | #undef REQUIRE_EXTENSIONS
43 | #endif
44 | #endif
45 |
46 | #include
47 |
48 | /* Restore old REQUIRE_EXTENSIONS value if necessary */
49 | #if defined TEMP_REQUIRE_EXTENSIONS
50 | #define REQUIRE_EXTENSIONS
51 | #undef TEMP_REQUIRE_EXTENSIONS
52 | #endif
53 |
54 | /** Category for player commands. */
55 | #define ADMINMENU_PLAYERCOMMANDS "PlayerCommands"
56 | /** Category for server commands. */
57 | #define ADMINMENU_SERVERCOMMANDS "ServerCommands"
58 | /** Category for voting commands. */
59 | #define ADMINMENU_VOTINGCOMMANDS "VotingCommands"
60 |
61 | /**
62 | * Called when the admin menu is created and 3rd party plugins can grab
63 | * the Handle or add categories.
64 | *
65 | * @param topmenu Handle to the admin menu's TopMenu.
66 | */
67 | forward void OnAdminMenuCreated(Handle topmenu);
68 |
69 | /**
70 | * Called when the admin menu is ready to have items added.
71 | *
72 | * @param topmenu Handle to the admin menu's TopMenu.
73 | */
74 | forward void OnAdminMenuReady(Handle topmenu);
75 |
76 | /**
77 | * Retrieves the Handle to the admin top menu.
78 | *
79 | * @return Handle to the admin menu's TopMenu,
80 | * or INVALID_HANDLE if not created yet.
81 | */
82 | native TopMenu GetAdminTopMenu();
83 |
84 | /**
85 | * Adds targets to an admin menu.
86 | *
87 | * Each client is displayed as: name (userid)
88 | * Each item contains the userid as a string for its info.
89 | *
90 | * @param menu Menu Handle.
91 | * @param source_client Source client, or 0 to ignore immunity.
92 | * @param in_game_only True to only select in-game players.
93 | * @param alive_only True to only select alive players.
94 | * @return Number of clients added.
95 | */
96 | native int AddTargetsToMenu(Handle menu,
97 | int source_client,
98 | bool in_game_only=true,
99 | bool alive_only=false);
100 |
101 | /**
102 | * Adds targets to an admin menu.
103 | *
104 | * Each client is displayed as: name (userid)
105 | * Each item contains the userid as a string for its info.
106 | *
107 | * @param menu Menu Handle.
108 | * @param source_client Source client, or 0 to ignore immunity.
109 | * @param flags COMMAND_FILTER flags from commandfilters.inc.
110 | * @return Number of clients added.
111 | */
112 | native int AddTargetsToMenu2(Handle menu, int source_client, int flags);
113 |
114 | /**
115 | * Re-displays the admin menu to a client after selecting an item.
116 | * Auto-aborts if the Handle is invalid.
117 | *
118 | * @param topmenu TopMenu Handle.
119 | * @param client Client index.
120 | * @return True on success, false on failure.
121 | */
122 | stock bool RedisplayAdminMenu(Handle topmenu, int client)
123 | {
124 | if (topmenu == INVALID_HANDLE)
125 | {
126 | return false;
127 | }
128 |
129 | return DisplayTopMenu(topmenu, client, TopMenuPosition_LastCategory);
130 | }
131 |
132 | /* DO NOT EDIT BELOW THIS LINE */
133 |
134 | public SharedPlugin __pl_adminmenu =
135 | {
136 | name = "adminmenu",
137 | file = "adminmenu.smx",
138 | #if defined REQUIRE_PLUGIN
139 | required = 1,
140 | #else
141 | required = 0,
142 | #endif
143 | };
144 |
145 | #if !defined REQUIRE_PLUGIN
146 | public void __pl_adminmenu_SetNTVOptional()
147 | {
148 | MarkNativeAsOptional("GetAdminTopMenu");
149 | MarkNativeAsOptional("AddTargetsToMenu");
150 | MarkNativeAsOptional("AddTargetsToMenu2");
151 | }
152 | #endif
153 |
--------------------------------------------------------------------------------
/scripting/include/logging.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _sm_logging_included
34 | #endinput
35 | #endif
36 | #define _sm_logging_included
37 |
38 | /**
39 | * Logs a plugin message to the SourceMod logs. The log message will be
40 | * prefixed by the plugin's logtag (filename).
41 | *
42 | * @param format String format.
43 | * @param ... Format arguments.
44 | */
45 | native void LogMessage(const char[] format, any ...);
46 |
47 | /**
48 | * Logs a message to any file. The log message will be in the normal
49 | * SourceMod format, with the plugin logtag prepended.
50 | *
51 | * @param file File to write the log message in.
52 | * @param format String format.
53 | * @param ... Format arguments.
54 | * @error File could not be opened/written.
55 | */
56 | native void LogToFile(const char[] file, const char[] format, any ...);
57 |
58 | /**
59 | * Same as LogToFile(), except no plugin logtag is prepended.
60 | *
61 | * @param file File to write the log message in.
62 | * @param format String format.
63 | * @param ... Format arguments.
64 | * @error File could not be opened/written.
65 | */
66 | native void LogToFileEx(const char[] file, const char[] format, any ...);
67 |
68 | /**
69 | * Logs an action from a command or event whereby interception and routing may
70 | * be important. This is intended to be a logging version of ShowActivity().
71 | *
72 | * @param client Client performing the action, 0 for server, or -1 if not
73 | * applicable.
74 | * @param target Client being targetted, or -1 if not applicable.
75 | * @param message Message format.
76 | * @param ... Message formatting parameters.
77 | */
78 | native void LogAction(int client, int target, const char[] message, any ...);
79 |
80 | /**
81 | * Logs a plugin error message to the SourceMod logs.
82 | *
83 | * @param format String format.
84 | * @param ... Format arguments.
85 | */
86 | native void LogError(const char[] format, any ...);
87 |
88 | /**
89 | * Called when an action is going to be logged.
90 | *
91 | * @param source Handle to the object logging the action, or INVALID_HANDLE
92 | * if Core is logging the action.
93 | * @param ident Type of object logging the action (plugin, ext, or core).
94 | * @param client Client the action is from; 0 for server, -1 if not applicable.
95 | * @param target Client the action is targetting, or -1 if not applicable.
96 | * @param message Message that is being logged.
97 | * @return Plugin_Continue will perform the default logging behavior.
98 | * Plugin_Handled will stop Core from logging the message.
99 | * Plugin_Stop is the same as Handled, but prevents any other
100 | * plugins from handling the message.
101 | */
102 | forward Action OnLogAction(Handle source,
103 | Identity ident,
104 | int client,
105 | int target,
106 | const char[] message);
107 |
108 | /**
109 | * Called when a game log message is received.
110 | *
111 | * Any Log*() functions called within this callback will not recursively
112 | * pass through. That is, they will log directly, bypassing this callback.
113 | *
114 | * Note that this does not capture log messages from the engine. It only
115 | * captures log messages being sent from the game/mod itself.
116 | *
117 | * @param message Message contents.
118 | * @return Plugin_Handled or Plugin_Stop will prevent the message
119 | * from being written to the log file.
120 | */
121 | typedef GameLogHook = function Action (const char[] message);
122 |
123 | /**
124 | * Adds a game log hook.
125 | *
126 | * @param hook Hook function.
127 | */
128 | native void AddGameLogHook(GameLogHook hook);
129 |
130 | /**
131 | * Removes a game log hook.
132 | *
133 | * @param hook Hook function.
134 | */
135 | native void RemoveGameLogHook(GameLogHook hook);
136 |
--------------------------------------------------------------------------------
/scripting/include/mapchooser.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 | #if defined _mapchooser_included_
33 | #endinput
34 | #endif
35 | #define _mapchooser_included_
36 |
37 | enum NominateResult
38 | {
39 | Nominate_Added, /** The map was added to the nominate list */
40 | Nominate_Replaced, /** A clients existing nomination was replaced */
41 | Nominate_AlreadyInVote, /** Specified map was already in the vote */
42 | Nominate_InvalidMap, /** Mapname specified wasn't a valid map */
43 | Nominate_VoteFull /** This will only occur if force was set to false */
44 | };
45 |
46 | enum MapChange
47 | {
48 | MapChange_Instant, /** Change map as soon as the voting results have come in */
49 | MapChange_RoundEnd, /** Change map at the end of the round */
50 | MapChange_MapEnd /** Change the sm_nextmap cvar */
51 | };
52 |
53 | /**
54 | * Attempt to add a map to the mapchooser map list.
55 | *
56 | * @param map Map to add.
57 | * @param force Should we force the map in even if it requires overwriting an existing nomination?
58 | * @param owner Client index of the nominator. If the client disconnects the nomination will be removed.
59 | * Use 0 for constant nominations
60 | * @return Nominate Result of the outcome
61 | */
62 | native NominateResult NominateMap(const char[] map, bool force, int owner);
63 |
64 | /**
65 | * Attempt to remove a map from the mapchooser map list.
66 | *
67 | * @param map Map to remove.
68 | * @return True if the nomination was found and removed, or false if the nomination was not found.
69 | */
70 | native bool RemoveNominationByMap(const char[] map);
71 |
72 | /**
73 | * Attempt to remove a map from the mapchooser map list.
74 | *
75 | * @param owner Client index of the nominator.
76 | * @return True if the nomination was found and removed, or false if the nomination was not found.
77 | */
78 | native bool RemoveNominationByOwner(int owner);
79 |
80 | /**
81 | * Gets the current list of excluded maps.
82 | *
83 | * @param array An ADT array handle to add the map strings to.
84 | */
85 | native void GetExcludeMapList(ArrayList array);
86 |
87 | /**
88 | * Gets the current list of nominated maps.
89 | *
90 | * @param maparray An ADT array handle to add the map strings to.
91 | * @param ownerarray An optional ADT array handle to add the nominator client indexes to.
92 | */
93 | native void GetNominatedMapList(ArrayList maparray, ArrayList ownerarray = null);
94 |
95 | /**
96 | * Checks if MapChooser will allow a vote
97 | *
98 | * @return True if a vote can be held, or false if mapchooser is already holding a vote.
99 | */
100 | native bool CanMapChooserStartVote();
101 |
102 | /**
103 | * Initiates a MapChooser map vote
104 | *
105 | * Note: If no input array is specified mapchooser will use its internal list. This includes
106 | * any nominations and excluded maps (as per mapchoosers convars).
107 | *
108 | * @param when MapChange consant of when the resulting mapchange should occur.
109 | * @param inputarray ADT array list of maps to add to the vote.
110 | */
111 | native void InitiateMapChooserVote(MapChange when, ArrayList inputarray=null);
112 |
113 | /**
114 | * Checks if MapChooser's end of map vote has completed.
115 | *
116 | * @return True if complete, false otherwise.
117 | */
118 | native bool HasEndOfMapVoteFinished();
119 |
120 | /**
121 | * Checks if MapChooser is set to run an end of map vote.
122 | *
123 | * @return True if enabled, false otherwise.
124 | */
125 | native bool EndOfMapVoteEnabled();
126 |
127 | /**
128 | * Called when mapchooser removes a nomination from its list.
129 | * Nominations cleared on map start will not trigger this forward
130 | */
131 | forward void OnNominationRemoved(const char[] map, int owner);
132 |
133 | /**
134 | * Called when mapchooser starts a Map Vote.
135 | */
136 | forward void OnMapVoteStarted();
137 |
138 | public SharedPlugin __pl_mapchooser =
139 | {
140 | name = "mapchooser",
141 | file = "mapchooser.smx",
142 | #if defined REQUIRE_PLUGIN
143 | required = 1,
144 | #else
145 | required = 0,
146 | #endif
147 | };
148 |
149 | public void __pl_mapchooser_SetNTVOptional()
150 | {
151 | MarkNativeAsOptional("NominateMap");
152 | MarkNativeAsOptional("RemoveNominationByMap");
153 | MarkNativeAsOptional("RemoveNominationByOwner");
154 | MarkNativeAsOptional("GetExcludeMapList");
155 | MarkNativeAsOptional("GetNominatedMapList");
156 | MarkNativeAsOptional("CanMapChooserStartVote");
157 | MarkNativeAsOptional("InitiateMapChooserVote");
158 | MarkNativeAsOptional("HasEndOfMapVoteFinished");
159 | MarkNativeAsOptional("EndOfMapVoteEnabled");
160 | }
161 |
--------------------------------------------------------------------------------
/scripting/include/vector.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _vector_included
34 | #endinput
35 | #endif
36 | #define _vector_included
37 |
38 | /**
39 | * Calculates a vector's length.
40 | *
41 | * @param vec Vector.
42 | * @param squared If true, the result will be squared (for optimization).
43 | * @return Vector length (magnitude).
44 | */
45 | native float GetVectorLength(const float vec[3], bool squared=false);
46 |
47 | /**
48 | * Calculates the distance between two vectors.
49 | *
50 | * @param vec1 First vector.
51 | * @param vec2 Second vector.
52 | * @param squared If true, the result will be squared (for optimization).
53 | * @return Vector distance.
54 | */
55 | native float GetVectorDistance(const float vec1[3], const float vec2[3], bool squared=false);
56 |
57 | /**
58 | * Calculates the dot product of two vectors.
59 | *
60 | * @param vec1 First vector.
61 | * @param vec2 Second vector.
62 | * @return Dot product of the two vectors.
63 | */
64 | native float GetVectorDotProduct(const float vec1[3], const float vec2[3]);
65 |
66 | /**
67 | * Computes the cross product of two vectors. Any input array can be the same
68 | * as the output array.
69 | *
70 | * @param vec1 First vector.
71 | * @param vec2 Second vector.
72 | * @param result Resultant vector.
73 | */
74 | native void GetVectorCrossProduct(const float vec1[3], const float vec2[3], float result[3]);
75 |
76 | /**
77 | * Normalizes a vector. The input array can be the same as the output array.
78 | *
79 | * @param vec Vector.
80 | * @param result Resultant vector.
81 | * @return Vector length.
82 | */
83 | native float NormalizeVector(const float vec[3], float result[3]);
84 |
85 | /**
86 | * Returns vectors in the direction of an angle.
87 | *
88 | * @param angle Angle.
89 | * @param fwd Forward vector buffer or NULL_VECTOR.
90 | * @param right Right vector buffer or NULL_VECTOR.
91 | * @param up Up vector buffer or NULL_VECTOR.
92 | */
93 | native void GetAngleVectors(const float angle[3], float fwd[3], float right[3], float up[3]);
94 |
95 | /**
96 | * Returns angles from a vector.
97 | *
98 | * @param vec Vector.
99 | * @param angle Angle buffer.
100 | */
101 | native void GetVectorAngles(const float vec[3], float angle[3]);
102 |
103 | /**
104 | * Returns direction vectors from a vector.
105 | *
106 | * @param vec Vector.
107 | * @param right Right vector buffer or NULL_VECTOR.
108 | * @param up Up vector buffer or NULL_VECTOR.
109 | */
110 | native void GetVectorVectors(const float vec[3], float right[3], float up[3]);
111 |
112 | /**
113 | * Adds two vectors. It is safe to use either input buffer as an output
114 | * buffer.
115 | *
116 | * @param vec1 First vector.
117 | * @param vec2 Second vector.
118 | * @param result Result buffer.
119 | */
120 | stock void AddVectors(const float vec1[3], const float vec2[3], float result[3])
121 | {
122 | result[0] = vec1[0] + vec2[0];
123 | result[1] = vec1[1] + vec2[1];
124 | result[2] = vec1[2] + vec2[2];
125 | }
126 |
127 | /**
128 | * Subtracts a vector from another vector. It is safe to use either input
129 | * buffer as an output buffer.
130 | *
131 | * @param vec1 First vector.
132 | * @param vec2 Second vector to subtract from first.
133 | * @param result Result buffer.
134 | */
135 | stock void SubtractVectors(const float vec1[3], const float vec2[3], float result[3])
136 | {
137 | result[0] = vec1[0] - vec2[0];
138 | result[1] = vec1[1] - vec2[1];
139 | result[2] = vec1[2] - vec2[2];
140 | }
141 |
142 | /**
143 | * Scales a vector.
144 | *
145 | * @param vec Vector.
146 | * @param scale Scale value.
147 | */
148 | stock void ScaleVector(float vec[3], float scale)
149 | {
150 | vec[0] *= scale;
151 | vec[1] *= scale;
152 | vec[2] *= scale;
153 | }
154 |
155 | /**
156 | * Negatives a vector.
157 | *
158 | * @param vec Vector.
159 | */
160 | stock void NegateVector(float vec[3])
161 | {
162 | vec[0] = -vec[0];
163 | vec[1] = -vec[1];
164 | vec[2] = -vec[2];
165 | }
166 |
167 | /**
168 | * Builds a vector from two points by subtracting the points.
169 | *
170 | * @param pt1 First point (to be subtracted from the second).
171 | * @param pt2 Second point.
172 | * @param output Output vector buffer.
173 | */
174 | stock void MakeVectorFromPoints(const float pt1[3], const float pt2[3], float output[3])
175 | {
176 | output[0] = pt2[0] - pt1[0];
177 | output[1] = pt2[1] - pt1[1];
178 | output[2] = pt2[2] - pt1[2];
179 | }
180 |
--------------------------------------------------------------------------------
/scripting/include/sorting.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 |
34 | #if defined _sorting_included
35 | #endinput
36 | #endif
37 | #define _sorting_included
38 |
39 | /**
40 | * Contains sorting orders.
41 | */
42 | enum SortOrder
43 | {
44 | Sort_Ascending = 0, /**< Ascending order */
45 | Sort_Descending = 1, /**< Descending order */
46 | Sort_Random = 2 /**< Random order */
47 | };
48 |
49 | /**
50 | * Data types for ADT Array Sorts
51 | */
52 | enum SortType
53 | {
54 | Sort_Integer = 0,
55 | Sort_Float,
56 | Sort_String
57 | };
58 |
59 | /**
60 | * Sorts an array of integers.
61 | *
62 | * @param array Array of integers to sort in-place.
63 | * @param array_size Size of the array.
64 | * @param order Sorting order to use.
65 | */
66 | native void SortIntegers(int[] array, int array_size, SortOrder order = Sort_Ascending);
67 |
68 | /**
69 | * Sorts an array of float point numbers.
70 | *
71 | * @param array Array of floating point numbers to sort in-place.
72 | * @param array_size Size of the array.
73 | * @param order Sorting order to use.
74 | */
75 | native void SortFloats(float[] array, int array_size, SortOrder order = Sort_Ascending);
76 |
77 | /**
78 | * Sorts an array of strings.
79 | *
80 | * @param array Array of strings to sort in-place.
81 | * @param array_size Size of the array.
82 | * @param order Sorting order to use.
83 | */
84 | native void SortStrings(char[][] array, int array_size, SortOrder order = Sort_Ascending);
85 |
86 | /**
87 | * Sort comparison function for 1D array elements.
88 | * @note You may need to use explicit tags in order to use data properly.
89 | *
90 | * @param elem1 First element to compare.
91 | * @param elem2 Second element to compare.
92 | * @param array Array that is being sorted (order is undefined).
93 | * @param hndl Handle optionally passed in while sorting.
94 | * @return -1 if first should go before second
95 | * 0 if first is equal to second
96 | * 1 if first should go after second
97 | */
98 | typedef SortFunc1D = function int (int elem1, int elem2, const int[] array, Handle hndl);
99 |
100 | /**
101 | * Sorts a custom 1D array. You must pass in a comparison function.
102 | *
103 | * @param array Array to sort.
104 | * @param array_size Size of the array to sort.
105 | * @param sortfunc Sort function.
106 | * @param hndl Optional Handle to pass through the comparison calls.
107 | */
108 | native void SortCustom1D(int[] array, int array_size, SortFunc1D sortfunc, Handle hndl=INVALID_HANDLE);
109 |
110 | /**
111 | * Sort comparison function for 2D array elements (sub-arrays).
112 | * @note You may need to use explicit tags in order to use data properly.
113 | *
114 | * @param elem1 First array to compare.
115 | * @param elem2 Second array to compare.
116 | * @param array Array that is being sorted (order is undefined).
117 | * @param hndl Handle optionally passed in while sorting.
118 | * @return -1 if first should go before second
119 | * 0 if first is equal to second
120 | * 1 if first should go after second
121 | */
122 | typeset SortFunc2D
123 | {
124 | function int (int[] elem1, int[] elem2, const int[][] array, Handle hndl);
125 | function int (char[] elem1, char[] elem2, const char[][] array, Handle hndl);
126 | };
127 |
128 | /**
129 | * Sorts a custom 2D array. You must pass in a comparison function.
130 | *
131 | * @param array Array to sort.
132 | * @param array_size Size of the major array to sort (first index, outermost).
133 | * @param sortfunc Sort comparison function to use.
134 | * @param hndl Optional Handle to pass through the comparison calls.
135 | */
136 | native void SortCustom2D(any[][] array, int array_size, SortFunc2D sortfunc, Handle hndl=INVALID_HANDLE);
137 |
138 | /**
139 | * Sort an ADT Array. Specify the type as Integer, Float, or String.
140 | *
141 | * @param array Array Handle to sort
142 | * @param order Sort order to use, same as other sorts.
143 | * @param type Data type stored in the ADT Array
144 | */
145 | native void SortADTArray(Handle array, SortOrder order, SortType type);
146 |
147 | /**
148 | * Sort comparison function for ADT Array elements. Function provides you with
149 | * indexes currently being sorted, use ADT Array functions to retrieve the
150 | * index values and compare.
151 | *
152 | * @param index1 First index to compare.
153 | * @param index2 Second index to compare.
154 | * @param array Array that is being sorted (order is undefined).
155 | * @param hndl Handle optionally passed in while sorting.
156 | * @return -1 if first should go before second
157 | * 0 if first is equal to second
158 | * 1 if first should go after second
159 | */
160 | typedef SortFuncADTArray = function int (int index1, int index2, Handle array, Handle hndl);
161 |
162 | /**
163 | * Custom sorts an ADT Array. You must pass in a comparison function.
164 | *
165 | * @param array Array Handle to sort
166 | * @param sortfunc Sort comparison function to use
167 | * @param hndl Optional Handle to pass through the comparison calls.
168 | */
169 | native void SortADTArrayCustom(Handle array, SortFuncADTArray sortfunc, Handle hndl=INVALID_HANDLE);
170 |
--------------------------------------------------------------------------------
/scripting/include/commandfilters.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _commandfilters_included
34 | #endinput
35 | #endif
36 | #define _commandfilters_included
37 |
38 | #define MAX_TARGET_LENGTH 64
39 |
40 | #define COMMAND_FILTER_ALIVE (1<<0) /**< Only allow alive players */
41 | #define COMMAND_FILTER_DEAD (1<<1) /**< Only filter dead players */
42 | #define COMMAND_FILTER_CONNECTED (1<<2) /**< Allow players not fully in-game */
43 | #define COMMAND_FILTER_NO_IMMUNITY (1<<3) /**< Ignore immunity rules */
44 | #define COMMAND_FILTER_NO_MULTI (1<<4) /**< Do not allow multiple target patterns */
45 | #define COMMAND_FILTER_NO_BOTS (1<<5) /**< Do not allow bots to be targetted */
46 |
47 | #define COMMAND_TARGET_NONE 0 /**< No target was found */
48 | #define COMMAND_TARGET_NOT_ALIVE -1 /**< Single client is not alive */
49 | #define COMMAND_TARGET_NOT_DEAD -2 /**< Single client is not dead */
50 | #define COMMAND_TARGET_NOT_IN_GAME -3 /**< Single client is not in game */
51 | #define COMMAND_TARGET_IMMUNE -4 /**< Single client is immune */
52 | #define COMMAND_TARGET_EMPTY_FILTER -5 /**< A multi-filter (such as @all) had no targets */
53 | #define COMMAND_TARGET_NOT_HUMAN -6 /**< Target was not human */
54 | #define COMMAND_TARGET_AMBIGUOUS -7 /**< Partial name had too many targets */
55 |
56 | /**
57 | * Processes a generic command target string, and resolves it to a list
58 | * of clients or one client, based on filtering rules and a pattern.
59 | *
60 | * Note that you should use LoadTranslations("common.phrases") in OnPluginStart(),
61 | * as that file is guaranteed to contain all of the translatable phrases that
62 | * ProcessTargetString() will return.
63 | *
64 | * @param pattern Pattern to find clients against.
65 | * @param admin Admin performing the action, or 0 if the server.
66 | * @param targets Array to hold targets.
67 | * @param max_targets Maximum size of the targets array.
68 | * @param filter_flags Filter flags.
69 | * @param target_name Buffer to store the target name.
70 | * @param tn_maxlength Maximum length of the target name buffer.
71 | * @param tn_is_ml OUTPUT: Will be true if the target name buffer is an ML phrase,
72 | * false if it is a normal string.
73 | * @return If a multi-target pattern was used, the number of clients found
74 | * is returned. If a single-target pattern was used, 1 is returned
75 | * if one valid client is found. Otherwise, a COMMAND_TARGET reason
76 | * for failure is returned.
77 | */
78 | native int ProcessTargetString(const char[] pattern,
79 | int admin,
80 | int[] targets,
81 | int max_targets,
82 | int filter_flags,
83 | char[] target_name,
84 | int tn_maxlength,
85 | bool &tn_is_ml);
86 |
87 | /**
88 | * Replies to a client with a given message describing a targetting
89 | * failure reason.
90 | *
91 | * Note: The translation phrases are found in common.phrases.txt.
92 | *
93 | * @param client Client index, or 0 for server.
94 | * @param reason COMMAND_TARGET reason.
95 | */
96 | stock void ReplyToTargetError(int client, int reason)
97 | {
98 | switch (reason)
99 | {
100 | case COMMAND_TARGET_NONE:
101 | {
102 | ReplyToCommand(client, "[SM] %t", "No matching client");
103 | }
104 | case COMMAND_TARGET_NOT_ALIVE:
105 | {
106 | ReplyToCommand(client, "[SM] %t", "Target must be alive");
107 | }
108 | case COMMAND_TARGET_NOT_DEAD:
109 | {
110 | ReplyToCommand(client, "[SM] %t", "Target must be dead");
111 | }
112 | case COMMAND_TARGET_NOT_IN_GAME:
113 | {
114 | ReplyToCommand(client, "[SM] %t", "Target is not in game");
115 | }
116 | case COMMAND_TARGET_IMMUNE:
117 | {
118 | ReplyToCommand(client, "[SM] %t", "Unable to target");
119 | }
120 | case COMMAND_TARGET_EMPTY_FILTER:
121 | {
122 | ReplyToCommand(client, "[SM] %t", "No matching clients");
123 | }
124 | case COMMAND_TARGET_NOT_HUMAN:
125 | {
126 | ReplyToCommand(client, "[SM] %t", "Cannot target bot");
127 | }
128 | case COMMAND_TARGET_AMBIGUOUS:
129 | {
130 | ReplyToCommand(client, "[SM] %t", "More than one client matched");
131 | }
132 | }
133 | }
134 |
135 | /**
136 | * Adds clients to a multi-target filter.
137 | *
138 | * @param pattern Pattern name.
139 | * @param clients Array to fill with unique, valid client indexes.
140 | * @return True if pattern was recognized, false otherwise.
141 | */
142 | typeset MultiTargetFilter {
143 | function bool (const char[] pattern, Handle clients);
144 | function bool (const char[] pattern, ArrayList clients);
145 | }
146 |
147 | /**
148 | * Adds a multi-target filter function for ProcessTargetString().
149 | *
150 | * @param pattern Pattern to match (case sensitive).
151 | * @param filter Filter function.
152 | * @param phrase Descriptive phrase to display on successful match.
153 | * @param phraseIsML True if phrase is multi-lingual, false otherwise.
154 | */
155 | native void AddMultiTargetFilter(const char[] pattern, MultiTargetFilter filter,
156 | const char[] phrase, bool phraseIsML);
157 |
158 | /**
159 | * Removes a multi-target filter function from ProcessTargetString().
160 | *
161 | * @param pattern Pattern to match (case sensitive).
162 | * @param filter Filter function.
163 | */
164 | native void RemoveMultiTargetFilter(const char[] pattern, MultiTargetFilter filter);
165 |
--------------------------------------------------------------------------------
/scripting/include/banning.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _banning_included
34 | #endinput
35 | #endif
36 | #define _banning_included
37 |
38 | #define BANFLAG_AUTO (1<<0) /**< Auto-detects whether to ban by steamid or IP */
39 | #define BANFLAG_IP (1<<1) /**< Always ban by IP address */
40 | #define BANFLAG_AUTHID (1<<2) /**< Always ban by authstring (for BanIdentity) if possible */
41 | #define BANFLAG_NOKICK (1<<3) /**< Does not kick the client */
42 |
43 | /**
44 | * Called for calls to BanClient() with a non-empty command.
45 | *
46 | * @param client Client being banned.
47 | * @param time Time the client is being banned for (0 = permanent).
48 | * @param flags One if AUTHID or IP will be enabled. If AUTO is also
49 | * enabled, it means Core autodetected which to use.
50 | * @param reason Reason passed via BanClient().
51 | * @param kick_message Kick message passed via BanClient().
52 | * @param command Command string to identify the ban source.
53 | * @param source Source value passed via BanClient().
54 | * @return Plugin_Handled to block the actual server banning.
55 | * Kicking will still occur.
56 | */
57 | forward Action OnBanClient(int client,
58 | int time,
59 | int flags,
60 | const char[] reason,
61 | const char[] kick_message,
62 | const char[] command,
63 | any source);
64 |
65 | /**
66 | * Called for calls to BanIdentity() with a non-empty command.
67 | *
68 | * @param identity Identity string being banned (authstring or ip).
69 | * @param time Time the client is being banned for (0 = permanent).
70 | * @param flags Ban flags (only IP or AUTHID are valid here).
71 | * @param reason Reason passed via BanIdentity().
72 | * @param command Command string to identify the ban source.
73 | * @param source Source value passed via BanIdentity().
74 | * @return Plugin_Handled to block the actual server banning.
75 | */
76 | forward Action OnBanIdentity(const char[] identity,
77 | int time,
78 | int flags,
79 | const char[] reason,
80 | const char[] command,
81 | any source);
82 |
83 | /**
84 | * Called for calls to RemoveBan() with a non-empty command.
85 | *
86 | * @param identity Identity string being banned (authstring or ip).
87 | * @param flags Ban flags (only IP or AUTHID are valid here).
88 | * @param command Command string to identify the ban source.
89 | * @param source Source value passed via BanIdentity().
90 | * @return Plugin_Handled to block the actual unbanning.
91 | */
92 | forward Action OnRemoveBan(const char[] identity,
93 | int flags,
94 | const char[] command,
95 | any source);
96 |
97 | /**
98 | * Bans a client.
99 | *
100 | * @param client Client being banned.
101 | * @param time Time (in minutes) to ban (0 = permanent).
102 | * @param flags Flags for controlling the ban mechanism. If AUTHID
103 | * is set and no AUTHID is available, the ban will fail
104 | * unless AUTO is also flagged.
105 | * @param reason Reason to ban the client for.
106 | * @param kick_message Message to display to the user when kicking.
107 | * @param command Command string to identify the source. If this is left
108 | * empty, then the OnBanClient forward will not be called.
109 | * @param source A source value that could be interpreted as a player
110 | * index of any sort (not actually checked by Core).
111 | * @return True on success, false on failure.
112 | * @error Invalid client index or client not in game.
113 | */
114 | native bool BanClient(int client,
115 | int time,
116 | int flags,
117 | const char[] reason,
118 | const char[] kick_message="",
119 | const char[] command="",
120 | any source=0);
121 |
122 | /**
123 | * Bans an identity (either an IP address or auth string).
124 | *
125 | * @param identity String to ban (ip or authstring).
126 | * @param time Time to ban for (0 = permanent).
127 | * @param flags Flags (only IP and AUTHID are valid flags here).
128 | * @param reason Ban reason string.
129 | * @param command Command string to identify the source. If this is left
130 | * empty, then the OnBanIdentity forward will not be called.
131 | * @param source A source value that could be interpreted as a player
132 | * index of any sort (not actually checked by Core).
133 | * @return True on success, false on failure.
134 | */
135 | native bool BanIdentity(const char[] identity,
136 | int time,
137 | int flags,
138 | const char[] reason,
139 | const char[] command="",
140 | any source=0);
141 |
142 | /**
143 | * Removes a ban that was written to the server (either in memory or on disk).
144 | *
145 | * @param identity String to unban (ip or authstring).
146 | * @param flags Flags (only IP and AUTHID are valid flags here).
147 | * @param command Command string to identify the source. If this is left
148 | * empty, then OnRemoveBan will not be called.
149 | * @param source A source value that could be interpreted as a player
150 | * index of any sort (not actually checked by Core).
151 | * @return True on success, false on failure.
152 | */
153 | native bool RemoveBan(const char[] identity,
154 | int flags,
155 | const char[] command="",
156 | any source=0);
157 |
--------------------------------------------------------------------------------
/scripting/include/sdktools_stringtables.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _sdktools_stringtables_included
34 | #endinput
35 | #endif
36 | #define _sdktools_stringtables_included
37 |
38 | #define INVALID_STRING_TABLE -1 /**< An invalid string table index */
39 | #define INVALID_STRING_INDEX -1 /**< An invalid string index in a table */
40 |
41 | /**
42 | * Searches for a string table.
43 | *
44 | * @param name Name of string table to find.
45 | * @return A string table index number if found, INVALID_STRING_TABLE otherwise.
46 | */
47 | native int FindStringTable(const char[] name);
48 |
49 | /**
50 | * Returns the number of string tables that currently exist.
51 | *
52 | * @return Number of string tables that currently exist.
53 | */
54 | native int GetNumStringTables();
55 |
56 | /**
57 | * Returns the number of strings that currently exist in a given string table.
58 | *
59 | * @param tableidx A string table index.
60 | * @return Number of strings that currently exist.
61 | * @error Invalid string table index.
62 | */
63 | native int GetStringTableNumStrings(int tableidx);
64 |
65 | /**
66 | * Returns the maximum number of strings that are allowed in a given string table.
67 | *
68 | * @param tableidx A string table index.
69 | * @return Maximum number of strings allowed.
70 | * @error Invalid string table index.
71 | */
72 | native int GetStringTableMaxStrings(int tableidx);
73 |
74 | /**
75 | * Retrieves the name of a string table.
76 | *
77 | * @param tableidx A string table index.
78 | * @param name Buffer to store the name of the string table.
79 | * @param maxlength Maximum length of string buffer.
80 | * @return Number of bytes written to the buffer (UTF-8 safe).
81 | * @error Invalid string table index.
82 | */
83 | native int GetStringTableName(int tableidx, char[] name, int maxlength);
84 |
85 | /**
86 | * Searches for the index of a given string in a string table.
87 | *
88 | * @param tableidx A string table index.
89 | * @param str String to find.
90 | * @return String index if found, INVALID_STRING_INDEX otherwise.
91 | * @error Invalid string table index.
92 | */
93 | native int FindStringIndex(int tableidx, const char[] str);
94 |
95 | /**
96 | * Retrieves the string at a given index of a string table.
97 | *
98 | * @param tableidx A string table index.
99 | * @param stringidx A string index.
100 | * @param str Buffer to store the string value.
101 | * @param maxlength Maximum length of string buffer.
102 | * @return Number of bytes written to the buffer (UTF-8 safe).
103 | * @error Invalid string table index or string index.
104 | */
105 | native int ReadStringTable(int tableidx, int stringidx, char[] str, int maxlength);
106 |
107 | /**
108 | * Returns the length of the user data associated with a given string index.
109 | *
110 | * @param tableidx A string table index.
111 | * @param stringidx A string index.
112 | * @return Length of user data. This will be 0 if there is no user data.
113 | * @error Invalid string table index or string index.
114 | */
115 | native int GetStringTableDataLength(int tableidx, int stringidx);
116 |
117 | /**
118 | * Retrieves the user data associated with a given string index.
119 | *
120 | * @param tableidx A string table index.
121 | * @param stringidx A string index.
122 | * @param userdata Buffer to store the user data. This will be set to "" if there is no user data.
123 | * @param maxlength Maximum length of string buffer.
124 | * @return Number of bytes written to the buffer (UTF-8 safe).
125 | * @error Invalid string table index or string index.
126 | */
127 | native int GetStringTableData(int tableidx, int stringidx, char[] userdata, int maxlength);
128 |
129 | /**
130 | * Sets the user data associated with a given string index.
131 | *
132 | * @param tableidx A string table index.
133 | * @param stringidx A string index.
134 | * @param userdata User data string that will be set.
135 | * @param length Length of user data string. This should include the null terminator.
136 | * @return Number of bytes written to the buffer (UTF-8 safe).
137 | * @error Invalid string table index or string index.
138 | */
139 | native int SetStringTableData(int tableidx, int stringidx, const char[] userdata, int length);
140 |
141 | /**
142 | * Adds a string to a given string table.
143 | *
144 | * @param tableidx A string table index.
145 | * @param str String to add.
146 | * @param userdata An optional user data string.
147 | * @param length Length of user data string. This should include the null terminator.
148 | * If set to -1, then user data will be not be altered if the specified string
149 | * already exists in the string table.
150 | */
151 | native void AddToStringTable(int tableidx, const char[] str, const char[] userdata="", int length=-1);
152 |
153 | /**
154 | * Locks or unlocks the network string tables.
155 | *
156 | * @param lock Determines whether network string tables should be locked.
157 | * True means the tables should be locked for writing; false means unlocked.
158 | * @return Previous lock state.
159 | */
160 | native bool LockStringTables(bool lock);
161 |
162 | /**
163 | * Adds a file to the downloadables network string table.
164 | * This forces a client to download the file if they do not already have it.
165 | *
166 | * @param filename File that will be added to downloadables table.
167 | */
168 | stock void AddFileToDownloadsTable(const char[] filename)
169 | {
170 | static int table = INVALID_STRING_TABLE;
171 |
172 | if (table == INVALID_STRING_TABLE)
173 | {
174 | table = FindStringTable("downloadables");
175 | }
176 |
177 | bool save = LockStringTables(false);
178 | AddToStringTable(table, filename);
179 | LockStringTables(save);
180 | }
181 |
--------------------------------------------------------------------------------
/scripting/include/sdktools_gamerules.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2011 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _sdktools_gamerules_included
34 | #endinput
35 | #endif
36 | #define _sdktools_gamerules_included
37 |
38 | enum RoundState {
39 | // initialize the game, create teams
40 | RoundState_Init,
41 |
42 | //Before players have joined the game. Periodically checks to see if enough players are ready
43 | //to start a game. Also reverts to this when there are no active players
44 | RoundState_Pregame,
45 |
46 | //The game is about to start, wait a bit and spawn everyone
47 | RoundState_StartGame,
48 |
49 | //All players are respawned, frozen in place
50 | RoundState_Preround,
51 |
52 | //Round is on, playing normally
53 | RoundState_RoundRunning,
54 |
55 | //Someone has won the round
56 | RoundState_TeamWin,
57 |
58 | //Noone has won, manually restart the game, reset scores
59 | RoundState_Restart,
60 |
61 | //Noone has won, restart the game
62 | RoundState_Stalemate,
63 |
64 | //Game is over, showing the scoreboard etc
65 | RoundState_GameOver,
66 |
67 | //Game is over, doing bonus round stuff
68 | RoundState_Bonus,
69 |
70 | //Between rounds
71 | RoundState_BetweenRounds
72 | };
73 |
74 | /**
75 | * Retrieves an integer value from a property of the gamerules entity.
76 | *
77 | * @param prop Property name.
78 | * @param size Number of bytes to read (valid values are 1, 2, or 4).
79 | * This value is auto-detected, and the size parameter is
80 | * only used as a fallback in case detection fails.
81 | * @param element Element # (starting from 0) if property is an array.
82 | * @return Value at the given property offset.
83 | * @error Not supported.
84 | */
85 | native int GameRules_GetProp(const char[] prop, int size=4, int element=0);
86 |
87 | /**
88 | * Sets an integer value for a property of the gamerules entity.
89 | *
90 | * @param prop Property name.
91 | * @param value Value to set.
92 | * @param size Number of bytes to write (valid values are 1, 2, or 4).
93 | * This value is auto-detected, and the size parameter is
94 | * only used as a fallback in case detection fails.
95 | * @param element Element # (starting from 0) if property is an array.
96 | * @param changeState This parameter is ignored.
97 | * @error Not supported.
98 | */
99 | native void GameRules_SetProp(const char[] prop, any value, int size=4, int element=0, bool changeState=false);
100 |
101 | /**
102 | * Retrieves a float value from a property of the gamerules entity.
103 | *
104 | * @param prop Property name.
105 | * @param element Element # (starting from 0) if property is an array.
106 | * @return Value at the given property offset.
107 | * @error Not supported.
108 | */
109 | native float GameRules_GetPropFloat(const char[] prop, int element=0);
110 |
111 | /**
112 | * Sets a float value for a property of the gamerules entity.
113 | *
114 | * @param prop Property name.
115 | * @param value Value to set.
116 | * @param element Element # (starting from 0) if property is an array.
117 | * @param changeState This parameter is ignored.
118 | * @error Not supported.
119 | */
120 | native void GameRules_SetPropFloat(const char[] prop, float value, int element=0, bool changeState=false);
121 |
122 | /**
123 | * Retrieves a entity index from a property of the gamerules entity.
124 | *
125 | * @param prop Property name.
126 | * @param element Element # (starting from 0) if property is an array.
127 | * @return Entity index at the given property.
128 | * If there is no entity, or the entity is not valid,
129 | * then -1 is returned.
130 | * @error Not supported.
131 | */
132 | native int GameRules_GetPropEnt(const char[] prop, int element=0);
133 |
134 | /**
135 | * Sets an entity index for a property of the gamerules entity.
136 | *
137 | * @param prop Property name.
138 | * @param other Entity index to set, or -1 to unset.
139 | * @param element Element # (starting from 0) if property is an array.
140 | * @param changeState This parameter is ignored.
141 | * @error Not supported.
142 | */
143 | native void GameRules_SetPropEnt(const char[] prop, int other, int element=0, bool changeState=false);
144 |
145 | /**
146 | * Retrieves a vector of floats from the gamerules entity, given a named network property.
147 | *
148 | * @param prop Property name.
149 | * @param vec Vector buffer to store data in.
150 | * @param element Element # (starting from 0) if property is an array.
151 | * @error Not supported.
152 | */
153 | native void GameRules_GetPropVector(const char[] prop, float vec[3], int element=0);
154 |
155 | /**
156 | * Sets a vector of floats in the gamerules entity, given a named network property.
157 | *
158 | * @param prop Property name.
159 | * @param vec Vector to set.
160 | * @param element Element # (starting from 0) if property is an array.
161 | * @param changeState This parameter is ignored.
162 | * @error Not supported.
163 | */
164 | native void GameRules_SetPropVector(const char[] prop, const float vec[3], int element=0, bool changeState=false);
165 |
166 | /**
167 | * Gets a gamerules property as a string.
168 | *
169 | * @param prop Property to use.
170 | * @param buffer Destination string buffer.
171 | * @param maxlen Maximum length of output string buffer.
172 | * @return Number of non-null bytes written.
173 | * @error Not supported.
174 | */
175 | native int GameRules_GetPropString(const char[] prop, char[] buffer, int maxlen);
176 |
177 | /**
178 | * Sets a gamerules property as a string.
179 | *
180 | * @param prop Property to use.
181 | * @param buffer String to set.
182 | * @param changeState This parameter is ignored.
183 | * @return Number of non-null bytes written.
184 | * @error Not supported.
185 | */
186 | native int GameRules_SetPropString(const char[] prop, const char[] buffer, bool changeState=false);
187 |
188 | /**
189 | * Gets the current round state.
190 | *
191 | * @return Round state.
192 | * @error Game doesn't support round state.
193 | */
194 | stock RoundState GameRules_GetRoundState()
195 | {
196 | return view_as(GameRules_GetProp("m_iRoundState"));
197 | }
198 |
--------------------------------------------------------------------------------
/scripting/include/sdktools_tempents.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _sdktools_tempents_included
34 | #endinput
35 | #endif
36 | #define _sdktools_tempents_included
37 |
38 | /**
39 | * Called when a temp entity is going to be sent.
40 | *
41 | * @param te_name TE name.
42 | * @param Players Array containing target player indexes.
43 | * @param numClients Number of players in the array.
44 | * @param delay Delay in seconds to send the TE.
45 | * @return Plugin_Continue to allow the transmission of the TE, Plugin_Stop to block it.
46 | */
47 | typedef TEHook = function Action (const char[] te_name, const int[] Players, int numClients, float delay);
48 |
49 | /**
50 | * Hooks a temp entity.
51 | *
52 | * @param te_name TE name to hook.
53 | * @param hook Function to use as a hook.
54 | * @error Temp Entity name not available or invalid function hook.
55 | */
56 | native void AddTempEntHook(const char[] te_name, TEHook hook);
57 |
58 | /**
59 | * Removes a temp entity hook.
60 | *
61 | * @param te_name TE name to unhook.
62 | * @param hook Function used for the hook.
63 | * @error Temp Entity name not available or invalid function hook.
64 | */
65 | native void RemoveTempEntHook(const char[] te_name, TEHook hook);
66 |
67 | /**
68 | * Starts a temp entity transmission.
69 | *
70 | * @param te_name TE name.
71 | * @error Temp Entity name not available.
72 | */
73 | native void TE_Start(const char[] te_name);
74 |
75 | /**
76 | * Checks if a certain TE property exists.
77 | *
78 | * @param prop Property to use.
79 | * @return True if the property exists, otherwise false.
80 | */
81 | native bool TE_IsValidProp(const char[] prop);
82 |
83 | /**
84 | * Sets an integer value in the current temp entity.
85 | *
86 | * @param prop Property to use.
87 | * @param value Integer value to set.
88 | * @error Property not found.
89 | */
90 | native void TE_WriteNum(const char[] prop, int value);
91 |
92 | /**
93 | * Reads an integer value in the current temp entity.
94 | *
95 | * @param prop Property to use.
96 | * @return Property value.
97 | * @error Property not found.
98 | */
99 | native int TE_ReadNum(const char[] prop);
100 |
101 | /**
102 | * Sets a floating point number in the current temp entity.
103 | *
104 | * @param prop Property to use.
105 | * @param value Floating point number to set.
106 | * @error Property not found.
107 | */
108 | native void TE_WriteFloat(const char[] prop, float value);
109 |
110 | /**
111 | * Reads a floating point number in the current temp entity.
112 | *
113 | * @param prop Property to use.
114 | * @return Property value.
115 | * @error Property not found.
116 | */
117 | native float TE_ReadFloat(const char[] prop);
118 |
119 | /**
120 | * Sets a vector in the current temp entity.
121 | *
122 | * @param prop Property to use.
123 | * @param vector Vector to set.
124 | * @error Property not found.
125 | */
126 | native void TE_WriteVector(const char[] prop, const float vector[3]);
127 |
128 | /**
129 | * Reads a vector in the current temp entity.
130 | *
131 | * @param prop Property to use.
132 | * @param vector Vector to read.
133 | * @error Property not found.
134 | */
135 | native void TE_ReadVector(const char[] prop, float vector[3]);
136 |
137 | /**
138 | * Sets a QAngle in the current temp entity.
139 | *
140 | * @param prop Property to use.
141 | * @param angles Angles to set.
142 | * @error Property not found.
143 | */
144 | native void TE_WriteAngles(const char[] prop, const float angles[3]);
145 |
146 | /**
147 | * Sets an array of floats in the current temp entity.
148 | *
149 | * @param prop Property to use.
150 | * @param array Array of values to copy.
151 | * @param arraySize Number of values to copy.
152 | * @error Property not found.
153 | */
154 | native void TE_WriteFloatArray(const char[] prop, const float[] array, int arraySize);
155 |
156 | /**
157 | * Sends the current temp entity to one or more clients.
158 | *
159 | * @param clients Array containing player indexes to broadcast to.
160 | * @param numClients Number of players in the array.
161 | * @param delay Delay in seconds to send the TE.
162 | * @error Invalid client index or client not in game.
163 | */
164 | native void TE_Send(const int[] clients, int numClients, float delay=0.0);
165 |
166 | /**
167 | * Sets an encoded entity index in the current temp entity.
168 | * (This is usually used for m_nStartEntity and m_nEndEntity).
169 | *
170 | * @param prop Property to use.
171 | * @param value Value to set.
172 | * @error Property not found.
173 | */
174 | stock void TE_WriteEncodedEnt(const char[] prop, int value)
175 | {
176 | int encvalue = (value & 0x0FFF) | ((1 & 0xF)<<12);
177 | TE_WriteNum(prop, encvalue);
178 | }
179 |
180 | /**
181 | * Broadcasts the current temp entity to all clients.
182 | * @note See TE_Start().
183 | *
184 | * @param delay Delay in seconds to send the TE.
185 | */
186 | stock void TE_SendToAll(float delay=0.0)
187 | {
188 | int total = 0;
189 | int[] clients = new int[MaxClients];
190 | for (int i=1; i<=MaxClients; i++)
191 | {
192 | if (IsClientInGame(i))
193 | {
194 | clients[total++] = i;
195 | }
196 | }
197 | TE_Send(clients, total, delay);
198 | }
199 |
200 | /**
201 | * Sends the current TE to only a client.
202 | * @note See TE_Start().
203 | *
204 | * @param client Client to send to.
205 | * @param delay Delay in seconds to send the TE.
206 | * @error Invalid client index or client not in game.
207 | */
208 | stock void TE_SendToClient(int client, float delay=0.0)
209 | {
210 | int players[1];
211 |
212 | players[0] = client;
213 |
214 | TE_Send(players, 1, delay);
215 | }
216 |
217 | /**
218 | * Sends the current TE to all clients that are in
219 | * visible or audible range of the origin.
220 | * @note See TE_Start().
221 | * @note See GetClientsInRange()
222 | *
223 | * @param origin Coordinates from which to test range.
224 | * @param rangeType Range type to use for filtering clients.
225 | * @param delay Delay in seconds to send the TE.
226 | */
227 | stock void TE_SendToAllInRange(float origin[3], ClientRangeType rangeType, float delay=0.0)
228 | {
229 | int[] clients = new int[MaxClients];
230 | int total = GetClientsInRange(origin, rangeType, clients, MaxClients);
231 | TE_Send(clients, total, delay);
232 | }
233 |
--------------------------------------------------------------------------------
/scripting/include/datapack.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 sw=4 tw=99 noet :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _datapack_included
34 | #endinput
35 | #endif
36 | #define _datapack_included
37 |
38 |
39 | /**
40 | * Opaque handle to a datapack position.
41 | */
42 | enum DataPackPos: {};
43 |
44 | // A DataPack allows serializing multiple variables into a single stream.
45 | methodmap DataPack < Handle
46 | {
47 | // Creates a new data pack.
48 | public native DataPack();
49 |
50 | // Packs a normal cell into a data pack.
51 | //
52 | // @param cell Cell to add.
53 | // @param insert Determines whether mid-pack writes will insert instead of overwrite.
54 | public native void WriteCell(any cell, bool insert = false);
55 |
56 | // Packs a float into a data pack.
57 | //
58 | // @param val Float to add.
59 | // @param insert Determines whether mid-pack writes will insert instead of overwrite.
60 | public native void WriteFloat(float val, bool insert = false);
61 |
62 | // Packs a string into a data pack.
63 | //
64 | // @param str String to add.
65 | // @param insert Determines whether mid-pack writes will insert instead of overwrite.
66 | public native void WriteString(const char[] str, bool insert = false);
67 |
68 | // Packs a function pointer into a data pack.
69 | //
70 | // @param fktptr Function pointer to add.
71 | // @param insert Determines whether mid-pack writes will insert instead of overwrite.
72 | public native void WriteFunction(Function fktptr, bool insert = false);
73 |
74 | // Reads a cell from a data pack.
75 | //
76 | // @param pack Handle to the data pack.
77 | public native any ReadCell();
78 |
79 | // Reads a float from a data pack.
80 | //
81 | // @param pack Handle to the data pack.
82 | public native float ReadFloat();
83 |
84 | // Reads a string from a data pack.
85 | //
86 | // @param buffer Destination string buffer.
87 | // @param maxlen Maximum length of output string buffer.
88 | public native void ReadString(char[] buffer, int maxlen);
89 |
90 | // Reads a function pointer from a data pack.
91 | //
92 | // @return Function pointer.
93 | public native Function ReadFunction();
94 |
95 | // Resets the position in a data pack.
96 | //
97 | // @param clear If true, clears the contained data.
98 | public native void Reset(bool clear=false);
99 |
100 | // Returns whether or not a specified number of bytes from the data pack
101 | // position to the end can be read.
102 | //
103 | // @param unused Unused variable. Exists for backwards compatability.
104 | public native bool IsReadable(int unused = 0);
105 |
106 | // The read or write position in a data pack.
107 | property DataPackPos Position {
108 | public native get();
109 | public native set(DataPackPos pos);
110 | }
111 | };
112 |
113 | /**
114 | * Creates a new data pack.
115 | *
116 | * @return A Handle to the data pack. Must be closed with CloseHandle().
117 | */
118 | native DataPack CreateDataPack();
119 |
120 | /**
121 | * Packs a normal cell into a data pack.
122 | *
123 | * @param pack Handle to the data pack.
124 | * @param cell Cell to add.
125 | * @error Invalid handle.
126 | */
127 | native void WritePackCell(Handle pack, any cell);
128 |
129 | /**
130 | * Packs a float into a data pack.
131 | *
132 | * @param pack Handle to the data pack.
133 | * @param val Float to add.
134 | * @error Invalid handle.
135 | */
136 | native void WritePackFloat(Handle pack, float val);
137 |
138 | /**
139 | * Packs a string into a data pack.
140 | *
141 | * @param pack Handle to the data pack.
142 | * @param str String to add.
143 | * @error Invalid handle.
144 | */
145 | native void WritePackString(Handle pack, const char[] str);
146 |
147 | /**
148 | * Packs a function pointer into a data pack.
149 | *
150 | * @param pack Handle to the data pack.
151 | * @param fktptr Function pointer to add.
152 | * @error Invalid handle.
153 | */
154 | native void WritePackFunction(Handle pack, Function fktptr);
155 |
156 | /**
157 | * Reads a cell from a data pack.
158 | *
159 | * @param pack Handle to the data pack.
160 | * @return Cell value.
161 | * @error Invalid handle, or bounds error.
162 | */
163 | native any ReadPackCell(Handle pack);
164 |
165 | /**
166 | * Reads a float from a data pack.
167 | *
168 | * @param pack Handle to the data pack.
169 | * @return Float value.
170 | * @error Invalid handle, or bounds error.
171 | */
172 | native float ReadPackFloat(Handle pack);
173 |
174 | /**
175 | * Reads a string from a data pack.
176 | *
177 | * @param pack Handle to the data pack.
178 | * @param buffer Destination string buffer.
179 | * @param maxlen Maximum length of output string buffer.
180 | * @error Invalid handle, or bounds error.
181 | */
182 | native void ReadPackString(Handle pack, char[] buffer, int maxlen);
183 |
184 | /**
185 | * Reads a function pointer from a data pack.
186 | *
187 | * @param pack Handle to the data pack.
188 | * @return Function pointer.
189 | * @error Invalid handle, or bounds error.
190 | */
191 | native Function ReadPackFunction(Handle pack);
192 |
193 | /**
194 | * Resets the position in a data pack.
195 | *
196 | * @param pack Handle to the data pack.
197 | * @param clear If true, clears the contained data.
198 | * @error Invalid handle.
199 | */
200 | native void ResetPack(Handle pack, bool clear=false);
201 |
202 | /**
203 | * Returns the read or write position in a data pack.
204 | *
205 | * @param pack Handle to the data pack.
206 | * @return Position in the data pack, only usable with calls to SetPackPosition.
207 | * @error Invalid handle.
208 | */
209 | native DataPackPos GetPackPosition(Handle pack);
210 |
211 | /**
212 | * Sets the read/write position in a data pack.
213 | *
214 | * @param pack Handle to the data pack.
215 | * @param position New position to set. Must have been previously retrieved from a call to GetPackPosition.
216 | * @error Invalid handle, or position is beyond the pack bounds.
217 | */
218 | native void SetPackPosition(Handle pack, DataPackPos position);
219 |
220 | /**
221 | * Returns whether or not a specified number of bytes from the data pack
222 | * position to the end can be read.
223 | *
224 | * @param pack Handle to the data pack.
225 | * @param bytes Number of bytes to simulate reading.
226 | * @return True if can be read, false otherwise.
227 | * @error Invalid handle.
228 | */
229 | native bool IsPackReadable(Handle pack, int bytes);
230 |
--------------------------------------------------------------------------------
/scripting/include/helpers.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _helpers_included
34 | #endinput
35 | #endif
36 | #define _helpers_included
37 |
38 | /**
39 | * This function is deprecated. Use the %L format specifier instead.
40 | *
41 | * Formats a user's info as log text.
42 | *
43 | * @param client Client index.
44 | * @param buffer Buffer for text.
45 | * @param maxlength Maximum length of text.
46 | * @deprecated Use the %L format specifier instead.
47 | */
48 | #pragma deprecated Use the %L format specifier instead.
49 | stock void FormatUserLogText(int client, char[] buffer, int maxlength)
50 | {
51 | FormatEx(buffer, maxlength, "\"%L\"", client);
52 | }
53 |
54 | /**
55 | * Returns plugin handle from plugin filename.
56 | *
57 | * @param filename Filename of the plugin to search for.
58 | * @return Handle to plugin if found, INVALID_HANDLE otherwise.
59 | */
60 | stock Handle FindPluginByFile(const char[] filename)
61 | {
62 | char buffer[256];
63 |
64 | Handle iter = GetPluginIterator();
65 | Handle pl;
66 |
67 | while (MorePlugins(iter))
68 | {
69 | pl = ReadPlugin(iter);
70 |
71 | GetPluginFilename(pl, buffer, sizeof(buffer));
72 | if (strcmp(buffer, filename, false) == 0)
73 | {
74 | CloseHandle(iter);
75 | return pl;
76 | }
77 | }
78 |
79 | CloseHandle(iter);
80 |
81 | return INVALID_HANDLE;
82 | }
83 |
84 | /**
85 | * @deprecated Use FindTarget() or ProcessTargetString().
86 | */
87 | #pragma deprecated Use FindTarget() or ProcessTargetString()
88 | stock int SearchForClients(const char[] pattern, int[] clients, int maxClients)
89 | {
90 | int total = 0;
91 |
92 | if (maxClients == 0)
93 | {
94 | return 0;
95 | }
96 |
97 | if (pattern[0] == '#')
98 | {
99 | int input = StringToInt(pattern[1]);
100 | if (!input) {
101 | char name[MAX_NAME_LENGTH];
102 | for (int i=1; i<=MaxClients; i++)
103 | {
104 | if (!IsClientInGame(i))
105 | {
106 | continue;
107 | }
108 | GetClientName(i, name, sizeof(name));
109 | if (strcmp(name, pattern, false) == 0)
110 | {
111 | clients[0] = i;
112 | return 1;
113 | }
114 | }
115 | }
116 | else
117 | {
118 | int client = GetClientOfUserId(input);
119 | if (client)
120 | {
121 | clients[0] = client;
122 | return 1;
123 | }
124 | }
125 | }
126 |
127 | char name[MAX_NAME_LENGTH];
128 | for (int i=1; i<=MaxClients; i++)
129 | {
130 | if (!IsClientInGame(i))
131 | {
132 | continue;
133 | }
134 |
135 | GetClientName(i, name, sizeof(name));
136 | if (StrContains(name, pattern, false) != -1)
137 | {
138 | clients[total++] = i;
139 | if (total >= maxClients)
140 | {
141 | break;
142 | }
143 | }
144 | }
145 |
146 | return total;
147 | }
148 |
149 | /**
150 | * Wraps ProcessTargetString() and handles producing error messages for
151 | * bad targets.
152 | *
153 | * @param client Client who issued command
154 | * @param target Client's target argument
155 | * @param nobots Optional. Set to true if bots should NOT be targetted
156 | * @param immunity Optional. Set to false to ignore target immunity.
157 | * @return Index of target client, or -1 on error.
158 | */
159 | stock int FindTarget(int client, const char[] target, bool nobots = false, bool immunity = true)
160 | {
161 | char target_name[MAX_TARGET_LENGTH];
162 | int target_list[1], target_count;
163 | bool tn_is_ml;
164 |
165 | int flags = COMMAND_FILTER_NO_MULTI;
166 | if (nobots)
167 | {
168 | flags |= COMMAND_FILTER_NO_BOTS;
169 | }
170 |
171 | if (!immunity)
172 | {
173 | flags |= COMMAND_FILTER_NO_IMMUNITY;
174 | }
175 |
176 | if ((target_count = ProcessTargetString(
177 | target,
178 | client,
179 | target_list,
180 | 1,
181 | flags,
182 | target_name,
183 | sizeof(target_name),
184 | tn_is_ml)) > 0)
185 | {
186 | return target_list[0];
187 | }
188 |
189 | ReplyToTargetError(client, target_count);
190 | return -1;
191 | }
192 |
193 | /**
194 | * This function is no longer supported. It has been replaced with ReadMapList(),
195 | * which uses a more unified caching and configuration mechanism. This function also
196 | * has a bug where if the cvar contents changes, the fileTime change won't be recognized.
197 | *
198 | * Loads a specified array with maps. The maps will be either loaded from mapcyclefile, or if supplied
199 | * a cvar containing a file name. If the file in the cvar is bad, it will use mapcyclefile. The fileTime
200 | * parameter is used to store a timestamp of the file. If specified, the file will only be reloaded if it
201 | * has changed.
202 | *
203 | * @param array Valid array handle, should be created with CreateArray(33) or larger.
204 | * @param fileTime Variable containing the "last changed" time of the file. Used to avoid needless reloading.
205 | * @param fileCvar CVAR set to the file to be loaded. Optional.
206 | * @return Number of maps loaded or 0 if in error.
207 | * @deprecated Use ReadMapList() instead.
208 | */
209 | #pragma deprecated Use ReadMapList() instead.
210 | stock int LoadMaps(Handle array, int &fileTime = 0, Handle fileCvar = INVALID_HANDLE)
211 | {
212 | char mapPath[256], mapFile[64];
213 | bool fileFound = false;
214 |
215 | if (fileCvar != INVALID_HANDLE)
216 | {
217 | GetConVarString(fileCvar, mapFile, 64);
218 | BuildPath(Path_SM, mapPath, sizeof(mapPath), mapFile);
219 | fileFound = FileExists(mapPath);
220 | }
221 |
222 | if (!fileFound)
223 | {
224 | Handle mapCycleFile = FindConVar("mapcyclefile");
225 | GetConVarString(mapCycleFile, mapPath, sizeof(mapPath));
226 | fileFound = FileExists(mapPath);
227 | }
228 |
229 | if (!fileFound)
230 | {
231 | LogError("Failed to find a file to load maps from. No maps loaded.");
232 | ClearArray(array);
233 |
234 | return 0;
235 | }
236 |
237 | // If the file hasn't changed, there's no reason to reload
238 | // all of the maps.
239 | int newTime = GetFileTime(mapPath, FileTime_LastChange);
240 | if (fileTime == newTime)
241 | {
242 | return GetArraySize(array);
243 | }
244 |
245 | fileTime = newTime;
246 |
247 | ClearArray(array);
248 |
249 | File file = OpenFile(mapPath, "rt");
250 | if (!file) {
251 | LogError("Could not open file: %s", mapPath);
252 | return 0;
253 | }
254 |
255 | LogMessage("Loading maps from file: %s", mapPath);
256 |
257 | int len;
258 | char buffer[64];
259 | while (!file.EndOfFile() && file.ReadLine(buffer, sizeof(buffer)))
260 | {
261 | TrimString(buffer);
262 |
263 | if ((len = StrContains(buffer, ".bsp", false)) != -1)
264 | {
265 | buffer[len] = '\0';
266 | }
267 |
268 | if (buffer[0] == '\0' || !IsValidConVarChar(buffer[0]) || !IsMapValid(buffer))
269 | {
270 | continue;
271 | }
272 |
273 | if (FindStringInArray(array, buffer) != -1)
274 | {
275 | continue;
276 | }
277 |
278 | PushArrayString(array, buffer);
279 | }
280 |
281 | file.Close();
282 | return GetArraySize(array);
283 | }
284 |
--------------------------------------------------------------------------------
/scripting/include/chat-processor.inc:
--------------------------------------------------------------------------------
1 | #if defined _chat_processor_included
2 | #endinput
3 | #endif
4 | #define _chat_processor_included
5 |
6 | //Globals
7 | #define MAXLENGTH_FLAG 32
8 | #define MAXLENGTH_NAME 128
9 | #define MAXLENGTH_MESSAGE 128
10 | #define MAXLENGTH_BUFFER 255
11 |
12 | ////////////////////////////
13 | //Natives
14 |
15 | /**
16 | * Retrieves the current format string assigned from a flag string.
17 | * Example: "Cstrike_Chat_All" = "{1} : {2}"
18 | * You can find the config formats in either the translations or the configs.
19 | *
20 | * param sFlag Flag string to retrieve the format string from.
21 | * param sBuffer Format string from the flag string.
22 | * param iSize Size of the format string buffer.
23 | *
24 | * noreturn
25 | **/
26 | native void ChatProcessor_GetFlagFormatString(const char[] sFlag, char[] sBuffer, int iSize);
27 |
28 | /**
29 | * Adds a specific tag to a clients name.
30 | *
31 | * param client Client index.
32 | * param tag Tag buffer.
33 | *
34 | * return True if added, false otherwise.
35 | **/
36 | native bool ChatProcessor_AddClientTag(int client, const char[] tag);
37 |
38 | /**
39 | * Removes a specific tag from a clients name.
40 | *
41 | * param client Client index.
42 | * param tag Tag buffer.
43 | *
44 | * return True if found and removed, false otherwise.
45 | **/
46 | native bool ChatProcessor_RemoveClientTag(int client, const char[] tag);
47 |
48 | /**
49 | * Swap client tags in place.
50 | *
51 | * param client Client index.
52 | * param tag1 Tag1 buffer.
53 | * param tag2 Tag2 buffer.
54 | *
55 | * return True if both found and swapped, false otherwise.
56 | **/
57 | native bool ChatProcessor_SwapClientTags(int client, const char[] tag1, const char[] tag2);
58 |
59 | /**
60 | * Strips all tags from a client.
61 | *
62 | * param client Client index.
63 | *
64 | * return True if tags were found and stripped, false if none were found and stripped.
65 | **/
66 | native bool ChatProcessor_StripClientTags(int client);
67 |
68 | /**
69 | * Sets the specific color for a tag.
70 | *
71 | * param client Client index.
72 | * param tag Tag buffer.
73 | * param color Color to use.
74 | *
75 | * return True if found and set, false otherwise.
76 | **/
77 | native bool ChatProcessor_SetTagColor(int client, const char[] tag, const char[] color);
78 |
79 | /**
80 | * Sets the specific color for the clients name.
81 | *
82 | * param client Client index.
83 | * param color Color to use.
84 | *
85 | * return True if set, false otherwise.
86 | **/
87 | native bool ChatProcessor_SetNameColor(int client, const char[] color);
88 |
89 | /**
90 | * Sets the specific color for the clients messages.
91 | *
92 | * param client Client index.
93 | * param color Color to use.
94 | *
95 | * return True if set, false otherwise.
96 | **/
97 | native bool ChatProcessor_SetChatColor(int client, const char[] color);
98 |
99 | ////////////////////////////
100 | //Forwards
101 |
102 | /**
103 | * Called before a chat message is sent, here the message is already processed.
104 | *
105 | * param sender Author that sent the message.
106 | * param reciver Reciver of the message.
107 | * param flag Message's flag.
108 | * param buffer Message's buffer.
109 | * param maxlength Max length of the buffer.
110 | *
111 | * return types
112 | * - Plugin_Continue Continues the message.
113 | * - Plugin_Changed Continues the message.
114 | * - Plugin_Handled Stops the message.
115 | * - Plugin_Stop Stops the message.
116 | **/
117 | forward Action CP_OnChatMessageSendPre(int sender, int reciever, char[] flag, char[] buffer, int maxlength);
118 |
119 | /**
120 | * Called while sending a chat message before It's sent.
121 | * Limits on the name and message strings can be found above.
122 | *
123 | * param author Author that created the message.
124 | * param recipients Array of clients who will receive the message.
125 | * param flagstring Flag string to determine the type of message.
126 | * param name Name string of the author to be pushed.
127 | * param message Message string from the author to be pushed.
128 | * param processcolors Toggle to process colors in the buffer strings.
129 | * param removecolors Toggle to remove colors in the buffer strings. (Requires bProcessColors = true)
130 | *
131 | * return types
132 | * - Plugin_Continue Continues the message.
133 | * - Plugin_Changed Fires the post-forward below and prints out a message.
134 | * - Plugin_Handled Fires the post-forward below but doesn't print a message.
135 | * - Plugin_Stop Stops the message.
136 | **/
137 | forward Action CP_OnChatMessage(int& author, ArrayList recipients, char[] flagstring, char[] name, char[] message, bool & processcolors, bool & removecolors);
138 |
139 | /**
140 | * Called after the chat message is sent to the designated clients by the author.
141 | *
142 | * param author Author that sent the message.
143 | * param recipients Array of clients who received the message.
144 | * param flagstring Flag string to determine the type of message.
145 | * param formatstring Format string used in the message based on the flag string.
146 | * param name Name string of the author.
147 | * param message Message string from the author.
148 | * param processcolors Check if colors were processed in the buffer strings.
149 | * param removecolors Check if colors were removed from the buffer strings.
150 | *
151 | * noreturn
152 | **/
153 | forward void CP_OnChatMessagePost(int author, ArrayList recipients, const char[] flagstring, const char[] formatstring, const char[] name, const char[] message, bool processcolors, bool removecolors);
154 |
155 | /**
156 | * Called after the client has had a new tag added.
157 | *
158 | * param client Client index.
159 | * param index Index for the tag.
160 | * param tag The tag itself.
161 | *
162 | * noreturn
163 | **/
164 | forward void CP_OnAddClientTagPost(int client, int index, const char[] tag);
165 |
166 | /**
167 | * Called after the client has had a new tag removed.
168 | *
169 | * param client Client index.
170 | * param index Index the tag used to have.
171 | * param tag The tag removed.
172 | *
173 | * noreturn
174 | **/
175 | forward void CP_OnRemoveClientTagPost(int client, int index, const char[] tag);
176 |
177 | /**
178 | * Called after the client has had two tags swapped in place.
179 | *
180 | * param client Client index.
181 | * param index1 Index for the first tag.
182 | * param tag1 The first tag itself.
183 | * param index2 Index for the second tag.
184 | * param tag2 The second tag itself.
185 | *
186 | * noreturn
187 | **/
188 | forward void CP_OnSwapClientTagsPost(int client, int index1, const char[] tag1, int index2, const char[] tag2);
189 |
190 | /**
191 | * Called after the client had all of their tags stripped.
192 | *
193 | * param client Client index.
194 | *
195 | * noreturn
196 | **/
197 | forward void CP_OnStripClientTagsPost(int client);
198 |
199 | /**
200 | * Called after a particular client tags color is set.
201 | *
202 | * param client Client index.
203 | * param index Index for the tag.
204 | * param tag The tag itself.
205 | * param color The color code used.
206 | *
207 | * noreturn
208 | **/
209 | forward void CP_OnSetTagColorPost(int client, int index, const char[] tag, const char[] color);
210 |
211 | /**
212 | * Called after a client's name color is set.
213 | *
214 | * param client Client index.
215 | * param color The color code used.
216 | *
217 | * noreturn
218 | **/
219 | forward void CP_OnSetNameColorPost(int client, const char[] color);
220 |
221 | /**
222 | * Called after a client's chat color is set.
223 | *
224 | * param client Client index.
225 | * param color The color code used.
226 | *
227 | * noreturn
228 | **/
229 | forward void CP_OnSetChatColorPost(int client, const char[] color);
230 |
231 | /**
232 | * Called once the plugin is fully loaded and chat data is ready to be parsed.
233 | *
234 | * noreturn
235 | **/
236 | forward void CP_OnReloadChatData();
237 |
238 | #if !defined REQUIRE_PLUGIN
239 | public void __pl_chat_processor_SetNTVOptional()
240 | {
241 | MarkNativeAsOptional("ChatProcessor_GetFlagFormatString");
242 | MarkNativeAsOptional("ChatProcessor_AddClientTag");
243 | MarkNativeAsOptional("ChatProcessor_RemoveClientTag");
244 | MarkNativeAsOptional("ChatProcessor_SwapClientTags");
245 | MarkNativeAsOptional("ChatProcessor_StripClientTags");
246 | MarkNativeAsOptional("ChatProcessor_SetTagColor");
247 | MarkNativeAsOptional("ChatProcessor_SetNameColor");
248 | MarkNativeAsOptional("ChatProcessor_SetChatColor");
249 | }
250 | #endif
251 |
252 | public SharedPlugin __pl_chat_processor =
253 | {
254 | name = "chat-processor",
255 | file = "chat-processor.smx",
256 | #if defined REQUIRE_PLUGIN
257 | required = 1
258 | #else
259 | required = 0
260 | #endif
261 | };
--------------------------------------------------------------------------------
/scripting/include/timers.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _timers_included
34 | #endinput
35 | #endif
36 | #define _timers_included
37 |
38 | #include
39 |
40 | #define TIMER_REPEAT (1<<0) /**< Timer will repeat until it returns Plugin_Stop */
41 | #define TIMER_FLAG_NO_MAPCHANGE (1<<1) /**< Timer will not carry over mapchanges */
42 | #define TIMER_HNDL_CLOSE (1<<9) /**< Deprecated define, replaced by below */
43 | #define TIMER_DATA_HNDL_CLOSE (1<<9) /**< Timer will automatically call CloseHandle() on its data when finished */
44 |
45 | /**
46 | * Any of the following prototypes will work for a timed function.
47 | */
48 | typeset Timer
49 | {
50 | /**
51 | * Called when the timer interval has elapsed.
52 | *
53 | * @param timer Handle to the timer object.
54 | * @param hndl Handle passed to CreateTimer() when timer was created.
55 | * @return Plugin_Stop to stop a repeating timer, any other value for
56 | * default behavior.
57 | */
58 | function Action(Handle timer, Handle hndl);
59 |
60 | /**
61 | * Called when the timer interval has elapsed.
62 | *
63 | * @param timer Handle to the timer object.
64 | * @param data Data passed to CreateTimer() when timer was created.
65 | * @return Plugin_Stop to stop a repeating timer, any other value for
66 | * default behavior.
67 | */
68 | function Action(Handle timer, any data);
69 |
70 | /**
71 | * Called when the timer interval has elapsed.
72 | *
73 | * @param timer Handle to the timer object.
74 | * @return Plugin_Stop to stop a repeating timer, any other value for
75 | * default behavior.
76 | */
77 | function Action(Handle timer);
78 | };
79 |
80 | /**
81 | * Creates a basic timer. Calling CloseHandle() on a timer will end the timer.
82 | *
83 | * @param interval Interval from the current game time to execute the given function.
84 | * @param func Function to execute once the given interval has elapsed.
85 | * @param data Handle or value to pass through to the timer callback function.
86 | * @param flags Flags to set (such as repeatability or auto-Handle closing).
87 | * @return Handle to the timer object. You do not need to call CloseHandle().
88 | * If the timer could not be created, INVALID_HANDLE will be returned.
89 | */
90 | native Handle CreateTimer(float interval, Timer func, any data=INVALID_HANDLE, int flags=0);
91 |
92 | /**
93 | * Kills a timer. Use this instead of CloseHandle() if you need more options.
94 | *
95 | * @param timer Timer Handle to kill.
96 | * @param autoClose If autoClose is true, the data that was passed to CreateTimer() will
97 | * be closed as a handle if TIMER_DATA_HNDL_CLOSE was not specified.
98 | * @error Invalid handles will cause a run time error.
99 | */
100 | native void KillTimer(Handle timer, bool autoClose=false);
101 |
102 | /**
103 | * Manually triggers a timer so its function will be called.
104 | *
105 | * @param timer Timer Handle to trigger.
106 | * @param reset If reset is true, the elapsed time counter is reset
107 | * so the full interval must pass again.
108 | */
109 | native void TriggerTimer(Handle timer, bool reset=false);
110 |
111 | /**
112 | * Returns the simulated game time.
113 | *
114 | * This time is internally maintained by SourceMod and is based on the game
115 | * tick count and tick rate. Unlike GetGameTime(), it will increment past
116 | * map changes and while no players are connected. Unlike GetEngineTime(),
117 | * it will not increment based on the system clock (i.e. it is still bound
118 | * to the ticking process).
119 | *
120 | * @return Time based on the game tick count.
121 | */
122 | native float GetTickedTime();
123 |
124 | /**
125 | * Returns an estimate of the time left before the map ends. If the server
126 | * has not processed any frames yet (i.e. no players have joined the map yet),
127 | * then the time left returned will always be infinite.
128 | *
129 | * @param timeleft Variable to store the time, in seconds. If the
130 | * value is less than 0, the time limit is infinite.
131 | * @return True if the operation is supported, false otherwise.
132 | */
133 | native bool GetMapTimeLeft(int &timeleft);
134 |
135 | /**
136 | * Retrieves the current map time limit. If the server has not processed any
137 | * frames yet (i.e. no players have joined the map yet), then the time limit
138 | * returned will always be 0.
139 | *
140 | * @param time Set to the number of total seconds in the map time
141 | * limit, or 0 if there is no time limit set.
142 | * @return True on success, false if operation is not supported.
143 | */
144 | native bool GetMapTimeLimit(int &time);
145 |
146 | /**
147 | * Extends the map time limit in a way that will notify all plugins.
148 | *
149 | * @param time Number of seconds to extend map time limit by.
150 | * The number can be negative to decrease the time limit.
151 | * If 0, the map will be set to have no time limit.
152 | * @return True on success, false if operation is not supported.
153 | */
154 | native bool ExtendMapTimeLimit(int time);
155 |
156 | /**
157 | * Returns the number of seconds in between game server ticks.
158 | *
159 | * Note: A tick, in this context, is a frame.
160 | *
161 | * @return Number of seconds in between ticks.
162 | */
163 | native float GetTickInterval();
164 |
165 | /**
166 | * Notification that the map's time left has changed via a change in the time
167 | * limit or a change in the game rules (such as mp_restartgame). This is useful
168 | * for plugins trying to create timers based on the time left in the map.
169 | *
170 | * Calling ExtendMapTimeLimit() from here, without proper precaution, will
171 | * cause infinite recursion.
172 | *
173 | * If the operation is not supported, this will never be called.
174 |
175 | * If the server has not yet processed any frames (i.e. no players have joined
176 | * the map yet), then this will be called once the server begins ticking, even
177 | * if there is no time limit set.
178 | */
179 | forward void OnMapTimeLeftChanged();
180 |
181 | /**
182 | * Returns whether or not the server is processing frames or not.
183 | *
184 | * The server does not process frames until at least one client joins the game.
185 | * Once the first player has in, even if that player, leaves, the server's
186 | * timers and entities will work.
187 | *
188 | * @return True if the server is ticking, false otherwise.
189 | */
190 | native bool IsServerProcessing();
191 |
192 | /**
193 | * Creates a timer associated with a new datapack, and returns the datapack.
194 | * @note The datapack is automatically freed when the timer ends.
195 | * @note The position of the datapack is not reset or changed for the timer function.
196 | *
197 | * @param interval Interval from the current game time to execute the given function.
198 | * @param func Function to execute once the given interval has elapsed.
199 | * @param datapack The newly created datapack is passed though this by-reference
200 | * parameter to the timer callback function.
201 | * @param flags Timer flags.
202 | * @return Handle to the timer object. You do not need to call CloseHandle().
203 | */
204 | stock Handle CreateDataTimer(float interval, Timer func, Handle &datapack, int flags=0)
205 | {
206 | datapack = new DataPack();
207 | flags |= TIMER_DATA_HNDL_CLOSE;
208 | return CreateTimer(interval, func, datapack, flags);
209 | }
210 |
--------------------------------------------------------------------------------
/scripting/include/sdktools.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2017 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _sdktools_included
34 | #endinput
35 | #endif
36 | #define _sdktools_included
37 |
38 | #include
39 | #include
40 | #include
41 | #if !defined SDKTOOLS_DISABLE_SOUNDAPI
42 | #include
43 | #endif
44 | #include
45 | #include
46 | #include
47 | #include
48 | #include
49 | #include
50 | #include
51 | #include
52 | #include
53 | #include
54 | #include
55 |
56 | enum SDKCallType
57 | {
58 | SDKCall_Static, /**< Static call */
59 | SDKCall_Entity, /**< CBaseEntity call */
60 | SDKCall_Player, /**< CBasePlayer call */
61 | SDKCall_GameRules, /**< CGameRules call */
62 | SDKCall_EntityList, /**< CGlobalEntityList call */
63 | SDKCall_Raw /**< |this| pointer with an arbitrary address */
64 | };
65 |
66 | enum SDKLibrary
67 | {
68 | SDKLibrary_Server, /**< server.dll/server_i486.so */
69 | SDKLibrary_Engine /**< engine.dll/engine_*.so */
70 | };
71 |
72 | enum SDKFuncConfSource
73 | {
74 | SDKConf_Virtual = 0, /**< Read a virtual index from the Offsets section */
75 | SDKConf_Signature = 1, /**< Read a signature from the Signatures section */
76 | SDKConf_Address = 2 /**< Read an address from the Addresses section */
77 | };
78 |
79 | enum SDKType
80 | {
81 | SDKType_CBaseEntity, /**< CBaseEntity (always as pointer) */
82 | SDKType_CBasePlayer, /**< CBasePlayer (always as pointer) */
83 | SDKType_Vector, /**< Vector (pointer, byval, or byref) */
84 | SDKType_QAngle, /**< QAngles (pointer, byval, or byref) */
85 | SDKType_PlainOldData, /**< Integer/generic data <=32bit (any) */
86 | SDKType_Float, /**< Float (any) */
87 | SDKType_Edict, /**< edict_t (always as pointer) */
88 | SDKType_String, /**< NULL-terminated string (always as pointer) */
89 | SDKType_Bool /**< Boolean (any) */
90 | };
91 |
92 | enum SDKPassMethod
93 | {
94 | SDKPass_Pointer, /**< Pass as a pointer */
95 | SDKPass_Plain, /**< Pass as plain data */
96 | SDKPass_ByValue, /**< Pass an object by value */
97 | SDKPass_ByRef /**< Pass an object by reference */
98 | };
99 |
100 | #define VDECODE_FLAG_ALLOWNULL (1<<0) /**< Allow NULL for pointers */
101 | #define VDECODE_FLAG_ALLOWNOTINGAME (1<<1) /**< Allow players not in game */
102 | #define VDECODE_FLAG_ALLOWWORLD (1<<2) /**< Allow World entity */
103 | #define VDECODE_FLAG_BYREF (1<<3) /**< Floats/ints by reference */
104 |
105 | #define VENCODE_FLAG_COPYBACK (1<<0) /**< Copy back data once done */
106 |
107 | /**
108 | * Starts the preparation of an SDK call.
109 | *
110 | * @param type Type of function call this will be.
111 | */
112 | native void StartPrepSDKCall(SDKCallType type);
113 |
114 | /**
115 | * Sets the virtual index of the SDK call if it is virtual.
116 | *
117 | * @param vtblidx Virtual table index.
118 | */
119 | native void PrepSDKCall_SetVirtual(int vtblidx);
120 |
121 | /**
122 | * Finds an address in a library and sets it as the address to use for the SDK call.
123 | *
124 | * @param lib Library to use.
125 | * @param signature Binary data to search for in the library. If it starts with '@',
126 | * the bytes parameter is ignored and the signature is interpreted
127 | * as a symbol lookup in the library.
128 | * @param bytes Number of bytes in the binary search string.
129 | * @return True on success, false if nothing was found.
130 | */
131 | native bool PrepSDKCall_SetSignature(SDKLibrary lib, const char[] signature, int bytes);
132 |
133 | /**
134 | * Uses the given function address for the SDK call.
135 | *
136 | * @param addr Address of function to use.
137 | * @return True on success, false on failure.
138 | */
139 | native bool PrepSDKCall_SetAddress(Address addr);
140 |
141 | /**
142 | * Finds an address or virtual function index in a GameConfig file and sets it as
143 | * the calling information for the SDK call.
144 | *
145 | * @param gameconf GameConfig Handle, or INVALID_HANDLE to use sdktools.games.txt.
146 | * @param source Whether to look in Offsets or Signatures.
147 | * @param name Name of the property to find.
148 | * @return True on success, false if nothing was found.
149 | */
150 | native bool PrepSDKCall_SetFromConf(Handle gameconf, SDKFuncConfSource source, const char[] name);
151 |
152 | /**
153 | * Sets the return information of an SDK call. Do not call this if there is no return data.
154 | * This must be called if there is a return value (i.e. it is not necessarily safe to ignore
155 | * the data).
156 | *
157 | * @param type Data type to convert to/from.
158 | * @param pass How the data is passed in C++.
159 | * @param decflags Flags on decoding from the plugin to C++.
160 | * @param encflags Flags on encoding from C++ to the plugin.
161 | */
162 | native void PrepSDKCall_SetReturnInfo(SDKType type, SDKPassMethod pass, int decflags=0, int encflags=0);
163 |
164 | /**
165 | * Adds a parameter to the calling convention. This should be called in normal ascending order.
166 | *
167 | * @param type Data type to convert to/from.
168 | * @param pass How the data is passed in C++.
169 | * @param decflags Flags on decoding from the plugin to C++.
170 | * @param encflags Flags on encoding from C++ to the plugin.
171 | */
172 | native void PrepSDKCall_AddParameter(SDKType type, SDKPassMethod pass, int decflags=0, int encflags=0);
173 |
174 | /**
175 | * Finalizes an SDK call preparation and returns the resultant Handle.
176 | *
177 | * @return A new SDKCall Handle on success, or INVALID_HANDLE on failure.
178 | */
179 | native Handle EndPrepSDKCall();
180 |
181 | /**
182 | * Calls an SDK function with the given parameters.
183 | *
184 | * If the call type is Entity or Player, the index MUST ALWAYS be the FIRST parameter passed.
185 | * If the call type is GameRules, then nothing special needs to be passed.
186 | * If the return value is a Vector or QAngles, the SECOND parameter must be a Float[3].
187 | * If the return value is a string, the THIRD parameter must be a String buffer, and the
188 | * FOURTH parameter must be the maximum length.
189 | * All parameters must be passed after the above is followed. Failure to follow these
190 | * rules will result in crashes or wildly unexpected behavior!
191 | *
192 | * If the return value is a float or integer, the return value will be this value.
193 | * If the return value is a CBaseEntity, CBasePlayer, or edict, the return value will
194 | * always be the entity index, or -1 for NULL.
195 | *
196 | * @param call SDKCall Handle.
197 | * @param ... Call Parameters.
198 | * @return Simple return value, if any.
199 | * @error Invalid Handle or internal decoding error.
200 | */
201 | native any SDKCall(Handle call, any ...);
202 |
203 | /**
204 | * Returns the entity index of the player resource/manager entity.
205 | *
206 | * @return Index of resource entity or -1 if not found.
207 | */
208 | native int GetPlayerResourceEntity();
209 |
210 | #include
211 |
212 | /**
213 | * Do not edit below this line!
214 | */
215 | public Extension __ext_sdktools =
216 | {
217 | name = "SDKTools",
218 | file = "sdktools.ext",
219 | #if defined AUTOLOAD_EXTENSIONS
220 | autoload = 1,
221 | #else
222 | autoload = 0,
223 | #endif
224 | #if defined REQUIRE_EXTENSIONS
225 | required = 1,
226 | #else
227 | required = 0,
228 | #endif
229 | };
230 |
--------------------------------------------------------------------------------
/scripting/include/adt_stack.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 sw=4 tw=99 noet :
3 | * =============================================================================
4 | * SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _adt_stack_included
34 | #endinput
35 | #endif
36 | #define _adt_stack_included
37 |
38 | methodmap ArrayStack < Handle
39 | {
40 | // Creates a stack structure. A stack is a LIFO (last in, first out)
41 | // vector (array) of items. It has O(1) insertion and O(1) removal.
42 | //
43 | // Stacks have two operations: Push (adding an item) and Pop (removes
44 | // items in reverse-push order).
45 | //
46 | // The contents of the stack are uniform; i.e. storing a string and then
47 | // retrieving it as an integer is NOT the same as StringToInt()!
48 | //
49 | // The "blocksize" determines how many cells each slot has; it cannot
50 | // be changed after creation.
51 | //
52 | // @param blocksize The number of cells each entry in the stack can
53 | // hold. For example, 32 cells is equivalent to:
54 | // new Array[X][32]
55 | public native ArrayStack(int blocksize=1);
56 |
57 | // Pushes a value onto the end of the stack, adding a new index.
58 | //
59 | // This may safely be used even if the stack has a blocksize
60 | // greater than 1.
61 | //
62 | // @param value Value to push.
63 | public native void Push(any value);
64 |
65 | // Pushes a copy of a string onto the end of a stack, truncating it if it
66 | // is too big.
67 | //
68 | // @param value String to push.
69 | public native void PushString(const char[] value);
70 |
71 | // Pushes a copy of an array of cells onto the end of a stack. The cells
72 | // are pushed as a block (i.e. the entire array takes up one stack slot),
73 | // rather than pushing each cell individually.
74 | //
75 | // @param stack Stack Handle.
76 | // @param values Block of values to copy.
77 | // @param size If not set, the number of elements copied from the array
78 | // will be equal to the blocksize. If set higher than the
79 | // blocksize, the operation will be truncated.
80 | public native void PushArray(const any[] values, int size=-1);
81 |
82 | // Pops a cell value from a stack.
83 | //
84 | // @param block Optionally specify which block to read from
85 | // (useful if the blocksize > 0).
86 | // @param asChar Optionally read as a byte instead of a cell.
87 | // @return True on success, false if the stack is empty.
88 | // @error The stack is empty.
89 | public native any Pop(int block=0, bool asChar=false);
90 |
91 | // Pops a string value from a stack.
92 | //
93 | // @param buffer Buffer to store string.
94 | // @param maxlength Maximum size of the buffer.
95 | // @oaram written Number of characters written to buffer, not including
96 | // the null terminator.
97 | // @error The stack is empty.
98 | public native void PopString(char[] buffer, int maxlength, int &written = 0);
99 |
100 | // Pops an array of cells from a stack.
101 | //
102 | // @param buffer Buffer to store the array in.
103 | // @param size If not set, assumes the buffer size is equal to the
104 | // blocksize. Otherwise, the size passed is used.
105 | // @error The stack is empty.
106 | public native void PopArray(any[] buffer, int size=-1);
107 |
108 | // Returns true if the stack is empty, false otherwise.
109 | property bool Empty {
110 | public native get();
111 | }
112 |
113 | // Retrieve the blocksize the stack was created with.
114 | property int BlockSize {
115 | public native get();
116 | }
117 | };
118 |
119 | /**
120 | * Creates a stack structure. A stack is a LIFO (last in, first out)
121 | * vector (array) of items. It has O(1) insertion and O(1) removal.
122 | *
123 | * Stacks have two operations: Push (adding an item) and Pop (removes
124 | * items in reverse-push order).
125 | *
126 | * The contents of the stack are uniform; i.e. storing a string and then
127 | * retrieving it as an integer is NOT the same as StringToInt()!
128 | *
129 | * The "blocksize" determines how many cells each slot has; it cannot
130 | * be changed after creation.
131 | *
132 | * @param blocksize The number of cells each entry in the stack can
133 | * hold. For example, 32 cells is equivalent to:
134 | * new Array[X][32]
135 | * @return New stack Handle.
136 | */
137 | native ArrayStack CreateStack(int blocksize=1);
138 |
139 | /**
140 | * Pushes a value onto the end of the stack, adding a new index.
141 | *
142 | * This may safely be used even if the stack has a blocksize
143 | * greater than 1.
144 | *
145 | * @param stack Stack Handle.
146 | * @param value Value to push.
147 | * @error Invalid Handle or out of memory.
148 | */
149 | native void PushStackCell(Handle stack, any value);
150 |
151 | /**
152 | * Pushes a copy of a string onto the end of a stack, truncating it if it is
153 | * too big.
154 | *
155 | * @param stack Stack Handle.
156 | * @param value String to push.
157 | * @error Invalid Handle or out of memory.
158 | */
159 | native void PushStackString(Handle stack, const char[] value);
160 |
161 | /**
162 | * Pushes a copy of an array of cells onto the end of a stack. The cells
163 | * are pushed as a block (i.e. the entire array takes up one stack slot),
164 | * rather than pushing each cell individually.
165 | *
166 | * @param stack Stack Handle.
167 | * @param values Block of values to copy.
168 | * @param size If not set, the number of elements copied from the array
169 | * will be equal to the blocksize. If set higher than the
170 | * blocksize, the operation will be truncated.
171 | * @error Invalid Handle or out of memory.
172 | */
173 | native void PushStackArray(Handle stack, const any[] values, int size=-1);
174 |
175 | /**
176 | * Pops a cell value from a stack.
177 | *
178 | * @param stack Stack Handle.
179 | * @param value Variable to store the value.
180 | * @param block Optionally specify which block to read from
181 | * (useful if the blocksize > 0).
182 | * @param asChar Optionally read as a byte instead of a cell.
183 | * @return True on success, false if the stack is empty.
184 | * @error Invalid Handle.
185 | */
186 | native bool PopStackCell(Handle stack, any &value, int block=0, bool asChar=false);
187 |
188 | /**
189 | * Pops a string value from a stack.
190 | *
191 | * @param stack Stack Handle.
192 | * @param buffer Buffer to store string.
193 | * @param maxlength Maximum size of the buffer.
194 | * @return True on success, false if the stack is empty.
195 | * @error Invalid Handle.
196 | */
197 | native bool PopStackString(Handle stack, char[] buffer, int maxlength, int &written=0);
198 |
199 | /**
200 | * Pops an array of cells from a stack.
201 | *
202 | * @param stack Stack Handle.
203 | * @param buffer Buffer to store the array in.
204 | * @param size If not set, assumes the buffer size is equal to the
205 | * blocksize. Otherwise, the size passed is used.
206 | * @return True on success, false if the stack is empty.
207 | * @error Invalid Handle.
208 | */
209 | native bool PopStackArray(Handle stack, any[] buffer, int size=-1);
210 |
211 | /**
212 | * Checks if a stack is empty.
213 | *
214 | * @param stack Stack Handle.
215 | * @return True if empty, false if not empty.
216 | * @error Invalid Handle.
217 | */
218 | native bool IsStackEmpty(Handle stack);
219 |
220 | /**
221 | * Pops a value off a stack, ignoring it completely.
222 | *
223 | * @param stack Stack Handle.
224 | * @return True if something was popped, false otherwise.
225 | * @error Invalid Handle.
226 | */
227 | stock bool PopStack(Handle stack)
228 | {
229 | int value;
230 | return PopStackCell(stack, value);
231 | }
232 |
233 | /**
234 | * Returns the blocksize the stack was created with.
235 | *
236 | * @param stack Stack Handle.
237 | * @return The blocksize of the stack.
238 | * @error Invalid Handle
239 | */
240 | native int GetStackBlockSize(Handle stack);
241 |
--------------------------------------------------------------------------------
/scripting/include/usermessages.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 :
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _eventsmsgs_included
34 | #endinput
35 | #endif
36 | #define _eventsmsgs_included
37 |
38 | /**
39 | * UserMsg helper values.
40 | */
41 | enum UserMsg
42 | {
43 | INVALID_MESSAGE_ID = -1
44 | };
45 |
46 | /**
47 | * UserMsg message serialization formats
48 | */
49 | enum UserMessageType
50 | {
51 | UM_BitBuf = 0,
52 | UM_Protobuf
53 | };
54 |
55 | /**
56 | * @section Message Flags.
57 | */
58 | #define USERMSG_RELIABLE (1<<2) /**< Message will be set on the reliable stream */
59 | #define USERMSG_INITMSG (1<<3) /**< Message will be considered to be an initmsg */
60 | #define USERMSG_BLOCKHOOKS (1<<7) /**< Prevents the message from triggering SourceMod and Metamod hooks */
61 |
62 | /**
63 | * @endsection
64 | */
65 |
66 | /**
67 | * Returns usermessage serialization type used for the current engine
68 | *
69 | * @return The supported usermessage type.
70 | */
71 | native UserMessageType GetUserMessageType();
72 |
73 | stock Protobuf UserMessageToProtobuf(Handle msg)
74 | {
75 | if (GetUserMessageType() != UM_Protobuf)
76 | {
77 | return null;
78 | }
79 |
80 | return view_as(msg);
81 | }
82 |
83 | // Make sure to only call this on writable buffers (eg from StartMessage).
84 | stock BfWrite UserMessageToBfWrite(Handle msg)
85 | {
86 | if (GetUserMessageType() == UM_Protobuf)
87 | {
88 | return null;
89 | }
90 |
91 | return view_as(msg);
92 | }
93 |
94 | // Make sure to only call this on readable buffers (eg from a message hook).
95 | stock BfRead UserMessageToBfRead(Handle msg)
96 | {
97 | if (GetUserMessageType() == UM_Protobuf)
98 | {
99 | return null;
100 | }
101 |
102 | return view_as(msg);
103 | }
104 |
105 | /**
106 | * Returns the ID of a given message, or -1 on failure.
107 | *
108 | * @param msg String containing message name (case sensitive).
109 | * @return A message index, or INVALID_MESSAGE_ID on failure.
110 | */
111 | native UserMsg GetUserMessageId(const char[] msg);
112 |
113 | /**
114 | * Retrieves the name of a message by ID.
115 | *
116 | * @param msg_id Message index.
117 | * @param msg Buffer to store the name of the message.
118 | * @param maxlength Maximum length of string buffer.
119 | * @return True if message index is valid, false otherwise.
120 | */
121 | native bool GetUserMessageName(UserMsg msg_id, char[] msg, int maxlength);
122 |
123 | /**
124 | * Starts a usermessage (network message).
125 | *
126 | * @note Only one message can be active at a time.
127 | * @note It is illegal to send any message while a non-intercept hook is in progress.
128 | *
129 | * @param msgname Message name to start.
130 | * @param clients Array containing player indexes to broadcast to.
131 | * @param numClients Number of players in the array.
132 | * @param flags Optional flags to set.
133 | * @return A handle to a bf_write bit packing structure, or
134 | * INVALID_HANDLE on failure.
135 | * @error Invalid message name, unable to start a message, invalid client,
136 | * or client not connected.
137 | */
138 | native Handle StartMessage(const char[] msgname, const int[] clients, int numClients, int flags=0);
139 |
140 | /**
141 | * Starts a usermessage (network message).
142 | *
143 | * @note Only one message can be active at a time.
144 | * @note It is illegal to send any message while a non-intercept hook is in progress.
145 | *
146 | * @param msg Message index to start.
147 | * @param clients Array containing player indexes to broadcast to.
148 | * @param numClients Number of players in the array.
149 | * @param flags Optional flags to set.
150 | * @return A handle to a bf_write bit packing structure, or
151 | * INVALID_HANDLE on failure.
152 | * @error Invalid message name, unable to start a message, invalid client,
153 | * or client not connected.
154 | */
155 | native Handle StartMessageEx(UserMsg msg, const int[] clients, int numClients, int flags=0);
156 |
157 | /**
158 | * Ends a previously started user message (network message).
159 | */
160 | native void EndMessage();
161 |
162 | /**
163 | * Hook function types for user messages.
164 | */
165 | typeset MsgHook
166 | {
167 | /**
168 | * Called when a bit buffer based usermessage is hooked
169 | *
170 | * @param msg_id Message index.
171 | * @param msg Handle to the input bit buffer.
172 | * @param players Array containing player indexes.
173 | * @param playersNum Number of players in the array.
174 | * @param reliable True if message is reliable, false otherwise.
175 | * @param init True if message is an initmsg, false otherwise.
176 | * @return Ignored for normal hooks. For intercept hooks, Plugin_Handled
177 | * blocks the message from being sent, and Plugin_Continue
178 | * resumes normal functionality.
179 | */
180 | function Action (UserMsg msg_id, BfRead msg, const int[] players, int playersNum, bool reliable, bool init);
181 | /**
182 | * Called when a protobuf based usermessage is hooked
183 | *
184 | * @param msg_id Message index.
185 | * @param msg Handle to the input protobuf.
186 | * @param players Array containing player indexes.
187 | * @param playersNum Number of players in the array.
188 | * @param reliable True if message is reliable, false otherwise.
189 | * @param init True if message is an initmsg, false otherwise.
190 | * @return Ignored for normal hooks. For intercept hooks, Plugin_Handled
191 | * blocks the message from being sent, and Plugin_Continue
192 | * resumes normal functionality.
193 | */
194 | function Action (UserMsg msg_id, Protobuf msg, const int[] players, int playersNum, bool reliable, bool init);
195 | };
196 |
197 | /**
198 | * Called when a message hook has completed.
199 | *
200 | * @param msg_id Message index.
201 | * @param sent True if message was sent, false if blocked.
202 | */
203 | typedef MsgPostHook = function void (UserMsg msg_id, bool sent);
204 |
205 | /**
206 | * Hooks a user message.
207 | *
208 | * @param msg_id Message index.
209 | * @param hook Function to use as a hook.
210 | * @param intercept If intercept is true, message will be fully intercepted,
211 | * allowing the user to block the message. Otherwise,
212 | * the hook is normal and ignores the return value.
213 | * @param post Notification function.
214 | * @error Invalid message index.
215 | */
216 | native void HookUserMessage(UserMsg msg_id, MsgHook hook, bool intercept=false, MsgPostHook post=INVALID_FUNCTION);
217 |
218 | /**
219 | * Removes one usermessage hook.
220 | *
221 | * @param msg_id Message index.
222 | * @param hook Function used for the hook.
223 | * @param intercept Specifies whether the hook was an intercept hook or not.
224 | * @error Invalid message index.
225 | */
226 | native void UnhookUserMessage(UserMsg msg_id, MsgHook hook, bool intercept=false);
227 |
228 | /**
229 | * Starts a usermessage (network message) that broadcasts to all clients.
230 | *
231 | * @note See StartMessage or StartMessageEx().
232 | *
233 | * @param msgname Message name to start.
234 | * @param flags Optional flags to set.
235 | * @return A handle to a bf_write bit packing structure, or
236 | * INVALID_HANDLE on failure.
237 | */
238 | stock Handle StartMessageAll(const char[] msgname, int flags=0)
239 | {
240 | int total = 0;
241 | int[] clients = new int[MaxClients];
242 | for (int i = 1; i <= MaxClients; i++)
243 | {
244 | if (IsClientConnected(i))
245 | {
246 | clients[total++] = i;
247 | }
248 | }
249 |
250 | return StartMessage(msgname, clients, total, flags);
251 | }
252 |
253 | /**
254 | * Starts a simpler usermessage (network message) for one client.
255 | *
256 | * @note See StartMessage or StartMessageEx().
257 | *
258 | * @param msgname Message name to start.
259 | * @param client Client to send to.
260 | * @param flags Optional flags to set.
261 | * @return A handle to a bf_write bit packing structure, or
262 | * INVALID_HANDLE on failure.
263 | */
264 | stock Handle StartMessageOne(const char[] msgname, int client, int flags=0)
265 | {
266 | int players[1];
267 | players[0] = client;
268 |
269 | return StartMessage(msgname, players, 1, flags);
270 | }
271 |
--------------------------------------------------------------------------------
/scripting/include/textparse.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 sw=4 tw=99 noet :
3 | * =============================================================================
4 | * SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _textparse_included
34 | #endinput
35 | #endif
36 | #define _textparse_included
37 |
38 |
39 | /********************************
40 | * Everything below describes the SMC Parse, or "SourceMod Configuration" format.
41 | * This parser is entirely event based. You must hook events to receive data.
42 | * The file format itself is nearly identical to Valve's KeyValues format.
43 | ********************************/
44 |
45 | /**
46 | * Parse result directive.
47 | */
48 | enum SMCResult
49 | {
50 | SMCParse_Continue, /**< Continue parsing */
51 | SMCParse_Halt, /**< Stop parsing here */
52 | SMCParse_HaltFail /**< Stop parsing and return failure */
53 | };
54 |
55 | /**
56 | * Parse error codes.
57 | */
58 | enum SMCError
59 | {
60 | SMCError_Okay = 0, /**< No error */
61 | SMCError_StreamOpen, /**< Stream failed to open */
62 | SMCError_StreamError, /**< The stream died... somehow */
63 | SMCError_Custom, /**< A custom handler threw an error */
64 | SMCError_InvalidSection1, /**< A section was declared without quotes, and had extra tokens */
65 | SMCError_InvalidSection2, /**< A section was declared without any header */
66 | SMCError_InvalidSection3, /**< A section ending was declared with too many unknown tokens */
67 | SMCError_InvalidSection4, /**< A section ending has no matching beginning */
68 | SMCError_InvalidSection5, /**< A section beginning has no matching ending */
69 | SMCError_InvalidTokens, /**< There were too many unidentifiable strings on one line */
70 | SMCError_TokenOverflow, /**< The token buffer overflowed */
71 | SMCError_InvalidProperty1 /**< A property was declared outside of any section */
72 | };
73 |
74 | /**
75 | * Called when parsing is started.
76 | *
77 | * @param smc The SMC Parse Handle.
78 | */
79 | typedef SMC_ParseStart = function void (SMCParser smc);
80 |
81 | /**
82 | * Called when the parser is entering a new section or sub-section.
83 | *
84 | * Note: Enclosing quotes are always stripped.
85 | *
86 | * @param smc The SMC Parser.
87 | * @param name String containing section name.
88 | * @param opt_quotes True if the section name was quote-enclosed in the file.
89 | * @return An SMCResult action to take.
90 | */
91 | typedef SMC_NewSection = function SMCResult (SMCParser smc, const char[] name, bool opt_quotes);
92 |
93 | /**
94 | * Called when the parser finds a new key/value pair.
95 | *
96 | * Note: Enclosing quotes are always stripped.
97 | *
98 | * @param smc The SMCParser.
99 | * @param key String containing key name.
100 | * @param value String containing value name.
101 | * @param key_quotes Whether or not the key was enclosed in quotes.
102 | * @param value_quotes Whether or not the value was enclosed in quotes.
103 | * @return An SMCResult action to take.
104 | */
105 | typedef SMC_KeyValue = function SMCResult (SMCParser smc, const char[] key, const char[] value, bool key_quotes, bool value_quotes);
106 |
107 | /** Called when the parser finds the end of the current section.
108 | *
109 | * @param smc The SMCParser.
110 | * @return An SMCResult action to take.
111 | */
112 | typedef SMC_EndSection = function SMCResult (SMCParser smc);
113 |
114 | /**
115 | * Called when parsing is halted.
116 | *
117 | * @param smc The SMCParser.
118 | * @param halted True if abnormally halted, false otherwise.
119 | * @param failed True if parsing failed, false otherwise.
120 | */
121 | typedef SMC_ParseEnd = function void (SMCParser smc, bool halted, bool failed);
122 |
123 | /**
124 | * Callback for whenever a new line of text is about to be parsed.
125 | *
126 | * @param smc The SMCParser.
127 | * @param line A string containing the raw line from the file.
128 | * @param lineno The line number it occurs on.
129 | * @return An SMCResult action to take.
130 | */
131 | typedef SMC_RawLine = function SMCResult (SMCParser smc, const char[] line, int lineno);
132 |
133 | // An SMCParser is a callback-driven parser for SourceMod configuration files.
134 | // SMC files are similar to Valve KeyValues format, with two key differences:
135 | // (1) SMC cannot handle single-item entries (that is, a key with no value).
136 | // (2) SMC files can have multi-line comment blocks, whereas KeyValues cannot.
137 | methodmap SMCParser < Handle
138 | {
139 | // Create a new SMC file format parser.
140 | public native SMCParser();
141 |
142 | // Parses an SMC file.
143 | //
144 | // @param file A string containing the file path.
145 | // @param line An optional variable to store the last line number read.
146 | // @param col An optional variable to store the last column number read.
147 | // @return An SMCParseError result.
148 | public native SMCError ParseFile(const char[] file, int &line = 0, int &col = 0);
149 |
150 | // Sets the callback for receiving SMC_ParseStart events.
151 | property SMC_ParseStart OnStart {
152 | public native set(SMC_ParseStart func);
153 | }
154 |
155 | // Sets the callback for receiving SMC_ParseEnd events.
156 | property SMC_ParseEnd OnEnd {
157 | public native set(SMC_ParseEnd func);
158 | }
159 |
160 | // Sets the callback for receiving SMC_NewSection events.
161 | property SMC_NewSection OnEnterSection {
162 | public native set(SMC_NewSection func);
163 | }
164 |
165 | // Sets the callback for receiving SMC_EndSection events.
166 | property SMC_EndSection OnLeaveSection {
167 | public native set(SMC_EndSection func);
168 | }
169 |
170 | // Sets the callback for receiving SMC_KeyValue events.
171 | property SMC_KeyValue OnKeyValue {
172 | public native set(SMC_KeyValue func);
173 | }
174 |
175 | // Sets the callback for receiving SMC_RawLine events.
176 | property SMC_RawLine OnRawLine {
177 | public native set(SMC_RawLine func);
178 | }
179 |
180 | // Gets an error string for an SMCError code.
181 | //
182 | // @param error The SMCParseError code.
183 | // @param buffer A string buffer for the error (contents undefined on failure).
184 | // @param buf_max The maximum size of the buffer.
185 | // @return The number of characters written to buffer.
186 | public native void GetErrorString(SMCError error, char[] buffer, int buf_max);
187 | };
188 |
189 | /**
190 | * Creates a new SMC file format parser. This is used to set parse hooks.
191 | *
192 | * @return A new Handle to an SMC Parse structure.
193 | */
194 | native SMCParser SMC_CreateParser();
195 |
196 | /**
197 | * Parses an SMC file.
198 | *
199 | * @param smc A Handle to an SMC Parse structure.
200 | * @param file A string containing the file path.
201 | * @param line An optional by reference cell to store the last line number read.
202 | * @param col An optional by reference cell to store the last column number read.
203 | * @return An SMCParseError result.
204 | * @error Invalid or corrupt Handle.
205 | */
206 | native SMCError SMC_ParseFile(Handle smc, const char[] file, int &line=0, int &col=0);
207 |
208 | /**
209 | * Gets an error string for an SMCError code.
210 | *
211 | * @note SMCError_Okay returns false.
212 | * @note SMCError_Custom (which is thrown on SMCParse_HaltFail) returns false.
213 | *
214 | * @param error The SMCParseError code.
215 | * @param buffer A string buffer for the error (contents undefined on failure).
216 | * @param buf_max The maximum size of the buffer.
217 | * @return True on success, false otherwise.
218 | */
219 | native bool SMC_GetErrorString(SMCError error, char[] buffer, int buf_max);
220 |
221 | /**
222 | * Sets the SMC_ParseStart function of a parse Handle.
223 | *
224 | * @param smc Handle to an SMC Parse.
225 | * @param func SMC_ParseStart function.
226 | * @error Invalid or corrupt Handle.
227 | */
228 | native void SMC_SetParseStart(Handle smc, SMC_ParseStart func);
229 |
230 | /**
231 | * Sets the SMC_ParseEnd of a parse handle.
232 | *
233 | * @param smc Handle to an SMC Parse.
234 | * @param func SMC_ParseEnd function.
235 | * @error Invalid or corrupt Handle.
236 | */
237 | native void SMC_SetParseEnd(Handle smc, SMC_ParseEnd func);
238 |
239 | /**
240 | * Sets the three main reader functions.
241 | *
242 | * @param smc An SMC parse Handle.
243 | * @param ns An SMC_NewSection function pointer.
244 | * @param kv An SMC_KeyValue function pointer.
245 | * @param es An SMC_EndSection function pointer.
246 | */
247 | native void SMC_SetReaders(Handle smc, SMC_NewSection ns, SMC_KeyValue kv, SMC_EndSection es);
248 |
249 | /**
250 | * Sets a raw line reader on an SMC parser Handle.
251 | *
252 | * @param smc Handle to an SMC Parse.
253 | * @param func SMC_RawLine function.
254 | */
255 | native void SMC_SetRawLine(Handle smc, SMC_RawLine func);
256 |
--------------------------------------------------------------------------------
/scripting/include/core.inc:
--------------------------------------------------------------------------------
1 | /**
2 | * vim: set ts=4 sw=4 tw=99 noet:
3 | * =============================================================================
4 | * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 | * =============================================================================
6 | *
7 | * This file is part of the SourceMod/SourcePawn SDK.
8 | *
9 | * This program is free software; you can redistribute it and/or modify it under
10 | * the terms of the GNU General Public License, version 3.0, as published by the
11 | * Free Software Foundation.
12 | *
13 | * This program is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU General Public License along with
19 | * this program. If not, see .
20 | *
21 | * As a special exception, AlliedModders LLC gives you permission to link the
22 | * code of this program (as well as its derivative works) to "Half-Life 2," the
23 | * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 | * by the Valve Corporation. You must obey the GNU General Public License in
25 | * all respects for all other code used. Additionally, AlliedModders LLC grants
26 | * this exception to all derivative works. AlliedModders LLC defines further
27 | * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 | * or .
29 | *
30 | * Version: $Id$
31 | */
32 |
33 | #if defined _core_included
34 | #endinput
35 | #endif
36 | #define _core_included
37 |
38 | #include
39 |
40 | /** If this gets changed, you need to update Core's check. */
41 | #define SOURCEMOD_PLUGINAPI_VERSION 5
42 |
43 | struct PlVers
44 | {
45 | public int version;
46 | public const char[] filevers;
47 | public const char[] date;
48 | public const char[] time;
49 | };
50 |
51 | /**
52 | * Specifies what to do after a hook completes.
53 | */
54 | enum Action
55 | {
56 | Plugin_Continue = 0, /**< Continue with the original action */
57 | Plugin_Changed = 1, /**< Inputs or outputs have been overridden with new values */
58 | Plugin_Handled = 3, /**< Handle the action at the end (don't call it) */
59 | Plugin_Stop = 4 /**< Immediately stop the hook chain and handle the original */
60 | };
61 |
62 | /**
63 | * Specifies identity types.
64 | */
65 | enum Identity
66 | {
67 | Identity_Core = 0,
68 | Identity_Extension = 1,
69 | Identity_Plugin = 2
70 | };
71 |
72 | public PlVers __version =
73 | {
74 | version = SOURCEMOD_PLUGINAPI_VERSION,
75 | filevers = SOURCEMOD_VERSION,
76 | date = __DATE__,
77 | time = __TIME__
78 | };
79 |
80 | /**
81 | * Plugin status values.
82 | */
83 | enum PluginStatus
84 | {
85 | Plugin_Running=0, /**< Plugin is running */
86 | /* All states below are "temporarily" unexecutable */
87 | Plugin_Paused, /**< Plugin is loaded but paused */
88 | Plugin_Error, /**< Plugin is loaded but errored/locked */
89 | /* All states below do not have all natives */
90 | Plugin_Loaded, /**< Plugin has passed loading and can be finalized */
91 | Plugin_Failed, /**< Plugin has a fatal failure */
92 | Plugin_Created, /**< Plugin is created but not initialized */
93 | Plugin_Uncompiled, /**< Plugin is not yet compiled by the JIT */
94 | Plugin_BadLoad, /**< Plugin failed to load */
95 | Plugin_Evicted /**< Plugin was unloaded due to an error */
96 | };
97 |
98 | /**
99 | * Plugin information properties. Plugins can declare a global variable with
100 | * their info. Example,
101 | *
102 | * public Plugin myinfo = {
103 | * name = "Admin Help",
104 | * author = "AlliedModders LLC",
105 | * description = "Display command information",
106 | * version = "1.0",
107 | * url = "http://www.sourcemod.net/"
108 | * };
109 | *
110 | * SourceMod will display this information when a user inspects plugins in the
111 | * console.
112 | */
113 | enum PluginInfo
114 | {
115 | PlInfo_Name, /**< Plugin name */
116 | PlInfo_Author, /**< Plugin author */
117 | PlInfo_Description, /**< Plugin description */
118 | PlInfo_Version, /**< Plugin version */
119 | PlInfo_URL /**< Plugin URL */
120 | };
121 |
122 | /**
123 | * Defines how an extension must expose itself for autoloading.
124 | */
125 | struct Extension
126 | {
127 | public const char[] name; /**< Short name */
128 | public const char[] file; /**< Default file name */
129 | public bool autoload; /**< Whether or not to auto-load */
130 | public bool required; /**< Whether or not to require */
131 | };
132 |
133 | /**
134 | * Defines how a plugin must expose itself for native requiring.
135 | */
136 | struct SharedPlugin
137 | {
138 | public const char[] name; /**< Short name */
139 | public const char[] file; /**< File name */
140 | public bool required; /**< Whether or not to require */
141 | };
142 |
143 | public float NULL_VECTOR[3]; /**< Pass this into certain functions to act as a C++ NULL */
144 | public const char NULL_STRING[1]; /**< pass this into certain functions to act as a C++ NULL */
145 |
146 | /**
147 | * Check if the given vector is the NULL_VECTOR.
148 | *
149 | * @param vec The vector to test.
150 | * @return True if NULL_VECTOR, false otherwise.
151 | */
152 | native bool IsNullVector(const float vec[3]);
153 |
154 | /**
155 | * Check if the given string is the NULL_STRING.
156 | *
157 | * @param str The string to test.
158 | * @return True if NULL_STRING, false otherwise.
159 | */
160 | native bool IsNullString(const char[] str);
161 |
162 | /**
163 | * Horrible compatibility shim.
164 | */
165 | public Extension __ext_core =
166 | {
167 | name = "Core",
168 | file = "core",
169 | autoload = 0,
170 | required = 0,
171 | };
172 |
173 | native int VerifyCoreVersion();
174 |
175 | /**
176 | * Sets a native as optional, such that if it is unloaded, removed,
177 | * or otherwise non-existent, the plugin will still work. Calling
178 | * removed natives results in a run-time error.
179 | *
180 | * @param name Native name.
181 | */
182 | native void MarkNativeAsOptional(const char[] name);
183 |
184 | public void __ext_core_SetNTVOptional()
185 | {
186 | MarkNativeAsOptional("GetFeatureStatus");
187 | MarkNativeAsOptional("RequireFeature");
188 | MarkNativeAsOptional("AddCommandListener");
189 | MarkNativeAsOptional("RemoveCommandListener");
190 |
191 | MarkNativeAsOptional("BfWriteBool");
192 | MarkNativeAsOptional("BfWriteByte");
193 | MarkNativeAsOptional("BfWriteChar");
194 | MarkNativeAsOptional("BfWriteShort");
195 | MarkNativeAsOptional("BfWriteWord");
196 | MarkNativeAsOptional("BfWriteNum");
197 | MarkNativeAsOptional("BfWriteFloat");
198 | MarkNativeAsOptional("BfWriteString");
199 | MarkNativeAsOptional("BfWriteEntity");
200 | MarkNativeAsOptional("BfWriteAngle");
201 | MarkNativeAsOptional("BfWriteCoord");
202 | MarkNativeAsOptional("BfWriteVecCoord");
203 | MarkNativeAsOptional("BfWriteVecNormal");
204 | MarkNativeAsOptional("BfWriteAngles");
205 | MarkNativeAsOptional("BfReadBool");
206 | MarkNativeAsOptional("BfReadByte");
207 | MarkNativeAsOptional("BfReadChar");
208 | MarkNativeAsOptional("BfReadShort");
209 | MarkNativeAsOptional("BfReadWord");
210 | MarkNativeAsOptional("BfReadNum");
211 | MarkNativeAsOptional("BfReadFloat");
212 | MarkNativeAsOptional("BfReadString");
213 | MarkNativeAsOptional("BfReadEntity");
214 | MarkNativeAsOptional("BfReadAngle");
215 | MarkNativeAsOptional("BfReadCoord");
216 | MarkNativeAsOptional("BfReadVecCoord");
217 | MarkNativeAsOptional("BfReadVecNormal");
218 | MarkNativeAsOptional("BfReadAngles");
219 | MarkNativeAsOptional("BfGetNumBytesLeft");
220 |
221 | MarkNativeAsOptional("BfWrite.WriteBool");
222 | MarkNativeAsOptional("BfWrite.WriteByte");
223 | MarkNativeAsOptional("BfWrite.WriteChar");
224 | MarkNativeAsOptional("BfWrite.WriteShort");
225 | MarkNativeAsOptional("BfWrite.WriteWord");
226 | MarkNativeAsOptional("BfWrite.WriteNum");
227 | MarkNativeAsOptional("BfWrite.WriteFloat");
228 | MarkNativeAsOptional("BfWrite.WriteString");
229 | MarkNativeAsOptional("BfWrite.WriteEntity");
230 | MarkNativeAsOptional("BfWrite.WriteAngle");
231 | MarkNativeAsOptional("BfWrite.WriteCoord");
232 | MarkNativeAsOptional("BfWrite.WriteVecCoord");
233 | MarkNativeAsOptional("BfWrite.WriteVecNormal");
234 | MarkNativeAsOptional("BfWrite.WriteAngles");
235 | MarkNativeAsOptional("BfRead.ReadBool");
236 | MarkNativeAsOptional("BfRead.ReadByte");
237 | MarkNativeAsOptional("BfRead.ReadChar");
238 | MarkNativeAsOptional("BfRead.ReadShort");
239 | MarkNativeAsOptional("BfRead.ReadWord");
240 | MarkNativeAsOptional("BfRead.ReadNum");
241 | MarkNativeAsOptional("BfRead.ReadFloat");
242 | MarkNativeAsOptional("BfRead.ReadString");
243 | MarkNativeAsOptional("BfRead.ReadEntity");
244 | MarkNativeAsOptional("BfRead.ReadAngle");
245 | MarkNativeAsOptional("BfRead.ReadCoord");
246 | MarkNativeAsOptional("BfRead.ReadVecCoord");
247 | MarkNativeAsOptional("BfRead.ReadVecNormal");
248 | MarkNativeAsOptional("BfRead.ReadAngles");
249 | MarkNativeAsOptional("BfRead.BytesLeft.get");
250 |
251 | MarkNativeAsOptional("PbReadInt");
252 | MarkNativeAsOptional("PbReadFloat");
253 | MarkNativeAsOptional("PbReadBool");
254 | MarkNativeAsOptional("PbReadString");
255 | MarkNativeAsOptional("PbReadColor");
256 | MarkNativeAsOptional("PbReadAngle");
257 | MarkNativeAsOptional("PbReadVector");
258 | MarkNativeAsOptional("PbReadVector2D");
259 | MarkNativeAsOptional("PbGetRepeatedFieldCount");
260 | MarkNativeAsOptional("PbSetInt");
261 | MarkNativeAsOptional("PbSetFloat");
262 | MarkNativeAsOptional("PbSetBool");
263 | MarkNativeAsOptional("PbSetString");
264 | MarkNativeAsOptional("PbSetColor");
265 | MarkNativeAsOptional("PbSetAngle");
266 | MarkNativeAsOptional("PbSetVector");
267 | MarkNativeAsOptional("PbSetVector2D");
268 | MarkNativeAsOptional("PbAddInt");
269 | MarkNativeAsOptional("PbAddFloat");
270 | MarkNativeAsOptional("PbAddBool");
271 | MarkNativeAsOptional("PbAddString");
272 | MarkNativeAsOptional("PbAddColor");
273 | MarkNativeAsOptional("PbAddAngle");
274 | MarkNativeAsOptional("PbAddVector");
275 | MarkNativeAsOptional("PbAddVector2D");
276 | MarkNativeAsOptional("PbRemoveRepeatedFieldValue");
277 | MarkNativeAsOptional("PbReadMessage");
278 | MarkNativeAsOptional("PbReadRepeatedMessage");
279 | MarkNativeAsOptional("PbAddMessage");
280 |
281 | MarkNativeAsOptional("Protobuf.ReadInt");
282 | MarkNativeAsOptional("Protobuf.ReadInt64");
283 | MarkNativeAsOptional("Protobuf.ReadFloat");
284 | MarkNativeAsOptional("Protobuf.ReadBool");
285 | MarkNativeAsOptional("Protobuf.ReadString");
286 | MarkNativeAsOptional("Protobuf.ReadColor");
287 | MarkNativeAsOptional("Protobuf.ReadAngle");
288 | MarkNativeAsOptional("Protobuf.ReadVector");
289 | MarkNativeAsOptional("Protobuf.ReadVector2D");
290 | MarkNativeAsOptional("Protobuf.GetRepeatedFieldCount");
291 | MarkNativeAsOptional("Protobuf.SetInt");
292 | MarkNativeAsOptional("Protobuf.SetInt64");
293 | MarkNativeAsOptional("Protobuf.SetFloat");
294 | MarkNativeAsOptional("Protobuf.SetBool");
295 | MarkNativeAsOptional("Protobuf.SetString");
296 | MarkNativeAsOptional("Protobuf.SetColor");
297 | MarkNativeAsOptional("Protobuf.SetAngle");
298 | MarkNativeAsOptional("Protobuf.SetVector");
299 | MarkNativeAsOptional("Protobuf.SetVector2D");
300 | MarkNativeAsOptional("Protobuf.AddInt");
301 | MarkNativeAsOptional("Protobuf.AddInt64");
302 | MarkNativeAsOptional("Protobuf.AddFloat");
303 | MarkNativeAsOptional("Protobuf.AddBool");
304 | MarkNativeAsOptional("Protobuf.AddString");
305 | MarkNativeAsOptional("Protobuf.AddColor");
306 | MarkNativeAsOptional("Protobuf.AddAngle");
307 | MarkNativeAsOptional("Protobuf.AddVector");
308 | MarkNativeAsOptional("Protobuf.AddVector2D");
309 | MarkNativeAsOptional("Protobuf.RemoveRepeatedFieldValue");
310 | MarkNativeAsOptional("Protobuf.ReadMessage");
311 | MarkNativeAsOptional("Protobuf.ReadRepeatedMessage");
312 | MarkNativeAsOptional("Protobuf.AddMessage");
313 |
314 | VerifyCoreVersion();
315 | }
316 |
317 |
318 | #define AUTOLOAD_EXTENSIONS
319 | #define REQUIRE_EXTENSIONS
320 | #define REQUIRE_PLUGIN
321 |
--------------------------------------------------------------------------------