Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions addons/sourcemod/data/vip/cfg/groups.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"VIP_GROUPS"
{
"vip1" // Имя группы
{
// Параметры

}

"vip2" // Имя группы
{
// Параметры

}
}
Empty file.
38 changes: 38 additions & 0 deletions addons/sourcemod/data/vip/cfg/times.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"TIMES"
{
"0" // Время в секундах
{
"ru" "Навсегда" // Отображение в меню
"en" "Permanent" // Отображение в меню
}

"3600"
{
"ru" "1 Час"
"en" "1 Hour"
}

"86400"
{
"ru" "1 Сутки"
"en" "1 Day"
}

"604800"
{
"ru" "1 Неделя"
"en" "1 Week"
}

"2592000"
{
"ru" "1 Месяц"
"en" "1 Month"
}

"15552000"
{
"ru" "6 Месяцев"
"en" "6 Months"
}
}
10 changes: 9 additions & 1 deletion addons/sourcemod/scripting/VIP_Core.sp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
#include <vip_core>
#include <clientprefs>

#define VIP_VERSION "3.0.1 R"
#if defined VIP_CORE_VERSION
#define VIP_VERSION VIP_CORE_VERSION
#else
#define VIP_VERSION "3.1 DEV"
#endif

#define DEBUG_MODE 0 // Режим отладки

Expand Down Expand Up @@ -82,6 +86,10 @@ public void OnPluginStart()
ITEM_DRAW = hDataPack.Position;
delete hDataPack;


g_bIsTranslationPhraseExistsAvailable = (CanTestFeatures() &&
GetFeatureStatus(FeatureType_Native, "TranslationPhraseExists") == FeatureStatus_Available);

ReadConfigs();

VIPMenu_Setup();
Expand Down
23 changes: 18 additions & 5 deletions addons/sourcemod/scripting/include/vip_core.inc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ forward void VIP_OnFeatureUnregistered(const char[] szFeature);
*
* @param iClient Индекс игрока.
*

* @return true - продолжить.
* false - не выполнять проверку.
*/
Expand Down Expand Up @@ -198,7 +197,7 @@ forward void VIP_OnClientDisconnect(int iClient, bool bIsVIP);
* Вызывается когда игрок получает VIP-статус.
*
* @param iClient Индекс игрока.
* @param iAdmin Индекс админа (0 - сервер).
* @param iAdmin Индекс админа (0 - сервер, -1 - плагин).
*
* @noreturn
*/
Expand All @@ -212,7 +211,7 @@ forward void VIP_OnVIPClientAdded(int iClient, int iAdmin);
* "Expired" - Истек;
* "Removed by Admin" - Удален админом;
* "Removed by native" - Удален нативом.
* @param iAdmin Индекс админа (0 - сервер).
* @param iAdmin Индекс админа (0 - сервер, -1 - плагин).
*
* @noreturn
*/
Expand Down Expand Up @@ -366,7 +365,7 @@ native void VIP_SendClientVIPMenu(int iClient, bool bSelection = false);
*
* @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);
Expand All @@ -382,7 +381,7 @@ native bool VIP_SetClientVIP(int iClient, int iTime, any AuthType, const char[]
* @return true - Успешно.
* false - Не удалось выполнить.
*/
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 Expand Up @@ -642,6 +641,20 @@ native bool VIP_GetTimeFromStamp(char[] szBuffer, int iMaxLength, int iTimeStamp
*/
native void VIP_AddStringToggleStatus(const char[] szInput, char[] szBuffer, int iMaxLength, const char[] szFeature, int iClient);

/**
* Формирует путь к файлу с настройками модуля.
*
* @param szBuffer Буфер, в который будет помещен результат.
* @param iMaxLength Размер буфера.
* @param szFileName Имя файла.
*
* @noreturn
*/
stock void VIP_BuildModulesPath(char[] szBuffer, int iMaxLen, const char[] szFileName)
{
BuildPath(Path_SM, szBuffer, iMaxLen, "data/vip/modules/%s", szFileName);
}

public SharedPlugin __pl_vip_core=
{
name = "vip_core",
Expand Down
49 changes: 25 additions & 24 deletions addons/sourcemod/scripting/vip/API.sp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

static Handle g_hGlobalForward_OnVIPLoaded;
static Handle g_hGlobalForward_OnClientPreLoad;
static Handle g_hGlobalForward_OnClientLoaded;
Expand Down Expand Up @@ -75,7 +74,7 @@ void CreateForward_OnClientDisconnect(int iClient)
Call_Finish();
}

void CreateForward_OnVIPClientAdded(int iClient, int iAdmin = 0)
void CreateForward_OnVIPClientAdded(int iClient, int iAdmin = OWNER_PLUGIN)
{
DBG_API("CreateForward_OnVIPClientAdded(%N (%d), %d)", iClient, iClient, iAdmin)
Call_StartForward(g_hGlobalForward_OnVIPClientAdded);
Expand All @@ -84,7 +83,7 @@ void CreateForward_OnVIPClientAdded(int iClient, int iAdmin = 0)
Call_Finish();
}

void CreateForward_OnVIPClientRemoved(int iClient, const char[] sReason, int iAdmin = 0)
void CreateForward_OnVIPClientRemoved(int iClient, const char[] sReason, int iAdmin = OWNER_PLUGIN)
{
DBG_API("CreateForward_OnVIPClientRemoved(%N (%d), %d, '%s')", iClient, iClient, iAdmin, sReason)
Call_StartForward(g_hGlobalForward_OnVIPClientRemoved);
Expand Down Expand Up @@ -114,7 +113,7 @@ Action CreateForward_OnShowClientInfo(int iClient, const char[] szEvent, const c
Call_PushString(szType);
Call_PushCell(hKeyValues);
Call_Finish(eResult);
DBG_API("CreateForward_OnShowClientInfo = %b", eResult)
DBG_API("CreateForward_OnShowClientInfo = %d", eResult)

return eResult;
}
Expand Down Expand Up @@ -568,7 +567,7 @@ public int Native_SetClientVIP(Handle hPlugin, int iNumParams)
char szGroup[64];
GetNativeString(4, SZF(szGroup));

return API_GiveClientVIP(hPlugin, REASON_PLUGIN, iClient, iTime, szGroup, bAddToDB);
return API_GiveClientVIP(hPlugin, OWNER_PLUGIN, iClient, iTime, szGroup, bAddToDB);
}

int API_GiveClientVIP(Handle hPlugin,
Expand Down Expand Up @@ -682,7 +681,7 @@ int API_RemoveClientVIP(Handle hPlugin,
int iClientID;
if (g_hFeatures[iClient].GetValue(KEY_CID, iClientID) && iClientID != -1)
{
DB_RemoveClientFromID(REASON_PLUGIN, iClient, _, true, _, _, szPluginName);
DB_RemoveClientFromID(OWNER_PLUGIN, iClient, _, true, _, _, szPluginName);
}
}

Expand Down Expand Up @@ -825,28 +824,30 @@ public int Native_UnregisterFeature(Handle hPlugin, int iNumParams)
public int Native_UnregisterMe(Handle hPlugin, int iNumParams)
{
DebugMessage("FeaturesArraySize: %d", g_hFeaturesArray.Length)
if (g_hFeaturesArray.Length > 0)
if (!g_hFeaturesArray.Length)
{
char szFeature[FEATURE_NAME_LENGTH];
ArrayList hArray;
return 0;
}

for (int i = 0, iSize = g_hFeaturesArray.Length; i < iSize; ++i)
{
g_hFeaturesArray.GetString(i, SZF(szFeature));
char szFeature[FEATURE_NAME_LENGTH];
ArrayList hArray;

for (int i = 0, iSize = g_hFeaturesArray.Length; i < iSize; ++i)
{
g_hFeaturesArray.GetString(i, SZF(szFeature));

if (GLOBAL_TRIE.GetValue(szFeature, hArray))
if (GLOBAL_TRIE.GetValue(szFeature, hArray))
{
if (view_as<Handle>(hArray.Get(FEATURES_PLUGIN)) != hPlugin)
{
if (view_as<Handle>(hArray.Get(FEATURES_PLUGIN)) != hPlugin)
{
continue;
}
continue;
}

UnregisterFeature(szFeature, hArray);
UnregisterFeature(szFeature, hArray);

g_hFeaturesArray.Erase(i);
--i;
--iSize;
}
g_hFeaturesArray.Erase(i);
--i;
--iSize;
}
}

Expand Down Expand Up @@ -888,7 +889,7 @@ void UnregisterFeature(const char[] szFeature, ArrayList hArray)
g_hVIPMenu.AddItem("NO_FEATURES", "NO_FEATURES", ITEMDRAW_DISABLED);
}
}

for (int j = 1; j <= MaxClients; ++j)
{
if (IsClientInGame(j) && g_iClientInfo[j] & IS_VIP)
Expand Down Expand Up @@ -1227,7 +1228,7 @@ public int Native_GetTimeFromStamp(Handle hPlugin, int iNumParams)
if (iTimeStamp > 0)
{
int iClient = GetNativeCell(4);
if (iClient == 0 || CheckValidClient(iClient, false))
if (iClient == LANG_SERVER || CheckValidClient(iClient, false))
{
char szBuffer[64];
UTIL_GetTimeFromStamp(SZF(szBuffer), iTimeStamp, iClient);
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/vip/AdminMenu.sp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void ShowTimeMenu(int iClient)

if (iMenuType != TIME_SET && szTime[0] == '0') continue;

hKv.GetString(szClientLang, SZF(szBuffer), "LangError");
hKv.GetString(szClientLang, SZF(szBuffer));
if (!szBuffer[0])
{
hKv.GetString(szServerLang, SZF(szBuffer), "LangError");
Expand Down
1 change: 0 additions & 1 deletion addons/sourcemod/scripting/vip/CMD.sp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

void CMD_Setup()
{
RegConsoleCmd("sm_refresh_vips", ReloadVIPPlayers_CMD);
Expand Down
6 changes: 6 additions & 0 deletions addons/sourcemod/scripting/vip/Features.sp
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

bool IsValidFeature(const char[] szFeature)
{
DebugMessage("IsValidFeature:: FindStringInArray -> %i", g_hFeaturesArray.FindString(szFeature))
return (g_hFeaturesArray.FindString(szFeature) != -1);
}

void Features_TurnOffAll(int iClient)
{
DebugMessage("Features_TurnOffAll %N (%i)", iClient, iClient)
Expand Down
5 changes: 5 additions & 0 deletions addons/sourcemod/scripting/vip/Global.sp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#define REASON_EXPIRED -2
#define REASON_OUTDATED -3


#define OWNER_SERVER 0
#define OWNER_PLUGIN -1

char KEY_CID[] = "Core->ClientID";
char KEY_EXPIRES[] = "Core->Expires";
char KEY_GROUP[] = "Core->Group";
Expand Down Expand Up @@ -118,6 +122,7 @@ bool g_CVAR_bDefaultStatus;
bool g_CVAR_bLogsEnable;

EngineVersion g_EngineVersion;
bool g_bIsTranslationPhraseExistsAvailable;

char g_szSID[64];

Expand Down
16 changes: 6 additions & 10 deletions addons/sourcemod/scripting/vip/UTIL.sp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@


int GET_UID(int iClient)
{
return iClient > 0 ? UID(iClient):iClient;
Expand Down Expand Up @@ -36,7 +35,7 @@ stock int UTIL_ReplaceChars(char[] szBuffer, int InChar, int OutChar)
if (szBuffer[i] == InChar)
{
szBuffer[i] = OutChar;
iNum++;
++iNum;
}
}

Expand All @@ -48,13 +47,10 @@ bool UTIL_StrCmpEx(const char[] szString1, const char[] szString2)
int iLen = strlen(szString1);
if (iLen != strlen(szString2))
{
// i don't see any reason, why we should compare strings,
// if length is different because this fact means: they
// different too.
return false;
}

for (int i = 0; i < iLen; i++)
for (int i = 0; i < iLen; ++i)
{
if (szString1[i] != szString2[i])
{
Expand Down Expand Up @@ -256,7 +252,7 @@ void UTIL_ReloadVIPPlayers(int iClient, bool bNotify)
}
}
/*
void UTIL_REM_VIP_PLAYER(int iClient = 0, int iTarget = 0, int iAccID = 0, int iClientID, const char[] szReason)
void UTIL_REM_VIP_PLAYER(int iClient = OWNER_SERVER, int iTarget = 0, int iAccID = 0, int iClientID, const char[] szReason)
{
if (g_CVAR_bLogsEnable)
{
Expand Down Expand Up @@ -297,7 +293,7 @@ void UTIL_Reply(int iClient, const char[] szMsg, any ...)
}
}

void UTIL_ADD_VIP_PLAYER(int iAdmin = 0,
void UTIL_ADD_VIP_PLAYER(int iAdmin = OWNER_SERVER,
int iTarget = 0,
int iAccID = 0,
int iDuration,
Expand Down Expand Up @@ -338,11 +334,11 @@ void UTIL_ADD_VIP_PLAYER(int iAdmin = 0,

switch(iAdmin)
{
case REASON_PLUGIN:
case OWNER_PLUGIN:
{
FormatEx(SZF(szAdmin), "%T %s", "BY_PLUGIN", LANG_SERVER, szByWho);
}
case 0:
case OWNER_SERVER:
{
FormatEx(SZF(szAdmin), "%T", "BY_SERVER", LANG_SERVER);
}
Expand Down
Loading