Untitled
unknown
c_cpp
4 years ago
3.7 kB
9
Indexable
bool g_bIsVipLoaded[MAXPLAYERS +1] = false; char sVipGroups[][] = {"VIP Silver", "VIP Gold", "VIP Platinum", "VIP BASIC", "VIP PRO", "VIP ULTRA", "VIP Ruby", "VIP Onyx", "VIP Diamond", "VIP ELITE", "Owner"}; enum CompareVipGroups { VIP_GROUP_NOTFOUND = -1, VIP_GROUP_LOWER = 0, VIP_GROUP_HIGHER = 1, VIP_GROUP_EQUAL = 2, } public void VIP_OnClientLoaded(int iClient, bool bIsVIP) { g_bIsVipLoaded[iClient] = true; } public void OnClientDisconnect(int client) { g_bIsVipLoaded[client] = false; } public void OnClientPutInServer(int client) { g_bIsVipLoaded[client] = false; } void AddVip(int client, int time, const char[] szGroup) { if(!g_bIsVipLoaded[client]) { ArrayList data; data = CreateArray(32); data.Push(GetClientUserId(client)); data.Push(time); data.PushString(szGroup); CreateTimer(1.0, Timer_RetryAddVip, data); return; } if(AV_HasAdminVip(client)) { LogToFile(LOGS_PATH, "%L has admin VIP, NOT giving him %s for %d seconds", client, szGroup, time); return; } if(VIP_IsClientVIP(client)) { if(VIP_GetClientID(client) == -1) // if temporary vip { LogToFile(LOGS_PATH, "%L has temporary VIP, giving him %s for %d seconds", client, szGroup, time); VIP_GiveClientVIP(_, client, time, szGroup, true); // seteaza-i VIP return; } if(VIP_GetClientAccessTime(client) == 0) { LogToFile(LOGS_PATH, "%L has permanent vip, returning", client); return; } char sCurrentGroup[32]; VIP_GetClientVIPGroup(client, sCurrentGroup, sizeof(sCurrentGroup)); int iCurrentTime = VIP_GetClientAccessTime(client) - GetTime(); switch(IsGroupHigher(sCurrentGroup, szGroup)) { case VIP_GROUP_EQUAL: { if(iCurrentTime < time) // if his time is lower than newtime, increase it { VIP_SetClientAccessTime(client, GetTime() + time, true); LogToFile(LOGS_PATH, "%L | CASE VIP_GROUP_EQUAL, INCREASING TIME ONLY", client); } return; } case VIP_GROUP_LOWER: { if(iCurrentTime < time) { VIP_SetClientAccessTime(client, GetTime() + time, true); LogToFile(LOGS_PATH, "%L | CASE VIP_GROUP_LOWER with iCurrentTime < newtime, changing his group. New: %s for %d seconds", client, szGroup, time); } LogToFile(LOGS_PATH, "%L | CASE VIP_GROUP_LOWER with iCurrentTime > newtime, changing his group. New: %s for %d seconds", client, szGroup, iCurrentTime); VIP_SetClientVIPGroup(client, szGroup, true); return; } case VIP_GROUP_HIGHER: { if(iCurrentTime < time) { VIP_SetClientAccessTime(client, GetTime() + time, true); LogToFile(LOGS_PATH, "%L | CASE VIP_GROUP_HIGHER with iCurrentTime < newtime, Increasing time to %d seconds", client, time); } return; } case VIP_GROUP_NOTFOUND: { SetFailState("Group %s or %s was not found. Error.", szGroup, sCurrentGroup); } } } else { LogToFile(LOGS_PATH, "%L doesn't have VIP, adding him %s for %d seconds", client, szGroup, time); VIP_GiveClientVIP(_, client, time, szGroup, true); } } public Action Timer_RetryAddVip(Handle timer, ArrayList data) { int client = GetClientUserId(data.Get(0)); if(!IsClientConnected(client)) { delete data; return Plugin_Continue; } char szGroup[32]; data.GetString(2, szGroup, sizeof(szGroup)); AddVip(client, data.Get(1), szGroup); delete data; return Plugin_Continue; }
Editor is loading...