· 8 years ago · Jul 01, 2018, 01:22 PM
1/*
2 * CSGO VIP System Plugin
3 * Required: Mysql\SQL Database, Simple Chat Proccesor, SourceMod.
4 * Version: 3.7
5 * Author: S4muRaY'(BraveFox)
6 * Remake of my old system https://forums.alliedmods.net/showthread.php?p=2541503
7*/
8//Includes
9#include <sourcemod>
10#include <cstrike>
11#include <clientprefs>
12#include <sdktools>
13#include <scp>
14#include <csgovip>
15#define prefix " \x07[VIP]\x03 "
16//Database
17Database DB = null;
18//Handles
19Handle g_hVIPTag = INVALID_HANDLE, g_hVIPClanTag = INVALID_HANDLE, g_hVIPTagColor = INVALID_HANDLE, g_hVIPNameColor = INVALID_HANDLE, g_hVIPChatColor = INVALID_HANDLE, g_hEnabled = INVALID_HANDLE, g_hSkins = INVALID_HANDLE, g_hHealth = INVALID_HANDLE, g_hDefuse = INVALID_HANDLE, g_hArmor = INVALID_HANDLE, g_hHealthAmount = INVALID_HANDLE;
20//Chars
21char sModel[512][512], sName[512][512], g_sBlockedTags[512][512];
22//Bools
23bool g_bEnabled = true;
24bool g_bSkins = true;
25bool g_bHP = true;
26bool g_bDefuse = true;
27bool g_bFullArmor = true;
28//Client's Chars
29char g_sClanTag[MAXPLAYERS + 1][512];
30char g_sChatColor[MAXPLAYERS + 1][512];
31char g_sNameColor[MAXPLAYERS + 1][512];
32char g_sTagColor[MAXPLAYERS + 1][512];
33char g_sTag[MAXPLAYERS + 1][512];
34char g_sClientSkin[MAXPLAYERS + 1][512];
35//Client's Bools
36bool g_bIsClientVIP[MAXPLAYERS + 1] = false;
37bool g_bArmor[MAXPLAYERS + 1] = false;
38bool g_bIsTypingTag[MAXPLAYERS + 1] = false;
39bool g_bIsTypingClanTag[MAXPLAYERS + 1] = false;
40bool g_bHealth[MAXPLAYERS + 1] = false;
41bool g_bDefusekit[MAXPLAYERS + 1] = false;
42//Client's Integers
43int g_iTimeLeft[MAXPLAYERS + 1] = 0;
44//Integer
45int g_iSkins;
46int g_iRounds = 0;
47int g_iBlockedTags = 0;
48int g_iHealthBonus = 1;
49// extra pénznek
50new g_iAccount = -1;
51new Handle:Cash;
52// killenkénti +hp
53new Handle:HsAdd
54new Handle:HpAdd
55new Handle:MaxHp
56//reduction string convars
57ConVar cv_sDamageReduction;
58ConVar cv_sDamageBoost;
59
60public Plugin myinfo =
61{
62 name = "Premium System",
63 author = "TOMI [HUN]",
64 description = "Premium System",
65 version = "0.1",
66 url = ""
67};
68
69public void OnPluginStart()
70{
71 g_iAccount = FindSendPropInfo("CCSPlayer", "m_iAccount");
72 Cash = CreateConVar("extra_cash_amount","20000","Megadja az osszeget Spawnolaskor",FCVAR_NOTIFY);
73
74 SQL_StartConnection();
75 //Translations
76 LoadTranslations("common.phrases");
77 //Cvars
78 g_hEnabled = CreateConVar("sm_vipsystem_enabled", "1", "Enable the vip system?", 0, true, 0.0, true, 1.0);
79 g_hSkins = CreateConVar("sm_vipsystem_skins", "0", "Allow vip players to use player skins?", 0, true, 0.0, true, 1.0);
80 g_hHealth = CreateConVar("sm_vipsystem_health", "1", "Allow vip players to use hp bonus?", 0, true, 0.0, true, 1.0);
81 g_hDefuse = CreateConVar("sm_vipsystem_defuse", "1", "Allow vip players to use defuse kit bonus?", 0, true, 0.0, true, 1.0);
82 g_hArmor = CreateConVar("sm_vipsystem_armor", "1", "Allow vip players to use full armor bonus?", 0, true, 0.0, true, 1.0);
83 g_hHealthAmount = CreateConVar("sm_vipsystem_health_amount", "10", "How much hp bonus will VIP players can get if hp bonus is enabled? (Default 10)", 0, true, 1.0, true, 999999999.0);
84 HsAdd = CreateConVar("kb_headshot", "10", "value # equals the amount of hp to add, when attacker headshots", FCVAR_NOTIFY)
85 HpAdd = CreateConVar("kb_hp", "5", "value # equals the amount of hp to add, when the someone kills someone", FCVAR_NOTIFY)
86 MaxHp = CreateConVar("kb_maxhp", "200", "value # equals the max hp that the attacker could get", FCVAR_NOTIFY)
87 cv_sDamageReduction = CreateConVar("vip_core_damage_reduction", "0", " Amount of damage boost ( Can be % also ). 0 - Disable.");
88 cv_sDamageBoost = CreateConVar("vip_core_damage_booster", "0", " Amount of damage reduction ( Can be % also ). 0 - Disable.");
89 //Hook Cvars Change
90 HookConVarChange(g_hEnabled, OnCvarChange_Enabled);
91 HookConVarChange(g_hSkins, OnCvarChange_Skins);
92 HookConVarChange(g_hHealth, OnCvarChange_Health);
93 HookConVarChange(g_hDefuse, OnCvarChange_Defuse);
94 HookConVarChange(g_hArmor, OnCvarChange_Armor);
95 HookConVarChange(g_hHealthAmount, OnCvarChange_HealthAmount);
96 //+hp-ért felelős a player_death
97 HookEvent("player_death", hookPlayerDie, EventHookMode_Post)
98 //Auto exec config
99 AutoExecConfig(true, "s4muray_vipsystem");
100 //Cookies
101 g_hVIPTag = RegClientCookie("VIPSystemTags", "Saving the VIP's chat tags here", CookieAccess_Protected);
102 g_hVIPClanTag = RegClientCookie("VIPSystemCTags", "Saving the VIP's clan tags here", CookieAccess_Protected);
103 g_hVIPTagColor = RegClientCookie("VIPSystemTagColor", "Saving the VIP's tag colors here", CookieAccess_Protected);
104 g_hVIPNameColor = RegClientCookie("VIPSystemNameColor", "Saving the VIP's name colors here", CookieAccess_Protected);
105 g_hVIPChatColor = RegClientCookie("VIPSystemChatColor", "Saving the VIP's chat colors here", CookieAccess_Protected);
106 //Custom Tags From Menu
107 AddCommandListener(OnSay, "say");
108 AddCommandListener(OnSay, "say_team");
109 //Hooks
110 HookEvent("player_spawn", player_spawn);
111 HookEvent("round_start", rounds);
112 HookEvent("round_end", rounds);
113 //Commands
114 RegAdminCmd("sm_addvip", Command_AddVIP, ADMFLAG_ROOT);
115 RegAdminCmd("sm_removevip", Command_RemoveVIP, ADMFLAG_ROOT);
116 RegConsoleCmd("sm_vip", Command_VIPMenu);
117 RegConsoleCmd("sm_vips", Command_VIPMenu);
118 RegConsoleCmd("sm_tag", Command_Tag);
119 RegConsoleCmd("sm_tagcolor", Command_TagColor);
120 RegConsoleCmd("sm_namecolor", Command_NameColor);
121 RegConsoleCmd("sm_chatcolor", Command_ChatColor);
122 RegConsoleCmd("sm_clantag", Command_ClanTag);
123 RegConsoleCmd("sm_skins", Command_Skins);
124 //For expire and time left
125 CreateTimer(60.0, Timer_CheckPlayersTime, _, TIMER_REPEAT);
126 for (int i = 0; i <= MaxClients; i++)
127 {
128 if (IsValidClient(i))
129 {
130 OnClientPostAdminCheck(i);
131 }
132 }
133}
134//Natives
135public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
136{
137 CreateNative("CSGOVIP_SetVIP", Native_SetVIP);
138 CreateNative("CSGOVIP_IsClientVIP", Native_IsClientVIP);
139 return APLRes_Success;
140}
141public int Native_SetVIP(Handle plugin, int numParams)
142{
143 int client = GetNativeCell(1);
144 if (client < 1 || client > MaxClients)
145 {
146 return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d)", client);
147 }
148 if (!IsClientConnected(client))
149 {
150 return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not connected", client);
151 }
152 bool test = GetNativeCell(2);
153 g_bIsClientVIP[client] = test;
154 return true;
155}
156public int Native_IsClientVIP(Handle plugin, int numParams)
157{
158 int client = GetNativeCell(1);
159 if (client < 1 || client > MaxClients)
160 {
161 return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d)", client);
162 }
163 if (!IsClientConnected(client))
164 {
165 return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not connected", client);
166 }
167 return g_bIsClientVIP[client];
168}
169//Convars
170public void OnCvarChange_Enabled(ConVar cvar, char[] oldvalue, char[] newvalue)
171{
172 if (StrEqual(newvalue, "1"))
173 g_bEnabled = true;
174 else if (StrEqual(newvalue, "0"))
175 g_bEnabled = false;
176}
177public void OnCvarChange_Skins(ConVar cvar, char[] oldvalue, char[] newvalue)
178{
179 if (StrEqual(newvalue, "1"))
180 g_bSkins = true;
181 else if (StrEqual(newvalue, "0"))
182 g_bSkins = false;
183}
184public void OnCvarChange_Health(ConVar cvar, char[] oldvalue, char[] newvalue)
185{
186 if (StrEqual(newvalue, "1"))
187 g_bHP = true;
188 else if (StrEqual(newvalue, "0"))
189 g_bHP = false;
190}
191public void OnCvarChange_Defuse(ConVar cvar, char[] oldvalue, char[] newvalue)
192{
193 if (StrEqual(newvalue, "1"))
194 g_bDefuse = true;
195 else if (StrEqual(newvalue, "0"))
196 g_bDefuse = false;
197}
198
199public void OnCvarChange_Armor(ConVar cvar, char[] oldvalue, char[] newvalue)
200{
201 if (StrEqual(newvalue, "1"))
202 g_bFullArmor = true;
203 else if (StrEqual(newvalue, "0"))
204 g_bFullArmor = false;
205}
206public void OnCvarChange_HealthAmount(ConVar cvar, char[] oldvalue, char[] newvalue)
207{
208 if (!IsValueNumeric(newvalue))
209 {
210 g_iHealthBonus = StringToInt(oldvalue);
211 }
212 else {
213 g_iHealthBonus = StringToInt(newvalue);
214 }
215}
216//Voids
217public void OnMapStart()
218{
219 //Player Skins
220 g_iSkins = 0;
221 GetSkins();
222 ReadBlockedTags();
223}
224
225//Check Players
226public Action Timer_CheckPlayersTime(Handle timer)
227{
228 for (int i = 0; i <= MaxClients; i++)
229 {
230 if (IsValidClient(i))
231 {
232 OnClientPostAdminCheck(i);
233 }
234 }
235}
236
237public void OnClientPostAdminCheck(int client)
238{
239 if (!IsValidClient(client) || IsFakeClient(client))
240 {
241 return;
242 }
243 if (DB == null)
244 {
245 return;
246 }
247 char playername[MAX_NAME_LENGTH], steamid[32];
248 GetClientName(client, playername, MAX_NAME_LENGTH);
249 if (!GetClientAuthId(client, AuthId_Steam2, steamid, 32))
250 {
251 KickClient(client, "Verification problem please reconnect.");
252 return;
253 }
254
255 int iLength = ((strlen(playername) * 2) + 1);
256 char[] escapedname = new char[iLength];
257 DB.Escape(playername, escapedname, iLength);
258
259 char gB_ClientIP[64];
260 GetClientIP(client, gB_ClientIP, 64);
261
262 char gB_Query[512];
263 FormatEx(gB_Query, sizeof(gB_Query), "SELECT COUNT(*) FROM `users` WHERE expiredate > NOW() AND `steamid` = '%s'", steamid);
264 DB.Query(SQL_SelectPlayer_Callback, gB_Query, GetClientSerial(client), DBPrio_Normal);
265 //Other
266 Format(g_sTag[client], sizeof(g_sTag), "");
267 Format(g_sClanTag[client], sizeof(g_sTag), "");
268 char test[512];
269 GetClientCookie(client, g_hVIPTag, test, sizeof(test));
270 if (!StrEqual(test, "") && !StrEqual(test, "none"))
271 Format(g_sTag[client], sizeof(test), test);
272 GetClientCookie(client, g_hVIPClanTag, g_sClanTag[client], 512);
273 GetClientCookie(client, g_hVIPTagColor, test, sizeof(test));
274 if (!StrEqual(test, ""))
275 Format(g_sTagColor[client], sizeof(test), test);
276
277 GetClientCookie(client, g_hVIPNameColor, test, sizeof(test));
278 if (!StrEqual(test, ""))
279 Format(g_sNameColor[client], sizeof(test), test);
280
281 GetClientCookie(client, g_hVIPChatColor, test, sizeof(test));
282 if (!StrEqual(test, ""))
283 Format(g_sChatColor[client], sizeof(test), test);
284}
285public void OnClientDisconnect(int client)
286{
287 if (IsFakeClient(client))
288 {
289 return;
290 }
291 char steamid[32];
292 if (!GetClientAuthId(client, AuthId_Steam2, steamid, 32))
293 {
294 return;
295 }
296 if (!g_bIsClientVIP[client])
297 {
298 SQL_RemoveVIP(steamid);
299 }
300 if (g_bIsClientVIP[client])
301 {
302 SetHudTextParams(0.05, 0.1, 7.0, 0, 255, 150, 255, 2, 6.0, 0.1, 0.2);
303 for (int i = 1; i <= MaxClients; i++)
304 {
305 if (IsValidClient(i))
306 {
307 ShowHudText(i, -1, "VIP %N has disconnected from the server!", client);
308 }
309 }
310 g_bIsClientVIP[client] = false;
311 }
312 Format(g_sTag[client], sizeof(g_sTag), "");
313 Format(g_sClanTag[client], sizeof(g_sTag), "");
314}
315//Staff
316public Action OnSay(int client, const char[] command, int args)
317{
318 char text[4096];
319 GetCmdArgString(text, sizeof(text));
320 StripQuotes(text);
321 if (g_bIsTypingTag[client])
322 {
323 if (StrEqual(text, "!cancel") || StrEqual(text, "/cancel"))
324 {
325 PrintToChat(client, "%sTag Type Aborted", prefix);
326 g_bIsTypingTag[client] = false;
327 }
328 else {
329 bool block;
330 for (int k = 0; k <= g_iBlockedTags; k++)
331 {
332 if (StrEqual(g_sBlockedTags[k], text, false))
333 {
334 block = true;
335 }
336 }
337 if (block)
338 {
339 PrintToChat(client, "%sThis tag is not allowed!", prefix);
340 return Plugin_Handled;
341 }
342 Format(g_sTag[client], sizeof(g_sTag), text);
343 g_bIsTypingTag[client] = false;
344 if (StrEqual(text, "none"))
345 PrintToChat(client, "%sYou just reset your tag!", prefix);
346 else
347 PrintToChat(client, "%sYou changed your tag to '%s'", prefix, text);
348
349 SetClientCookie(client, g_hVIPTag, g_sTag[client]);
350 }
351 return Plugin_Handled;
352 }
353 if (g_bIsTypingClanTag[client])
354 {
355 if (StrEqual(text, "!cancel") || StrEqual(text, "/cancel"))
356 {
357 PrintToChat(client, "%sClan Tag Type Aborted", prefix);
358 g_bIsTypingClanTag[client] = false;
359 }
360 else {
361 bool block;
362 for (int k = 0; k <= g_iBlockedTags; k++)
363 {
364 if (StrEqual(g_sBlockedTags[k], text, false))
365 {
366 block = true;
367 }
368 }
369 if (block)
370 {
371 PrintToChat(client, "%sThis tag is not allowed!", prefix);
372 return Plugin_Handled;
373 }
374 Format(g_sClanTag[client], sizeof(g_sTag), text);
375 g_bIsTypingClanTag[client] = false;
376 if (StrEqual(text, "none"))
377 PrintToChat(client, "%sYou just reset your clan tag!", prefix);
378 else
379 {
380 PrintToChat(client, "%sYou changed your clan tag to '%s'", prefix, text);
381 CS_SetClientClanTag(client, g_sClanTag[client]);
382 }
383 SetClientCookie(client, g_hVIPClanTag, g_sClanTag[client]);
384 }
385 return Plugin_Handled;
386 }
387 return Plugin_Continue;
388}
389public Action rounds(Event event, char[] name, bool dontBroadcast)
390{
391 if (StrEqual(name, "round_start"))
392 g_iRounds++;
393}
394public Action player_spawn(Event event, char[] name, bool dontBroadcast)
395{
396 if (!g_bEnabled)
397 return;
398 int client = GetClientOfUserId(event.GetInt("userid"));
399 if (g_bIsClientVIP[client])
400 {
401 if (g_bArmor[client] && g_bFullArmor)
402 {
403 SetEntProp(client, Prop_Send, "m_ArmorValue", 100, 1);
404 SetEntProp(client, Prop_Send, "m_bHasHelmet", 1);
405 PrintToChat(client, "%sYou spawned with \x04Full Armor\x01!", prefix);
406 }
407 if (g_bHealth[client] && g_bHP)
408 {
409 int hp = GetClientHealth(client);
410 SetEntityHealth(client, hp + 10);
411 PrintToChat(client, "%sYou recived a\x04 %d HP Bonus\x01!", prefix, g_iHealthBonus);
412 }
413 if (GetClientTeam(client) == CS_TEAM_CT && g_bDefusekit[client] && g_bDefuse)
414 {
415 PrintToChat(client, "%sYou recived a \x04defuse kit!", prefix);
416 SetEntProp(client, Prop_Send, "m_bHasDefuser", 1);
417 }
418 if (GetClientTeam(client) == CS_TEAM_CT)
419 {
420 new weapon = 1;
421 if(weapon = GetPlayerWeaponSlot(client, 1))
422 {
423 RemovePlayerItem(client, weapon);
424 }
425 GivePlayerItem(client, "weapon_ak47");
426 GivePlayerItem(client, "weapon_deagle");
427 GivePlayerItem(client, "weapon_hegrenade");
428 GivePlayerItem(client, "weapon_flashbang");
429 GivePlayerItem(client, "weapon_flashbang");
430 GivePlayerItem(client, "weapon_smokegrenade");
431 SetMoney(client,GetConVarInt(Cash));
432 PrintToChat(client, "%sYou recived a \x04Your Ct!", prefix);
433 }
434 if (GetClientTeam(client) == CS_TEAM_T)
435 {
436 new weapon = 1;
437 if(weapon = GetPlayerWeaponSlot(client, 1))
438 {
439 RemovePlayerItem(client, weapon);
440 }
441 GivePlayerItem(client, "weapon_m4a1");
442 GivePlayerItem(client, "weapon_deagle");
443 GivePlayerItem(client, "weapon_hegrenade");
444 GivePlayerItem(client, "weapon_flashbang");
445 GivePlayerItem(client, "weapon_flashbang");
446 GivePlayerItem(client, "weapon_smokegrenade");
447 SetMoney(client,GetConVarInt(Cash));
448 PrintToChat(client, "%sYou recived a \x04Your T!", prefix);
449 }
450 if (!StrEqual(g_sClanTag[client], "") && !StrEqual(g_sClanTag[client], "none"))
451 {
452 CS_SetClientClanTag(client, g_sClanTag[client]);
453 }
454 if (!StrEqual(g_sClientSkin[client], "") && g_bSkins)
455 CreateTimer(1.1, Timer_ApplySkin, client);
456 }
457}
458
459public Action:hookPlayerDie(Handle:event, const String:name[], bool:dontBroadcast)
460{
461 new attacker = GetEventInt(event, "attacker")
462 new id = GetClientOfUserId(attacker)
463 new bool:headshot = GetEventBool(event, "headshot")
464
465 new Hs = GetConVarInt(HsAdd)
466 new Hp = GetConVarInt(HpAdd)
467 new Max = GetConVarInt(MaxHp)
468 new CurrentHp = GetClientHealth(id)
469
470 if(CurrentHp == Max)
471 return Plugin_Handled
472
473 if (g_bIsClientVIP[id])
474 {
475
476 if(headshot)
477 {
478 if((CurrentHp + Hs) > Max)
479 {
480 SetEntProp(id, Prop_Send, "m_iHealth", Max, 1)
481
482 PrintToChat(id, "You been giving %i hp, for getting a headshot kill", (Max - CurrentHp))
483 } else {
484 SetEntProp(id, Prop_Send, "m_iHealth", Hs + CurrentHp, 1)
485
486 PrintToChat(id, "You been giving %i hp, for getting a headshot kill", Hs)
487 }
488
489 } else if(!headshot)
490 {
491 if((CurrentHp + Hp) > Max)
492 {
493 SetEntProp(id, Prop_Send, "m_iHealth", Max, 1)
494
495 PrintToChat(id, "You been giving %i hp, for getting a kill", (Max - CurrentHp))
496 } else {
497 SetEntProp(id, Prop_Send, "m_iHealth", Hp + CurrentHp, 1)
498
499 PrintToChat(id, "You been giving %i hp, for getting a kill", Hp)
500 }
501
502 } }
503 return Plugin_Continue
504
505}
506
507public Action OnTraceAttack(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int hitgroup)
508{
509
510 if (!IsValidClient(attacker, true, false) && (victim == attacker) && !HexVips_IsClientVip(attacker))
511 return Plugin_Continue;
512
513 char sDamageReduction[16];
514 char sDamageBoost[16];
515
516 cv_sDamageReduction.GetString(sDamageReduction, sizeof(sDamageReduction));
517 cv_sDamageBoost.GetString(sDamageBoost, sizeof(sDamageBoost));
518 if (IsValidClient(victim, true, false) && cv_sDamageBoost.BoolValue)
519 {
520 if (StrContains(sDamageBoost, "%", false) != -1)
521 {
522 ReplaceString(sDamageBoost, sizeof(sDamageBoost), "%", "", false);
523 int iDamageBoost = StringToInt(sDamageBoost);
524 damage += damage / 100 * iDamageBoost;
525 return Plugin_Changed;
526 }
527 else
528 {
529 damage += cv_sDamageBoost.IntValue;
530 return Plugin_Changed;
531 }
532 }
533
534 if (IsValidClient(victim, true, false) && cv_sDamageReduction.BoolValue)
535 {
536 if (StrContains(sDamageReduction, "%", false) != -1)
537 {
538 ReplaceString(sDamageReduction, sizeof(sDamageReduction), "%", "", false);
539 int iDamageReduction = StringToInt(sDamageReduction);
540 damage -= damage / 100 * iDamageReduction;
541 return Plugin_Changed;
542 }
543 else
544 {
545 damage -= cv_sDamageReduction.IntValue;
546 return Plugin_Changed;
547 }
548 }
549
550 return Plugin_Continue;
551}
552
553public SetMoney(client, amount)
554{
555 if (g_iAccount != -1)
556 {
557 SetEntData(client, g_iAccount, amount);
558 }
559}
560
561//Commands
562public Action Command_Skins(int client, int args)
563{
564 if (!g_bEnabled)
565 {
566 PrintToChat(client, "%sThe \x07VIP System \x03is disabled right now!", prefix);
567 return Plugin_Handled;
568 }
569 if (!g_bSkins)
570 {
571 PrintToChat(client, "%sThe \x07Player Skins \x03option is disabled right now!", prefix);
572 return Plugin_Handled;
573 }
574 if (!g_bIsClientVIP[client])
575 {
576 PrintToChat(client, "%sThis command is for \x05VIP \x01only!", prefix);
577 return Plugin_Handled;
578 }
579 Menu menu = CreateMenu(SkinsMenu);
580 menu.SetTitle("VIP Skins - Choose A Skin");
581 char sTest[512];
582 Format(sTest, sizeof(sTest), "%s", g_sClientSkin[client]);
583 if (StrEqual(sTest, ""))
584 menu.AddItem("", "Default Skin[Equipped]");
585 else
586 menu.AddItem("", "Default Skin");
587 for (int i = 1; i <= g_iSkins; i++)
588 {
589 if (StrEqual(sModel[i], sTest) && !StrEqual(sTest, ""))
590 {
591 char sNoName[512];
592 Format(sNoName, sizeof(sNoName), "%s[Equipped]", sName[i]);
593 menu.AddItem(sModel[i], sNoName);
594 }
595 else
596 menu.AddItem(sModel[i], sName[i]);
597 }
598 menu.Display(client, MENU_TIME_FOREVER);
599 return Plugin_Handled;
600}
601public int SkinsMenu(Menu menu, MenuAction action, int client, int itemNum)
602{
603 if (action == MenuAction_Select)
604 {
605 if (!g_bEnabled)
606 {
607 PrintToChat(client, "%sThe \x07VIP System \x03is disabled right now!", prefix);
608 return;
609 }
610 if (!g_bSkins)
611 {
612 PrintToChat(client, "%sThe \x07Player Skins \x03option is disabled right now!", prefix);
613 return;
614 }
615 char sTest[512];
616 menu.GetItem(itemNum, sTest, sizeof(sTest));
617 menu.GetItem(itemNum, g_sClientSkin[client], 512);
618 if (itemNum == 0)
619 PrintToChat(client, "%sSuccessfuly Changed Your Player Skin To Default Skin!", prefix);
620 else
621 PrintToChat(client, "%sSuccessfuly Changed Your Player Skin To \"%s\"!", prefix, sName[itemNum]);
622
623 menu.Display(client, MENU_TIME_FOREVER);
624 }
625}
626public Action Command_Tag(int client, int args)
627{
628 if (!g_bEnabled)
629 {
630 PrintToChat(client, "%sThe \x07VIP System \x03is disabled right now!", prefix);
631 return Plugin_Handled;
632 }
633 if (!g_bIsClientVIP[client])
634 {
635 PrintToChat(client, "%sThis command is for \x07VIP \x03members only!", prefix);
636 return Plugin_Handled;
637 }
638 if (args == 0)
639 {
640 PrintToChat(client, "%sWrong usage: sm_tag <Text | None = reset tag>", prefix);
641 return Plugin_Handled;
642 }
643 char arg[512];
644 GetCmdArgString(arg, sizeof(arg));
645 bool block;
646 for (int k = 0; k <= g_iBlockedTags; k++)
647 {
648 if (StrEqual(arg, g_sBlockedTags[k]))
649 {
650 block = true;
651 }
652 }
653 if (block)
654 {
655 PrintToChat(client, "%sThis tag is not allowed!", prefix);
656 return Plugin_Handled;
657 }
658 Format(g_sTag[client], sizeof(arg), arg);
659 SetClientCookie(client, g_hVIPTag, g_sTag[client]);
660
661 if (StrEqual(arg, "none"))
662 PrintToChat(client, "%sYou just reset your tag!", prefix);
663 else
664 PrintToChat(client, "%sYou changed your tag to '%s'", prefix, arg);
665 return Plugin_Handled;
666}
667public Action Command_TagColor(int client, int args)
668{
669 if (!g_bEnabled)
670 {
671 PrintToChat(client, "%sThe \x07VIP System \x03is disabled right now!", prefix);
672 return Plugin_Handled;
673 }
674 if (!g_bIsClientVIP[client])
675 {
676 PrintToChat(client, "%sThis command is for \x07VIP \x03members only!", prefix);
677 return Plugin_Handled;
678 }
679 Menu menu = CreateMenu(TagMenu);
680 menu.SetTitle("Choose Your Color");
681 menu.AddItem("\x03", "Default");
682 menu.AddItem("\x02", "Strong Red");
683 menu.AddItem("\x03", "Team Color");
684 menu.AddItem("\x04", "Green");
685 menu.AddItem("\x05", "Turquoise");
686 menu.AddItem("\x06", "Yellow-Green");
687 menu.AddItem("\x07", "Light Red");
688 menu.AddItem("\x08", "Gray");
689 menu.AddItem("\x09", "Light Yellow");
690 menu.AddItem("\x0A", "Light Blue");
691 menu.AddItem("\x0C", "Purple");
692 menu.AddItem("\x0E", "Pink");
693 menu.AddItem("\x10", "Orange");
694 menu.Display(client, 30);
695 return Plugin_Handled;
696}
697public int TagMenu(Menu menu, MenuAction action, int client, int itemNum)
698{
699 if (action == MenuAction_Select)
700 {
701 if (!g_bEnabled)
702 {
703 PrintToChat(client, "%sThe \x07VIP System \x03is disabled right now!", prefix);
704 return;
705 }
706 char info[64], sItemName[64];
707 GetMenuItem(menu, itemNum, info, sizeof(info), _, sItemName, sizeof(sItemName));
708 Format(g_sTagColor[client], sizeof(g_sTagColor), info);
709 PrintToChat(client, "%sYou changed your tag color to %s%s", prefix, info, sItemName);
710 SetClientCookie(client, g_hVIPTagColor, g_sTagColor[client]);
711 menu.DisplayAt(client, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
712 }
713}
714public Action Command_NameColor(int client, int args)
715{
716 if (!g_bEnabled)
717 {
718 PrintToChat(client, "%sThe \x07VIP System \x03is disabled right now!", prefix);
719 return Plugin_Handled;
720 }
721 if (!g_bIsClientVIP[client])
722 {
723 PrintToChat(client, "%sThis command is for \x07VIP \x03members only!", prefix);
724 return Plugin_Handled;
725 }
726 Menu menu = CreateMenu(NameMenu);
727 menu.SetTitle("Choose Your Color");
728 menu.AddItem("\x03", "Default");
729 menu.AddItem("\x02", "Strong Red");
730 menu.AddItem("\x03", "Team Color");
731 menu.AddItem("\x04", "Green");
732 menu.AddItem("\x05", "Turquoise");
733 menu.AddItem("\x06", "Yellow-Green");
734 menu.AddItem("\x07", "Light Red");
735 menu.AddItem("\x08", "Gray");
736 menu.AddItem("\x09", "Light Yellow");
737 menu.AddItem("\x0A", "Light Blue");
738 menu.AddItem("\x0C", "Purple");
739 menu.AddItem("\x0E", "Pink");
740 menu.AddItem("\x10", "Orange");
741 menu.Display(client, 30);
742 return Plugin_Handled;
743}
744public int NameMenu(Menu menu, MenuAction action, int client, int itemNum)
745{
746 if (action == MenuAction_Select)
747 {
748 if (!g_bEnabled)
749 {
750 PrintToChat(client, "%sThe \x07VIP System \x03is disabled right now!", prefix);
751 return;
752 }
753 char info[64], sItemName[64];
754 GetMenuItem(menu, itemNum, info, sizeof(info), _, sItemName, sizeof(sItemName));
755 Format(g_sNameColor[client], sizeof(g_sNameColor), info);
756 PrintToChat(client, "%sYou changed your name color to %s%s", prefix, info, sItemName);
757 SetClientCookie(client, g_hVIPNameColor, g_sNameColor[client]);
758 menu.DisplayAt(client, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
759 }
760}
761public Action Command_ChatColor(int client, int args)
762{
763 if (!g_bEnabled)
764 {
765 PrintToChat(client, "%sThe \x07VIP System \x03is disabled right now!", prefix);
766 return Plugin_Handled;
767 }
768 if (!g_bIsClientVIP[client])
769 {
770 PrintToChat(client, "%sThis command is for \x07VIP \x03members only!", prefix);
771 return Plugin_Handled;
772 }
773 Menu menu = CreateMenu(ChatMenu);
774 menu.SetTitle("Choose Your Color");
775 menu.AddItem("\x01", "Default");
776 menu.AddItem("\x02", "Strong Red");
777 menu.AddItem("\x03", "Team Color");
778 menu.AddItem("\x04", "Green");
779 menu.AddItem("\x05", "Turquoise");
780 menu.AddItem("\x06", "Yellow-Green");
781 menu.AddItem("\x07", "Light Red");
782 menu.AddItem("\x08", "Gray");
783 menu.AddItem("\x09", "Light Yellow");
784 menu.AddItem("\x0A", "Light Blue");
785 menu.AddItem("\x0C", "Purple");
786 menu.AddItem("\x0E", "Pink");
787 menu.AddItem("\x10", "Orange");
788 menu.Display(client, 30);
789 return Plugin_Handled;
790}
791public int ChatMenu(Menu menu, MenuAction action, int client, int itemNum)
792{
793 if (action == MenuAction_Select)
794 {
795 if (!g_bEnabled)
796 {
797 PrintToChat(client, "%sThe \x07VIP System \x03is disabled right now!", prefix);
798 return;
799 }
800 char info[64], sItemName[64];
801 GetMenuItem(menu, itemNum, info, sizeof(info), _, sItemName, sizeof(sItemName));
802 Format(g_sChatColor[client], sizeof(g_sChatColor), info);
803 PrintToChat(client, "%sYou changed your chat color to %s%s", prefix, info, sItemName);
804 SetClientCookie(client, g_hVIPChatColor, g_sChatColor[client]);
805 menu.DisplayAt(client, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
806 }
807}
808public Action Command_ClanTag(int client, int args)
809{
810 if (!g_bEnabled)
811 {
812 PrintToChat(client, "%sThe \x07VIP System \x03is disabled right now!", prefix);
813 return Plugin_Handled;
814 }
815 if (!g_bIsClientVIP[client])
816 {
817 PrintToChat(client, "%sThis command is for \x07VIP \x03members only!", prefix);
818 return Plugin_Handled;
819 }
820 if (args == 0)
821 {
822 PrintToChat(client, "%sWrong usage: sm_clantag <Text | None=reset>", prefix);
823 return Plugin_Handled;
824 }
825 char arg[512];
826 GetCmdArgString(arg, sizeof(arg));
827 bool block;
828 for (int k = 0; k <= g_iBlockedTags; k++)
829 {
830 if (StrEqual(g_sBlockedTags[k], arg, false))
831 {
832 block = true;
833 }
834 }
835 if (block)
836 {
837 PrintToChat(client, "%sThis tag is not allowed!", prefix);
838 return Plugin_Handled;
839 }
840 Format(g_sClanTag[client], sizeof(arg), arg);
841 CS_SetClientClanTag(client, g_sClanTag[client]);
842 SetClientCookie(client, g_hVIPClanTag, g_sClanTag[client]);
843 if (StrEqual(arg, "none"))
844 PrintToChat(client, "%sYou just reset your tag!", prefix);
845 else
846 PrintToChat(client, "%sYou changed your tag to '%s'", prefix, arg);
847 return Plugin_Handled;
848}
849public Action Command_VIPMenu(int client, int args)
850{
851 if (!g_bEnabled)
852 {
853 PrintToChat(client, "%sThe \x07VIP System \x03is disabled right now!", prefix);
854 return Plugin_Handled;
855 }
856 if (!g_bIsClientVIP[client])
857 {
858 PrintToChat(client, "%sThis command is for \x07VIP \x03members only!", prefix);
859 return Plugin_Handled;
860 }
861 ShowVIPMenu(client, 0);
862 return Plugin_Handled;
863}
864public int VIPMenu(Menu menu, MenuAction action, int client, int itemNum)
865{
866 if (action == MenuAction_Select)
867 {
868 if (!g_bEnabled)
869 {
870 PrintToChat(client, "%sThe \x07VIP System \x03is disabled right now!", prefix);
871 return;
872 }
873 char info[64];
874 GetMenuItem(menu, itemNum, info, sizeof(info));
875 if (StrEqual(info, "skins"))
876 {
877 FakeClientCommand(client, "say /skins");
878 }
879 if (StrEqual(info, "clantag"))
880 {
881 PrintToChat(client, "%sType your clan tag in the chat or type !cancel to abort(Tip: type 'none' to reset your clan tag)", prefix);
882 g_bIsTypingClanTag[client] = true;
883 ShowVIPMenu(client, itemNum);
884 }
885 if (StrEqual(info, "tag"))
886 {
887 PrintToChat(client, "%sType your tag in the chat or type !cancel to abort(Tip: type 'none' to reset your tag)", prefix);
888 g_bIsTypingTag[client] = true;
889 ShowVIPMenu(client, itemNum);
890 }
891 if (StrEqual(info, "tagcolor"))
892 {
893 FakeClientCommand(client, "say /tagcolor");
894 }
895 if (StrEqual(info, "namecolor"))
896 {
897 FakeClientCommand(client, "say /namecolor");
898 }
899 if (StrEqual(info, "chatcolor"))
900 {
901 FakeClientCommand(client, "say /chatcolor");
902 }
903 if (StrEqual(info, "armor"))
904 {
905 if (g_bArmor[client])g_bArmor[client] = false;
906 else g_bArmor[client] = true;
907 PrintToChat(client, "%sYou just %s \x03the Full Armor bonus!", prefix, g_bArmor[client] ? "\x04Enabled" : "\x02Disabled");
908 ShowVIPMenu(client, itemNum);
909 }
910 if (StrEqual(info, "health"))
911 {
912 if (g_bHealth[client])g_bHealth[client] = false;
913 else g_bHealth[client] = true;
914 PrintToChat(client, "%sYou just %s \x03the %d HP bonus!", prefix, g_bHealth[client] ? "\x04Enabled" : "\x02Disabled", g_iHealthBonus);
915 ShowVIPMenu(client, itemNum);
916 }
917 if (StrEqual(info, "defuse"))
918 {
919 if (g_bDefusekit[client])g_bDefusekit[client] = false;
920 else g_bDefusekit[client] = true;
921 PrintToChat(client, "%sYou just %s \x03the Defuse Kit bonus!", prefix, g_bDefusekit[client] ? "\x04Enabled" : "\x02Disabled");
922 ShowVIPMenu(client, itemNum);
923 }
924 }
925}
926stock void ShowVIPMenu(int client, int itemNum)
927{
928 Menu menu = CreateMenu(VIPMenu);
929 menu.SetTitle("VIP Menu [%d Days Left]\n ", g_iTimeLeft[client]);
930 menu.AddItem("skins", "VIP Player Skins", g_bSkins ? 0 : 1);
931 menu.AddItem("clantag", "Manage Clan Tag");
932 menu.AddItem("tag", "Manage Chat Tag");
933 menu.AddItem("tagcolor", "Manage Tag Color");
934 menu.AddItem("namecolor", "Manage Name Color");
935 menu.AddItem("chatcolor", "Manage Chat Color");
936 if (g_bArmor[client])
937 menu.AddItem("armor", "Disable Full Armor", g_bFullArmor ? 0 : 1);
938 else
939 menu.AddItem("armor", "Enable Full Armor", g_bFullArmor ? 0 : 1);
940 char sHealth[64];
941 if (g_bHealth[client])
942 {
943 Format(sHealth, sizeof(sHealth), "Disable %d HP Bonus", g_iHealthBonus);
944 menu.AddItem("health", sHealth, g_bHP ? 0 : 1);
945 }
946 else
947 {
948 Format(sHealth, sizeof(sHealth), "Enabled %d HP Bonus", g_iHealthBonus);
949 menu.AddItem("health", sHealth, g_bHP ? 0 : 1);
950 }
951 if (g_bDefusekit[client])
952 menu.AddItem("defuse", "Disable Defuse Kit Bonus", g_bDefuse ? 0 : 1);
953 else
954 menu.AddItem("defuse", "Enable Defuse Kit Bonus", g_bDefuse ? 0 : 1);
955 menu.AddItem("", "Automatic Perks:", ITEMDRAW_DISABLED);
956 menu.AddItem("", "Connect & Disconnect Messages", ITEMDRAW_DISABLED);
957 menu.AddItem("", "Reserved Slots", ITEMDRAW_DISABLED);
958 menu.AddItem("", "V.I.P Tag In Chat", ITEMDRAW_DISABLED);
959 menu.Display(client, MENU_TIME_FOREVER);
960}
961public Action Command_AddVIP(int client, int args)
962{
963 if (args != 2)
964 PrintToChat(client, "%sWrong usage: sm_addvip <name | steamid> <days>", prefix);
965 else {
966 char arg1[64], arg2[64];
967 GetCmdArg(1, arg1, sizeof(arg1));
968 GetCmdArg(2, arg2, sizeof(arg2));
969 if (StrContains(arg1, "STEAM_", false) != -1)
970 {
971 int time = StringToInt(arg2);
972 PrintToChat(client, "%sSteamID '%s' was added to a VIP for %d days!", prefix, arg1, time);
973 SQL_AddVIP_Steamid(arg1, time);
974 }
975 else
976 {
977 char target_name[MAX_TARGET_LENGTH];
978 int target_list[MAXPLAYERS], target_count;
979 bool tn_is_ml;
980
981 if ((target_count = ProcessTargetString(
982 arg1,
983 client,
984 target_list,
985 MAXPLAYERS,
986 0,
987 target_name,
988 sizeof(target_name),
989 tn_is_ml)) <= 0)
990 {
991 ReplyToTargetError(client, target_count);
992 return Plugin_Handled;
993 }
994
995 for (int i = 0; i < target_count; i++)
996 {
997 int time = StringToInt(arg2);
998 g_bIsClientVIP[target_list[i]] = true;
999 //Info
1000 char playername[MAX_NAME_LENGTH], steamid[32];
1001 GetClientName(target_list[i], playername, MAX_NAME_LENGTH);
1002 if (!GetClientAuthId(target_list[i], AuthId_Steam2, steamid, 32))
1003 {
1004 PrintToChat(client, "%sError execued while getting target's info", prefix);
1005 return Plugin_Handled;
1006 }
1007
1008 int iLength = ((strlen(playername) * 2) + 1);
1009 char[] escapedname = new char[iLength];
1010 DB.Escape(playername, escapedname, iLength);
1011
1012 char gB_ClientIP[64];
1013 GetClientIP(target_list[i], gB_ClientIP, 64);
1014 //End of info
1015 UpdatePlayer(target_list[i], time);
1016 //Message
1017 SetHudTextParams(0.05, 0.1, 7.0, 0, 255, 150, 255, 2, 6.0, 0.1, 0.2);
1018 for (int targets = 1; targets <= MaxClients; targets++)
1019 {
1020 if (IsValidClient(targets))
1021 {
1022 ShowHudText(targets, -1, "%N is now a VIP!", target_list[i]);
1023 }
1024 }
1025 //Confirm MSG
1026 PrintToChat(client, "%s%N has been added to a VIP for %d days!", prefix, target_list[i], time);
1027 }
1028 }
1029 }
1030 return Plugin_Handled;
1031}
1032public Action Command_RemoveVIP(int client, int args)
1033{
1034 if (args != 1)
1035 PrintToChat(client, "%sWrong usage: sm_removevip <name | steamid> ", prefix);
1036 else {
1037 char arg1[64];
1038 GetCmdArg(1, arg1, sizeof(arg1));
1039 if (StrContains(arg1, "STEAM_", false) != -1)
1040 {
1041 SQL_RemoveVIP(arg1);
1042 PrintToChat(client, "%sSteamID '%s' has been removed from a VIP", prefix, arg1);
1043 }
1044 else
1045 {
1046 char target_name[MAX_TARGET_LENGTH];
1047 int target_list[MAXPLAYERS], target_count;
1048 bool tn_is_ml;
1049
1050 if ((target_count = ProcessTargetString(
1051 arg1,
1052 client,
1053 target_list,
1054 MAXPLAYERS,
1055 0,
1056 target_name,
1057 sizeof(target_name),
1058 tn_is_ml)) <= 0)
1059 {
1060 ReplyToTargetError(client, target_count);
1061 return Plugin_Handled;
1062 }
1063
1064 for (int i = 0; i < target_count; i++)
1065 {
1066 char steamid[64];
1067 if (!GetClientAuthId(target_list[i], AuthId_Steam2, steamid, 32))
1068 {
1069 PrintToChat(client, "%sError execued while getting target's info", prefix);
1070 return Plugin_Handled;
1071 }
1072 SQL_RemoveVIP(steamid);
1073 g_bIsClientVIP[target_list[i]] = false;
1074 PrintToChat(client, "%s%N has been removed from a VIP", prefix, target_list[i]);
1075 }
1076 }
1077 }
1078 return Plugin_Handled;
1079}
1080//Database
1081void UpdatePlayer(int client, int days)
1082{
1083 if (DB == null)
1084 {
1085 return;
1086 }
1087 char gB_Query[512], steamid[32];
1088 if (!GetClientAuthId(client, AuthId_Steam2, steamid, 32))
1089 {
1090 return;
1091 }
1092 FormatEx(gB_Query, sizeof(gB_Query), "INSERT INTO `users` (`expiredate`, `steamid`) VALUES (NOW() + INTERVAL %d DAY, '%s') ON DUPLICATE KEY UPDATE `expiredate` = NOW() + INTERVAL %d DAY;", days, steamid, days);
1093 DB.Query(SQL_UpdatePlayer_Callback, gB_Query, GetClientSerial(client), DBPrio_Normal);
1094}
1095void SQL_AddVIP_Steamid(const char[] steamid, int days)
1096{
1097 if (DB == null)
1098 {
1099 return;
1100 }
1101 char gB_Query[512];
1102 char test[512];
1103 Format(test, sizeof(test), "NOW() + INTERVAL %d DAY", days);
1104 FormatEx(gB_Query, sizeof(gB_Query), "INSERT INTO `users` (`expiredate`, `steamid`) VALUES (%s, '%s') ON DUPLICATE KEY UPDATE `expiredate` = %s;", test, steamid, test);
1105 DB.Query(SQL_UpdatePlayer_Callback2, gB_Query, _, DBPrio_Normal);
1106}
1107public void SQL_UpdatePlayer_Callback(Database db, DBResultSet results, const char[] error, any data)
1108{
1109 int client = GetClientFromSerial(data);
1110 if (results == null)
1111 {
1112 if (client == 0)
1113 {
1114 LogError("[Line 873] Client is not valid. Reason: %s", error);
1115 }
1116 else
1117 {
1118 LogError("[Line 877] Cant use client data. Reason: %s", error);
1119 }
1120 return;
1121 }
1122}
1123public void SQL_UpdatePlayer_Callback2(Database db, DBResultSet results, const char[] error, any data)
1124{
1125 if (results == null)
1126 {
1127 LogError("[Line 886] Cant use client data. Reason: %s", error);
1128 return;
1129 }
1130}
1131void SQL_StartConnection()
1132{
1133 if (DB != null)
1134 {
1135 delete DB;
1136 }
1137
1138 char gB_Error[255];
1139 if (SQL_CheckConfig("vipsystem"))
1140 {
1141 DB = SQL_Connect("vipsystem", true, gB_Error, 255);
1142
1143 if (DB == null)
1144 {
1145 SetFailState("[CSGOVIP] Error on start. Reason: %s", gB_Error);
1146 }
1147 }
1148 else
1149 {
1150 SetFailState("[CSGOVIP] Cant find `vipsystem` on database.cfg");
1151 }
1152
1153 DB.SetCharset("utf8");
1154
1155 char gB_Query[512];
1156 FormatEx(gB_Query, sizeof(gB_Query), "CREATE TABLE IF NOT EXISTS `users`( `steamid` VARCHAR(32) NOT NULL PRIMARY KEY, `expiredate` DATETIME NOT NULL, UNIQUE (`steamid`));");
1157 if (!SQL_FastQuery(DB, gB_Query))
1158 {
1159 SQL_GetError(DB, gB_Error, 255);
1160 LogError("[CSGOVIP] Cant create table. Error : %s", gB_Error);
1161 }
1162}
1163void SQL_RemoveVIP(const char[] steamid)
1164{
1165 char gB_Query[512];
1166 FormatEx(gB_Query, sizeof(gB_Query), "DELETE FROM `users` WHERE `steamid` = '%s'", steamid);
1167 DB.Query(SQL_RemovePlayer_Callback, gB_Query, DBPrio_Normal);
1168}
1169public void SQL_RemovePlayer_Callback(Database db, DBResultSet results, const char[] error, any data)
1170{
1171 if (results == null)
1172 {
1173 LogError("Error: %s", error);
1174 return;
1175 }
1176}
1177public void SQL_SelectPlayer_Callback(Database db, DBResultSet results, const char[] error, any data)
1178{
1179 int client = GetClientFromSerial(data);
1180 if (results == null)
1181 {
1182 if (client == 0)
1183 {
1184 LogError("[Line 988] Client is not valid. Reason: %s", error);
1185 }
1186 else
1187 {
1188 LogError("[CSGOVIP] Cant use client data on insert. Reason: %s", error);
1189 }
1190 return;
1191 }
1192 while (results.FetchRow())
1193 {
1194 int iCount = results.FetchInt(0);
1195 if (!g_bIsClientVIP[client]) { //Client connected now
1196 if (iCount != 0)
1197 {
1198 g_bIsClientVIP[client] = true;
1199 SetHudTextParams(0.05, 0.1, 7.0, 0, 255, 150, 255, 2, 6.0, 0.1, 0.2);
1200 for (int i = 1; i <= MaxClients; i++)
1201 {
1202 if (IsValidClient(i))
1203 {
1204 ShowHudText(i, -1, "VIP %N has connected to the server!", client);
1205 }
1206 }
1207 }
1208 if (iCount == 0 && GetMaxHumanPlayers() < GetOnlineUsers() && g_iRounds > 1)
1209 {
1210 KickClient(client, "Server is full, buy a V.I.P to join the server while full.");
1211 return;
1212 }
1213 if (iCount != 0 && GetMaxHumanPlayers() < GetOnlineUsers())
1214 {
1215 int iRandom = GetRandomPlayer();
1216 KickClient(iRandom, "You were kicked to make a space for a V.I.P user!");
1217 }
1218 CheckTimeLeft(client);
1219 }
1220 else {
1221 if (g_bIsClientVIP[client] && iCount == 0)
1222 {
1223 PrintToChat(client, "%sYour \x07VIP \x03has expired!", prefix);
1224 g_bIsClientVIP[client] = false;
1225 return;
1226 }
1227 CheckTimeLeft(client);
1228 }
1229 }
1230}
1231stock void CheckTimeLeft(int client)
1232{
1233 if (!IsValidClient(client))return;
1234 char authid[64];
1235 if (!GetClientAuthId(client, AuthId_Steam2, authid, 32))
1236 {
1237 return;
1238 }
1239 char gB_Query[512];
1240 FormatEx(gB_Query, sizeof(gB_Query), "SELECT TIMESTAMPDIFF(DAY, NOW(), expiredate) FROM `users` WHERE `steamid` = '%s';", authid);
1241 DB.Query(SQL_VIPTime, gB_Query, GetClientSerial(client), DBPrio_Normal);
1242}
1243public void SQL_VIPTime(Database db, DBResultSet results, const char[] error, any data)
1244{
1245 int client = GetClientFromSerial(data);
1246 if (results == null)
1247 {
1248 if (client == 0)
1249 {
1250 LogError("[Line 1059] Client is not valid. Reason: %s", error);
1251 }
1252 else
1253 {
1254 LogError("[CSGOVIP] Cant use client data on insert. Reason: %s", error);
1255 }
1256 return;
1257 }
1258 while (results.FetchRow())
1259 {
1260 g_iTimeLeft[client] = results.FetchInt(0);
1261 }
1262}
1263//Timers
1264//Apply Skin
1265public Action Timer_ApplySkin(Handle timer, any client)
1266{
1267 char sTest[512];
1268 Format(sTest, sizeof(sTest), "%s", g_sClientSkin[client]) // Should fix crashes
1269 if (StrEqual(sTest, ""))return;
1270 PrecacheModel(sTest);
1271 SetEntityModel(client, sTest);
1272}
1273//Chat
1274public Action OnChatMessage(&author, Handle recipients, char[] name, char[] message)
1275{
1276 if (g_bIsClientVIP[author])
1277 {
1278 if (StrEqual(g_sTag[author], "") || StrEqual(g_sTag[author], "none"))
1279 Format(name, MAX_NAME_LENGTH, " %s[V.I.P] \x03%s%s", g_sTagColor[author], g_sNameColor[author], name);
1280 else
1281 Format(name, MAX_NAME_LENGTH, " %s[%s] \x03%s%s", g_sTagColor[author], g_sTag[author], g_sNameColor[author], name);
1282 Format(message, MAXLENGTH_MESSAGE, "%s%s", g_sChatColor[author], message);
1283 return Plugin_Changed;
1284 }
1285 return Plugin_Continue;
1286}
1287//Stocks
1288stock void GetSkins()
1289{
1290 char sPath[512];
1291 BuildPath(Path_SM, sPath, sizeof(sPath), "configs/vipskins.txt");
1292 if (!FileExists(sPath))SetFailState("[CSGOVIP] - Couldn't Find configs/vipskins.txt");
1293 KeyValues kConfig = new KeyValues("");
1294 kConfig.ImportFromFile(sPath);
1295
1296 kConfig.JumpToKey("Skins");
1297 kConfig.GotoFirstSubKey();
1298 do {
1299 g_iSkins++;
1300 kConfig.GetString("name", sName[g_iSkins], 512);
1301 kConfig.GetString("location", sModel[g_iSkins], 512);
1302 AddFileToDownloadsTable(sModel[g_iSkins]);
1303 } while (kConfig.GotoNextKey());
1304}
1305stock void ReadBlockedTags()
1306{
1307 char sPath[512];
1308 BuildPath(Path_SM, sPath, sizeof(sPath), "configs/blockedtags.txt");
1309 if (!FileExists(sPath))SetFailState("[CSGOVIP] - Couldn't Find configs/blockedtags.txt");
1310 KeyValues kConfig = new KeyValues("");
1311 kConfig.ImportFromFile(sPath);
1312
1313 kConfig.JumpToKey("Blocked Tags");
1314 kConfig.GotoFirstSubKey();
1315 do {
1316 g_iBlockedTags++;
1317 kConfig.GetString("tag", g_sBlockedTags[g_iBlockedTags], sizeof(g_sBlockedTags));
1318 } while (kConfig.GotoNextKey());
1319}
1320stock int GetRandomPlayer()
1321{
1322 int[] clients = new int[MaxClients + 1];
1323 int clientCount;
1324 for (int i = 1; i <= MaxClients; i++)
1325 if (IsClientInGame(i) && IsValidClient(i) && !CheckCommandAccess(i, "", ADMFLAG_GENERIC) && !g_bIsClientVIP[i])
1326 clients[clientCount++] = i;
1327 return (clientCount == 0) ? -1 : clients[GetRandomInt(0, clientCount - 1)];
1328}
1329stock int GetOnlineUsers()
1330{
1331 int iCount = 0;
1332 for (int i = 1; i <= MaxClients; i++)
1333 {
1334 if (IsValidClient(i))
1335 iCount++;
1336 }
1337 return iCount;
1338}
1339stock bool IsValidClient(int client, bool alive = false, bool bots = false)
1340{
1341 if (client > 0 && client <= MaxClients && IsClientInGame(client) && (alive == false || IsPlayerAlive(client)) && (bots == false && !IsFakeClient(client)))
1342 {
1343 return true;
1344 }
1345 return false;
1346}
1347//Taken from "SMLib"
1348stock bool IsValueNumeric(char[] str)
1349{
1350 int x = 0;
1351 int dotsFound = 0;
1352 int numbersFound = 0;
1353
1354 if (str[x] == '+' || str[x] == '-') {
1355 x++;
1356 }
1357
1358 while (str[x] != '\0') {
1359
1360 if (IsCharNumeric(str[x])) {
1361 numbersFound++;
1362 }
1363 else if (str[x] == '.') {
1364 dotsFound++;
1365
1366 if (dotsFound > 1) {
1367 return false;
1368 }
1369 }
1370 else {
1371 return false;
1372 }
1373
1374 x++;
1375 }
1376
1377 if (!numbersFound) {
1378 return false;
1379 }
1380 return true;
1381}