Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* [CS:GO] Jailbreak Gangs
- *
- * Copyright (C) 2017 Michael Flaherty // michaelwflaherty.com // michaelwflaherty@me.com
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation, either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see http://www.gnu.org/licenses/.
- */
- #include <sourcemod>
- #include <sdkhooks>
- #include <sdktools>
- #include <autoexecconfig>
- #include <hl_gangs>
- #undef REQUIRE_PLUGIN
- #include <store>
- #define REQUIRE_PLUGIN
- #define TAG " \x03[Clans]\x04"
- /* Compiler Instructions */
- #pragma semicolon 1
- #pragma newdecls required
- /* ConVars */
- ConVar gcv_bPluginEnabled;
- ConVar gcv_sDatabase;
- ConVar gcv_iMaxGangSize;
- ConVar gcv_bInviteStyle;
- ConVar gcv_iHealthPrice;
- ConVar gcv_iCashPrice;
- ConVar gcv_iStorePrice;
- ConVar gcv_iMedishotPrice;
- ConVar gcv_iCreateGangPrice;
- ConVar gcv_iRenamePrice;
- ConVar gcv_iSizePrice;
- ConVar gcv_iPriceModifier;
- ConVar gcv_bDisableMedishot;
- ConVar gcv_bDisableStore;
- ConVar gcv_bDisableHealth;
- ConVar gcv_bDisableCash;
- ConVar gcv_bDisableSize;
- ConVar gcv_fStoreModifier;
- ConVar gcv_fHealthModifier;
- ConVar gcv_iGangSizeMaxUpgrades;
- /* Forwards */
- Handle g_hOnMainMenu;
- Handle g_hOnMainMenuCallback;
- Handle g_hOnPerkMenu;
- Handle g_hOnPerkMenuCallback;
- Handle g_hOnGangPerksSetPre;
- /* Gang Globals */
- GangRank ga_iRank[MAXPLAYERS + 1] = {Rank_Invalid, ...};
- int ga_iGangSize[MAXPLAYERS + 1] = {-1, ...};
- int ga_iInvitation[MAXPLAYERS + 1] = {-1, ...};
- int ga_iDateJoined[MAXPLAYERS + 1] = {-1, ...};
- int ga_iFunds[MAXPLAYERS + 1] = {0, ...};
- int ga_iHealth[MAXPLAYERS + 1] = {0, ...};
- int ga_iCash[MAXPLAYERS + 1] = {0, ...};
- int ga_iStore[MAXPLAYERS + 1] = {0, ...};
- int ga_iMedishot[MAXPLAYERS + 1] = {0, ...};
- int ga_iSize[MAXPLAYERS + 1] = {0, ...};
- int ga_iTempInt[MAXPLAYERS + 1] = {0, ...};
- int ga_iTempInt2[MAXPLAYERS + 1] = {0, ...};
- int g_iGangAmmount = 0;
- int KickShare[MAXPLAYERS + 1] = {0, ...};
- int ga_iShare[MAXPLAYERS + 1] = {0, ...};
- char ga_sGangName[MAXPLAYERS + 1][128];
- char ga_sInvitedBy[MAXPLAYERS + 1][128];
- bool ga_bSetName[MAXPLAYERS + 1] = {false, ...};
- bool ga_bIsPlayerInDatabase[MAXPLAYERS + 1] = {false, ...};
- bool ga_bIsGangInDatabase[MAXPLAYERS + 1] = {false, ...};
- bool ga_bHasGang[MAXPLAYERS + 1] = {false, ...};
- bool ga_bRename[MAXPLAYERS + 1] = {false, ...};
- /* Supported Store Modules */
- bool g_bZepyhrus = false;
- /* Player Globals */
- char ga_sSteamID[MAXPLAYERS + 1][30];
- bool g_bLateLoad = false;
- bool ga_bLoaded[MAXPLAYERS + 1] = {false, ...};
- bool ga_bReloaded[MAXPLAYERS + 1] = {false, ...};
- /* Database Globals */
- Database g_hDatabase = null;
- char g_sDatabaseName[60];
- public APLRes AskPluginLoad2(Handle hMyself, bool bLate, char[] sError, int err_max)
- {
- MarkNativeAsOptional("Store_GetClientCredits");
- MarkNativeAsOptional("Store_SetClientCredits");
- MarkNativeAsOptional("Gangs_GetCredits");
- MarkNativeAsOptional("Gangs_SetCredits");
- MarkNativeAsOptional("MyJailShop_SetCredits");
- MarkNativeAsOptional("MyJailShop_GetCredits");
- CreateNative("Gangs_GetGangName", Native_GetGangName);
- CreateNative("Gangs_GetGangRank", Native_GetGangRank);
- CreateNative("Gangs_HasGang", Native_HasGang);
- CreateNative("Gangs_GetGangSize", Native_GetGangSize);
- CreateNative("Gangs_Message", Native_Message);
- CreateNative("Gangs_MessageToAll", Native_MessageToAll);
- RegPluginLibrary("hl_gangs");
- g_bLateLoad = bLate;
- return APLRes_Success;
- }
- public int Native_MessageToAll(Handle plugin, int numParams)
- {
- char phrase[1024];
- int bytes;
- FormatNativeString(0, 1, 2, sizeof(phrase), bytes, phrase);
- PrintToChatAll("%s %s", TAG, phrase);
- }
- public int Native_Message(Handle plugin, int numParams)
- {
- int client = GetNativeCell(1);
- if (!IsValidClient(client))
- {
- return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%i)", client);
- }
- char phrase[1024];
- int bytes;
- FormatNativeString(0, 2, 3, sizeof(phrase), bytes, phrase);
- PrintToChat(client, "%s %s", TAG, phrase);
- return 0;
- }
- public int Native_GetGangName(Handle plugin, int numParams)
- {
- int client = GetNativeCell(1);
- if (!IsValidClient(client))
- {
- return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%i)", client);
- }
- SetNativeString(2, ga_sGangName[client], GetNativeCell(3));
- return 0;
- }
- public int Native_GetGangRank(Handle plugin, int numParams)
- {
- int client = GetNativeCell(1);
- if (!IsValidClient(client))
- {
- return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%i)", client);
- }
- return view_as<int>(ga_iRank[client]);
- }
- public int Native_HasGang(Handle plugin, int numParams)
- {
- int client = GetNativeCell(1);
- if (!IsValidClient(client))
- {
- return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%i)", client);
- }
- return view_as<int>(ga_bHasGang[client]);
- }
- public int Native_GetGangSize(Handle plugin, int numParams)
- {
- int client = GetNativeCell(1);
- if (!IsValidClient(client))
- {
- return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%i)", client);
- }
- return ga_iGangSize[client];
- }
- public Plugin myinfo =
- {
- name = "[CS:GO/CS:S] Jailbreak Gangs",
- author = "Headline",
- description = "An SQL-based gang plugin",
- version = GANGS_VERSION,
- url = "http://michaelwflaherty.com"
- };
- public void OnPluginStart()
- {
- LoadTranslations("hl_gangs.phrases");
- LoadTranslations("core.phrases");
- LoadTranslations("common.phrases");
- AutoExecConfig_SetFile("hl_gangs");
- AutoExecConfig_CreateConVar("hl_gangs_version", GANGS_VERSION, "Headline's Gangs Plugin : Version", FCVAR_NOTIFY|FCVAR_DONTRECORD);
- gcv_bPluginEnabled = AutoExecConfig_CreateConVar("hl_gangs_enabled", "1", "Enable the plugin? (1 = Yes, 0 = No)", FCVAR_NOTIFY, true, 0.0, true, 1.0);
- gcv_bInviteStyle = AutoExecConfig_CreateConVar("hl_gangs_invite_style", "1", "Set invite style to pop up a Menu? \n (1 = Menu, 0 = Registered Command)", FCVAR_NOTIFY, true, 0.0, true, 1.0);
- gcv_sDatabase = AutoExecConfig_CreateConVar("hl_gangs_database_name", "hl_gangs", "Name of the database for the plugin.");
- gcv_iMaxGangSize = AutoExecConfig_CreateConVar("hl_gangs_max_size", "3", "Initial size for a gang");
- gcv_iSizePrice = AutoExecConfig_CreateConVar("hl_gangs_size_price", "20000", "Price of the Size perk");
- gcv_iPriceModifier = AutoExecConfig_CreateConVar("hl_gangs_price_modifier", "30000", "Price modifier for perks\n Set 0 to disable");
- gcv_iGangSizeMaxUpgrades = AutoExecConfig_CreateConVar("hl_gangs_size_max_upgrades", "6", "The maximum amount of size upgrades that may occur");
- gcv_iHealthPrice = AutoExecConfig_CreateConVar("hl_gangs_health_price", "10000", "Price of the Health perk");
- gcv_fHealthModifier = AutoExecConfig_CreateConVar("hl_gangs_health_modifier", "10", "Health perk modifier. 1.0 default");
- gcv_iCashPrice = AutoExecConfig_CreateConVar("hl_gangs_cash_price", "20000", "Price of the Cash perk");
- gcv_iStorePrice = AutoExecConfig_CreateConVar("hl_gangs_store_price", "20000", "Price of the Store perk");
- gcv_fStoreModifier = AutoExecConfig_CreateConVar("hl_gangs_store_modifier", "1", "Store perk modifier. 0.02 default");
- gcv_iMedishotPrice = AutoExecConfig_CreateConVar("hl_gangs_medishot_price", "15000", "Price of the Medishot perk");
- gcv_iCreateGangPrice = AutoExecConfig_CreateConVar("hl_gangs_creation_price", "500", "Price of gang creation");
- gcv_iRenamePrice = AutoExecConfig_CreateConVar("hl_gangs_rename_price", "50000", "Price to rename");
- /* Perk Disabling */
- gcv_bDisableCash = AutoExecConfig_CreateConVar("hl_gangs_cash", "0", "Disable the cash perk?\n Set 1 to disable");
- gcv_bDisableHealth = AutoExecConfig_CreateConVar("hl_gangs_health", "0", "Disable the health perk?\n Set 1 to disable");
- gcv_bDisableMedishot = AutoExecConfig_CreateConVar("hl_gangs_medishot", "0", "Disable the medishot perk?\n Set 1 to disable");
- gcv_bDisableStore = AutoExecConfig_CreateConVar("hl_gangs_store", "0", "Disable the store perk?\n Set 1 to disable");
- gcv_bDisableSize = AutoExecConfig_CreateConVar("hl_gangs_size", "0", "Disable the size perk?\n Set 1 to disable");
- AutoExecConfig_ExecuteFile();
- AutoExecConfig_CleanFile();
- gcv_sDatabase.GetString(g_sDatabaseName, sizeof(g_sDatabaseName));
- /* Forwards */
- g_hOnMainMenuCallback = CreateGlobalForward("Gangs_OnMenuCallback", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
- g_hOnMainMenu = CreateGlobalForward("Gangs_OnMenuCreated", ET_Ignore, Param_Cell, Param_Cell);
- g_hOnPerkMenuCallback = CreateGlobalForward("Gangs_OnPerkMenuCallback", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
- g_hOnPerkMenu = CreateGlobalForward("Gangs_OnPerkMenuCreated", ET_Ignore, Param_Cell, Param_Cell);
- g_hOnGangPerksSetPre = CreateGlobalForward("Gangs_OnPerksSetPre", ET_Ignore, Param_Cell, Param_CellByRef);
- /* Events */
- HookEvent("player_spawn", Event_PlayerSpawn);
- HookEvent("round_start", Event_RoundStart);
- RegConsoleCmd("sm_gang", Command_Gang, "Open the gang menu!");
- RegConsoleCmd("sm_gangs", Command_Gang, "Open the gang menu!");
- RegConsoleCmd("sm_clan", Command_Gang, "Open the gang menu!");
- RegConsoleCmd("sm_clans", Command_Gang, "Open the gang menu!");
- RegConsoleCmd("sm_klan", Command_Gang, "Open the gang menu!");
- RegConsoleCmd("sm_klany", Command_Gang, "Open the gang menu!");
- RegConsoleCmd("sm_addfunds", sm_addfunds);
- RegConsoleCmd("sm_bank", sm_addfunds);
- RegConsoleCmd("sm_reload", sm_reload);
- if (gcv_bInviteStyle.BoolValue)
- {
- RegConsoleCmd("sm_accept", Command_Accept, "Accept an invitation!");
- }
- AddCommandListener(OnSay, "say");
- AddCommandListener(OnSay, "say_team");
- for(int i = 1; i <= MaxClients; i++)
- {
- if(IsValidClient(i))
- {
- LoadSteamID(i);
- OnClientPutInServer(i);
- }
- }
- g_bZepyhrus = LibraryExists("store_zephyrus");
- if (g_bZepyhrus)
- {
- return; // Don't bother checking if others exist
- }
- }
- public void OnClientConnected(int client)
- {
- if (gcv_bPluginEnabled.BoolValue)
- {
- ResetVariables(client);
- }
- if (ga_iStore[client] != 0 && !gcv_bDisableStore.BoolValue)
- {
- Store_SetClientCredits(client, (Store_GetClientCredits(client) + gcv_fStoreModifier.IntValue * ga_iStore[client]));
- CreateTimer(30.0, Timer_GrantStore, GetClientUserId(client), TIMER_REPEAT);
- }
- }
- public void OnClientDisconnect(int client)
- {
- if (gcv_bPluginEnabled.BoolValue)
- {
- UpdateSQL(client);
- ResetVariables(client);
- }
- }
- public void OnConfigsExecuted()
- {
- if (gcv_bPluginEnabled.BoolValue)
- {
- if (g_hDatabase == null)
- {
- SetDB();
- }
- if (g_bLateLoad)
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i))
- {
- GetClientAuthId(i, AuthId_Steam2, ga_sSteamID[i], sizeof(ga_sSteamID[]));
- if (StrContains(ga_sSteamID[i], "STEAM_", true) != -1)
- {
- LoadSteamID(i);
- }
- else
- {
- CreateTimer(10.0, RefreshSteamID, GetClientUserId(i), TIMER_FLAG_NO_MAPCHANGE);
- }
- }
- }
- }
- }
- }
- public Action Timer_GiveHealth(Handle timer, any client)
- {
- if (ga_iHealth[client] != 0 && !gcv_bDisableHealth.BoolValue)
- {
- int iHealth = ga_iHealth[client] * gcv_fHealthModifier.IntValue + GetClientHealth(client);
- SetEntProp(client, Prop_Send, "m_iHealth", iHealth);
- }
- if (ga_iMedishot[client] != 0 && !gcv_bDisableMedishot.BoolValue)
- {
- GivePlayerItem(client, "weapon_healthshot");
- }
- }
- public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
- {
- CreateTimer(5.0, GiveExtraCash);
- }
- public Action GiveExtraCash(Handle timer)
- {
- for(int i; i < MAXPLAYERS + 1; i++)
- {
- if(ga_iCash[i] > 0)
- {
- int g_iToolsAccount = FindSendPropInfo("CCSPlayer", "m_iAccount");
- int cash = GetEntData(i, g_iToolsAccount, 4);
- cash = cash + (ga_iCash[i]*2000);
- SetEntData(i, g_iToolsAccount, cash, 4);
- }
- }
- }
- public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(event.GetInt("userid"));
- if (IsValidClient(client))
- {
- if (ga_bHasGang[client])
- {
- bool shouldSetPerks = true;
- Call_StartForward(g_hOnGangPerksSetPre);
- Call_PushCell(client);
- Call_PushCellRef(shouldSetPerks);
- Call_Finish();
- if (!shouldSetPerks)
- {
- return Plugin_Continue;
- }
- CreateTimer(2.0, Timer_GiveHealth, client);
- }
- }
- return Plugin_Continue;
- }
- public Action Timer_GrantStore(Handle hHandle, int iUserid)
- {
- int client = GetClientOfUserId(iUserid);
- if (ga_iStore[client] != 0 && !gcv_bDisableStore.BoolValue)
- {
- Store_SetClientCredits(client, (Store_GetClientCredits(client) + gcv_fStoreModifier.IntValue * ga_iStore[client]));
- }
- return Plugin_Continue;
- }
- public Action RefreshSteamID(Handle hTimer, int iUserID)
- {
- int client = GetClientOfUserId(iUserID);
- if (!IsValidClient(client))
- {
- return;
- }
- GetClientAuthId(client, AuthId_Steam2, ga_sSteamID[client], sizeof(ga_sSteamID[]));
- if (StrContains(ga_sSteamID[client], "STEAM_", true) == -1) //still invalid - retry again
- {
- CreateTimer(10.0, RefreshSteamID, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
- }
- else
- {
- LoadSteamID(client);
- }
- }
- public void OnClientPutInServer(int client)
- {
- if (IsValidClient(client))
- {
- CreateTimer(2.0, Timer_AlertGang, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
- }
- }
- public Action Timer_AlertGang(Handle hTimer, int userid)
- {
- int client = GetClientOfUserId(userid);
- if (!IsValidClient(client))
- {
- return;
- }
- char name[MAX_NAME_LENGTH];
- GetClientName(client, name, sizeof(name));
- PrintToGang(client, false, "%s %T", TAG, "GangAlert", LANG_SERVER, name);
- }
- public void OnClientPostAdminCheck(int client)
- {
- if (gcv_bPluginEnabled.BoolValue)
- {
- LoadSteamID(client);
- }
- }
- public void OnLibraryAdded(const char[] name)
- {
- if (StrEqual(name, "store_zephyrus"))
- {
- g_bZepyhrus = true;
- }
- }
- public void OnLibraryRemoved(const char[] name)
- {
- if (StrEqual(name, "store_zephyrus"))
- {
- g_bZepyhrus = false;
- }
- }
- /* SQL Callback On First Connection */
- public void SQLCallback_Connect(Database db, const char[] error, any data)
- {
- if (db == null)
- {
- SetFailState(error);
- }
- else
- {
- g_hDatabase = db;
- g_hDatabase.Query(SQLCallback_Void, "CREATE TABLE IF NOT EXISTS `hl_gangs_players` (`id` int(20) NOT NULL AUTO_INCREMENT, `steamid` varchar(32) NOT NULL, `playername` varchar(32) NOT NULL, `gang` varchar(32) NOT NULL, `rank` int(16) NOT NULL, `invitedby` varchar(32) NOT NULL, `date` int(32) NOT NULL, `share` int(20) NOT NULL, PRIMARY KEY (`id`)) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1", 1);
- g_hDatabase.Query(SQLCallback_Void, "CREATE TABLE IF NOT EXISTS `hl_gangs_groups` (`id` int(20) NOT NULL AUTO_INCREMENT, `gang` varchar(32) NOT NULL, `health` int(16) NOT NULL, `cash` int(16) NOT NULL, `store` int(16) NOT NULL, `medishot` int(16) NOT NULL, `size` int(16) NOT NULL, `funds` int(20) NOT NULL, PRIMARY KEY (`id`)) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1", 1);
- g_hDatabase.Query(SQLCallback_Void, "CREATE TABLE IF NOT EXISTS `hl_gangs_statistics` (`id` int(20) NOT NULL AUTO_INCREMENT, `gang` varchar(32) NOT NULL, `value` int(20) NOT NULL, PRIMARY KEY (`id`)) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1", 1);
- g_hDatabase.Query(SQLCallback_Void, "ALTER TABLE `hl_gangs_groups` MODIFY COLUMN `gang` varchar(32) NOT NULL unique", 1);
- g_hDatabase.Query(SQLCallback_Void, "ALTER TABLE `hl_gangs_statistics` MODIFY COLUMN `gang` varchar(32) NOT NULL unique", 1);
- DeleteDuplicates();
- }
- }
- void LoadSteamID(int client)
- {
- if (gcv_bPluginEnabled.BoolValue)
- {
- if (!IsValidClient(client))
- {
- return;
- }
- GetClientAuthId(client, AuthId_Steam2, ga_sSteamID[client], sizeof(ga_sSteamID[]));
- if (StrContains(ga_sSteamID[client], "STEAM_", true) == -1) //if ID is invalid
- {
- CreateTimer(10.0, RefreshSteamID, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
- }
- if (g_hDatabase == null) //connect not loaded - retry to give it time
- {
- CreateTimer(1.0, RepeatCheckRank, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
- }
- else
- {
- char sQuery[300];
- Format(sQuery, sizeof(sQuery), "SELECT * FROM hl_gangs_players WHERE steamid=\"%s\"", ga_sSteamID[client]);
- g_hDatabase.Query(SQLCallback_CheckSQL_Player, sQuery, GetClientUserId(client));
- }
- }
- }
- public void SQLCallback_CheckSQL_Player(Database db, DBResultSet results, const char[] error, int data)
- {
- if (db == null)
- {
- SetDB();
- }
- if (results == null)
- {
- LogError(error);
- return;
- }
- int client = GetClientOfUserId(data);
- if (!IsValidClient(client))
- {
- return;
- }
- else
- {
- if (results.RowCount == 1)
- {
- results.FetchRow();
- results.FetchString(3, ga_sGangName[client], sizeof(ga_sGangName[]));
- ga_iRank[client] = view_as<GangRank>(results.FetchInt(4));
- results.FetchString(5, ga_sInvitedBy[client], sizeof(ga_sInvitedBy[]));
- ga_iDateJoined[client] = results.FetchInt(6);
- ga_iShare[client] = results.FetchInt(7);
- ga_bIsPlayerInDatabase[client] = true;
- ga_bHasGang[client] = true;
- ga_iFunds[client] = 0;
- ga_iHealth[client] = 0;
- ga_iCash[client] = 0;
- ga_iStore[client] = 0;
- ga_iMedishot[client] = 0;
- ga_iSize[client] = 0;
- char sQuery_2[300];
- Format(sQuery_2, sizeof(sQuery_2), "SELECT * FROM hl_gangs_groups WHERE gang=\"%s\"", ga_sGangName[client]);
- g_hDatabase.Query(SQLCallback_CheckSQL_Groups, sQuery_2, GetClientUserId(client));
- }
- else
- {
- if (results.RowCount > 1)
- {
- LogError("Player %L has multiple entries under their ID. Running script to clean up duplicates and keep original entry (oldest)", client);
- DeleteDuplicates();
- CreateTimer(20.0, RepeatCheckRank, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
- PrintToChat(client, "Player %L has multiple entries under their ID. Running script to clean up duplicates and keep original entry (oldest)", client);
- }
- else if (g_hDatabase == null)
- {
- CreateTimer(2.0, RepeatCheckRank, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
- }
- else
- {
- ga_bHasGang[client] = false;
- ga_bLoaded[client] = true;
- }
- }
- }
- }
- public void SQLCallback_CheckSQL_Groups(Database db, DBResultSet results, const char[] error, int data)
- {
- if (db == null)
- {
- SetDB();
- }
- if (results == null)
- {
- LogError(error);
- return;
- }
- int client = GetClientOfUserId(data);
- if (!IsValidClient(client))
- {
- return;
- }
- else
- {
- if (results.RowCount == 1)
- {
- results.FetchRow();
- ga_iHealth[client] = results.FetchInt(2);
- ga_iCash[client] = results.FetchInt(3);
- ga_iStore[client] = results.FetchInt(4);
- ga_iMedishot[client] = results.FetchInt(5);
- ga_iSize[client] = results.FetchInt(6);
- ga_iFunds[client] = results.FetchInt(7);
- }
- }
- }
- public Action RepeatCheckRank(Handle timer, int iUserID)
- {
- int client = GetClientOfUserId(iUserID);
- LoadSteamID(client);
- }
- public void SQLCallback_Void(Database db, DBResultSet results, const char[] error, int data)
- {
- if (db == null)
- {
- LogError("Error (%i): %s", data, error);
- }
- }
- public Action Command_Accept(int client, int args)
- {
- if (!gcv_bPluginEnabled.BoolValue)
- {
- ReplyToCommand(client, "%t", "DisabledPlugin");
- return Plugin_Handled;
- }
- if (gcv_bInviteStyle.BoolValue)
- {
- ReplyToCommand(client, "%t","DisabledAcceptCommand");
- return Plugin_Handled;
- }
- if (!IsValidClient(client))
- {
- ReplyToCommand(client, "[SM] %t", "PlayerNotInGame");
- return Plugin_Handled;
- }
- if (ga_bHasGang[client])
- {
- ReplyToCommand(client, "%s %t", TAG, "AlreadyInGang");
- return Plugin_Handled;
- }
- if (ga_iInvitation[client] == -1)
- {
- ReplyToCommand(client, "%s %t", TAG, "NotInvited");
- return Plugin_Handled;
- }
- int sender = GetClientOfUserId(ga_iInvitation[client]);
- if (ga_iGangSize[sender] >= gcv_iMaxGangSize.IntValue + ga_iSize[sender] && !gcv_bDisableSize.BoolValue)
- {
- ReplyToCommand(client, "%s %t", TAG, "GangIsFull");
- return Plugin_Handled;
- }
- ga_sGangName[client] = ga_sGangName[sender];
- ga_iDateJoined[client] = GetTime();
- ga_bHasGang[client] = true;
- ga_bSetName[client] = false;
- char sName[MAX_NAME_LENGTH];
- GetClientName(sender, sName, sizeof(sName));
- ga_iShare[client] = 0;
- ga_iFunds[client] = ga_iFunds[sender];
- ga_iHealth[client] = ga_iHealth[sender];
- ga_iCash[client] = ga_iCash[sender];
- ga_iStore[client] = ga_iStore[sender];
- ga_iMedishot[client] = ga_iMedishot[sender];
- ga_iSize[client] = ga_iSize[sender];
- ga_iGangSize[client] = ++ga_iGangSize[sender];
- ga_sInvitedBy[client] = sName;
- ga_iRank[client] = Rank_Normal;
- UpdateSQL(client);
- return Plugin_Handled;
- }
- public Action Command_Gang(int client, int args)
- {
- if (!IsValidClient(client))
- {
- ReplyToCommand(client, "[SM] %t", "PlayerNotInGame");
- return Plugin_Handled;
- }
- StartOpeningGangMenu(client);
- return Plugin_Handled;
- }
- public Action sm_addfunds(int client, int args) {
- if (!IsValidClient(client)) { // invalid client
- PrintToChat(client, "[SM] %t", "PlayerNotInGame");
- return Plugin_Handled;
- }
- if(ga_bHasGang[client])
- {
- if (args != 1)
- { // invalid argument count
- PrintToChat(client, "%s %t", TAG, "Invalid Arguments");
- return Plugin_Handled;
- }
- char FundsAmount[64], sQuery[300];
- GetCmdArg(1, FundsAmount, sizeof(FundsAmount));
- int curCredits = Store_GetClientCredits(client);
- int addCredits = StringToInt(FundsAmount);
- if (curCredits < addCredits) { // not enough credits
- PrintToChat(client, "%s %t", TAG, "Not Enough Credits", curCredits);
- return Plugin_Handled;
- }
- Store_SetClientCredits(client, (Store_GetClientCredits(client) - addCredits));
- ga_iShare[client] = ga_iShare[client] + addCredits;
- for (int i = 0; i <= MaxClients; i++)
- {
- if (IsValidClient(i) && StrEqual(ga_sGangName[i], ga_sGangName[client]))
- {
- ga_iFunds[i] = ga_iFunds[i] + addCredits;
- }
- }
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_players SET share = share + %i WHERE steamid=\"%s\"", addCredits, ga_sSteamID[client]);
- g_hDatabase.Query(SQLCallback_Void, sQuery);
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_groups SET funds = funds + %i WHERE gang=\"%s\"", addCredits, ga_sGangName[client]);
- g_hDatabase.Query(SQLCallback_Void, sQuery);
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_statistics SET value = value + %i WHERE gang=\"%s\"", addCredits, ga_sGangName[client]);
- g_hDatabase.Query(SQLCallback_Void, sQuery);
- PrintToChat(client, "%s %t", TAG, "Funds Added", addCredits);
- }
- else
- PrintToChat(client, "%s %t", TAG, "Funds Not Added");
- return Plugin_Handled;
- }
- public Action sm_reload(int client, int args)
- {
- if (IsValidClient(client))
- {
- if(!ga_bReloaded)
- {
- if(ga_bHasGang[client])
- {
- LoadSteamID(client);
- PrintToChat(client, "%s %t", TAG, "Reloaded");
- ga_bReloaded[client] = true;
- return Plugin_Handled;
- } else
- {
- PrintToChat(client, "%s %t", TAG, "Not Reloaded");
- return Plugin_Handled;
- }
- } else
- {
- PrintToChat(client, "%s %t", TAG, "Already Reloaded");
- return Plugin_Handled;
- }
- }
- else
- return Plugin_Handled;
- }
- /*****************************************************************
- *********************** MAIN GANG MENU **************************
- ******************************************************************/
- void StartOpeningGangMenu(int client)
- {
- if (!StrEqual(ga_sGangName[client], ""))
- {
- char sQuery[300];
- Format(sQuery, sizeof(sQuery), "SELECT * FROM hl_gangs_players WHERE gang = \"%s\"", ga_sGangName[client]);
- g_hDatabase.Query(SQLCallback_OpenGangMenu, sQuery, GetClientUserId(client));
- }
- else
- {
- OpenGangsMenu(client);
- }
- }
- public void SQLCallback_OpenGangMenu(Database db, DBResultSet results, const char[] error, int data)
- {
- if (results == null)
- {
- LogError(error);
- return;
- }
- int client = GetClientOfUserId(data);
- if (!IsValidClient(client))
- {
- return;
- }
- else
- {
- ga_iGangSize[client] = results.RowCount;
- }
- OpenGangsMenu(client);
- }
- void OpenGangsMenu(int client)
- {
- Menu menu = CreateMenu(GangsMenu_Callback, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem);
- if (ga_bHasGang[client])
- {
- char sString[128];
- Format(sString, sizeof(sString), "%T \n%T %i \n%T: %s %i/%i", "GangsMenuTitle", client
- , "Credits", client
- , ga_iFunds[client]
- , "CurrentGang", client
- , ga_sGangName[client], ga_iGangSize[client], gcv_iMaxGangSize.IntValue + ga_iSize[client]);
- SetMenuTitle(menu, sString);
- }
- else
- {
- char sString[128];
- Format(sString, sizeof(sString), "%T \n%T: %i \n%T N/A", "GangsMenuTitle", client
- , "Credits", client
- , GetClientCredits(client)
- , "CurrentGang", client);
- SetMenuTitle(menu, sString);
- }
- char sDisplayBuffer[128];
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i %T]", "CreateAGang", client, gcv_iCreateGangPrice.IntValue, "Credits", client);
- menu.AddItem("create", sDisplayBuffer, (ga_bHasGang[client] || GetClientCredits(client) < gcv_iCreateGangPrice.IntValue)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T", "InviteToGang", client);
- menu.AddItem("invite", sDisplayBuffer, (ga_bHasGang[client] && ga_iRank[client] > Rank_Normal && ga_iGangSize[client] < gcv_iMaxGangSize.IntValue + ga_iSize[client])?ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T", "GangMembers", client);
- menu.AddItem("members", sDisplayBuffer, (ga_bHasGang[client])?ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
- if (gcv_bDisableCash.BoolValue && gcv_bDisableStore.BoolValue && gcv_bDisableHealth.BoolValue && gcv_bDisableSize.BoolValue && gcv_bDisableMedishot.BoolValue)
- {
- // draw nothing
- }
- else
- {
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T", "GangPerks", client);
- menu.AddItem("perks", sDisplayBuffer, (ga_bHasGang[client])?ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
- }
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T", "GangAdmin", client);
- menu.AddItem("admin", sDisplayBuffer, (ga_iRank[client] >= Rank_Admin)?ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T", "LeaveGang", client);
- menu.AddItem("leave", sDisplayBuffer, (ga_bHasGang[client])?ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T", "TopGangs", client);
- menu.AddItem("topgangs", sDisplayBuffer);
- Call_StartForward(g_hOnMainMenu);
- Call_PushCell(client);
- Call_PushCell(menu);
- Call_Finish();
- menu.Display(client, MENU_TIME_FOREVER);
- }
- public int GangsMenu_Callback(Menu menu, MenuAction action, int param1, int param2)
- {
- Call_StartForward(g_hOnMainMenuCallback);
- Call_PushCell(menu);
- Call_PushCell(action);
- Call_PushCell(param1);
- Call_PushCell(param2);
- Call_Finish();
- if (!IsValidClient(param1))
- {
- return;
- }
- switch (action)
- {
- case MenuAction_Select:
- {
- char sInfo[64];
- GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
- if (StrEqual(sInfo, "create"))
- {
- SetClientCredits(param1, GetClientCredits(param1) - gcv_iCreateGangPrice.IntValue);
- StartGangCreation(param1);
- }
- else if (StrEqual(sInfo, "invite"))
- {
- OpenInvitationMenu(param1);
- }
- else if (StrEqual(sInfo, "members"))
- {
- StartOpeningMembersMenu(param1);
- }
- else if (StrEqual(sInfo, "perks"))
- {
- StartOpeningPerkMenu(param1);
- }
- else if (StrEqual(sInfo, "admin"))
- {
- OpenAdministrationMenu(param1);
- }
- else if (StrEqual(sInfo, "leave"))
- {
- OpenLeaveConfirmation(param1);
- }
- else if (StrEqual(sInfo, "topgangs"))
- {
- StartOpeningTopGangsMenu(param1);
- }
- }
- case MenuAction_End:
- {
- delete menu;
- }
- }
- return;
- }
- /*****************************************************************
- *********************** GANG CREATION **************************
- ******************************************************************/
- void StartGangCreation(int client)
- {
- if (!IsValidClient(client))
- {
- ReplyToCommand(client, "[SM] %t", "PlayerNotInGame", client);
- return;
- }
- for (int i = 0; i <= 5; i++)
- {
- PrintToChat(client, "%s %t", TAG, "GangName");
- }
- ga_bSetName[client] = true;
- }
- public Action OnSay(int client, const char[] command, int args)
- {
- if (!IsValidClient(client))
- {
- return Plugin_Continue;
- }
- if (ga_bSetName[client])
- {
- char sText[64], sFormattedText[2*sizeof(sText)+1];
- GetCmdArgString(sText, sizeof(sText));
- StripQuotes(sText);
- g_hDatabase.Escape(sText, sFormattedText, sizeof(sFormattedText));
- TrimString(sFormattedText);
- if (strlen(sText) > 16)
- {
- PrintToChat(client, "%s %t", TAG, "NameTooLong");
- return Plugin_Handled;
- }
- else if (strlen(sText) == 0)
- {
- return Plugin_Handled;
- }
- DataPack data = new DataPack();
- data.WriteCell(client);
- data.WriteString(sText);
- data.Reset();
- char sQuery[300];
- Format(sQuery, sizeof(sQuery), "SELECT * FROM hl_gangs_groups WHERE gang=\"%s\"", sFormattedText);
- g_hDatabase.Query(SQL_Callback_CheckName, sQuery, data);
- return Plugin_Handled;
- }
- else if (ga_bRename[client])
- {
- char sText[64], sFormattedText[2*sizeof(sText)+1];
- GetCmdArgString(sText, sizeof(sText));
- StripQuotes(sText);
- g_hDatabase.Escape(sText, sFormattedText, sizeof(sFormattedText));
- TrimString(sFormattedText);
- if (strlen(sText) > 16)
- {
- PrintToChat(client, "%s %t", TAG, "NameTooLong");
- return Plugin_Handled;
- }
- else if (strlen(sText) == 0)
- {
- return Plugin_Handled;
- }
- DataPack data = new DataPack();
- data.WriteCell(client);
- data.WriteString(sText);
- data.Reset();
- char sQuery[300];
- Format(sQuery, sizeof(sQuery), "SELECT * FROM hl_gangs_groups WHERE gang=\"%s\"", sFormattedText);
- g_hDatabase.Query(SQL_Callback_CheckName, sQuery, data);
- return Plugin_Handled;
- }
- return Plugin_Continue;
- }
- public void SQL_Callback_CheckName(Database db, DBResultSet results, const char[] error, DataPack data)
- {
- if (db == null)
- {
- SetDB();
- }
- if (results == null)
- {
- LogError(error);
- return;
- }
- char sText[64];
- int client = data.ReadCell();
- data.ReadString(sText, sizeof(sText));
- delete data;
- if (!IsValidClient(client))
- {
- return;
- }
- else
- {
- if (ga_bSetName[client])
- {
- if (results.RowCount == 0)
- {
- strcopy(ga_sGangName[client], sizeof(ga_sGangName[]), sText);
- ga_bHasGang[client] = true;
- ga_iDateJoined[client] = GetTime();
- ga_bHasGang[client] = true;
- ga_sInvitedBy[client] = "N/A";
- ga_iRank[client] = Rank_Owner;
- ga_iGangSize[client] = 1;
- ga_iShare[client] = gcv_iCreateGangPrice.IntValue;
- ga_iFunds[client] = gcv_iCreateGangPrice.IntValue;
- ga_iHealth[client] = 0;
- ga_iCash[client] = 0;
- ga_iStore[client] = 0;
- ga_iMedishot[client] = 0;
- ga_iSize[client] = 0;
- UpdateSQL(client);
- char sQuery[300];
- Format(sQuery, sizeof(sQuery), "SELECT * FROM hl_gangs_statistics WHERE gang = \"%s\"", ga_sGangName[client]);
- g_hDatabase.Query(SQL_Callback_LoadStatistics, sQuery, GetClientUserId(client));
- CreateTimer(0.2, Timer_OpenGangMenu, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
- char name[MAX_NAME_LENGTH];
- GetClientName(client, name, sizeof(name));
- PrintToChatAll("%s %T", TAG, "GangCreated", LANG_SERVER, name, ga_sGangName[client]);
- }
- else
- {
- PrintToChat(client, "%s %t", TAG, "NameAlreadyUsed");
- }
- ga_bSetName[client] = false;
- }
- else if (ga_bRename[client])
- {
- if (results.RowCount == 0)
- {
- char sOldName[32];
- strcopy(sOldName, sizeof(sOldName), ga_sGangName[client]);
- strcopy(ga_sGangName[client], sizeof(ga_sGangName[]), sText);
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i) && StrEqual(ga_sGangName[i], sOldName))
- {
- strcopy(ga_sGangName[i], sizeof(ga_sGangName[]), sText);
- }
- }
- char sQuery[300];
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_players SET gang=\"%s\" WHERE gang=\"%s\"", sText, sOldName);
- g_hDatabase.Query(SQLCallback_Void, sQuery);
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_groups SET gang=\"%s\" WHERE gang=\"%s\"", sText, sOldName);
- g_hDatabase.Query(SQLCallback_Void, sQuery);
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_statistics SET gang=\"%s\" WHERE gang=\"%s\"", sText, sOldName);
- g_hDatabase.Query(SQLCallback_Void, sQuery);
- char name[MAX_NAME_LENGTH];
- GetClientName(client, name, sizeof(name));
- PrintToChatAll("%s %T", TAG, "GangNameChange", LANG_SERVER, name, sOldName, sText);
- ga_iFunds[client] = ga_iFunds[client] - gcv_iRenamePrice.IntValue;
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_groups SET funds=%i WHERE gang=\"%s\"", ga_iFunds[client], ga_sGangName[client]);
- g_hDatabase.Query(SQLCallback_Void, sQuery);
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_statistics SET value=value-%i WHERE gang=\"%s\"", gcv_iRenamePrice, ga_sGangName[client]);
- g_hDatabase.Query(SQLCallback_Void, sQuery);
- StartOpeningGangMenu(client);
- }
- else
- {
- PrintToChat(client, "%s %t", TAG, "NameAlreadyUsed");
- }
- ga_bRename[client] = false;
- }
- }
- }
- public void SQL_Callback_LoadStatistics(Database db, DBResultSet results, const char[] error, int data)
- {
- if (db == null)
- {
- SetDB();
- }
- if (results == null)
- {
- LogError(error);
- return;
- }
- int client = GetClientOfUserId(data);
- if (!IsValidClient(client))
- {
- return;
- }
- if (results.RowCount == 0)
- {
- ga_bIsGangInDatabase[client] = false;
- }
- else
- {
- ga_bIsGangInDatabase[client] = true;
- }
- char sQuery[300];
- if (!ga_bIsGangInDatabase[client])
- {
- Format(sQuery, sizeof(sQuery), "INSERT INTO hl_gangs_statistics (gang, value) VALUES(\"%s\", %i)", ga_sGangName[client], gcv_iCreateGangPrice.IntValue);
- }
- g_hDatabase.Query(SQLCallback_Void, sQuery);
- }
- public Action Timer_OpenGangMenu(Handle hTimer, int userid)
- {
- int client = GetClientOfUserId(userid);
- if(IsValidClient(client))
- {
- StartOpeningGangMenu(client);
- }
- }
- /*****************************************************************
- *********************** MEMBER LIST MENU *************************
- ******************************************************************/
- void StartOpeningMembersMenu(int client)
- {
- if (!StrEqual(ga_sGangName[client], ""))
- {
- char sQuery[300];
- Format(sQuery, sizeof(sQuery), "SELECT * FROM hl_gangs_players WHERE gang=\"%s\"", ga_sGangName[client]);
- g_hDatabase.Query(SQLCallback_OpenMembersMenu, sQuery, GetClientUserId(client));
- }
- }
- public void SQLCallback_OpenMembersMenu(Database db, DBResultSet results, const char[] error, int data)
- {
- if (db == null)
- {
- SetDB();
- }
- int client = GetClientOfUserId(data);
- if (!IsValidClient(client))
- {
- return;
- }
- else
- {
- Menu menu = CreateMenu(MemberListMenu_CallBack, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem | MenuAction_Cancel);
- char sTitleString[128];
- Format(sTitleString, sizeof(sTitleString), "%T", "MemberList", client);
- SetMenuTitle(menu, sTitleString);
- while (results.FetchRow())
- {
- char a_sTempArray[6][128]; // 0 - SteamID | 1 - Name | 2 - Invited By | 3 - Rank | 4 - Date (UTF) | 5 - Share
- results.FetchString(1, a_sTempArray[0], sizeof(a_sTempArray[])); // Steam-ID
- results.FetchString(2, a_sTempArray[1], sizeof(a_sTempArray[])); // Player Name
- results.FetchString(5, a_sTempArray[2], sizeof(a_sTempArray[])); // Invited By
- IntToString(results.FetchInt(4), a_sTempArray[3], sizeof(a_sTempArray[])); // Rank
- IntToString(results.FetchInt(6), a_sTempArray[4], sizeof(a_sTempArray[])); // Date
- IntToString(results.FetchInt(7), a_sTempArray[5], sizeof(a_sTempArray[])); // Share
- char sInfoString[128];
- char sDisplayString[128];
- Format(sInfoString, sizeof(sInfoString), "%s;%s;%s;%i;%i;%i", a_sTempArray[0], a_sTempArray[1], a_sTempArray[2], StringToInt(a_sTempArray[3]), StringToInt(a_sTempArray[4]), StringToInt(a_sTempArray[5]));
- if (StrEqual(a_sTempArray[3], "0"))
- {
- Format(sDisplayString, sizeof(sDisplayString), "%s (%T)", a_sTempArray[1], "MemberRank", client);
- }
- else if (StrEqual(a_sTempArray[3], "1"))
- {
- Format(sDisplayString, sizeof(sDisplayString), "%s (%T)", a_sTempArray[1], "AdminRank", client);
- }
- else if (StrEqual(a_sTempArray[3], "2"))
- {
- Format(sDisplayString, sizeof(sDisplayString), "%s (%T)", a_sTempArray[1], "OwnerRank", client);
- }
- menu.AddItem(sInfoString, sDisplayString);
- }
- menu.ExitBackButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- }
- }
- public int MemberListMenu_CallBack(Menu menu, MenuAction action, int param1, int param2)
- {
- switch (action)
- {
- case MenuAction_Select:
- {
- char sInfo[128];
- GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
- OpenIndividualMemberMenu(param1, sInfo);
- }
- case MenuAction_Cancel:
- {
- StartOpeningGangMenu(param1);
- }
- case MenuAction_End:
- {
- delete menu;
- }
- }
- return;
- }
- void OpenIndividualMemberMenu(int client, char[] sInfo)
- {
- Menu menu = CreateMenu(IndividualMemberMenu_Callback, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem | MenuAction_Cancel);
- SetMenuTitle(menu, "Information On : ");
- char sTempArray[6][64]; // 0 - SteamID | 1 - Name | 2 - Invited By | 3 - Rank | 4 - Date (UTF) | 5 - Share
- char sDisplayBuffer[32];
- ExplodeString(sInfo, ";", sTempArray, 6, sizeof(sTempArray[]));
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T %s", "Name", client, sTempArray[1]);
- menu.AddItem("", sDisplayBuffer, ITEMDRAW_DISABLED);
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "Steam ID : %s", sTempArray[0]);
- menu.AddItem("", sDisplayBuffer, ITEMDRAW_DISABLED);
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T %s", "InvitedBy", client, sTempArray[2]);
- menu.AddItem("", sDisplayBuffer, ITEMDRAW_DISABLED);
- if (StrEqual(sTempArray[3], "0"))
- {
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T %T", "Rank", client, "MemberRank", client);
- }
- else if (StrEqual(sTempArray[3], "1"))
- {
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T %T", "Rank", client, "AdminRank", client);
- }
- else if (StrEqual(sTempArray[3], "2"))
- {
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T %T", "Rank", client, "OwnerRank", client);
- }
- menu.AddItem("", sDisplayBuffer, ITEMDRAW_DISABLED);
- char sFormattedTime[64];
- FormatTime(sFormattedTime, sizeof(sFormattedTime), "%x", StringToInt(sTempArray[4]));
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T %s", "DateJoined", client, sFormattedTime);
- menu.AddItem("", sDisplayBuffer, ITEMDRAW_DISABLED);
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T %i", "Share", client, StringToInt(sTempArray[5]));
- menu.AddItem("", sDisplayBuffer, ITEMDRAW_DISABLED);
- menu.ExitBackButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- }
- public int IndividualMemberMenu_Callback(Menu menu, MenuAction action, int param1, int param2)
- {
- switch (action)
- {
- case MenuAction_Select:
- {
- }
- case MenuAction_Cancel:
- {
- StartOpeningMembersMenu(param1);
- }
- case MenuAction_End:
- {
- delete menu;
- }
- }
- return;
- }
- /*****************************************************************
- *********************** INVITATION MENU **************************
- ******************************************************************/
- void OpenInvitationMenu(int client)
- {
- Menu menu = CreateMenu(InvitationMenu_Callback, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem);
- char sInfoString[64];
- char sDisplayString[64];
- char sMenuString[32];
- Format(sMenuString, sizeof(sMenuString), "%T", "InviteToGang", client);
- SetMenuTitle(menu, sMenuString);
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i) && i != client)
- {
- Format(sInfoString, sizeof(sInfoString), "%i", GetClientUserId(i));
- Format(sDisplayString, sizeof(sDisplayString), "%N", i);
- SanitizeName(sDisplayString);
- menu.AddItem(sInfoString, sDisplayString, (ga_bHasGang[i] || ga_iRank[client] == Rank_Normal)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
- }
- }
- menu.Display(client, MENU_TIME_FOREVER);
- }
- public int InvitationMenu_Callback(Menu menu, MenuAction action, int param1, int param2)
- {
- switch (action)
- {
- case MenuAction_Select:
- {
- char sInfo[64];
- GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
- int iUserID = StringToInt(sInfo);
- ga_iInvitation[GetClientOfUserId(iUserID)] = GetClientUserId(param1);
- if (ga_iGangSize[param1] >= gcv_iMaxGangSize.IntValue + ga_iSize[param1]
- && !gcv_bDisableSize.BoolValue)
- {
- PrintToChat(param1, "%s %t", TAG, "GangIsFull");
- return;
- }
- if (!gcv_bInviteStyle.BoolValue)
- {
- PrintToChat(GetClientOfUserId(iUserID), "%s %t", TAG, "AcceptInstructions", ga_sGangName[param1]);
- }
- else
- {
- OpenGangInvitationMenu(GetClientOfUserId(iUserID));
- }
- // StartOpeningGangMenu(param1);
- }
- case MenuAction_Cancel:
- {
- StartOpeningGangMenu(param1);
- }
- case MenuAction_End:
- {
- delete menu;
- }
- }
- return;
- }
- void OpenGangInvitationMenu(int client)
- {
- if (!IsValidClient(client))
- {
- return;
- }
- Menu menu = CreateMenu(SentInviteMenu_Callback, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem);
- char sDisplayString[64];
- char sTitleString[64];
- Format(sTitleString, sizeof(sTitleString), "%T", "GangInvitation", client);
- SetMenuTitle(menu, sTitleString);
- int sender = GetClientOfUserId(ga_iInvitation[client]);
- char senderName[MAX_NAME_LENGTH];
- GetClientName(sender, senderName, sizeof(senderName));
- SanitizeName(senderName);
- Format(sDisplayString, sizeof(sDisplayString), "%T", "InviteString", client, senderName);
- menu.AddItem("", sDisplayString, ITEMDRAW_DISABLED);
- Format(sDisplayString, sizeof(sDisplayString), "%T", "WouldYouLikeToJoin", client, ga_sGangName[sender]);
- menu.AddItem("", sDisplayString, ITEMDRAW_DISABLED);
- Format(sDisplayString, sizeof(sDisplayString), "%T", "IWouldLikeTo", client);
- menu.AddItem("yes", sDisplayString);
- Format(sDisplayString, sizeof(sDisplayString), "%T", "IWouldNotLikeTo", client);
- menu.AddItem("no", sDisplayString);
- menu.Display(client, MENU_TIME_FOREVER);
- }
- public int SentInviteMenu_Callback(Menu menu, MenuAction action, int param1, int param2)
- {
- if (!IsValidClient(param1))
- {
- return;
- }
- switch (action)
- {
- case MenuAction_Select:
- {
- char sInfo[64];
- GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
- if (StrEqual(sInfo, "yes"))
- {
- int sender = GetClientOfUserId(ga_iInvitation[param1]);
- if (ga_iGangSize[param1] >= gcv_iMaxGangSize.IntValue + ga_iSize[param1] && !gcv_bDisableSize.BoolValue)
- {
- PrintToChat(param1, "%s %t", TAG, "GangIsFull");
- return;
- }
- ga_sGangName[param1] = ga_sGangName[sender];
- ga_iDateJoined[param1] = GetTime();
- ga_bHasGang[param1] = true;
- ga_bSetName[param1] = false;
- ga_iShare[param1] = 0;
- ga_iFunds[param1] = ga_iFunds[sender];
- ga_iHealth[param1] = ga_iHealth[sender];
- ga_iCash[param1] = ga_iCash[sender];
- ga_iStore[param1] = ga_iStore[sender];
- ga_iMedishot[param1] = ga_iMedishot[sender];
- ga_iSize[param1] = ga_iSize[sender];
- ga_iGangSize[param1] = ++ga_iGangSize[sender];
- char sName[MAX_NAME_LENGTH];
- GetClientName(sender, sName, sizeof(sName));
- ga_sInvitedBy[param1] = sName;
- ga_iRank[param1] = Rank_Normal;
- UpdateSQL(param1);
- CreateTimer(2.0, AnnounceJoining, param1);
- }
- else if (StrEqual(sInfo, "no"))
- {
- // Do Nothing
- }
- }
- case MenuAction_Cancel:
- {
- StartOpeningGangMenu(param1);
- }
- case MenuAction_End:
- {
- delete menu;
- }
- }
- return;
- }
- public Action AnnounceJoining(Handle timer, any param1)
- {
- char name[MAX_NAME_LENGTH];
- GetClientName(param1, name, sizeof(name));
- PrintToChatAll("%s %T", TAG, "GangJoined", LANG_SERVER, name, ga_sGangName[param1]);
- }
- /*****************************************************************
- *********************** PERK MENU *************************
- ******************************************************************/
- public void StartOpeningPerkMenu(int client)
- {
- if (IsValidClient(client))
- {
- char sQuery[300];
- Format(sQuery, sizeof(sQuery), "SELECT health, cash, store, medishot, size, funds FROM hl_gangs_groups WHERE gang=\"%s\"", ga_sGangName[client]);
- g_hDatabase.Query(SQLCallback_Perks, sQuery, GetClientUserId(client));
- }
- }
- public void SQLCallback_Perks(Database db, DBResultSet results, const char[] error, int data)
- {
- if (db == null)
- {
- SetDB();
- }
- int client = GetClientOfUserId(data);
- if (!IsValidClient(client))
- {
- return;
- }
- else
- {
- Menu menu = CreateMenu(PerksMenu_CallBack, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem);
- char sTitleString[64];
- Format(sTitleString, sizeof(sTitleString), "%T", "GangPerks", client);
- SetMenuTitle(menu, sTitleString);
- if (results.RowCount == 1 && results.FetchRow())
- {
- ga_iHealth[client] = results.FetchInt(0); // Health
- ga_iCash[client] = results.FetchInt(1); // Cash
- ga_iStore[client] = results.FetchInt(2); // Store credits
- ga_iMedishot[client] = results.FetchInt(3); // Medishot
- ga_iSize[client] = results.FetchInt(4);
- ga_iFunds[client] = results.FetchInt(5);
- }
- char sDisplayBuffer[64];
- int price;
- if (!gcv_bDisableHealth.BoolValue)
- {
- price = gcv_iHealthPrice.IntValue * (ga_iHealth[client] + 1);
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/5] [%i %T]", "Health", client, ga_iHealth[client], price, "Credits", client);
- menu.AddItem("health", sDisplayBuffer, (ga_iHealth[client] >= 5 || ga_iFunds[client] < price)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
- }
- if (!gcv_bDisableCash.BoolValue)
- {
- price = gcv_iCashPrice.IntValue * (ga_iCash[client] + 1);
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/5] [%i %T]", "Cash", client, ga_iCash[client], price, "Credits", client);
- menu.AddItem("cash", sDisplayBuffer, (ga_iCash[client] >= 5 || ga_iFunds[client] < price)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
- }
- if (!gcv_bDisableStore.BoolValue)
- {
- price = gcv_iStorePrice.IntValue * (ga_iStore[client] + 1);
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/5] [%i %T]", "Store", client, ga_iStore[client], price, "Credits", client);
- menu.AddItem("store", sDisplayBuffer, (ga_iStore[client] >= 5 || ga_iFunds[client] < price)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
- }
- if (!gcv_bDisableMedishot.BoolValue)
- {
- price = gcv_iMedishotPrice.IntValue * (ga_iMedishot[client] + 1);
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/1] [%i %T]", "Medishot", client, ga_iMedishot[client], price, "Credits", client);
- menu.AddItem("medishot", sDisplayBuffer, (ga_iMedishot[client] >= 1 || ga_iFunds[client] < price)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
- }
- if (!gcv_bDisableSize.BoolValue && gcv_iMaxGangSize.IntValue != 0)
- {
- price = gcv_iSizePrice.IntValue + (gcv_iPriceModifier.IntValue * ga_iSize[client]);
- Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%T [%i/%i] [%i %T]", "GangSize", client, ga_iSize[client], gcv_iGangSizeMaxUpgrades.IntValue, price, "Credits", client);
- menu.AddItem("size", sDisplayBuffer, (ga_iSize[client] >= gcv_iGangSizeMaxUpgrades.IntValue || ga_iFunds[client] < price)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
- }
- Call_StartForward(g_hOnPerkMenu);
- Call_PushCell(client);
- Call_PushCell(menu);
- Call_Finish();
- menu.ExitBackButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- }
- }
- public int PerksMenu_CallBack(Menu menu, MenuAction action, int param1, int param2)
- {
- Call_StartForward(g_hOnPerkMenuCallback);
- Call_PushCell(menu);
- Call_PushCell(action);
- Call_PushCell(param1);
- Call_PushCell(param2);
- Call_Finish();
- if (!IsValidClient(param1))
- {
- return;
- }
- switch (action)
- {
- case MenuAction_Select:
- {
- char sInfo[64];
- GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
- char sQuery[300];
- if (StrEqual(sInfo, "health"))
- {
- int price = gcv_iHealthPrice.IntValue * (ga_iHealth[param1] + 1);
- for (int i = 0; i <= MaxClients; i++)
- {
- if (IsValidClient(i) && StrEqual(ga_sGangName[i], ga_sGangName[param1]))
- {
- ga_iFunds[i] = ga_iFunds[i] - price;
- ++ga_iHealth[i];
- }
- }
- PrintToGang(param1, true, "%s %T", TAG, "HealthUpgrade", LANG_SERVER);
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_groups SET health=%i, funds=%i WHERE gang=\"%s\"", ga_iHealth[param1], ga_iFunds[param1], ga_sGangName[param1]);
- }
- else if (StrEqual(sInfo, "cash"))
- {
- int price = gcv_iCashPrice.IntValue * (ga_iCash[param1] + 1);
- for (int i = 0; i <= MaxClients; i++)
- {
- if (IsValidClient(i) && StrEqual(ga_sGangName[i], ga_sGangName[param1]))
- {
- ga_iFunds[i] = ga_iFunds[i] - price;
- ++ga_iCash[i];
- }
- }
- PrintToGang(param1, true, "%s %T", TAG, "CashUpgrade", LANG_SERVER);
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_groups SET cash=%i, funds=%i WHERE gang=\"%s\"", ga_iCash[param1], ga_iFunds[param1], ga_sGangName[param1]);
- }
- else if (StrEqual(sInfo, "store"))
- {
- int price = gcv_iStorePrice.IntValue * (ga_iStore[param1] + 1);
- for (int i = 0; i <= MaxClients; i++)
- {
- if (IsValidClient(i) && StrEqual(ga_sGangName[i], ga_sGangName[param1]))
- {
- ga_iFunds[i] = ga_iFunds[i] - price;
- ++ga_iStore[i];
- }
- }
- PrintToGang(param1, true, "%s %T", TAG, "StoreUpgrade", LANG_SERVER);
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_groups SET store=%i, funds=%i WHERE gang=\"%s\"", ga_iStore[param1], ga_iFunds[param1], ga_sGangName[param1]);
- }
- else if (StrEqual(sInfo, "medishot"))
- {
- int price = gcv_iMedishotPrice.IntValue * (ga_iMedishot[param1] + 1);
- for (int i = 0; i <= MaxClients; i++)
- {
- if (IsValidClient(i) && StrEqual(ga_sGangName[i], ga_sGangName[param1]))
- {
- ga_iFunds[i] = ga_iFunds[i] - price;
- ++ga_iMedishot[i];
- }
- }
- PrintToGang(param1, true, "%s %T", TAG, "MedishotUpgrade", LANG_SERVER);
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_groups SET medishot=%i, funds=%i WHERE gang=\"%s\"", ga_iMedishot[param1], ga_iFunds[param1],ga_sGangName[param1]);
- }
- else if (StrEqual(sInfo, "size"))
- {
- int price = gcv_iSizePrice.IntValue + (gcv_iPriceModifier.IntValue * ga_iSize[param1]);
- for (int i = 0; i <= MaxClients; i++)
- {
- if (IsValidClient(i) && StrEqual(ga_sGangName[i], ga_sGangName[param1]))
- {
- ga_iFunds[i] = ga_iFunds[i] - price;
- ++ga_iSize[i];
- }
- }
- PrintToGang(param1, true, "%s %T", TAG, "SizeUpgrade", LANG_SERVER);
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_groups SET size=%i WHERE gang=\"%s\"", ga_iSize[param1], ga_iFunds[param1], ga_sGangName[param1]);
- }
- g_hDatabase.Query(SQLCallback_Void, sQuery, GetClientUserId(param1));
- StartOpeningPerkMenu(param1);
- }
- case MenuAction_Cancel:
- {
- StartOpeningGangMenu(param1);
- }
- case MenuAction_End:
- {
- delete menu;
- }
- }
- return;
- }
- /*****************************************************************
- ******************* LEAVE CONFIRMATION ********************
- ******************************************************************/
- void OpenLeaveConfirmation(int client)
- {
- Menu menu = CreateMenu(LeaveConfirmation_Callback, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem | MenuAction_Cancel);
- char tempBuffer[128];
- Format(tempBuffer, sizeof(tempBuffer), "%T", "LeaveGang", client);
- SetMenuTitle(menu, tempBuffer);
- Format(tempBuffer, sizeof(tempBuffer), "%T", "AreYouSure", client);
- menu.AddItem("", tempBuffer, ITEMDRAW_DISABLED);
- if (ga_iRank[client] == Rank_Owner)
- {
- Format(tempBuffer, sizeof(tempBuffer), "%T", "OwnerWarning", client);
- menu.AddItem("", tempBuffer, ITEMDRAW_DISABLED);
- }
- Format(tempBuffer, sizeof(tempBuffer), "%T", "YesLeave", client);
- menu.AddItem("yes", tempBuffer);
- Format(tempBuffer, sizeof(tempBuffer), "%T", "NoLeave", client);
- menu.AddItem("no", tempBuffer);
- menu.ExitBackButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- }
- public int LeaveConfirmation_Callback(Menu menu, MenuAction action, int param1, int param2)
- {
- switch (action)
- {
- case MenuAction_Select:
- {
- char sInfo[64];
- GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
- if (StrEqual(sInfo, "yes"))
- {
- RemoveFromGang(param1);
- }
- else if (StrEqual(sInfo, "no"))
- {
- StartOpeningGangMenu(param1);
- }
- }
- case MenuAction_Cancel:
- {
- StartOpeningGangMenu(param1);
- }
- case MenuAction_End:
- {
- delete menu;
- }
- }
- return;
- }
- /*****************************************************************
- ********************* ADMIN MAIN MENU **************************
- ******************************************************************/
- void OpenAdministrationMenu(int client)
- {
- if (!IsValidClient(client))
- {
- return;
- }
- Menu menu = CreateMenu(AdministrationMenu_Callback, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem | MenuAction_Cancel);
- char tempBuffer[128];
- Format(tempBuffer, sizeof(tempBuffer), "%T", "GangAdmin", client);
- SetMenuTitle(menu, tempBuffer);
- char sDisplayString[128];
- Format(sDisplayString, sizeof(sDisplayString), "%T", "KickAMember", client);
- menu.AddItem("kick", "Kick a member", (ga_iRank[client] == Rank_Normal)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
- Format(sDisplayString, sizeof(sDisplayString), "%T [%i %T]", "RenameGang", client, gcv_iRenamePrice.IntValue, "Credits", client);
- menu.AddItem("rename", sDisplayString, (ga_iRank[client] == Rank_Owner && ga_iFunds[client] >= gcv_iRenamePrice.IntValue)?ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
- Format(sDisplayString, sizeof(sDisplayString), "%T", "Promote", client);
- menu.AddItem("promote", sDisplayString, (ga_iRank[client] == Rank_Normal)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
- Format(sDisplayString, sizeof(sDisplayString), "%T", "Disband", client);
- menu.AddItem("disband", sDisplayString, (ga_iRank[client] == Rank_Owner)?ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
- menu.ExitBackButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- }
- public int AdministrationMenu_Callback(Menu menu, MenuAction action, int param1, int param2)
- {
- if (!IsValidClient(param1))
- {
- return;
- }
- switch (action)
- {
- case MenuAction_Select:
- {
- char sInfo[64];
- GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
- if (StrEqual(sInfo, "kick"))
- {
- OpenAdministrationKickMenu(param1);
- }
- else if (StrEqual(sInfo, "rename"))
- {
- for (int i = 1; i <= 5; i++)
- {
- PrintToChat(param1, "%s %t", TAG, "GangName");
- }
- ga_bRename[param1] = true;
- }
- else if (StrEqual(sInfo, "promote"))
- {
- OpenAdministrationPromotionMenu(param1);
- }
- else if (StrEqual(sInfo, "disband"))
- {
- OpenDisbandMenu(param1);
- }
- }
- case MenuAction_Cancel:
- {
- StartOpeningGangMenu(param1);
- }
- case MenuAction_End:
- {
- delete menu;
- }
- }
- return;
- }
- /*****************************************************************
- ******************* ADMIN PROMOTION MENU ***********************
- ******************************************************************/
- void OpenAdministrationPromotionMenu(int client)
- {
- if (!StrEqual(ga_sGangName[client], ""))
- {
- char sQuery[200];
- Format(sQuery, sizeof(sQuery), "SELECT * FROM hl_gangs_players WHERE gang=\"%s\"", ga_sGangName[client]);
- g_hDatabase.Query(SQLCallback_AdministrationPromotionMenu, sQuery, GetClientUserId(client));
- }
- }
- public void SQLCallback_AdministrationPromotionMenu(Database db, DBResultSet results, const char[] error, int data)
- {
- if (db == null)
- {
- SetDB();
- }
- int client = GetClientOfUserId(data);
- if (!IsValidClient(client))
- {
- return;
- }
- else
- {
- Menu menu = CreateMenu(AdministrationPromoMenu_CallBack, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem | MenuAction_Cancel);
- char tempBuffer[128];
- Format(tempBuffer, sizeof(tempBuffer), "%T", "Promote", client);
- SetMenuTitle(menu, tempBuffer);
- while (results.FetchRow())
- {
- char sTempArray[3][128]; // 0 - SteamID | 1 - Name | 2 - Invited By | 3 - Rank | 4 - Date (UTF)
- results.FetchString(1, sTempArray[0], sizeof(sTempArray[])); // Steam-ID
- results.FetchString(2, sTempArray[1], sizeof(sTempArray[])); // Player Name
- IntToString(results.FetchInt(4), sTempArray[2], sizeof(sTempArray[])); // Rank
- char sSteamID[34];
- GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID));
- if (!StrEqual(sSteamID, sTempArray[0]))
- {
- char sInfoString[128];
- char sDisplayString[128];
- Format(sInfoString, sizeof(sInfoString), "%s;%s;%i", sTempArray[0], sTempArray[1], StringToInt(sTempArray[2]));
- Format(sDisplayString, sizeof(sDisplayString), "%s (%s)", sTempArray[1], sTempArray[0]);
- menu.AddItem(sInfoString, sDisplayString, (ga_iRank[client] == Rank_Owner)?ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
- }
- }
- menu.ExitBackButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- }
- }
- public int AdministrationPromoMenu_CallBack(Menu menu, MenuAction action, int param1, int param2)
- {
- switch (action)
- {
- case MenuAction_Select:
- {
- char sInfo[256];
- GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
- OpenPromoteDemoteMenu(param1, sInfo);
- }
- case MenuAction_Cancel:
- {
- OpenAdministrationMenu(param1);
- }
- case MenuAction_End:
- {
- delete menu;
- }
- }
- return;
- }
- void OpenPromoteDemoteMenu(int client, const char[] sInfo)
- {
- char sTempArray[3][32];
- ExplodeString(sInfo, ";", sTempArray, 3, 32);
- Menu menu = CreateMenu(AdministrationPromoDemoteMenu_CallBack, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem | MenuAction_Cancel);
- char tempBuffer[128];
- Format(tempBuffer, sizeof(tempBuffer), "%T", "GangMembersRanks", client);
- SetMenuTitle(menu, tempBuffer);
- char sInfoString[32];
- Format(tempBuffer, sizeof(tempBuffer), "%T", "Simply", client);
- menu.AddItem("", tempBuffer, ITEMDRAW_DISABLED);
- Format(sInfoString, sizeof(sInfoString), "%s;normal", sTempArray[0]);
- Format(tempBuffer, sizeof(tempBuffer), "%T", "MemberRank", client);
- menu.AddItem(sInfoString, tempBuffer, (ga_iRank[client] != Rank_Owner)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
- Format(sInfoString, sizeof(sInfoString), "%s;admin", sTempArray[0]);
- Format(tempBuffer, sizeof(tempBuffer), "%T", "AdminRank", client);
- menu.AddItem(sInfoString, tempBuffer, (ga_iRank[client] != Rank_Owner)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
- menu.ExitBackButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- }
- public int AdministrationPromoDemoteMenu_CallBack(Menu menu, MenuAction action, int param1, int param2)
- {
- switch (action)
- {
- case MenuAction_Select:
- {
- char sInfo[256];
- GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
- char sTempArray[2][32];
- ExplodeString(sInfo, ";", sTempArray, 2, 32);
- char sQuery[300];
- if (StrEqual(sTempArray[1], "normal"))
- {
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_players SET rank=0 WHERE steamid=\"%s\"", sTempArray[0]);
- }
- else if (StrEqual(sTempArray[1], "admin"))
- {
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_players SET rank=1 WHERE steamid=\"%s\"", sTempArray[0]);
- }
- g_hDatabase.Query(SQLCallback_Void, sQuery);
- char sSteamID[32];
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i))
- {
- GetClientAuthId(i, AuthId_Steam2, sSteamID, sizeof(sSteamID));
- if (StrEqual(sSteamID, sTempArray[0]))
- {
- LoadSteamID(i);
- break;
- }
- }
- }
- }
- case MenuAction_Cancel:
- {
- OpenAdministrationMenu(param1);
- }
- case MenuAction_End:
- {
- delete menu;
- }
- }
- return;
- }
- /*****************************************************************
- ********************* DISBAND MENU **************************
- ******************************************************************/
- void OpenDisbandMenu(int client)
- {
- Menu menu = CreateMenu(DisbandMenu_CallBack, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem | MenuAction_Cancel);
- char tempString[128];
- Format(tempString, sizeof(tempString), "%T", "DisbandGang", client);
- SetMenuTitle(menu, tempString);
- Format(tempString, sizeof(tempString), "%T", "DisbandConfirmation", client);
- menu.AddItem("", tempString, ITEMDRAW_DISABLED);
- Format(tempString, sizeof(tempString), "%T", "YesDisband", client);
- menu.AddItem("disband", tempString, (ga_iRank[client] != Rank_Owner)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
- Format(tempString, sizeof(tempString), "%T", "NoDisband", client);
- menu.AddItem("no", tempString, (ga_iRank[client] != Rank_Owner)?ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
- menu.ExitBackButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- }
- public int DisbandMenu_CallBack(Menu menu, MenuAction action, int param1, int param2)
- {
- switch (action)
- {
- case MenuAction_Select:
- {
- char sInfo[256];
- GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
- if (StrEqual(sInfo, "disband"))
- {
- RemoveFromGang(param1);
- }
- }
- case MenuAction_Cancel:
- {
- OpenAdministrationMenu(param1);
- }
- case MenuAction_End:
- {
- delete menu;
- }
- }
- return;
- }
- /*****************************************************************
- ********************* ADMIN KICK MENU **************************
- ******************************************************************/
- void OpenAdministrationKickMenu(int client)
- {
- if (!StrEqual(ga_sGangName[client], ""))
- {
- char sQuery[200];
- Format(sQuery, sizeof(sQuery), "SELECT * FROM hl_gangs_players WHERE gang=\"%s\"", ga_sGangName[client]);
- g_hDatabase.Query(SQLCallback_AdministrationKickMenu, sQuery, GetClientUserId(client));
- }
- }
- public void SQLCallback_AdministrationKickMenu(Database db, DBResultSet results, const char[] error, int data)
- {
- if (db == null)
- {
- SetDB();
- }
- int client = GetClientOfUserId(data);
- if (!IsValidClient(client))
- {
- return;
- }
- else
- {
- Menu menu = CreateMenu(AdministrationKickMenu_CallBack, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem | MenuAction_Cancel);
- char tempString[128];
- Format(tempString, sizeof(tempString), "%T", "KickGangMembers", client);
- SetMenuTitle(menu, tempString);
- while (results.FetchRow())
- {
- char sTempArray[3][128]; // 0 - SteamID | 1 - Name | 2 - Invited By | 3 - Rank | 4 - Date (UTF)
- results.FetchString(1, sTempArray[0], sizeof(sTempArray[])); // Steam-ID
- results.FetchString(2, sTempArray[1], sizeof(sTempArray[])); // Player Name
- IntToString(results.FetchInt(4), sTempArray[2], sizeof(sTempArray[])); // Rank
- KickShare[client] = results.FetchInt(7);
- char sInfoString[128];
- char sDisplayString[128];
- Format(sInfoString, sizeof(sInfoString), "%s;%s", sTempArray[0], sTempArray[1]);
- Format(sDisplayString, sizeof(sDisplayString), "%s (%s)", sTempArray[1], sTempArray[0]);
- menu.AddItem(sInfoString, sDisplayString, (ga_iRank[client] > view_as<GangRank>(StringToInt(sTempArray[2])))?ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
- }
- menu.ExitBackButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- }
- }
- public int AdministrationKickMenu_CallBack(Menu menu, MenuAction action, int param1, int param2)
- {
- switch (action)
- {
- case MenuAction_Select:
- {
- char sInfo[256];
- char sTempArray[2][128];
- char sQuery1[128];
- GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
- ExplodeString(sInfo, ";", sTempArray, 2, 128);
- Format(sQuery1, sizeof(sQuery1), "DELETE FROM hl_gangs_players WHERE steamid = \"%s\"", sTempArray[0]);
- g_hDatabase.Query(SQLCallback_Void, sQuery1);
- KickShare[param1] = KickShare[param1] * 7 / 10;
- char sQuery2[300];
- Format(sQuery2, sizeof(sQuery2), "UPDATE hl_gangs_groups SET funds = funds - %i WHERE gang=\"%s\"", KickShare[param1], ga_sGangName[param1]);
- g_hDatabase.Query(SQLCallback_Void, sQuery2);
- Format(sQuery2, sizeof(sQuery2), "UPDATE hl_gangs_statistics SET value = value - %i WHERE gang=\"%s\"", KickShare[param1], ga_sGangName[param1]);
- g_hDatabase.Query(SQLCallback_Void, sQuery2);
- KickShare[param1] = 0;
- PrintToChatAll("%s %T", TAG, "GangMemberKick", LANG_SERVER, sTempArray[1], ga_sGangName[param1]);
- char sSteamID[64];
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i))
- {
- GetClientAuthId(i, AuthId_Steam2, sSteamID, sizeof(sSteamID));
- if (StrEqual(sSteamID, sTempArray[0]))
- {
- ResetVariables(i);
- ga_bLoaded[i] = true;
- }
- }
- }
- }
- case MenuAction_Cancel:
- {
- OpenAdministrationMenu(param1);
- }
- case MenuAction_End:
- {
- delete menu;
- }
- }
- }
- /*****************************************************************
- ********************** TOP GANGS MENU **************************
- ******************************************************************/
- void StartOpeningTopGangsMenu(int client)
- {
- if (IsValidClient(client))
- {
- g_hDatabase.Query(SQL_Callback_TopMenu, "SELECT * FROM hl_gangs_statistics ORDER BY value DESC", GetClientUserId(client));
- }
- }
- public void SQL_Callback_TopMenu(Database db, DBResultSet results, const char[] error, int data)
- {
- if (db == null)
- {
- SetDB();
- }
- if (results == null)
- {
- LogError(error);
- return;
- }
- int client = GetClientOfUserId(data);
- if (!IsValidClient(client))
- {
- return;
- }
- else
- {
- Menu menu = CreateMenu(TopGangsMenu_Callback, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem);
- char menuTitle[64];
- Format(menuTitle, sizeof(menuTitle), "%T", "TopGangs", client);
- menu.SetTitle(menuTitle);
- if (results.RowCount == 0)
- {
- PrintToChat(client, "%s %t", TAG, "NoGangs");
- delete menu;
- return;
- }
- char sGangName[128];
- char sInfoString[128];
- ga_iTempInt2[client] = 0;
- g_iGangAmmount = 0;
- while (results.FetchRow())
- {
- g_iGangAmmount++;
- ga_iTempInt2[client]++;
- results.FetchString(1, sGangName, sizeof(sGangName));
- Format(sInfoString, sizeof(sInfoString), "%i;%s;%i", ga_iTempInt2[client], sGangName, results.FetchInt(2));
- menu.AddItem(sInfoString, sGangName);
- }
- menu.ExitBackButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- }
- }
- public int TopGangsMenu_Callback(Menu menu, MenuAction action, int param1, int param2)
- {
- switch (action)
- {
- case MenuAction_Select:
- {
- char sInfo[300];
- char sQuery[300];
- char sTempArray[3][128];
- GetMenuItem(menu, param2, sInfo, sizeof(sInfo));
- ExplodeString(sInfo, ";", sTempArray, 3, sizeof(sTempArray[]));
- ga_iTempInt2[param1] = StringToInt(sTempArray[0]);
- ga_iTempInt[param1] = StringToInt(sTempArray[2]);
- Format(sQuery, sizeof(sQuery), "SELECT * FROM `hl_gangs_players` WHERE `gang` = \"%s\" AND `rank` = 2", sTempArray[1]);
- g_hDatabase.Query(SQL_Callback_GangStatistics, sQuery, GetClientUserId(param1));
- }
- case MenuAction_Cancel:
- {
- StartOpeningGangMenu(param1);
- }
- case MenuAction_End:
- {
- delete menu;
- }
- }
- return;
- }
- public void SQL_Callback_GangStatistics(Database db, DBResultSet results, const char[] error, int data)
- {
- if (db == null)
- {
- SetDB();
- }
- if (results == null)
- {
- LogError(error);
- return;
- }
- int client = GetClientOfUserId(data);
- if (!IsValidClient(client))
- {
- return;
- }
- else
- {
- char sTempArray[2][128]; // Gang Name | Player Name
- char sFormattedTime[64];
- char sDisplayString[128];
- results.FetchRow();
- results.FetchString(3, sTempArray[0], sizeof(sTempArray[]));
- results.FetchString(2, sTempArray[1], sizeof(sTempArray[]));
- int iDate = results.FetchInt(6);
- Menu menu = CreateMenu(MenuCallback_Void, MenuAction_Select | MenuAction_End | MenuAction_DisplayItem);
- menu.SetTitle("Top Gangs");
- Format(sDisplayString, sizeof(sDisplayString), "%T : %s", "MenuGangName", client, sTempArray[0]);
- menu.AddItem("", sDisplayString, ITEMDRAW_DISABLED);
- Format(sDisplayString, sizeof(sDisplayString), "%T : %i/%i", "GangRank", client, ga_iTempInt2[client], g_iGangAmmount);
- menu.AddItem("", sDisplayString, ITEMDRAW_DISABLED);
- FormatTime(sFormattedTime, sizeof(sFormattedTime), "%x", iDate);
- Format(sDisplayString, sizeof(sDisplayString), "%T : %s", "DateCreated", client, sFormattedTime);
- menu.AddItem("", sDisplayString, ITEMDRAW_DISABLED);
- Format(sDisplayString, sizeof(sDisplayString), "%T : %s", "CreatedBy", client, sTempArray[1]);
- menu.AddItem("", sDisplayString, ITEMDRAW_DISABLED);
- Format(sDisplayString, sizeof(sDisplayString), "%T : %i ", "Value", client, ga_iTempInt[client]);
- menu.AddItem("", sDisplayString, ITEMDRAW_DISABLED);
- menu.ExitBackButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- }
- }
- public int MenuCallback_Void(Menu menu, MenuAction action, int param1, int param2)
- {
- switch (action)
- {
- case MenuAction_Select:
- {
- // Do Nothing
- }
- case MenuAction_Cancel:
- {
- StartOpeningTopGangsMenu(param1);
- }
- case MenuAction_End:
- {
- delete menu;
- }
- }
- return;
- }
- /*****************************************************************
- *********************** HELPER FUNCTIONS ***********************
- ******************************************************************/
- void UpdateSQL(int client)
- {
- DeleteDuplicates();
- /* We need to ensure that users are completely loaded in before calling save queries.
- * This may prevent errors where CT kills are reset to zero. */
- if (ga_bHasGang[client] && ga_bLoaded[client])
- {
- GetClientAuthId(client, AuthId_Steam2, ga_sSteamID[client], sizeof(ga_sSteamID[]));
- char sQuery[300];
- Format(sQuery, sizeof(sQuery), "SELECT * FROM hl_gangs_players WHERE steamid=\"%s\"", ga_sSteamID[client]);
- g_hDatabase.Query(SQLCallback_CheckIfInDatabase_Player, sQuery, GetClientUserId(client));
- }
- }
- public void SQLCallback_CheckIfInDatabase_Player(Database db, DBResultSet results, const char[] error, int data)
- {
- if (db == null)
- {
- SetDB();
- }
- int client = GetClientOfUserId(data);
- if (!IsValidClient(client))
- {
- return;
- }
- if (results.RowCount == 0)
- {
- ga_bIsPlayerInDatabase[client] = false;
- }
- else
- {
- ga_bIsPlayerInDatabase[client] = true;
- }
- char sQuery[300];
- char playerName[MAX_NAME_LENGTH], escapedName[MAXPLAYERS*2+1];
- GetClientName(client, playerName, sizeof(playerName));
- g_hDatabase.Escape(playerName, escapedName, sizeof(escapedName));
- if (!ga_bIsPlayerInDatabase[client])
- {
- Format(sQuery, sizeof(sQuery), "INSERT INTO hl_gangs_players (gang, invitedby, rank, date, steamid, playername, share) VALUES(\"%s\", \"%s\", %i, %i, \"%s\", \"%s\", %i)", ga_sGangName[client], ga_sInvitedBy[client], ga_iRank[client], ga_iDateJoined[client], ga_sSteamID[client], escapedName, ga_iShare[client]);
- }
- else
- {
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_players SET gang=\"%s\",invitedby=\"%s\",playername=\"%s\",rank=%i,date=%i WHERE steamid=\"%s\"", ga_sGangName[client], ga_sInvitedBy[client], escapedName, ga_iRank[client], ga_iDateJoined[client], ga_sSteamID[client]);
- }
- g_hDatabase.Query(SQLCallback_Void, sQuery);
- char sQuery2[128];
- Format(sQuery2, sizeof(sQuery2), "SELECT * FROM hl_gangs_groups WHERE gang=\"%s\"", ga_sGangName[client]);
- g_hDatabase.Query(SQLCALLBACK_GROUPS, sQuery2, GetClientUserId(client));
- }
- public void SQLCALLBACK_GROUPS(Database db, DBResultSet results, const char[] error, int data)
- {
- if (db == null)
- {
- SetDB();
- }
- int client = GetClientOfUserId(data);
- if (!IsValidClient(client))
- {
- return;
- }
- if (results.RowCount == 0)
- {
- ga_bIsGangInDatabase[client] = false;
- }
- else
- {
- ga_bIsGangInDatabase[client] = true;
- }
- char sQuery[300];
- if (!ga_bIsGangInDatabase[client])
- {
- Format(sQuery, sizeof(sQuery), "INSERT INTO hl_gangs_groups (gang, health, cash, store, medishot, size, funds) VALUES(\"%s\", %i, %i, %i, %i, %i, %i)", ga_sGangName[client], ga_iHealth[client], ga_iCash[client], ga_iStore[client], ga_iMedishot[client], ga_iSize[client], ga_iFunds[client]);
- }
- else
- {
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_groups SET health=%i,cash=%i,store=%i,medishot=%i,size=%i,funds=%i WHERE gang=\"%s\"", ga_iHealth[client], ga_iCash[client], ga_iStore[client], ga_iMedishot[client], ga_iSize[client], ga_sGangName[client], ga_iFunds[client]);
- }
- g_hDatabase.Query(SQLCallback_Void, sQuery);
- }
- void SetDB()
- {
- if (g_hDatabase == null)
- {
- gcv_sDatabase.GetString(g_sDatabaseName, sizeof(g_sDatabaseName));
- Database.Connect(SQLCallback_Connect, g_sDatabaseName);
- }
- }
- void DeleteDuplicates()
- {
- if (g_hDatabase != null)
- {
- g_hDatabase.Query(SQLCallback_Void, "delete hl_gangs_players from hl_gangs_players inner join (select min(id) minid, steamid from hl_gangs_players group by steamid having count(1) > 1) as duplicates on (duplicates.steamid = hl_gangs_players.steamid and duplicates.minid <> hl_gangs_players.id)", 4);
- g_hDatabase.Query(SQLCallback_Void, "delete hl_gangs_groups from hl_gangs_groups inner join (select min(id) minid, gang from hl_gangs_groups group by gang having count(1) > 1) as duplicates on (duplicates.gang = hl_gangs_groups.gang and duplicates.minid <> hl_gangs_groups.id)", 4);
- g_hDatabase.Query(SQLCallback_Void, "delete hl_gangs_statistics from hl_gangs_statistics inner join (select min(id) minid, gang from hl_gangs_statistics group by gang having count(1) > 1) as duplicates on (duplicates.gang = hl_gangs_statistics.gang and duplicates.minid <> hl_gangs_statistics.id)", 4);
- }
- }
- int GetClientCredits(int client)
- {
- if (g_bZepyhrus)
- {
- return Store_GetClientCredits(client);
- }
- else
- {
- SetFailState("ERROR: No supported credits plugin loaded!");
- return 0;
- }
- }
- void SetClientCredits(int client, int iAmmount)
- {
- if (g_bZepyhrus)
- {
- Store_SetClientCredits(client, iAmmount);
- }
- else
- {
- SetFailState("ERROR: No supported credits plugin loaded!");
- }
- }
- void RemoveFromGang(int client)
- {
- if (ga_iRank[client] == Rank_Owner)
- {
- char sQuery[300];
- Format(sQuery, sizeof(sQuery), "SELECT steamid, playername, rank FROM hl_gangs_players WHERE gang=\"%s\" ORDER BY share DESC", ga_sGangName[client]);
- g_hDatabase.Query(SQLCallback_CheckSQL_Owner, sQuery, GetClientUserId(client));
- }
- else
- {
- char sQuery1[128];
- Format(sQuery1, sizeof(sQuery1), "DELETE FROM hl_gangs_players WHERE steamid = \"%s\"", ga_sSteamID[client]);
- g_hDatabase.Query(SQLCallback_Void, sQuery1);
- char name[MAX_NAME_LENGTH];
- GetClientName(client, name, sizeof(name));
- PrintToChatAll("%s %T", TAG, "LeftGang", LANG_SERVER, name, ga_sGangName[client]);
- ResetVariables(client);
- ga_bLoaded[client] = true;
- }
- }
- public void SQLCallback_CheckSQL_Owner(Database db, DBResultSet results, const char[] error, int data)
- {
- if (db == null)
- {
- SetDB();
- }
- if (results == null)
- {
- LogError(error);
- return;
- }
- int client = GetClientOfUserId(data);
- if (!IsValidClient(client))
- {
- return;
- }
- else
- {
- if (results.RowCount == 1)
- {
- char sQuery1[300];
- char sQuery2[300];
- char sQuery3[300];
- Format(sQuery1, sizeof(sQuery1), "DELETE FROM hl_gangs_players WHERE gang = \"%s\"", ga_sGangName[client]);
- Format(sQuery2, sizeof(sQuery2), "DELETE FROM hl_gangs_groups WHERE gang = \"%s\"", ga_sGangName[client]);
- Format(sQuery3, sizeof(sQuery3), "DELETE FROM hl_gangs_statistics WHERE gang = \"%s\"", ga_sGangName[client]);
- g_hDatabase.Query(SQLCallback_Void, sQuery1);
- g_hDatabase.Query(SQLCallback_Void, sQuery2);
- g_hDatabase.Query(SQLCallback_Void, sQuery3);
- char name[MAX_NAME_LENGTH];
- GetClientName(client, name, sizeof(name));
- PrintToChatAll("%s %T", TAG, "GangDisbanded", LANG_SERVER, name, ga_sGangName[client]);
- ResetVariables(client);
- ga_bLoaded[client] = true;
- }
- else
- {
- if (results.RowCount > 1)
- {
- char own_name[7][128];
- char own_sid[7][30];
- int own_rank[7];
- int own_admin = 0;
- int order = 0;
- while (results.FetchRow())
- {
- order++;
- results.FetchString(0, own_sid[order], sizeof(own_sid[]));
- results.FetchString(1, own_name[order], sizeof(own_name[]));
- own_rank[order] = results.FetchInt(2);
- if(own_rank[order] == 1) own_admin = 1;
- }
- char own_new[128];
- char own_newsid[30];
- char own_old[128];
- for(int i=0;i<=order;i++)
- {
- if(own_admin == 1)
- {
- if(own_rank[i] == 1 && StrEqual(own_new,""))
- {
- own_new = own_name[i];
- own_newsid = own_sid[i];
- }
- }
- else
- {
- if(own_rank[i] != 2 && StrEqual(own_new,""))
- {
- own_new = own_name[i];
- own_newsid = own_sid[i];
- }
- }
- if(own_rank[i] == 2) own_old = own_name[i];
- own_name[i] = "";
- own_rank[i] = 0;
- own_sid[i] = "";
- }
- own_admin = 0;
- char sQuery1[128];
- Format(sQuery1, sizeof(sQuery1), "DELETE FROM hl_gangs_players WHERE steamid = \"%s\"", ga_sSteamID[client]);
- g_hDatabase.Query(SQLCallback_Void, sQuery1);
- char sQuery[300];
- Format(sQuery, sizeof(sQuery), "UPDATE hl_gangs_players SET rank = 2 WHERE steamid=\"%s\"", own_newsid);
- g_hDatabase.Query(SQLCallback_Void, sQuery);
- PrintToGang(client, false, "%s %T", TAG, "OwnerLeave", LANG_SERVER, own_old, own_new);
- own_newsid = "";
- own_new = "";
- own_old = "";
- ResetVariables(client);
- ga_bLoaded[client] = true;
- }
- }
- }
- }
- void PrintToGang(int client, bool bPrintToClient = false, const char[] sMsg, any ...)
- {
- if(!IsValidClient(client))
- {
- return;
- }
- char sFormattedMsg[256];
- VFormat(sFormattedMsg, sizeof(sFormattedMsg), sMsg, 4);
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i) && StrEqual(ga_sGangName[i], ga_sGangName[client]) && !StrEqual(ga_sGangName[client], ""))
- {
- if (bPrintToClient)
- {
- PrintToChat(i, sFormattedMsg);
- }
- else
- {
- if (i == client)
- {
- // Do nothing
- }
- else
- {
- PrintToChat(i, sFormattedMsg);
- }
- }
- }
- }
- }
- void ResetVariables(int client)
- {
- ga_iRank[client] = Rank_Invalid;
- ga_iGangSize[client] = -1;
- ga_iInvitation[client] = -1;
- ga_iDateJoined[client] = -1;
- ga_iShare[client] = 0;
- ga_iFunds[client] = 0;
- ga_iHealth[client] = 0;
- ga_iCash[client] = 0;
- ga_iStore[client] = 0;
- ga_iMedishot[client] = 0;
- ga_iSize[client] = 0;
- ga_iTempInt[client] = 0;
- ga_iTempInt2[client] = 0;
- ga_sGangName[client] = "";
- ga_sInvitedBy[client] = "";
- ga_bSetName[client] = false;
- ga_bIsPlayerInDatabase[client] = false;
- ga_bIsGangInDatabase[client] = false;
- ga_bHasGang[client] = false;
- ga_bRename[client] = false;
- ga_sSteamID[client] = "";
- ga_bLoaded[client] = false;
- ga_bReloaded[client] = false;
- }
- // to avoid this https://user-images.githubusercontent.com/3672466/28637962-0d324952-724c-11e7-8b27-15ff021f0a59.png
- void SanitizeName(char[] name)
- {
- ReplaceString(name, MAX_NAME_LENGTH, "#", "?");
- }
- bool IsValidClient(int client, bool bAllowBots = false, bool bAllowDead = true)
- {
- if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
- {
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement