Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
## Layout
- `scripting/VIP_Core.sp` — entry point; `#include`s every `vip/*.sp` into ONE compilation unit (order matters: Global → Debug → ... → API → CMD → Clients). New file = add `#include` there.
- Compile-time switches in `VIP_Core.sp`: `DEBUG_MODE`, `USE_ADMINMENU` (gates `AdminMenu.sp` + `vip/adminmenu/*`), `USE_MORE_SERVERS`, `USE_CLIENTPREFS` (toggle statuses in cookies vs `vip_storage`; status I/O only via `Features_GetSavedStatus`/`Features_SaveStatus`).
- `vip/Global.sp` — all globals, macros (`SZF`, `UID/CID`, `SET_BIT/UNSET_BIT`), client flag bits (`IS_VIP`, `IS_LOADED`, ...), core state bits (`IS_STARTED`, `IS_MySQL`, `IS_LOADING`).
- `vip/Global.sp` — all globals, macros (`SZF`, `UID/CID`), feature registry (`Feature` in `g_hFeatureRegistry`), per-player state (`PlayerData g_ePlayer[]`), server state (`g_bStarted`, `g_bMySQL`, `g_bConnecting`).
- `vip/API.sp` — forwards (`API_SetupForwards`, `CreateForward_*`) and natives (`AskPluginLoad2`, `RegNative(X)` → `VIP_X` bound to `Native_X`).
- `vip/Database.sp` — connection, schema, queries. `UTIL.sp` — shared helpers; check here before writing new ones. `Clients.sp` — client load/unload lifecycle, spawn. `Features.sp` — feature registry.
- `include/vip_core.inc` — PUBLIC API for third-party modules. `data/vip/cfg/*.ini` — runtime configs (groups, info, sort_menu, times). `translations/vip_core.phrases.txt` — all user-facing strings.
Expand Down Expand Up @@ -44,7 +44,6 @@

## Conventions
- Pass client across async boundaries as userid (`UID`/`CID`), never raw index.
- `GLOBAL_TRIE` / `GLOBAL_INFO` are index `[0]` of per-client arrays — slot 0 = global, not a player.
- Use methodmaps (`StringMap`, `Cookie`, `KeyValues`, `delete`), not legacy procedural calls (`CreateTrie`, `SetClientCookie`, `CloseHandle`, `Kv*`).
- Debug logging via `DBG_*` / `DebugMessage` functions from `Debug.sp` (empty unless `DEBUG_MODE 1`); calls still need a trailing `;`.
- English only in code, comments, cvar descriptions, log/error strings and docs. Other languages live only in `translations/*.phrases.txt` and the per-language values of `data/vip/cfg/*.ini`. Any new user-facing text → new phrase in `vip_core.phrases.txt` with at least `en` and `ru`. Bump `VIP_VERSION` in `VIP_Core.sp` only when asked; changelog lives in `updates.md`.
- English only in code, comments, cvar descriptions, log/error strings and docs. Other languages live only in `translations/*.phrases.txt` and the per-language values of `data/vip/cfg/*.ini`. Any new user-facing text → new phrase in `vip_core.phrases.txt` with at least `en` and `ru`. Bump `VIP_VERSION` in `VIP_Core.sp` only when asked; changelog lives in GitHub Releases (release notes).
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ The plugin is very flexible and easy to configure, it can work with both SQLite
### Guides
- [Module update guide](docs/update_modules.md)
- [Issue labels](docs/issue_labels.md)
- [Changelog](updates.md)
- [Changelog](https://github.com/R1KO/VIP-Core/releases)
12 changes: 2 additions & 10 deletions addons/sourcemod/scripting/VIP_Core.sp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <clientprefs>

#if !defined VIP_VERSION
#define VIP_VERSION "3.1.0 R"
#define VIP_VERSION "3.1.1 R"
#endif


Expand Down Expand Up @@ -67,15 +67,7 @@ public void OnPluginStart()

g_iMaxPageItems = GetMaxPageItems(GetMenuStyleHandle(MenuStyle_Default));
g_hFeaturesArray = new ArrayList(ByteCountToCells(FEATURE_NAME_LENGTH));
GLOBAL_TRIE = new StringMap();

// Fix DataPack positions in sm 1.10
DataPack hDataPack = new DataPack();
hDataPack.WriteCell(0);
ITEM_DISPLAY = hDataPack.Position;
hDataPack.WriteCell(0);
ITEM_DRAW = hDataPack.Position;
delete hDataPack;
g_hFeatureRegistry = new StringMap();

API_SetupForwards();
ReadConfigs();
Expand Down
27 changes: 20 additions & 7 deletions addons/sourcemod/scripting/include/vip_core.inc
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ forward void VIP_OnClientDisconnect(int iClient, bool bIsVIP);
* Called when a player receives VIP status.
*
* @param iClient Client index.
* @param iAdmin Admin index (0 - server).
* @param iAdmin Who gave it: admin index (> 0), 0 - server,
* -1 - admin who left before the database answered,
* -2 - plugin (VIP_GiveClientVIP).
* Check iAdmin > 0 before using it as a client index.
*
* @noreturn
*/
Expand All @@ -231,8 +234,12 @@ forward void VIP_OnVIPClientAdded(int iClient, int iAdmin);
* @param szReason Reason:
* "Expired" - Expired;
* "Removed by Admin" - Removed by an admin;
* "Removed by native" - Removed by a native.
* @param iAdmin Admin index (0 - server).
* "VIP-Group Changed" - Group changed by an admin;
* "Removed for VIP-status change" - VIP given again via VIP_GiveClientVIP;
* "Removed by <plugin name>" - Removed via VIP_RemoveClientVIP2.
* @param iAdmin Who removed it: admin index (> 0), 0 - server (expiry),
* -2 - plugin.
* Check iAdmin > 0 before using it as a client index.
*
* @noreturn
*/
Expand Down Expand Up @@ -384,6 +391,8 @@ native void VIP_GetClientStorageValue(int iClient, const char[] szKey, char[] sz

/**
* Prints a chat message to a player with a prefix (translation phrase "VIP_CHAT_PREFIX").
* A line break ("\n" or the two characters \n, e.g. from a translation) starts a new chat message;
* each line holds up to about 250 bytes, the whole message up to 1024.
*
* @param iClient Client index.
* @param szMessage Formatting rules.
Expand All @@ -395,6 +404,8 @@ native void VIP_PrintToChatClient(int iClient, const char[] szMessage, any ...);

/**
* Prints a chat message to all players with a prefix (translation phrase "VIP_CHAT_PREFIX").
* A line break ("\n" or the two characters \n, e.g. from a translation) starts a new chat message;
* each line holds up to about 250 bytes, the whole message up to 1024.
*
* @param szMessage Formatting rules.
* @param ... Formatting parameters.
Expand Down Expand Up @@ -428,31 +439,33 @@ native void VIP_SendClientVIPMenu(int iClient, bool bSelection = false);
/**
* Gives VIP rights to a player.
*
* @param iAdmin Admin index (0 - server, -1 or any negative - plugin).
* @param iAdmin Admin index, 0 - server, -1 or any negative - plugin (default).
* Logged as "by server" / "by plugin <name>" / "by admin <name>".
* @param iClient Client index.
* @param iTime Time in seconds.
* @param szGroup VIP group name.
* @param bAddToDB Whether to add to the database.
*
* @noreturn
*/
native void VIP_GiveClientVIP(int iAdmin = 0, int iClient, int iTime, const char[] szGroup, bool bAddToDB = true);
native void VIP_GiveClientVIP(int iAdmin = -1, int iClient, int iTime, const char[] szGroup, bool bAddToDB = true);

#pragma deprecated Use VIP_GiveClientVIP() instead
native bool VIP_SetClientVIP(int iClient, int iTime, any AuthType, const char[] szGroup, bool bAddToDB = true);

/**
* Removes VIP rights from a player.
*
* @param iAdmin Admin index (0 - server, -1 or any negative - plugin).
* @param iAdmin Admin index, 0 - server, -1 or any negative - plugin (default).
* Logged as "by server" / "by plugin <name>" / "by admin <name>".
* @param iClient Client index.
* @param bInDB Whether to remove from the database.
* @param bNotify Player notification (true - notify / false - do not notify).
*
* @return true - on success.
* false - on failure.
*/
native bool VIP_RemoveClientVIP2(int iAdmin = 0, int iClient, bool bInDB, bool bNotify);
native bool VIP_RemoveClientVIP2(int iAdmin = -1, int iClient, bool bInDB, bool bNotify);

#pragma deprecated Use VIP_RemoveClientVIP2() instead
native bool VIP_RemoveClientVIP(int iClient, bool bInDB, bool bNotify);
Expand Down
Loading
Loading