Skip to content

Commit 5edc4f7

Browse files
committed
Review vip_core.inc
1 parent d1637f1 commit 5edc4f7

File tree

9 files changed

+818
-258
lines changed

9 files changed

+818
-258
lines changed

CHANGELOG.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
[x] - Функция переработана и может быть неправельная работа в старых модулях
1111

1212
- Natives:
13-
[-] Native VIP_CheckClient
13+
[+] Native VIP_CheckClient
1414
[+] Native VIP_IsClientVIP
15-
[R] Native VIP_GetClientID
15+
[+] Native VIP_GetClientID
1616
[R] Native VIP_GetClientAccessTime
1717
[R] Native VIP_SetClientAccessTime
1818
[x] Native VIP_GetClientVIPGroup
1919
[R] Native VIP_SetClientVIPGroup
2020
[+] Native VIP_IsGroupExists
2121
[+] Native VIP_IsValidVIPGroup
22-
[-] Native VIP_AddGroup
23-
[-] Native VIP_RemoveGroup
24-
[-] Native VIP_PrintToChatClient
25-
[-] Native VIP_PrintToChatAll
22+
[+] Native VIP_AddGroup
23+
[+] Native VIP_RemoveGroup
24+
[+] Native VIP_PrintToChatClient
25+
[+] Native VIP_PrintToChatAll
2626
[+] Native VIP_LogMessage
2727
[+] Native VIP_SendClientVIPMenu
2828
[R] Native VIP_GiveClientVIP
@@ -52,8 +52,8 @@
5252
[+] Native VIP_GetClientStorageValue
5353
[+] Native VIP_GetDatabase
5454
[+] Native VIP_GetDatabaseType
55-
[-] Native VIP_TimeToSeconds
56-
[-] Native VIP_SecondsToTime
55+
[+] Native VIP_TimeToSeconds
56+
[+] Native VIP_SecondsToTime
5757
[+] Native VIP_GetTimeFromStamp
5858
[-] Native VIP_AddStringToggleStatus
5959
[N] Native VIP_GiveClientGroup
@@ -73,10 +73,10 @@
7373
[R] Forward VIP_OnClientStorageLoaded
7474
[+] Forward VIP_OnFeatureToggle
7575
[+] Forward VIP_OnVIPLoaded
76-
[-] Forward VIP_OnConfigsLoaded
76+
[+] Forward VIP_OnConfigsLoaded
7777
[+] Forward VIP_OnFeatureRegistered
7878
[+] Forward VIP_OnFeatureUnregistered
79-
[-] Forward VIP_OnClientPreLoad
79+
[+] Forward VIP_OnClientPreLoad
8080
[+] Forward VIP_OnClientLoaded // Гарантирует загрузку Storage - VIP_OnClientStorageLoaded
8181
[+] Forward VIP_OnVIPClientLoaded
8282
[+] Forward VIP_OnClientDisconnect

data/vip/cfg/groups.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Все параметры перечисленные после extend будут иметь 0 приоритет
1111
Если вы задаёте кастомное значение параметра игроку, оно будет иметь наивысшый приоритет
1212
*/
13+
1314
// Опции (основные VIP-модули) | Options (VIP Core Modules)
1415
"hp" "150"
1516
"money" "50"

scripting/VIP-Core.sp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ DBG_Level g_iDBGLevel = DBG_SQL;
4040
#include "VIP-Core/Downloads.sp"
4141
#include "VIP-Core/Sounds.sp"
4242
//#include "VIP-Core/Info.sp"
43-
//#include "VIP-Core/Colors.sp"
43+
#include "VIP-Core/Colors.sp"
4444
#include "VIP-Core/UTIL.sp"
4545
#include "VIP-Core/API.sp"
4646
#include "VIP-Core/menus/MainMenu.sp"

scripting/VIP-Core/API.sp

Lines changed: 105 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -39,37 +39,6 @@ void API_SetupForwards()
3939
g_hGlobalForward_OnRemoveGroup = CreateGlobalForward("VIP_OnRemoveGroup", ET_Ignore, Param_String);
4040
}
4141

42-
void CallForward_OnConfigsLoaded()
43-
{
44-
Call_StartForward(g_hGlobalForward_OnConfigsLoaded);
45-
Call_Finish();
46-
}
47-
48-
void CallForward_OnAddGroup(char[] sGroup)
49-
{
50-
Call_StartForward(g_hGlobalForward_OnAddGroup);
51-
Call_PushString(sGroup);
52-
Call_Finish();
53-
}
54-
55-
void CallForward_OnRemoveGroup(char[] sGroup)
56-
{
57-
Call_StartForward(g_hGlobalForward_OnRemoveGroup);
58-
Call_PushString(sGroup);
59-
Call_Finish();
60-
}
61-
62-
63-
bool CallForward_OnClientPreLoad(int iClient)
64-
{
65-
bool bResult = true;
66-
Call_StartForward(g_hGlobalForward_OnClientPreLoad);
67-
Call_PushCell(iClient);
68-
Call_Finish(bResult);
69-
70-
return bResult;
71-
}
72-
7342
public APLRes AskPluginLoad2(Handle myself, bool bLate, char[] szError, int err_max)
7443
{
7544
g_eServerData.Engine = GetEngineVersion();
@@ -103,8 +72,9 @@ public APLRes AskPluginLoad2(Handle myself, bool bLate, char[] szError, int err_
10372

10473

10574
// Clients
106-
//RegNative(CheckClient);
10775
RegNative(IsClientVIP);
76+
RegNative(GetClientID);
77+
RegNative(CheckClient);
10878

10979
RegNative(GetClientGroupName);
11080
RegNative(GetClientGroupExpire);
@@ -134,19 +104,50 @@ public APLRes AskPluginLoad2(Handle myself, bool bLate, char[] szError, int err_
134104
RegNative(GetClientStorageValue);
135105

136106
// Helpers
137-
RegNative(GetTimeFromStamp);
138107
RegNative(LogMessage);
139-
//RegNative(PrintToChatClient);
140-
//RegNative(PrintToChatAll);
108+
RegNative(PrintToChatClient);
109+
RegNative(PrintToChatAll);
141110
//RegNative(AddStringToggleStatus);
142-
//RegNative(TimeToSeconds);
143-
//RegNative(SecondsToTime);
111+
RegNative(GetTimeFromStamp);
112+
RegNative(TimeToSeconds);
113+
RegNative(SecondsToTime);
144114

145115
RegPluginLibrary("vip_core");
146116

147117
return APLRes_Success;
148118
}
149119

120+
void CallForward_OnConfigsLoaded()
121+
{
122+
Call_StartForward(g_hGlobalForward_OnConfigsLoaded);
123+
Call_Finish();
124+
}
125+
126+
void CallForward_OnAddGroup(char[] sGroup)
127+
{
128+
Call_StartForward(g_hGlobalForward_OnAddGroup);
129+
Call_PushString(sGroup);
130+
Call_Finish();
131+
}
132+
133+
void CallForward_OnRemoveGroup(char[] sGroup)
134+
{
135+
Call_StartForward(g_hGlobalForward_OnRemoveGroup);
136+
Call_PushString(sGroup);
137+
Call_Finish();
138+
}
139+
140+
141+
bool CallForward_OnClientPreLoad(int iClient)
142+
{
143+
bool bResult = true;
144+
Call_StartForward(g_hGlobalForward_OnClientPreLoad);
145+
Call_PushCell(iClient);
146+
Call_Finish(bResult);
147+
148+
return bResult;
149+
}
150+
150151
void CallForward_OnClientLoaded(int iClient)
151152
{
152153
Call_StartForward(g_hGlobalForward_OnClientLoaded);
@@ -291,6 +292,26 @@ bool Function_OnItemSelect(Handle hPlugin, Function FuncSelect, int iClient, con
291292
return bResult;
292293
}
293294

295+
public int Native_GetClientID(Handle hPlugin, int iNumParams)
296+
{
297+
int iClient = GetNativeCell(1);
298+
if (CheckValidClient(iClient, false))
299+
{
300+
return g_ePlayerData[iClient].AccountID;
301+
}
302+
303+
return 0;
304+
}
305+
306+
public int Native_CheckClient(Handle hPlugin, int iNumParams)
307+
{
308+
int iClient = GetNativeCell(1);
309+
310+
g_ePlayerData[iClient].RebuildFeatureList();
311+
312+
return 1;
313+
}
314+
294315
public int Native_FillArrayByGroups(Handle hPlugin, int iNumParams)
295316
{
296317
ArrayList hArray = view_as<ArrayList>(GetNativeCell(1));
@@ -372,6 +393,8 @@ public int Native_GroupAddFeature(Handle hPlugin, int iNumParams)
372393
hGroup.AddFeature(sFeature, sValue);
373394

374395
g_hGroups.SetArray(iIndex, hGroup, sizeof(hGroup));
396+
397+
RebuildFeatureList();
375398

376399
return 1;
377400
}
@@ -395,6 +418,8 @@ public int Native_GroupRemoveFeature(Handle hPlugin, int iNumParams)
395418
hGroup.DelFeature(sFeature);
396419

397420
g_hGroups.SetArray(iIndex, hGroup, sizeof(hGroup));
421+
422+
RebuildFeatureList();
398423

399424
return 1;
400425
}
@@ -1032,6 +1057,49 @@ public int Native_LogMessage(Handle hPlugin, int iNumParams)
10321057
return 0;
10331058
}
10341059

1060+
public int Native_PrintToChatClient(Handle hPlugin, int iNumParams)
1061+
{
1062+
int iClient = GetNativeCell(1);
1063+
1064+
if (CheckValidClient(iClient, false))
1065+
{
1066+
char szMessage[PLATFORM_MAX_PATH];
1067+
SetGlobalTransTarget(iClient);
1068+
FormatNativeString(0, 2, 3, sizeof(szMessage), _, szMessage);
1069+
1070+
Colors_Print(iClient, szMessage);
1071+
}
1072+
1073+
return 0;
1074+
}
1075+
1076+
public int Native_PrintToChatAll(Handle hPlugin, int iNumParams)
1077+
{
1078+
char szMessage[PLATFORM_MAX_PATH];
1079+
1080+
for (int i = 1; i <= MaxClients; ++i)
1081+
{
1082+
if (IsClientInGame(i) && !IsFakeClient(i))
1083+
{
1084+
SetGlobalTransTarget(i);
1085+
FormatNativeString(0, 1, 2, sizeof(szMessage), _, szMessage);
1086+
Colors_Print(i, szMessage);
1087+
}
1088+
}
1089+
1090+
return 0;
1091+
}
1092+
1093+
public int Native_TimeToSeconds(Handle hPlugin, int iNumParams)
1094+
{
1095+
return UTIL_TimeToSeconds(GetNativeCell(1));
1096+
}
1097+
1098+
public int Native_SecondsToTime(Handle hPlugin, int iNumParams)
1099+
{
1100+
return UTIL_SecondsToTime(GetNativeCell(1));
1101+
}
1102+
10351103
bool CheckValidClient(const int &iClient, bool bCheckVIP = true)
10361104
{
10371105
if (iClient < 1 || iClient > MaxClients)

0 commit comments

Comments
 (0)