Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- [12.04.15] РЕЛИЗ ПЛАГИНА версия 1.0.0
- [22.04.2015] Плагин обновлён до версии 1.0.1
- - оптимизация кода, спасибо R1KO.
- - исправление ошибки массива, забивающая логи
- - добавление скинов для ножей (пока неполный список)
- - исключение из плагина Knife Choice Core
- =========================================================
- [25.04.2015] Плагин обновлён до версии 1.0.2
- - добавлен файл перевода для плагина (теперь вы можете добавить нужные вам языки)
- - добавлены новые хуки событий над бомбой, а также MVP и команда победителей
- - добавлены раскраски ножей по уровням (со следующими версиями будут подобраны лучшие)
- - добавлены новые квары
- =========================================================
- [28.04.2015] Плагин обновлён до версии 1.0.3
- - добавлены новые квары
- - добавлены звуки повышения или понижения ранга
- =========================================================
- [04.05.2015] Плагин обновлён до версии 1.0.4
- - добавлены новые квары
- - добавлена возможность выбирать перчатки
- - исправлен баг неработоспособности Double- Triple- Quadro- PentaKills (он работает по принципу, если вы убили игрока, то если вы успеете за 2 секунды убить другого и т.д. вам будут начислять доп.очки)
- - теперь есть возможность самому выбирать и ставить пути до звуков повышения или понижения рангов
- - теперь способ выбора текстур для ножей изменён. Сначала вы выбираете нож, а потом сразу же для него текстуру.
- - все скины для ножей сохраняются
- - добавлены ассист-килл и хедшот-килл
- - теперь, если вы не хотите, чтобы игроку не засчитывался опыт за определённое действие, поставьте 0, сообщение о выдаче также будет отключено.
- - файл перевода обновлён
- =========================================================
- [18.05.2015] Плагин обновлён до версии 1.0.5
- - исправлены некоторые баги и оптимизирован код
- - добавлена функция ТОП-12 (сделано на основе SoD Stats)
- - ваше место среди всех игроков, теперь показывается в главном меню
- - добавлен раздел, показывающий список всех званий с кол-вом необходимого опыта
- - добавлен конфиг файл, в котором вы можете настроить название, цену и префикс звания
- - добавлено 3 новых звания: Теневой Совет, Величайший, Бог
- =========================================================
- [19.05.2015] Плагин обновлён до версии 1.0.6
- - исправлена ошибка, когда у игроков сбрасывались звания и все очки опыта
- */
- #pragma semicolon 1
- #include <sourcemod>
- #include <clientprefs>
- #include <sdkhooks>
- #include <sdktools>
- #undef REQUIRE_PLUGIN
- // #define PLUGIN_CORE "[Levels Ranks] Core"
- #define PLUGIN_NAME "Levels Ranks"
- #define PLUGIN_AUTHOR "RoadSide Romeo"
- #define PLUGIN_VERSION "v1.0.6"
- #define Max_Paints 600
- #define Max_Counts 64
- #define Max_Length 192
- #define DBTYPE_MYSQL 1
- #define DBTYPE_SQLITE 2
- #define DEFAULT "\x01"
- #define RED "\x02"
- #define GREEN "\x04"
- #define LIME "\x05"
- #define ORANGE "\x10"
- #define PURPLE "\x0E"
- enum Special_Knife
- {
- String:knife_name[64],
- knife_paint,
- knife_level
- }
- new ClientTeam[MAXPLAYERS+1],
- c_zCompetitiveRank[MAXPLAYERS+1],
- c_zIDKnife[MAXPLAYERS+1],
- c_zRank[MAXPLAYERS+1],
- c_zExp[MAXPLAYERS+1],
- // Cvars Bools
- g_iSpawnMenu,
- g_iSpawnMessage,
- g_iActiveKnife,
- g_iActiveGloves,
- // Cvars Integer - Give
- g_iGiveKillUsuallyExp,
- g_iGiveKillAssisterExp,
- g_iGiveKillHeadshotExp,
- g_iGiveTaserExp,
- g_iGiveGrenadeExp,
- g_iGiveMolotovExp,
- g_iGiveDoubleExp,
- g_iGiveTripleExp,
- g_iGiveQuadroExp,
- g_iGivePentaExp,
- g_iGiveBombPlanted,
- g_iGiveBombDefused,
- g_iGiveBombPickup,
- g_iGiveRoundWin,
- g_iGiveRoundMVP,
- // Cvars Integer - Lose
- g_iLoseSuicideExp,
- g_iLoseBombDropped,
- g_iLoseKillUsuallyExp,
- g_iLoseRoundLose,
- iRankOffset,
- IDGivePP,
- g_aPaintCount = 0,
- g_iChooseSkinKnife[Max_Paints][Special_Knife],
- bool:doublekill[MAXPLAYERS+1],
- bool:triplekill[MAXPLAYERS+1],
- bool:quadrokill[MAXPLAYERS+1],
- bool:pentakill[MAXPLAYERS+1],
- Float:KillTime[MAXPLAYERS+1],
- Float:GameTime[MAXPLAYERS+1],
- Handle:sp_mLevelUpHand = INVALID_HANDLE,
- Handle:sp_mLevelDownHand = INVALID_HANDLE,
- Handle:g_mExp = INVALID_HANDLE,
- Handle:g_mRank = INVALID_HANDLE,
- Handle:g_mSaveKnife = INVALID_HANDLE,
- Handle:g_mPaintsSkin = INVALID_HANDLE,
- Handle:arbol[MAXPLAYERS+1] = INVALID_HANDLE,
- String:Download_Path[192],
- String:Download_Path2[192],
- String:EmitSound_Path[192],
- String:EmitSound_Path2[192],
- String:Paints_Path[PLATFORM_MAX_PATH],
- String:RanksArms[Max_Counts][Max_Length], Arms_Count, SelectedArms[MAXPLAYERS + 1],
- String:NameArms[Max_Counts][Max_Length],
- String:IDArms[Max_Counts][Max_Length],
- String:UseArms[Max_Counts][Max_Length],
- String:AllExp[Max_Counts][Max_Length],
- String:AllPrefix[Max_Counts][Max_Length],
- String:AllRanksMenu[][] = {
- "Unranked",
- "Srebro - I",
- "Srebro - II",
- "Srebro - III",
- "Srebro - IV",
- "Srebro - Elitarne",
- "Srebro - Mistrzowskie Elitarne",
- "Gold - I",
- "Gold - II",
- "Gold - III",
- "Gold - Nova Master",
- "Kałach - I",
- "Kałach - II",
- "Kałach - Double",
- "Wybitny mistrzowski obrońca",
- "Orzełek",
- "Orzełek - Mistrzowski",
- "Supreme",
- "Global Elite",
- "Rada Cienia",
- "Najlepszy",
- "Bot"};
- // SQL переменные
- new String:m_iSQL_SavePlayer[] = "UPDATE players SET score = %i, name = '%s', time_played = time_played + %i, last_connect = current_timestamp WHERE steamid = '%s'",
- String:m_iSQL_CreatePlayer[] = "INSERT INTO players (score, steamid, name, time_played, last_connect) VALUES (0, '%s', '%s', 0, current_timestamp)",
- String:g_sqlite_createtable_players[] = "CREATE TABLE IF NOT EXISTS players (rank INTEGER PRIMARY KEY AUTOINCREMENT,score int(12) NOT NULL default 0,steamid varchar(255) NOT NULL default '',name varchar(255) NOT NULL default '',time_played int(11) NOT NULL default 0, last_connect timestamp NOT NULL default CURRENT_TIMESTAMP);",
- String:g_mysql_createtable_players[] = "CREATE TABLE IF NOT EXISTS players (rank INTEGER PRIMARY KEY AUTO_INCREMENT,score int(12) NOT NULL default 0,steamid varchar(255) NOT NULL default '',name varchar(255) NOT NULL default '',time_played int(11) NOT NULL default 0, last_connect timestamp NOT NULL default CURRENT_TIMESTAMP);",
- String:g_sql_droptable_players[] = "DROP TABLE IF EXISTS 'players'; VACUUM;",
- String:g_sql_playercount[] = "SELECT * FROM players",
- String:g_sql_addtimestamp[] = "ALTER TABLE players ADD COLUMN last_connect timestamp DEFAULT NULL;",
- String:g_sql_loadplayer[] = "SELECT name, steamid, score, time_played FROM players WHERE steamid = '%s'",
- String:g_sql_top[] = "SELECT name, steamid, score, time_played FROM players ORDER BY score DESC LIMIT %i OFFSET %i",
- String:g_sql_rank[] = "SELECT DISTINCT score FROM players WHERE score >= %i ORDER BY score ASC;",
- String:g_name[MAXPLAYERS+1][MAX_NAME_LENGTH],
- String:g_steamid[MAXPLAYERS+1][Max_Length],
- String:g_ident[16],
- g_dbtype,
- g_player_count,
- g_time_joined[MAXPLAYERS+1],
- g_time_played[MAXPLAYERS+1],
- g_last_saved_time[MAXPLAYERS+1],
- bool:g_initialized[MAXPLAYERS+1],
- myplace[MAXPLAYERS+1];
- #include "include/levels_ranks/sql.inc"
- #include "levels_ranks/SQL.sp"
- public Plugin:myinfo = {name = PLUGIN_NAME, author = PLUGIN_AUTHOR, version = PLUGIN_VERSION}
- public OnPluginStart()
- {
- decl String:game[80];
- GetGameFolderName(game, 80);
- if(!StrEqual(game, "csgo"))
- {
- SetFailState("[%s] Плагин работает только на CS:GO", PLUGIN_NAME);
- }
- g_mExp = RegClientCookie("ExpClient", "ExpClient", CookieAccess_Private);
- g_mRank = RegClientCookie("RankLevel", "RankLevel", CookieAccess_Private);
- g_mSaveKnife = RegClientCookie("SaveKnifeUsually", "SaveKnifeUsually", CookieAccess_Private);
- g_mPaintsSkin = RegClientCookie("PaintsSkin", "PaintsSkin", CookieAccess_Private);
- // Hooks Round
- HookEvent("round_mvp", RoundMVP, EventHookMode_Pre);
- HookEvent("round_start", RoundStart);
- HookEvent("round_end", RoundEnd);
- // Hooks Player
- HookEvent("player_spawn", PlayerSpawn, EventHookMode_Post);
- HookEvent("player_death", PlayerDeath);
- HookEvent("player_death", PlayerDeathMulti);
- HookEvent("player_team", PlayerTeam);
- // Hooks Bomb
- HookEvent("bomb_planted", Hook_BombPlanted);
- HookEvent("bomb_defused", Hook_BombDefused);
- HookEvent("bomb_dropped", Hook_BombDropped);
- HookEvent("bomb_pickup", Hook_BombPickup);
- new Handle:hCvar;
- CreateConVar("sm_levels_ranks", PLUGIN_VERSION, "Levels Ranks Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
- // Bools
- HookConVarChange((hCvar = CreateConVar("ranks_spawnmenu", "0")), OnSpawnMenuChange); g_iSpawnMenu = GetConVarBool(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_spawnmessage", "1")), OnSpawnMessageChange); g_iSpawnMessage = GetConVarBool(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_knife", "1")), OnActiveKnifeChange); g_iActiveKnife = GetConVarBool(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_gloves", "1")), OnActiveGlovesChange); g_iActiveGloves = GetConVarBool(hCvar);
- // Integer
- HookConVarChange((hCvar = CreateConVar("ranks_kill", "2")), OnGiveKillExpChange); g_iGiveKillUsuallyExp = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_assister", "1")), OnGiveKillAssisterChange); g_iGiveKillAssisterExp = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_headshot", "1")), OnGiveKillHeadShotChange); g_iGiveKillHeadshotExp = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_mydeath", "1")), OnLoseKillExpChange); g_iLoseKillUsuallyExp = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_taserkill", "3")), OnGiveTaserExpChange); g_iGiveTaserExp = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_doublekill", "4")), OnGiveDoubleExpChange); g_iGiveDoubleExp = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_triplekill", "8")), OnGiveTripleExpChange); g_iGiveTripleExp = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_quadrokill", "12")), OnGiveQuadroExpChange); g_iGiveQuadroExp = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_pentakill", "16")), OnGivePentaExpChange); g_iGivePentaExp = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_grenadekill", "7")), OnGiveGrenadeExpChange); g_iGiveGrenadeExp = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_molotovkill", "14")), OnGiveMolotovExpChange); g_iGiveMolotovExp = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_suicide", "6")), OnLoseSuicideExpChange); g_iLoseSuicideExp = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_give_bombplanted", "3")), OnGiveBombPlantedChange); g_iGiveBombPlanted = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_give_bombdefused", "3")), OnGiveBombDefusedChange); g_iGiveBombDefused = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_give_bombpickup", "2")), OnGiveBombPickupChange); g_iGiveBombPickup = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_lose_bombdropped", "2")), OnLoseBombDroppedChange); g_iLoseBombDropped = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_give_roundwin", "1")), OnGiveRoundWinChange); g_iGiveRoundWin = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_give_roundmvp", "2")), OnGiveRoundMVPChange); g_iGiveRoundMVP = GetConVarInt(hCvar);
- HookConVarChange((hCvar = CreateConVar("ranks_lose_roundlose", "1")), OnLoseRoundLoseChange); g_iLoseRoundLose = GetConVarInt(hCvar);
- sp_mLevelUpHand = CreateConVar("ranks_sound_levelup", "levels_ranks/levelup.mp3");
- sp_mLevelDownHand = CreateConVar("ranks_sound_leveldown", "levels_ranks/leveldown.mp3");
- CloseHandle(hCvar);
- AddCommandListener(ActivatedTrigger, "say");
- AddCommandListener(ActivatedTrigger, "say_team");
- RegAdminCmd("sm_levels_reset", ResetStatsSQL, ADMFLAG_ROOT);
- RegAdminCmd("sm_levels_purge", PurgeStatsSQL, ADMFLAG_ROOT);
- AutoExecConfig(true, "levels_ranks");
- LoadTranslations("levels_ranks.phrases");
- RegPluginLibrary("levels_ranks");
- // ClientPrefs
- for(new client = 1; client <= MaxClients; client++)
- {
- if(IsClientInGame(client))
- {
- if(AreClientCookiesCached(client))
- {
- OnClientCookiesCached(client);
- }
- }
- }
- RegisterSQL();
- }
- public OnMapStart()
- {
- ServerCommand("sv_tags Levels_Ranks");
- iRankOffset = FindSendPropInfo("CCSPlayerResource", "m_iCompetitiveRanking");
- SDKHook(FindEntityByClassname(MaxClients+1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
- LoadTranslations("levels_ranks.phrases");
- decl String:path[192];
- new Handle:filedownload = OpenFile("cfg/sourcemod/levels_ranks/downloads.txt", "r");
- if(filedownload == INVALID_HANDLE)
- {
- SetFailState("Fail exist cfg/sourcemod/levels_ranks/downloads.txt");
- return;
- }
- while(!IsEndOfFile(filedownload) && ReadFileLine(filedownload, path, 192))
- {
- TrimString(path);
- if (IsCharAlpha(path[0])) AddFileToDownloadsTable(path);
- }
- CloseHandle(filedownload);
- GetConVarString(sp_mLevelUpHand, Download_Path, sizeof(Download_Path));
- Format(path, sizeof(path), "sound/%s", Download_Path);
- AddFileToDownloadsTable(path);
- Format(EmitSound_Path, sizeof(EmitSound_Path), "*%s", Download_Path);
- FakePrecacheSound(EmitSound_Path);
- GetConVarString(sp_mLevelDownHand, Download_Path2, sizeof(Download_Path2));
- Format(path, sizeof(path), "sound/%s", Download_Path2);
- AddFileToDownloadsTable(path);
- Format(EmitSound_Path2, sizeof(EmitSound_Path2), "*%s", Download_Path2);
- FakePrecacheSound(EmitSound_Path2);
- ReadPaints();
- MakeBuildGloves();
- MakeExpRanks();
- }
- public OnMapEnd() iRankOffset = FindSendPropInfo("CCSPlayerResource", "m_iCompetitiveRanking"), SDKUnhook(FindEntityByClassname(MaxClients+1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
- bool:IsValidClient(client) return (1 <= client <= MaxClients && IsClientInGame(client)) ? true : false;
- MakeExpRanks()
- {
- BuildPath(Path_SM, Paints_Path, sizeof(Paints_Path), "configs/levels_ranks/expranks.ini");
- decl Handle:kv, String:id[Max_Counts], String:exp[Max_Counts], String:prefix[Max_Counts];
- kv = CreateKeyValues("Exp_Ranks");
- FileToKeyValues(kv, Paints_Path);
- if(!KvGotoFirstSubKey(kv)) {
- SetFailState("Levels Ranks: %s is incorrect", Paints_Path);
- CloseHandle(kv);
- }
- do
- {
- KvGetSectionName(kv, id, sizeof(id));
- new id_rank = StringToInt(id);
- if(id_rank != 0)
- {
- KvGetString(kv, "exp", exp, sizeof(exp));
- strcopy(AllExp[id_rank-1], sizeof(AllExp[]), exp);
- }
- // prefix пока не работает. Будет сделан в версии 1.0.6
- KvGetString(kv, "prefix", prefix, sizeof(prefix));
- strcopy(AllPrefix[id_rank], sizeof(AllPrefix[]), prefix);
- }
- while (KvGotoNextKey(kv));
- CloseHandle(kv);
- }
- MakeBuildGloves()
- {
- decl String:buffer[PLATFORM_MAX_PATH];
- if(!FileExists(buffer))
- {
- BuildPath(Path_SM, buffer, sizeof(buffer), "configs/levels_ranks/gloves.ini");
- if(!FileExists(buffer))
- {
- SetFailState("Fatal Error: File don't exist \"%s\"!", buffer);
- }
- }
- Arms_Count = 0;
- new Handle:kv_skins_gloves = CreateKeyValues("Glove");
- FileToKeyValues(kv_skins_gloves, buffer);
- if(KvJumpToKey(kv_skins_gloves, "Gloves"))
- {
- decl String:section[Max_Counts], String:id[Max_Counts], String:arms[Max_Counts], String:level[Max_Counts];
- KvGotoFirstSubKey(kv_skins_gloves);
- do
- {
- KvGetSectionName(kv_skins_gloves, section, sizeof(section));
- if(KvGetString(kv_skins_gloves, "id", id, sizeof(id))
- && KvGetString(kv_skins_gloves, "arms", arms, sizeof(arms))
- && KvGetString(kv_skins_gloves, "level", level, sizeof(level)))
- {
- strcopy(IDArms[Arms_Count], sizeof(IDArms[]), id);
- strcopy(UseArms[Arms_Count], sizeof(UseArms[]), arms);
- strcopy(RanksArms[Arms_Count], sizeof(RanksArms[]), level);
- strcopy(NameArms[Arms_Count], sizeof(NameArms[]), section);
- Arms_Count++;
- PrecacheModel(arms, true);
- }
- else SetFailState("Player arms for \"%s\" is incorrect!", section);
- }
- while (KvGotoNextKey(kv_skins_gloves));
- }
- else SetFailState("Fatal error: Missing section!");
- KvRewind(kv_skins_gloves);
- CloseHandle(kv_skins_gloves);
- }
- // Hooks Integer ConVars - Give
- public OnGiveKillExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveKillUsuallyExp = GetConVarInt(hCvar);
- public OnGiveKillAssisterChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveKillAssisterExp = GetConVarInt(hCvar);
- public OnGiveKillHeadShotChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveKillHeadshotExp = GetConVarInt(hCvar);
- public OnLoseKillExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iLoseKillUsuallyExp = GetConVarInt(hCvar);
- public OnGiveTaserExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveTaserExp = GetConVarInt(hCvar);
- public OnGiveDoubleExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveDoubleExp = GetConVarInt(hCvar);
- public OnGiveTripleExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveTripleExp = GetConVarInt(hCvar);
- public OnGiveQuadroExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveQuadroExp = GetConVarInt(hCvar);
- public OnGivePentaExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGivePentaExp = GetConVarInt(hCvar);
- public OnGiveGrenadeExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveGrenadeExp = GetConVarInt(hCvar);
- public OnGiveMolotovExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveMolotovExp = GetConVarInt(hCvar);
- public OnGiveBombPlantedChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveBombPlanted = GetConVarInt(hCvar);
- public OnGiveBombDefusedChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveBombDefused = GetConVarInt(hCvar);
- public OnGiveBombPickupChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveBombPickup = GetConVarInt(hCvar);
- public OnGiveRoundWinChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveRoundWin = GetConVarInt(hCvar);
- public OnGiveRoundMVPChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveRoundMVP = GetConVarInt(hCvar);
- // Hooks Integer ConVars - Lose
- public OnLoseSuicideExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iLoseSuicideExp = GetConVarInt(hCvar);
- public OnLoseBombDroppedChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iLoseBombDropped = GetConVarInt(hCvar);
- public OnLoseRoundLoseChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iLoseRoundLose = GetConVarInt(hCvar);
- // Hooks Bool ConVars
- public OnSpawnMessageChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iSpawnMessage = GetConVarBool(hCvar);
- public OnSpawnMenuChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iSpawnMenu = GetConVarBool(hCvar);
- public OnActiveGlovesChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iActiveGloves = GetConVarBool(hCvar);
- public OnActiveKnifeChange(Handle:hCvar, const String:oldValue[], const String:newValue[])
- {
- g_iActiveKnife = GetConVarBool(hCvar);
- if(g_iActiveKnife)
- {
- for(new i = 1; i <= MaxClients; i++)
- {
- if(IsClientInGame(i))
- {
- SDKHook(i, SDKHook_WeaponEquipPost, OnPostWeaponEquip);
- }
- }
- }
- else
- {
- for(new i = 1; i <= MaxClients; i++)
- {
- SDKUnhook(i, SDKHook_WeaponEquipPost, OnPostWeaponEquip);
- }
- }
- }
- stock FakePrecacheSound( const String:szPath[] )
- {
- AddToStringTable(FindStringTable("soundprecache"), szPath);
- }
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- ////////////////////////// HOOKS //////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- public PlayerTeam(Handle:event, const String:name[], bool:silent)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- ClientTeam[client] = GetClientTeam(client);
- }
- public PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- new arms = SelectedArms[client];
- if(g_iSpawnMenu)
- {
- MainMenu(client);
- }
- if(IsValidClient(client) && g_iActiveGloves)
- {
- if (-1 < arms < Arms_Count)
- {
- SetEntPropString(client, Prop_Send, "m_szArmsModel", UseArms[arms]);
- }
- }
- if(client && GetClientTeam(client) > 1)
- {
- if(g_iActiveKnife)
- {
- new iWeapon = GetPlayerWeaponSlot(client, 2);
- new iItem;
- switch(c_zIDKnife[client])
- {
- case 1: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knifegg");}
- case 2: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_gut");}
- case 3: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_flip");}
- case 4: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_bayonet");}
- case 5: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_m9_bayonet");}
- case 6: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_karambit");}
- case 7: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_tactical");}
- case 8: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_butterfly");}
- default: {return;}
- }
- EquipPlayerWeapon(client, iItem);
- }
- }
- }
- public PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- new assist = GetClientOfUserId(GetEventInt(event, "assister"));
- new bool:headshot = GetEventBool(event, "headshot");
- if(!attacker || !client)
- return;
- SetGlobalTransTarget(attacker);
- decl String:weapon[64];
- GetEventString(event, "weapon", weapon, sizeof(weapon));
- // decl String:classname[64];
- // GetEdictClassname(weapon, classname, sizeof(classname));
- if((attacker == client) && g_iLoseSuicideExp)
- {
- SetGlobalTransTarget(client);
- c_zExp[client] -= g_iLoseSuicideExp;
- PrintToChat(client, " \x02[LR] %t", "Suicide", DEFAULT, RED, c_zExp[client], g_iLoseSuicideExp);
- SavePlayer(client);
- }
- else
- {
- if(g_iLoseKillUsuallyExp)
- {
- SetGlobalTransTarget(client);
- c_zExp[client] -= g_iLoseKillUsuallyExp;
- PrintToChat(client, " \x02[LR] %t", "MyDeath", DEFAULT, RED, c_zExp[client], g_iLoseKillUsuallyExp);
- }
- SetGlobalTransTarget(attacker);
- if(StrEqual(weapon, "taser") && g_iGiveTaserExp)
- {
- c_zExp[attacker] += g_iGiveTaserExp;
- PrintToChat(attacker, " \x02[LR] %t", "TaserKill", DEFAULT, GREEN, c_zExp[attacker], g_iGiveTaserExp);
- }
- else if(StrEqual(weapon, "hegrenade") && g_iGiveGrenadeExp)
- {
- c_zExp[attacker] += g_iGiveGrenadeExp;
- PrintToChat(attacker, " \x02[LR] %t", "HEKill", DEFAULT, GREEN, c_zExp[attacker], g_iGiveGrenadeExp);
- }
- else if(StrEqual(weapon, "inferno") && g_iGiveMolotovExp)
- {
- c_zExp[attacker] += g_iGiveMolotovExp;
- PrintToChat(attacker, " \x02[LR] %t", "MolotovKill", DEFAULT, GREEN, c_zExp[attacker], g_iGiveMolotovExp);
- }
- else if(!StrEqual(weapon, "hegrenade") && !StrEqual(weapon, "inferno") && !StrEqual(weapon, "taser"))
- {
- if(g_iGiveKillUsuallyExp)
- {
- SetGlobalTransTarget(attacker);
- c_zExp[attacker] += g_iGiveKillUsuallyExp;
- PrintToChat(attacker, " \x02[LR] %t", "Kill", DEFAULT, GREEN, c_zExp[attacker], g_iGiveKillUsuallyExp);
- }
- if(headshot && g_iGiveKillHeadshotExp)
- {
- c_zExp[attacker] += g_iGiveKillHeadshotExp;
- PrintToChat(attacker, " \x02[LR] %t", "HeadShotKill", DEFAULT, ORANGE, c_zExp[attacker], g_iGiveKillHeadshotExp);
- }
- }
- SavePlayer(attacker);
- if(assist && g_iGiveKillAssisterExp)
- {
- SetGlobalTransTarget(assist);
- c_zExp[assist] += g_iGiveKillAssisterExp;
- PrintToChat(assist, " \x02[LR] %t", "AssisterKill", DEFAULT, ORANGE, c_zExp[assist], g_iGiveKillAssisterExp);
- SavePlayer(assist);
- }
- }
- return;
- }
- public PlayerDeathMulti(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- if(!attacker || !client)
- return;
- SetGlobalTransTarget(client);
- SetGlobalTransTarget(attacker);
- GameTime[attacker] = GetGameTime();
- if(attacker != client)
- {
- if(!doublekill[attacker] && !triplekill[attacker] && !quadrokill[attacker] && !pentakill[attacker])
- {
- doublekill[attacker] = true;
- KillTime[attacker] = GameTime[attacker];
- }
- else if(doublekill[attacker])
- {
- if((GameTime[attacker] - KillTime[attacker] < 2.0) && g_iGiveDoubleExp)
- {
- c_zExp[attacker] += g_iGiveDoubleExp;
- PrintToChat(attacker, " \x02[LR] %t", "DoubleKill", DEFAULT, PURPLE, c_zExp[attacker], g_iGiveDoubleExp);
- doublekill[attacker] = false;
- triplekill[attacker] = true;
- KillTime[attacker] = GameTime[attacker];
- }
- else doublekill[attacker] = true, KillTime[attacker] = GameTime[attacker];
- }
- else if(triplekill[attacker])
- {
- if((GameTime[attacker] - KillTime[attacker] < 2.0) && g_iGiveTripleExp)
- {
- c_zExp[attacker] += g_iGiveTripleExp;
- PrintToChat(attacker, " \x02[LR] %t", "TripleKill", DEFAULT, PURPLE, c_zExp[attacker], g_iGiveTripleExp);
- triplekill[attacker] = false;
- quadrokill[attacker] = true;
- KillTime[attacker] = GameTime[attacker];
- }
- else triplekill[attacker] = false, doublekill[attacker] = true, KillTime[attacker] = GameTime[attacker];
- }
- else if(quadrokill[attacker])
- {
- if((GameTime[attacker] - KillTime[attacker] < 2.0) && g_iGiveQuadroExp)
- {
- c_zExp[attacker] += g_iGiveQuadroExp;
- PrintToChat(attacker, " \x02[LR] %t", "QuadroKill", DEFAULT, PURPLE, c_zExp[attacker], g_iGiveQuadroExp);
- quadrokill[attacker] = false;
- pentakill[attacker] = true;
- KillTime[attacker] = GameTime[attacker];
- }
- else quadrokill[attacker] = false, doublekill[attacker] = true, KillTime[attacker] = GameTime[attacker];
- }
- else if(pentakill[attacker])
- {
- if((GameTime[attacker] - KillTime[attacker] < 2.0) && g_iGivePentaExp)
- {
- c_zExp[attacker] += g_iGivePentaExp;
- PrintToChat(attacker, " \x02[LR] %t", "PentaKill", DEFAULT, PURPLE, c_zExp[attacker], g_iGivePentaExp);
- pentakill[attacker] = false;
- doublekill[attacker] = false;
- KillTime[attacker] = 0.0;
- }
- else pentakill[attacker] = false, doublekill[attacker] = true, KillTime[attacker] = GameTime[attacker];
- }
- SavePlayer(attacker);
- }
- return;
- }
- public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
- {
- if(g_iSpawnMessage)
- {
- for(new i = 1; i <= MaxClients; i++)
- {
- if(IsClientInGame(i))
- {
- SetGlobalTransTarget(i);
- PrintToChat(i, " \x02[LR] %t", "RoundStartMessageRanks", DEFAULT, GREEN, DEFAULT);
- if(g_iActiveKnife)
- {
- PrintToChat(i, " \x02[LR] %t", "RoundStartMessageKnife", DEFAULT, GREEN, DEFAULT);
- }
- }
- }
- }
- return Plugin_Continue;
- }
- public Action:RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new checkteam = GetEventInt(event, "winner");
- for(new i = 1; i <= MaxClients; i++)
- {
- if(IsClientInGame(i))
- {
- SetGlobalTransTarget(i);
- ClientTeam[i] = GetClientTeam(i);
- if(checkteam != 0 && checkteam != 1)
- {
- if((checkteam == ClientTeam[i]) && g_iGiveRoundWin)
- {
- c_zExp[i] += g_iGiveRoundWin;
- PrintToChat(i, " \x02[LR] %t", "RoundWin", DEFAULT, GREEN, c_zExp[i], g_iGiveRoundWin);
- }
- else if((checkteam != ClientTeam[i]) && g_iLoseRoundLose)
- {
- c_zExp[i] -= g_iLoseRoundLose;
- PrintToChat(i, " \x02[LR] %t", "RoundLose", DEFAULT, RED, c_zExp[i], g_iLoseRoundLose);
- }
- }
- }
- }
- return Plugin_Continue;
- }
- public Action:RoundMVP(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- if(g_iGiveRoundMVP && client)
- {
- SetGlobalTransTarget(client);
- c_zExp[client] += g_iGiveRoundMVP;
- PrintToChat(client, " \x02[LR] %t", "RoundMVP", DEFAULT, GREEN, c_zExp[client], g_iGiveRoundMVP);
- SavePlayer(client);
- }
- }
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////// Hooks Bomb //////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- public Hook_BombPlanted(Handle:event, const String:name[], bool:dontBroadcast)
- {
- if(g_iGiveBombPlanted)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- SetGlobalTransTarget(client);
- c_zExp[client] += g_iGiveBombPlanted;
- PrintToChat(client, " \x02[LR] %t", "BombPlanted", DEFAULT, GREEN, c_zExp[client], g_iGiveBombPlanted);
- SavePlayer(client);
- }
- }
- public Hook_BombDefused(Handle:event, const String:name[], bool:dontBroadcast)
- {
- if(g_iGiveBombDefused)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- SetGlobalTransTarget(client);
- c_zExp[client] += g_iGiveBombDefused;
- PrintToChat(client, " \x02[LR] %t", "BombDefused", DEFAULT, GREEN, c_zExp[client], g_iGiveBombDefused);
- SavePlayer(client);
- }
- }
- public Hook_BombPickup(Handle:event, const String:name[], bool:dontBroadcast)
- {
- if(g_iGiveBombPickup)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- SetGlobalTransTarget(client);
- c_zExp[client] += g_iGiveBombPickup;
- PrintToChat(client, " \x02[LR] %t", "BombPickup", DEFAULT, GREEN, c_zExp[client], g_iGiveBombPickup);
- SavePlayer(client);
- }
- }
- public Hook_BombDropped(Handle:event, const String:name[], bool:dontBroadcast)
- {
- if(g_iLoseBombDropped)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- SetGlobalTransTarget(client);
- c_zExp[client] -= g_iLoseBombDropped;
- PrintToChat(client, " \x02[LR] %t", "BombDropped", DEFAULT, RED, c_zExp[client], g_iLoseBombDropped);
- SavePlayer(client);
- }
- }
- public Action:ActivatedTrigger(client, const String:command[], arg)
- {
- new String:KnifeMenuStr[][] = {"!лтшау", "knife" , "!knife"},
- String:MainMenuStr[][] = {"!думуд", "level" , "!level", "!lvl", "!дмд"};
- decl String:text[192];
- GetCmdArgString(text, sizeof(text));
- StripQuotes(text);
- TrimString(text);
- if(client && IsClientInGame(client))
- {
- if(g_iActiveKnife)
- {
- for(new i = 0; i < sizeof(KnifeMenuStr); i++)
- {
- if(StrEqual(text, KnifeMenuStr[i], false))
- {
- KnifeMenu(client);
- return Plugin_Handled;
- }
- }
- }
- for(new i = 0; i < sizeof(MainMenuStr); i++)
- {
- if(StrEqual(text, MainMenuStr[i], false))
- {
- MakePlace(client);
- return Plugin_Handled;
- }
- }
- }
- return Plugin_Continue;
- }
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- ////////////////////////// MENUS ALL //////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- public Action:MainMenu(client)
- {
- decl String:text[64];
- SetGlobalTransTarget(client);
- new Handle:menu = CreateMenu(MainMenuHandler);
- new rank_client = c_zRank[client];
- SavePlayer(client);
- if(c_zRank[client] < 21)
- {
- SetMenuTitle(menu, "%t", "MainMenuLowRank", PLUGIN_NAME, PLUGIN_VERSION, AllRanksMenu[rank_client], c_zExp[client], StringToInt(AllExp[rank_client]), c_zRank[client], myplace[client], g_player_count);
- }
- else if(c_zRank[client] == 21)
- {
- SetMenuTitle(menu, "%t", "MainMenuHighRank", PLUGIN_NAME, PLUGIN_VERSION, AllRanksMenu[rank_client], c_zExp[client], c_zRank[client], myplace[client], g_player_count);
- }
- Format(text, sizeof(text), "%t", "AllRanks");
- AddMenuItem(menu, "0", text);
- Format(text, sizeof(text), "%t", "TOP");
- AddMenuItem(menu, "1", text);
- if(g_iActiveKnife)
- {
- Format(text, sizeof(text), "%t", "Knifes");
- AddMenuItem(menu, "2", text);
- }
- if(g_iActiveGloves)
- {
- Format(text, sizeof(text), "%t", "Gloves");
- AddMenuItem(menu, "3", text);
- }
- Format(text, sizeof(text), "%t", "Functions");
- AddMenuItem(menu, "4", text);
- SetMenuExitButton(menu, true);
- DisplayMenu(menu, client, 9);
- }
- public MainMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
- {
- if(action == MenuAction_Select)
- {
- decl String:info[4];
- GetMenuItem(menu, itemNum, info, sizeof(info));
- switch(StringToInt(info))
- {
- case 0: AllRankMenu(client);
- case 1: PrintTop(client);
- case 2: KnifeMenu(client);
- case 3: ArmsMenu(client);
- case 4: FuncMenu(client);
- }
- }
- else if(action == MenuAction_End)
- {
- CloseHandle(menu);
- }
- }
- public Action:AllRankMenu(client)
- {
- decl String:text[192];
- SetGlobalTransTarget(client);
- new Handle:menu = CreateMenu(AllRankMenuHandler);
- Format(text, sizeof(text), "%t", "AllRanks");
- SetMenuTitle(menu, "%s | %s\n ", PLUGIN_NAME, text);
- for(new i = 0; i <= 21; i++)
- {
- if(i == 0)
- {
- Format(text, sizeof(text), "%s [0 exp]", AllRanksMenu[i]);
- AddMenuItem(menu, "", text, ITEMDRAW_DISABLED);
- }
- else if(i > 0)
- {
- Format(text, sizeof(text), "%s [%s exp]", AllRanksMenu[i], AllExp[i-1]);
- AddMenuItem(menu, "", text, ITEMDRAW_DISABLED);
- }
- }
- SetMenuExitButton(menu, true);
- DisplayMenu(menu, client, 9);
- }
- public AllRankMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
- {
- if(action == MenuAction_End)
- {
- CloseHandle(menu);
- }
- }
- public FuncMenu(client)
- {
- decl String:text[64];
- SetGlobalTransTarget(client);
- new flags = GetUserFlagBits(client);
- new Handle:menu = CreateMenu(FuncMenuHandler);
- Format(text, sizeof(text), "%t", "Functions");
- SetMenuTitle(menu, "%s | %s\n ", PLUGIN_NAME, text);
- Format(text, sizeof(text), "%t", "GivePoints");
- if(flags & ADMFLAG_PASSWORD || flags & ADMFLAG_ROOT)
- {
- AddMenuItem(menu, "0", text);
- }
- else
- {
- AddMenuItem(menu, "0", text, ITEMDRAW_DISABLED);
- }
- SetMenuExitButton(menu, true);
- DisplayMenu(menu, client, 9);
- }
- public FuncMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
- {
- if(action == MenuAction_Select)
- {
- decl String:info[4];
- GetMenuItem(menu, itemNum, info, sizeof(info));
- switch(StringToInt(info))
- {
- case 0: GivePointsPlayers(client);
- }
- }
- else if(action == MenuAction_End)
- {
- CloseHandle(menu);
- }
- }
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- ////////////////////////// KNIFECHOOSE ////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- public Action:KnifeMenu(client)
- {
- decl String:text[64];
- SetGlobalTransTarget(client);
- new Handle:menu = CreateMenu(KnifeMenuHandler);
- Format(text, sizeof(text), "%t", "UsuallyKnife");
- SetMenuTitle(menu, "%s | %s\n ", PLUGIN_NAME, text);
- Format(text, sizeof(text), "%t", "KnifeUsual");
- if(c_zIDKnife[client] == 0) Format(text, sizeof(text), "[x] %t", "KnifeUsual"), AddMenuItem(menu, "", text, ITEMDRAW_DISABLED);
- else AddMenuItem(menu, "", text);
- Format(text, sizeof(text), "%t", "KnifeGold");
- if(c_zIDKnife[client] == 1) Format(text, sizeof(text), "[x] %t", "KnifeGold"), AddMenuItem(menu, "", text, ITEMDRAW_DISABLED);
- else AddMenuItem(menu, "", text);
- Format(text, sizeof(text), "%t", "KnifeGut");
- if(c_zIDKnife[client] == 2) Format(text, sizeof(text), "[x] %t", "KnifeGut"), AddMenuItem(menu, "", text);
- else AddMenuItem(menu, "", text);
- Format(text, sizeof(text), "%t", "KnifeFlip");
- if(c_zIDKnife[client] == 3) Format(text, sizeof(text), "[x] %t", "KnifeFlip"), AddMenuItem(menu, "", text);
- else AddMenuItem(menu, "", text);
- Format(text, sizeof(text), "%t", "KnifeBayonet");
- if(c_zIDKnife[client] == 4) Format(text, sizeof(text), "[x] %t", "KnifeBayonet"), AddMenuItem(menu, "", text);
- else AddMenuItem(menu, "", text);
- Format(text, sizeof(text), "%t", "KnifeM9");
- if(c_zIDKnife[client] == 5) Format(text, sizeof(text), "[x] %t", "KnifeM9"), AddMenuItem(menu, "", text);
- else AddMenuItem(menu, "", text);
- Format(text, sizeof(text), "%t", "KnifeKarambit");
- if(c_zIDKnife[client] == 6) Format(text, sizeof(text), "[x] %t", "KnifeKarambit"), AddMenuItem(menu, "", text);
- else AddMenuItem(menu, "", text);
- Format(text, sizeof(text), "%t", "KnifeHuntsman");
- if(c_zIDKnife[client] == 7) Format(text, sizeof(text), "[x] %t", "KnifeHuntsman"), AddMenuItem(menu, "", text);
- else AddMenuItem(menu, "", text);
- Format(text, sizeof(text), "%t", "KnifeButterfly");
- if(c_zIDKnife[client] == 8) Format(text, sizeof(text), "[x] %t", "KnifeButterfly"), AddMenuItem(menu, "", text);
- else AddMenuItem(menu, "", text);
- SetMenuExitBackButton(menu, true);
- DisplayMenu(menu, client, 15);
- }
- public KnifeMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
- {
- if(action == MenuAction_Select)
- {
- if(IsPlayerAlive(client) && GetClientTeam(client) > 1)
- {
- new knife;
- new currentknife = GetPlayerWeaponSlot(client, 2);
- if(IsValidEntity(currentknife) && currentknife != INVALID_ENT_REFERENCE)
- {
- RemovePlayerItem(client, currentknife);
- RemoveEdict(currentknife);
- }
- switch(itemNum)
- {
- case 0: knife = GivePlayerItem(client, "weapon_knife");
- case 1: knife = GivePlayerItem(client, "weapon_knifegg");
- case 2: knife = GivePlayerItem(client, "weapon_knife_gut"), KnifeMenuSpec(client, 0);
- case 3: knife = GivePlayerItem(client, "weapon_knife_flip"), KnifeMenuSpec(client, 0);
- case 4: knife = GivePlayerItem(client, "weapon_bayonet"), KnifeMenuSpec(client, 0);
- case 5: knife = GivePlayerItem(client, "weapon_knife_m9_bayonet"), KnifeMenuSpec(client, 0);
- case 6: knife = GivePlayerItem(client, "weapon_knife_karambit"), KnifeMenuSpec(client, 0);
- case 7: knife = GivePlayerItem(client, "weapon_knife_tactical"), KnifeMenuSpec(client, 0);
- case 8: knife = GivePlayerItem(client, "weapon_knife_butterfly"), KnifeMenuSpec(client, 0);
- }
- c_zIDKnife[client] = itemNum;
- EquipPlayerWeapon(client, knife);
- }
- }
- else if(action == MenuAction_Cancel && itemNum == MenuCancel_ExitBack)
- {
- MainMenu(client);
- }
- }
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- ////////////////////////// Skins Knife ////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- public KnifeMenuSpec(client, item)
- {
- decl String:text[64];
- SetGlobalTransTarget(client);
- new Handle:menu = CreateMenu(KnifeMenuSpecHandler);
- Format(text, sizeof(text), "%t", "SpecialKnife");
- SetMenuTitle(menu, "%s | %s\n ", PLUGIN_NAME, text);
- for(new i = 1; i < g_aPaintCount; i++)
- {
- new normal = g_iChooseSkinKnife[i][knife_level];
- decl String:itemknife[4];
- Format(itemknife, 4, "%i", i);
- if(c_zRank[client] >= normal)
- {
- AddMenuItem(menu, itemknife, g_iChooseSkinKnife[i][knife_name]);
- }
- else
- {
- AddMenuItem(menu, itemknife, g_iChooseSkinKnife[i][knife_name], ITEMDRAW_DISABLED);
- }
- }
- SetMenuExitButton(menu, true);
- DisplayMenuAtItem(menu, client, item, 9);
- }
- public KnifeMenuSpecHandler(Handle:menu, MenuAction:action, client, itemNum)
- {
- if(action == MenuAction_Select)
- {
- decl String:info[4];
- GetMenuItem(menu, itemNum, info, sizeof(info));
- new theindex = StringToInt(info);
- new windex = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
- if(windex < 1)
- {
- KnifeMenuSpec(client, GetMenuSelectionPosition());
- return;
- }
- decl String:Classname[64];
- GetEdictClassname(windex, Classname, 64);
- new weaponindex = GetEntProp(windex, Prop_Send, "m_iItemDefinitionIndex");
- if(weaponindex == 42 || weaponindex == 59)
- {
- KnifeMenuSpec(client, GetMenuSelectionPosition());
- return;
- }
- if(GetPlayerWeaponSlot(client, 2) == windex)
- {
- switch(weaponindex)
- {
- case 506: strcopy(Classname, 64, "weapon_knife_gut");
- case 505: strcopy(Classname, 64, "weapon_knife_flip");
- case 500: strcopy(Classname, 64, "weapon_bayonet");
- case 508: strcopy(Classname, 64, "weapon_knife_m9_bayonet");
- case 507: strcopy(Classname, 64, "weapon_knife_karambit");
- case 509: strcopy(Classname, 64, "weapon_knife_tactical");
- case 515: strcopy(Classname, 64, "weapon_knife_butterfly");
- }
- if(arbol[client] != INVALID_HANDLE)
- {
- SetTrieValue(arbol[client], Classname, theindex);
- ChangePaint(client, windex, Classname, weaponindex);
- FakeClientCommand(client, "use %s", Classname);
- }
- }
- }
- }
- ChangePaint(client, windex, String:Classname[64], weaponindex)
- {
- if(g_iActiveKnife)
- {
- new bool:knife = false;
- if(StrContains(Classname, "weapon_knife", false) == 0 || StrContains(Classname, "weapon_bayonet", false) == 0)
- {
- knife = true;
- }
- new clip;
- if(!knife)
- {
- clip = GetEntProp(windex, Prop_Send, "m_iClip1");
- }
- RemovePlayerItem(client, windex);
- AcceptEntityInput(windex, "Kill");
- new Handle:pack;
- new entity = GivePlayerItem(client, Classname);
- if(knife)
- {
- if (weaponindex != 42 && weaponindex != 59)
- EquipPlayerWeapon(client, entity);
- }
- else
- {
- SetEntProp(entity, Prop_Send, "m_iClip1", clip);
- }
- if(arbol[client] == INVALID_HANDLE)
- {
- return;
- }
- new theindex;
- GetTrieValue(arbol[client], Classname, theindex);
- if(theindex == 0) return;
- if(theindex == -1)
- {
- theindex = GetRandomInt(1, g_aPaintCount-1);
- }
- new m_iItemIDHigh = GetEntProp(entity, Prop_Send, "m_iItemIDHigh");
- new m_iItemIDLow = GetEntProp(entity, Prop_Send, "m_iItemIDLow");
- SetEntProp(entity,Prop_Send,"m_iItemIDLow",2048);
- SetEntProp(entity,Prop_Send,"m_iItemIDHigh",0);
- SetEntProp(entity,Prop_Send,"m_nFallbackPaintKit", g_iChooseSkinKnife[theindex][knife_paint]);
- SetEntProp(entity,Prop_Send,"m_nFallbackStatTrak", c_zExp[client]);
- SetEntProp(entity,Prop_Send,"m_iEntityQuality", 3);
- SetEntPropFloat(entity,Prop_Send,"m_flFallbackWear", 0.0);
- CreateDataTimer(0.2, RestoreItemID, pack);
- WritePackCell(pack,EntIndexToEntRef(entity));
- WritePackCell(pack,m_iItemIDHigh);
- WritePackCell(pack,m_iItemIDLow);
- }
- }
- public Action:RestoreItemID(Handle:timer, Handle:pack)
- {
- if(g_iActiveKnife)
- {
- new entity;
- new m_iItemIDHigh;
- new m_iItemIDLow;
- ResetPack(pack);
- entity = EntRefToEntIndex(ReadPackCell(pack));
- m_iItemIDHigh = ReadPackCell(pack);
- m_iItemIDLow = ReadPackCell(pack);
- if(entity != INVALID_ENT_REFERENCE)
- {
- SetEntProp(entity,Prop_Send,"m_iItemIDHigh",m_iItemIDHigh);
- SetEntProp(entity,Prop_Send,"m_iItemIDLow",m_iItemIDLow);
- }
- }
- }
- ReadPaints()
- {
- BuildPath(Path_SM, Paints_Path, sizeof(Paints_Path), "configs/levels_ranks/knifes.ini");
- decl Handle:kv;
- g_aPaintCount = 1;
- kv = CreateKeyValues("KnifeSkins");
- FileToKeyValues(kv, Paints_Path);
- if(!KvGotoFirstSubKey(kv)) {
- SetFailState("CFG File not found: %s", Paints_Path);
- CloseHandle(kv);
- }
- do
- {
- KvGetSectionName(kv, g_iChooseSkinKnife[g_aPaintCount][knife_name], 64);
- g_iChooseSkinKnife[g_aPaintCount][knife_paint] = KvGetNum(kv, "paint", -2);
- g_iChooseSkinKnife[g_aPaintCount][knife_level] = KvGetNum(kv, "level", -2);
- g_aPaintCount++;
- }
- while (KvGotoNextKey(kv));
- CloseHandle(kv);
- }
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- ////////////////////////// Gloves ///////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- public Action:ArmsMenu(client)
- {
- decl String:text[64];
- SetGlobalTransTarget(client);
- new Handle:menu = CreateMenu(ArmsMenuHandler);
- Format(text, sizeof(text), "%t", "Gloves");
- SetMenuTitle(menu, "%s | %s\n ", PLUGIN_NAME, text);
- Format(text, sizeof(text), "%t", "GloveUsual");
- AddMenuItem(menu, "-1", text);
- for(new i=0; i < Arms_Count; i++)
- {
- new normal = StringToInt(RanksArms[i]);
- new String:g_MsgArms[192];
- if(c_zRank[client] >= normal)
- {
- Format(g_MsgArms, 192, "%s", NameArms[i]);
- AddMenuItem(menu, IDArms[i], g_MsgArms);
- }
- else
- {
- Format(g_MsgArms, 192, "%s", NameArms[i]);
- AddMenuItem(menu, IDArms[i], g_MsgArms, ITEMDRAW_DISABLED);
- }
- }
- SetMenuExitButton(menu, true);
- DisplayMenu(menu, client, 9);
- return Plugin_Handled;
- }
- public ArmsMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
- {
- if (action == MenuAction_Select)
- {
- decl String:arms_id[10];
- GetMenuItem(menu, itemNum, arms_id, sizeof(arms_id));
- new arms = StringToInt(arms_id, sizeof(arms_id));
- SelectedArms[client] = arms;
- if (IsValidClient(client))
- {
- if (-1 < arms < Arms_Count)
- {
- SetEntPropString(client, Prop_Send, "m_szArmsModel", UseArms[arms]);
- }
- }
- PrintToChat(client, " \x02[LR] %t", "ChooseGlove", DEFAULT);
- }
- }
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- ////////////////////////// GIVE EXP ///////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- GivePointsPlayers(client, item = 0)
- {
- decl String:givepp_id[15], String:givepp_nick[32], String:text[64];
- new Handle:menu = CreateMenu(GivePointsPlayers_CallBack);
- new flags = GetUserFlagBits(client);
- SetGlobalTransTarget(client);
- Format(text, sizeof(text), "%t", "GivePoints");
- SetMenuTitle(menu, "%s | %s:\n ", PLUGIN_NAME, text);
- for (new i = 1; i <= MaxClients; i++)
- {
- if(IsClientInGame(i) && !IsFakeClient(i) && (flags & ADMFLAG_ROOT))
- {
- IntToString(GetClientUserId(i), givepp_id, 15);
- givepp_nick[0] = '\0';
- GetClientName(i, givepp_nick, 32);
- AddMenuItem(menu, givepp_id, givepp_nick);
- }
- else if(IsClientInGame(i) && !IsFakeClient(i))
- {
- IntToString(GetClientUserId(i), givepp_id, 15);
- givepp_nick[0] = '\0';
- GetClientName(i, givepp_nick, 32);
- AddMenuItem(menu, givepp_id, givepp_nick, i != client ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED);
- }
- }
- DisplayMenuAtItem(menu, client, item, 0);
- }
- public GivePointsPlayers_CallBack(Handle:menu, MenuAction:action, client, item)
- {
- if(action == MenuAction_Select)
- {
- decl String:givepp_id[15];
- if(!GetMenuItem(menu, item, givepp_id, 15))
- return;
- IDGivePP = GetClientOfUserId(StringToInt(givepp_id));
- GivePointsPlayers2(client, 0);
- }
- else if(action == MenuAction_End)
- {
- CloseHandle(menu);
- }
- }
- public GivePointsPlayers2(client, item)
- {
- decl String:text[64];
- SetGlobalTransTarget(client);
- Format(text, sizeof(text), "%t", "GivePoints");
- new Handle:menu = CreateMenu(GivePointsPlayers2Handler);
- SetMenuTitle(menu, "%s | %s\n ", PLUGIN_NAME, text);
- AddMenuItem(menu, "opt1", "10");
- AddMenuItem(menu, "opt2", "50");
- AddMenuItem(menu, "opt3", "100");
- AddMenuItem(menu, "opt4", "500");
- AddMenuItem(menu, "opt5", "1000");
- AddMenuItem(menu, "opt6", "5000");
- AddMenuItem(menu, "opt7", "-5000");
- AddMenuItem(menu, "opt8", "-1000");
- AddMenuItem(menu, "opt9", "-500");
- AddMenuItem(menu, "opt10", "-100");
- AddMenuItem(menu, "opt11", "-50");
- AddMenuItem(menu, "opt12", "-10");
- SetMenuExitButton(menu, true);
- DisplayMenuAtItem(menu, client, item, 15);
- }
- public GivePointsPlayers2Handler(Handle:menu, MenuAction:action, client, itemNum)
- {
- if(action == MenuAction_Select)
- {
- new String:info[32], String:s_buffer[32];
- GetMenuItem(menu, itemNum, info, sizeof(info), _ , s_buffer, sizeof(s_buffer));
- new i_buffer = StringToInt(s_buffer);
- c_zExp[IDGivePP] += i_buffer;
- GivePointsPlayers2(client, GetMenuSelectionPosition());
- SetGlobalTransTarget(client);
- if(i_buffer > 0)
- {
- PrintToChat(client, "%t", "AdminGiveExp", GREEN, DEFAULT, GREEN, i_buffer, DEFAULT, IDGivePP, LIME);
- }
- else if(i_buffer < 0)
- {
- PrintToChat(client, "%t", "AdminTookExp", GREEN, DEFAULT, GREEN, i_buffer, DEFAULT, IDGivePP, LIME);
- }
- }
- else if(action == MenuAction_End)
- {
- CloseHandle(menu);
- }
- }
- /////////////////////////////////////////////
- /////////////////////////////////////////////
- ///////// MAIN FUNCT ////////////////////////
- /////////////////////////////////////////////
- /////////////////////////////////////////////
- public Hook_OnThinkPost(iEnt)
- {
- SetEntDataArray(iEnt, iRankOffset, c_zCompetitiveRank, MaxClients+1);
- new Handle:hBuffer = StartMessageAll("ServerRankRevealAll");
- if(hBuffer == INVALID_HANDLE)
- {
- PrintToServer("ServerRankRevealAll = INVALID_HANDLE");
- }
- else
- {
- EndMessage();
- }
- }
- public OnPostThinkPost(client)
- {
- SetGlobalTransTarget(client);
- if(c_zRank[client] < 21)
- {
- if(c_zExp[client] >= StringToInt(AllExp[c_zRank[client]]))
- {
- EmitSoundToClient(client, EmitSound_Path);
- c_zRank[client] += 1;
- PrintToChat(client, " \x02[LR] %t", "LevelUp", DEFAULT, GREEN, AllRanksMenu[c_zRank[client]]);
- }
- else if(c_zRank[client] > 0 && c_zExp[client] < StringToInt(AllExp[c_zRank[client] - 1]))
- {
- EmitSoundToClient(client, EmitSound_Path2);
- c_zRank[client] -= 1;
- PrintToChat(client, " \x02[LR] %t", "LevelDown", DEFAULT, RED, AllRanksMenu[c_zRank[client]]);
- }
- }
- else if(c_zRank[client] == 21)
- {
- if(c_zExp[client] < StringToInt(AllExp[c_zRank[client] - 1]))
- {
- c_zRank[client] -= 1;
- EmitSoundToClient(client, EmitSound_Path2);
- PrintToChat(client, " \x02[LR] %t", "LevelDown", DEFAULT, RED, AllRanksMenu[c_zRank[client]]);
- }
- }
- if(c_zRank[client] <= 18)
- {
- c_zCompetitiveRank[client] = c_zRank[client];
- }
- else if(c_zRank[client] > 18)
- {
- c_zCompetitiveRank[client] = 18;
- }
- }
- public Action:OnPostWeaponEquip(client, weapon)
- {
- new Handle:pack;
- CreateDataTimer(0.0, Pasado, pack);
- WritePackCell(pack,EntIndexToEntRef(weapon));
- WritePackCell(pack, client);
- }
- public Action:Pasado(Handle:timer, Handle:pack)
- {
- if(g_iActiveKnife)
- {
- new weapon;
- new client;
- ResetPack(pack);
- weapon = EntRefToEntIndex(ReadPackCell(pack));
- client = ReadPackCell(pack);
- if(weapon == INVALID_ENT_REFERENCE || !IsClientInGame(client) || !IsPlayerAlive(client))
- {
- return;
- }
- if(weapon < 1 || !IsValidEdict(weapon) || !IsValidEntity(weapon))
- {
- return;
- }
- if (GetEntProp(weapon, Prop_Send, "m_hPrevOwner") > 0 || (GetEntProp(weapon, Prop_Send, "m_iItemIDHigh") == 0 && GetEntProp(weapon, Prop_Send, "m_iItemIDLow") == 2048))
- return;
- decl String:Classname[64];
- GetEdictClassname(weapon, Classname, 64);
- new weaponindex = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
- if(weaponindex == 42 || weaponindex == 59)
- {
- return;
- }
- if(GetPlayerWeaponSlot(client, 2) == weapon)
- {
- switch (weaponindex)
- {
- case 506: strcopy(Classname, 64, "weapon_knife_gut");
- case 505: strcopy(Classname, 64, "weapon_knife_flip");
- case 500: strcopy(Classname, 64, "weapon_bayonet");
- case 508: strcopy(Classname, 64, "weapon_knife_m9_bayonet");
- case 507: strcopy(Classname, 64, "weapon_knife_karambit");
- case 509: strcopy(Classname, 64, "weapon_knife_tactical");
- case 515: strcopy(Classname, 64, "weapon_knife_butterfly");
- }
- if(arbol[client] == INVALID_HANDLE)
- {
- return;
- }
- new valor = 0;
- GetTrieValue(arbol[client], Classname, valor);
- if(valor == 0)
- {
- return;
- }
- ChangePaint(client, weapon, Classname, weaponindex);
- }
- }
- }
- public OnClientPostAdminCheck(client)
- {
- doublekill[client] = false;
- triplekill[client] = false;
- quadrokill[client] = false;
- pentakill[client] = false;
- SelectedArms[client] = -1;
- if(g_iActiveKnife)
- {
- SDKHook(client, SDKHook_WeaponEquipPost, OnPostWeaponEquip);
- }
- SDKHook(client, SDKHook_PostThinkPost, OnPostThinkPost);
- }
- public OnClientCookiesCached(client)
- {
- decl String:SaveString[100], String:cookie1[100];
- GetClientCookie(client, g_mPaintsSkin, cookie1, sizeof(cookie1));
- if(strlen(cookie1) < 3) Format(cookie1, sizeof(cookie1), "0;0;0;0;0;0;0;");
- SetTrieValue_Arbol(client, cookie1);
- GetClientCookie(client, g_mExp, SaveString, sizeof(SaveString));
- c_zExp[client] = StringToInt(SaveString);
- GetClientCookie(client, g_mRank, SaveString, sizeof(SaveString));
- c_zRank[client] = StringToInt(SaveString);
- GetClientCookie(client, g_mSaveKnife, SaveString, sizeof(SaveString));
- c_zIDKnife[client] = StringToInt(SaveString);
- }
- SetTrieValue_Arbol(client, String:cookie1[100])
- {
- arbol[client] = CreateTrie();
- decl String:parte1[7][4];
- ExplodeString(cookie1, ";", parte1, sizeof(parte1), sizeof(parte1[]));
- SetTrieValue(arbol[client], "weapon_knife_gut", StringToInt(parte1[0]));
- SetTrieValue(arbol[client], "weapon_knife_flip", StringToInt(parte1[1]));
- SetTrieValue(arbol[client], "weapon_bayonet", StringToInt(parte1[2]));
- SetTrieValue(arbol[client], "weapon_knife_m9_bayonet", StringToInt(parte1[3]));
- SetTrieValue(arbol[client], "weapon_knife_karambit", StringToInt(parte1[4]));
- SetTrieValue(arbol[client], "weapon_knife_tactical", StringToInt(parte1[5]));
- SetTrieValue(arbol[client], "weapon_knife_butterfly", StringToInt(parte1[6]));
- }
- SaveCookies(client)
- {
- decl String:cookie1[100];
- new valor;
- GetTrieValue(arbol[client], "weapon_knife_gut", valor);
- Format(cookie1, sizeof(cookie1), "%i", valor);
- GetTrieValue(arbol[client], "weapon_knife_flip", valor);
- Format(cookie1, sizeof(cookie1), "%s;%i", cookie1, valor);
- GetTrieValue(arbol[client], "weapon_bayonet", valor);
- Format(cookie1, sizeof(cookie1), "%s;%i", cookie1, valor);
- GetTrieValue(arbol[client], "weapon_knife_m9_bayonet", valor);
- Format(cookie1, sizeof(cookie1), "%s;%i", cookie1, valor);
- GetTrieValue(arbol[client], "weapon_knife_karambit", valor);
- Format(cookie1, sizeof(cookie1), "%s;%i", cookie1, valor);
- GetTrieValue(arbol[client], "weapon_knife_tactical", valor);
- Format(cookie1, sizeof(cookie1), "%s;%i", cookie1, valor);
- GetTrieValue(arbol[client], "weapon_knife_butterfly", valor);
- Format(cookie1, sizeof(cookie1), "%s;%i", cookie1, valor);
- SetClientCookie(client, g_mPaintsSkin, cookie1);
- }
- public OnClientAuthorized(client, const String:steamid[])
- {
- if(!IsFakeClient(client))
- {
- Format(g_steamid[client], Max_Length, steamid);
- GetClientName(client, g_name[client], MAX_NAME_LENGTH);
- GetPlayerBySteamId(steamid, LoadPlayerCallback, client);
- }
- }
- public OnPluginEnd()
- {
- for(new client = 1; client <= MaxClients; client++)
- {
- if(IsClientInGame(client) && client > 0)
- {
- OnClientDisconnect(client);
- }
- }
- }
- public OnClientDisconnect(client)
- {
- if(AreClientCookiesCached(client))
- {
- SaveCookies(client);
- }
- if(g_initialized[client] == true)
- {
- SavePlayer(client);
- g_initialized[client] = false;
- }
- if(arbol[client] != INVALID_HANDLE)
- {
- ClearTrie(arbol[client]);
- CloseHandle(arbol[client]);
- arbol[client] = INVALID_HANDLE;
- }
- if(g_iActiveKnife)
- {
- SDKUnhook(client, SDKHook_WeaponEquipPost, OnPostWeaponEquip);
- }
- SDKUnhook(client, SDKHook_PostThinkPost, OnPostThinkPost);
- if(AreClientCookiesCached(client))
- {
- decl String:SaveString[15];
- Format(SaveString, sizeof(SaveString), "%i", c_zExp[client]);
- SetClientCookie(client, g_mExp, SaveString);
- Format(SaveString, sizeof(SaveString), "%i", c_zRank[client]);
- SetClientCookie(client, g_mRank, SaveString);
- Format(SaveString, sizeof(SaveString), "%i", c_zIDKnife[client]);
- SetClientCookie(client, g_mSaveKnife, SaveString);
- }
- doublekill[client] = false;
- triplekill[client] = false;
- quadrokill[client] = false;
- pentakill[client] = false;
- c_zExp[client] = 0;
- c_zCompetitiveRank[client] = 0;
- c_zRank[client] = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement