Advertisement
Guest User

Untitled

a guest
May 24th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 58.58 KB | None | 0 0
  1. /*
  2.  
  3. [12.04.15] РЕЛИЗ ПЛАГИНА версия 1.0.0
  4. [22.04.2015] Плагин обновлён до версии 1.0.1
  5.  
  6. - оптимизация кода, спасибо R1KO.
  7. - исправление ошибки массива, забивающая логи
  8. - добавление скинов для ножей (пока неполный список)
  9. - исключение из плагина Knife Choice Core
  10.  
  11. =========================================================
  12.  
  13. [25.04.2015] Плагин обновлён до версии 1.0.2
  14.  
  15. - добавлен файл перевода для плагина (теперь вы можете добавить нужные вам языки)
  16. - добавлены новые хуки событий над бомбой, а также MVP и команда победителей
  17. - добавлены раскраски ножей по уровням (со следующими версиями будут подобраны лучшие)
  18. - добавлены новые квары
  19.  
  20. =========================================================
  21.  
  22. [28.04.2015] Плагин обновлён до версии 1.0.3
  23.  
  24. - добавлены новые квары
  25. - добавлены звуки повышения или понижения ранга
  26.  
  27. =========================================================
  28.  
  29. [04.05.2015] Плагин обновлён до версии 1.0.4
  30.  
  31. - добавлены новые квары
  32. - добавлена возможность выбирать перчатки
  33. - исправлен баг неработоспособности Double- Triple- Quadro- PentaKills (он работает по принципу, если вы убили игрока, то если вы успеете за 2 секунды убить другого и т.д. вам будут начислять доп.очки)
  34. - теперь есть возможность самому выбирать и ставить пути до звуков повышения или понижения рангов
  35. - теперь способ выбора текстур для ножей изменён. Сначала вы выбираете нож, а потом сразу же для него текстуру.
  36. - все скины для ножей сохраняются
  37. - добавлены ассист-килл и хедшот-килл
  38. - теперь, если вы не хотите, чтобы игроку не засчитывался опыт за определённое действие, поставьте 0, сообщение о выдаче также будет отключено.
  39. - файл перевода обновлён
  40.  
  41. =========================================================
  42.  
  43. [18.05.2015] Плагин обновлён до версии 1.0.5
  44.  
  45. - исправлены некоторые баги и оптимизирован код
  46. - добавлена функция ТОП-12 (сделано на основе SoD Stats)
  47. - ваше место среди всех игроков, теперь показывается в главном меню
  48. - добавлен раздел, показывающий список всех званий с кол-вом необходимого опыта
  49. - добавлен конфиг файл, в котором вы можете настроить название, цену и префикс звания
  50. - добавлено 3 новых звания: Теневой Совет, Величайший, Бог
  51.  
  52. =========================================================
  53.  
  54. [19.05.2015] Плагин обновлён до версии 1.0.6
  55.  
  56. - исправлена ошибка, когда у игроков сбрасывались звания и все очки опыта
  57.  
  58. */
  59.  
  60. #pragma semicolon 1
  61. #include <sourcemod>
  62. #include <clientprefs>
  63. #include <sdkhooks>
  64. #include <sdktools>
  65. #undef REQUIRE_PLUGIN
  66.  
  67. // #define PLUGIN_CORE "[Levels Ranks] Core"
  68. #define PLUGIN_NAME "Levels Ranks"
  69. #define PLUGIN_AUTHOR "RoadSide Romeo"
  70. #define PLUGIN_VERSION "v1.0.6"
  71. #define Max_Paints 600
  72. #define Max_Counts 64
  73. #define Max_Length 192
  74. #define DBTYPE_MYSQL 1
  75. #define DBTYPE_SQLITE 2
  76.  
  77. #define DEFAULT "\x01"
  78. #define RED "\x02"
  79. #define GREEN "\x04"
  80. #define LIME "\x05"
  81. #define ORANGE "\x10"
  82. #define PURPLE "\x0E"
  83.  
  84. enum Special_Knife
  85. {
  86. String:knife_name[64],
  87. knife_paint,
  88. knife_level
  89. }
  90.  
  91. new ClientTeam[MAXPLAYERS+1],
  92. c_zCompetitiveRank[MAXPLAYERS+1],
  93. c_zIDKnife[MAXPLAYERS+1],
  94. c_zRank[MAXPLAYERS+1],
  95. c_zExp[MAXPLAYERS+1],
  96.  
  97. // Cvars Bools
  98. g_iSpawnMenu,
  99. g_iSpawnMessage,
  100. g_iActiveKnife,
  101. g_iActiveGloves,
  102.  
  103. // Cvars Integer - Give
  104. g_iGiveKillUsuallyExp,
  105. g_iGiveKillAssisterExp,
  106. g_iGiveKillHeadshotExp,
  107. g_iGiveTaserExp,
  108. g_iGiveGrenadeExp,
  109. g_iGiveMolotovExp,
  110. g_iGiveDoubleExp,
  111. g_iGiveTripleExp,
  112. g_iGiveQuadroExp,
  113. g_iGivePentaExp,
  114. g_iGiveBombPlanted,
  115. g_iGiveBombDefused,
  116. g_iGiveBombPickup,
  117. g_iGiveRoundWin,
  118. g_iGiveRoundMVP,
  119.  
  120. // Cvars Integer - Lose
  121. g_iLoseSuicideExp,
  122. g_iLoseBombDropped,
  123. g_iLoseKillUsuallyExp,
  124. g_iLoseRoundLose,
  125.  
  126. iRankOffset,
  127. IDGivePP,
  128. g_aPaintCount = 0,
  129. g_iChooseSkinKnife[Max_Paints][Special_Knife],
  130.  
  131. bool:doublekill[MAXPLAYERS+1],
  132. bool:triplekill[MAXPLAYERS+1],
  133. bool:quadrokill[MAXPLAYERS+1],
  134. bool:pentakill[MAXPLAYERS+1],
  135.  
  136. Float:KillTime[MAXPLAYERS+1],
  137. Float:GameTime[MAXPLAYERS+1],
  138.  
  139. Handle:sp_mLevelUpHand = INVALID_HANDLE,
  140. Handle:sp_mLevelDownHand = INVALID_HANDLE,
  141. Handle:g_mExp = INVALID_HANDLE,
  142. Handle:g_mRank = INVALID_HANDLE,
  143. Handle:g_mSaveKnife = INVALID_HANDLE,
  144. Handle:g_mPaintsSkin = INVALID_HANDLE,
  145. Handle:arbol[MAXPLAYERS+1] = INVALID_HANDLE,
  146.  
  147. String:Download_Path[192],
  148. String:Download_Path2[192],
  149. String:EmitSound_Path[192],
  150. String:EmitSound_Path2[192],
  151. String:Paints_Path[PLATFORM_MAX_PATH],
  152. String:RanksArms[Max_Counts][Max_Length], Arms_Count, SelectedArms[MAXPLAYERS + 1],
  153. String:NameArms[Max_Counts][Max_Length],
  154. String:IDArms[Max_Counts][Max_Length],
  155. String:UseArms[Max_Counts][Max_Length],
  156. String:AllExp[Max_Counts][Max_Length],
  157. String:AllPrefix[Max_Counts][Max_Length],
  158. String:AllRanksMenu[][] = {
  159. "Unranked",
  160. "Srebro - I",
  161. "Srebro - II",
  162. "Srebro - III",
  163. "Srebro - IV",
  164. "Srebro - Elitarne",
  165. "Srebro - Mistrzowskie Elitarne",
  166. "Gold - I",
  167. "Gold - II",
  168. "Gold - III",
  169. "Gold - Nova Master",
  170. "Kałach - I",
  171. "Kałach - II",
  172. "Kałach - Double",
  173. "Wybitny mistrzowski obrońca",
  174. "Orzełek",
  175. "Orzełek - Mistrzowski",
  176. "Supreme",
  177. "Global Elite",
  178. "Rada Cienia",
  179. "Najlepszy",
  180. "Bot"};
  181. // SQL переменные
  182.  
  183. new String:m_iSQL_SavePlayer[] = "UPDATE players SET score = %i, name = '%s', time_played = time_played + %i, last_connect = current_timestamp WHERE steamid = '%s'",
  184. String:m_iSQL_CreatePlayer[] = "INSERT INTO players (score, steamid, name, time_played, last_connect) VALUES (0, '%s', '%s', 0, current_timestamp)",
  185. 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);",
  186. 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);",
  187. String:g_sql_droptable_players[] = "DROP TABLE IF EXISTS 'players'; VACUUM;",
  188. String:g_sql_playercount[] = "SELECT * FROM players",
  189. String:g_sql_addtimestamp[] = "ALTER TABLE players ADD COLUMN last_connect timestamp DEFAULT NULL;",
  190. String:g_sql_loadplayer[] = "SELECT name, steamid, score, time_played FROM players WHERE steamid = '%s'",
  191. String:g_sql_top[] = "SELECT name, steamid, score, time_played FROM players ORDER BY score DESC LIMIT %i OFFSET %i",
  192. String:g_sql_rank[] = "SELECT DISTINCT score FROM players WHERE score >= %i ORDER BY score ASC;",
  193. String:g_name[MAXPLAYERS+1][MAX_NAME_LENGTH],
  194. String:g_steamid[MAXPLAYERS+1][Max_Length],
  195. String:g_ident[16],
  196. g_dbtype,
  197. g_player_count,
  198. g_time_joined[MAXPLAYERS+1],
  199. g_time_played[MAXPLAYERS+1],
  200. g_last_saved_time[MAXPLAYERS+1],
  201. bool:g_initialized[MAXPLAYERS+1],
  202. myplace[MAXPLAYERS+1];
  203.  
  204. #include "include/levels_ranks/sql.inc"
  205. #include "levels_ranks/SQL.sp"
  206.  
  207. public Plugin:myinfo = {name = PLUGIN_NAME, author = PLUGIN_AUTHOR, version = PLUGIN_VERSION}
  208. public OnPluginStart()
  209. {
  210. decl String:game[80];
  211. GetGameFolderName(game, 80);
  212.  
  213. if(!StrEqual(game, "csgo"))
  214. {
  215. SetFailState("[%s] Плагин работает только на CS:GO", PLUGIN_NAME);
  216. }
  217.  
  218. g_mExp = RegClientCookie("ExpClient", "ExpClient", CookieAccess_Private);
  219. g_mRank = RegClientCookie("RankLevel", "RankLevel", CookieAccess_Private);
  220. g_mSaveKnife = RegClientCookie("SaveKnifeUsually", "SaveKnifeUsually", CookieAccess_Private);
  221. g_mPaintsSkin = RegClientCookie("PaintsSkin", "PaintsSkin", CookieAccess_Private);
  222.  
  223. // Hooks Round
  224. HookEvent("round_mvp", RoundMVP, EventHookMode_Pre);
  225. HookEvent("round_start", RoundStart);
  226. HookEvent("round_end", RoundEnd);
  227.  
  228. // Hooks Player
  229. HookEvent("player_spawn", PlayerSpawn, EventHookMode_Post);
  230. HookEvent("player_death", PlayerDeath);
  231. HookEvent("player_death", PlayerDeathMulti);
  232. HookEvent("player_team", PlayerTeam);
  233.  
  234. // Hooks Bomb
  235. HookEvent("bomb_planted", Hook_BombPlanted);
  236. HookEvent("bomb_defused", Hook_BombDefused);
  237. HookEvent("bomb_dropped", Hook_BombDropped);
  238. HookEvent("bomb_pickup", Hook_BombPickup);
  239.  
  240. new Handle:hCvar;
  241.  
  242. CreateConVar("sm_levels_ranks", PLUGIN_VERSION, "Levels Ranks Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  243.  
  244. // Bools
  245. HookConVarChange((hCvar = CreateConVar("ranks_spawnmenu", "0")), OnSpawnMenuChange); g_iSpawnMenu = GetConVarBool(hCvar);
  246. HookConVarChange((hCvar = CreateConVar("ranks_spawnmessage", "1")), OnSpawnMessageChange); g_iSpawnMessage = GetConVarBool(hCvar);
  247. HookConVarChange((hCvar = CreateConVar("ranks_knife", "1")), OnActiveKnifeChange); g_iActiveKnife = GetConVarBool(hCvar);
  248. HookConVarChange((hCvar = CreateConVar("ranks_gloves", "1")), OnActiveGlovesChange); g_iActiveGloves = GetConVarBool(hCvar);
  249.  
  250. // Integer
  251. HookConVarChange((hCvar = CreateConVar("ranks_kill", "2")), OnGiveKillExpChange); g_iGiveKillUsuallyExp = GetConVarInt(hCvar);
  252. HookConVarChange((hCvar = CreateConVar("ranks_assister", "1")), OnGiveKillAssisterChange); g_iGiveKillAssisterExp = GetConVarInt(hCvar);
  253. HookConVarChange((hCvar = CreateConVar("ranks_headshot", "1")), OnGiveKillHeadShotChange); g_iGiveKillHeadshotExp = GetConVarInt(hCvar);
  254. HookConVarChange((hCvar = CreateConVar("ranks_mydeath", "1")), OnLoseKillExpChange); g_iLoseKillUsuallyExp = GetConVarInt(hCvar);
  255. HookConVarChange((hCvar = CreateConVar("ranks_taserkill", "3")), OnGiveTaserExpChange); g_iGiveTaserExp = GetConVarInt(hCvar);
  256. HookConVarChange((hCvar = CreateConVar("ranks_doublekill", "4")), OnGiveDoubleExpChange); g_iGiveDoubleExp = GetConVarInt(hCvar);
  257. HookConVarChange((hCvar = CreateConVar("ranks_triplekill", "8")), OnGiveTripleExpChange); g_iGiveTripleExp = GetConVarInt(hCvar);
  258. HookConVarChange((hCvar = CreateConVar("ranks_quadrokill", "12")), OnGiveQuadroExpChange); g_iGiveQuadroExp = GetConVarInt(hCvar);
  259. HookConVarChange((hCvar = CreateConVar("ranks_pentakill", "16")), OnGivePentaExpChange); g_iGivePentaExp = GetConVarInt(hCvar);
  260. HookConVarChange((hCvar = CreateConVar("ranks_grenadekill", "7")), OnGiveGrenadeExpChange); g_iGiveGrenadeExp = GetConVarInt(hCvar);
  261. HookConVarChange((hCvar = CreateConVar("ranks_molotovkill", "14")), OnGiveMolotovExpChange); g_iGiveMolotovExp = GetConVarInt(hCvar);
  262. HookConVarChange((hCvar = CreateConVar("ranks_suicide", "6")), OnLoseSuicideExpChange); g_iLoseSuicideExp = GetConVarInt(hCvar);
  263. HookConVarChange((hCvar = CreateConVar("ranks_give_bombplanted", "3")), OnGiveBombPlantedChange); g_iGiveBombPlanted = GetConVarInt(hCvar);
  264. HookConVarChange((hCvar = CreateConVar("ranks_give_bombdefused", "3")), OnGiveBombDefusedChange); g_iGiveBombDefused = GetConVarInt(hCvar);
  265. HookConVarChange((hCvar = CreateConVar("ranks_give_bombpickup", "2")), OnGiveBombPickupChange); g_iGiveBombPickup = GetConVarInt(hCvar);
  266. HookConVarChange((hCvar = CreateConVar("ranks_lose_bombdropped", "2")), OnLoseBombDroppedChange); g_iLoseBombDropped = GetConVarInt(hCvar);
  267. HookConVarChange((hCvar = CreateConVar("ranks_give_roundwin", "1")), OnGiveRoundWinChange); g_iGiveRoundWin = GetConVarInt(hCvar);
  268. HookConVarChange((hCvar = CreateConVar("ranks_give_roundmvp", "2")), OnGiveRoundMVPChange); g_iGiveRoundMVP = GetConVarInt(hCvar);
  269. HookConVarChange((hCvar = CreateConVar("ranks_lose_roundlose", "1")), OnLoseRoundLoseChange); g_iLoseRoundLose = GetConVarInt(hCvar);
  270.  
  271. sp_mLevelUpHand = CreateConVar("ranks_sound_levelup", "levels_ranks/levelup.mp3");
  272. sp_mLevelDownHand = CreateConVar("ranks_sound_leveldown", "levels_ranks/leveldown.mp3");
  273. CloseHandle(hCvar);
  274.  
  275. AddCommandListener(ActivatedTrigger, "say");
  276. AddCommandListener(ActivatedTrigger, "say_team");
  277. RegAdminCmd("sm_levels_reset", ResetStatsSQL, ADMFLAG_ROOT);
  278. RegAdminCmd("sm_levels_purge", PurgeStatsSQL, ADMFLAG_ROOT);
  279.  
  280. AutoExecConfig(true, "levels_ranks");
  281. LoadTranslations("levels_ranks.phrases");
  282. RegPluginLibrary("levels_ranks");
  283.  
  284. // ClientPrefs
  285. for(new client = 1; client <= MaxClients; client++)
  286. {
  287. if(IsClientInGame(client))
  288. {
  289. if(AreClientCookiesCached(client))
  290. {
  291. OnClientCookiesCached(client);
  292. }
  293. }
  294. }
  295.  
  296. RegisterSQL();
  297. }
  298.  
  299. public OnMapStart()
  300. {
  301. ServerCommand("sv_tags Levels_Ranks");
  302. iRankOffset = FindSendPropInfo("CCSPlayerResource", "m_iCompetitiveRanking");
  303. SDKHook(FindEntityByClassname(MaxClients+1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
  304. LoadTranslations("levels_ranks.phrases");
  305.  
  306. decl String:path[192];
  307. new Handle:filedownload = OpenFile("cfg/sourcemod/levels_ranks/downloads.txt", "r");
  308.  
  309. if(filedownload == INVALID_HANDLE)
  310. {
  311. SetFailState("Fail exist cfg/sourcemod/levels_ranks/downloads.txt");
  312. return;
  313. }
  314.  
  315. while(!IsEndOfFile(filedownload) && ReadFileLine(filedownload, path, 192))
  316. {
  317. TrimString(path);
  318. if (IsCharAlpha(path[0])) AddFileToDownloadsTable(path);
  319. }
  320.  
  321. CloseHandle(filedownload);
  322.  
  323. GetConVarString(sp_mLevelUpHand, Download_Path, sizeof(Download_Path));
  324. Format(path, sizeof(path), "sound/%s", Download_Path);
  325. AddFileToDownloadsTable(path);
  326. Format(EmitSound_Path, sizeof(EmitSound_Path), "*%s", Download_Path);
  327. FakePrecacheSound(EmitSound_Path);
  328.  
  329. GetConVarString(sp_mLevelDownHand, Download_Path2, sizeof(Download_Path2));
  330. Format(path, sizeof(path), "sound/%s", Download_Path2);
  331. AddFileToDownloadsTable(path);
  332. Format(EmitSound_Path2, sizeof(EmitSound_Path2), "*%s", Download_Path2);
  333. FakePrecacheSound(EmitSound_Path2);
  334.  
  335. ReadPaints();
  336. MakeBuildGloves();
  337. MakeExpRanks();
  338. }
  339.  
  340. public OnMapEnd() iRankOffset = FindSendPropInfo("CCSPlayerResource", "m_iCompetitiveRanking"), SDKUnhook(FindEntityByClassname(MaxClients+1, "cs_player_manager"), SDKHook_ThinkPost, Hook_OnThinkPost);
  341. bool:IsValidClient(client) return (1 <= client <= MaxClients && IsClientInGame(client)) ? true : false;
  342.  
  343. MakeExpRanks()
  344. {
  345. BuildPath(Path_SM, Paints_Path, sizeof(Paints_Path), "configs/levels_ranks/expranks.ini");
  346.  
  347. decl Handle:kv, String:id[Max_Counts], String:exp[Max_Counts], String:prefix[Max_Counts];
  348. kv = CreateKeyValues("Exp_Ranks");
  349. FileToKeyValues(kv, Paints_Path);
  350.  
  351. if(!KvGotoFirstSubKey(kv)) {
  352.  
  353. SetFailState("Levels Ranks: %s is incorrect", Paints_Path);
  354. CloseHandle(kv);
  355. }
  356.  
  357. do
  358. {
  359. KvGetSectionName(kv, id, sizeof(id));
  360. new id_rank = StringToInt(id);
  361.  
  362. if(id_rank != 0)
  363. {
  364. KvGetString(kv, "exp", exp, sizeof(exp));
  365. strcopy(AllExp[id_rank-1], sizeof(AllExp[]), exp);
  366. }
  367.  
  368. // prefix пока не работает. Будет сделан в версии 1.0.6
  369. KvGetString(kv, "prefix", prefix, sizeof(prefix));
  370. strcopy(AllPrefix[id_rank], sizeof(AllPrefix[]), prefix);
  371. }
  372. while (KvGotoNextKey(kv));
  373. CloseHandle(kv);
  374. }
  375.  
  376. MakeBuildGloves()
  377. {
  378. decl String:buffer[PLATFORM_MAX_PATH];
  379.  
  380. if(!FileExists(buffer))
  381. {
  382. BuildPath(Path_SM, buffer, sizeof(buffer), "configs/levels_ranks/gloves.ini");
  383.  
  384. if(!FileExists(buffer))
  385. {
  386. SetFailState("Fatal Error: File don't exist \"%s\"!", buffer);
  387. }
  388. }
  389.  
  390. Arms_Count = 0;
  391.  
  392. new Handle:kv_skins_gloves = CreateKeyValues("Glove");
  393. FileToKeyValues(kv_skins_gloves, buffer);
  394.  
  395. if(KvJumpToKey(kv_skins_gloves, "Gloves"))
  396. {
  397. decl String:section[Max_Counts], String:id[Max_Counts], String:arms[Max_Counts], String:level[Max_Counts];
  398.  
  399. KvGotoFirstSubKey(kv_skins_gloves);
  400.  
  401. do
  402. {
  403. KvGetSectionName(kv_skins_gloves, section, sizeof(section));
  404.  
  405. if(KvGetString(kv_skins_gloves, "id", id, sizeof(id))
  406. && KvGetString(kv_skins_gloves, "arms", arms, sizeof(arms))
  407. && KvGetString(kv_skins_gloves, "level", level, sizeof(level)))
  408. {
  409. strcopy(IDArms[Arms_Count], sizeof(IDArms[]), id);
  410. strcopy(UseArms[Arms_Count], sizeof(UseArms[]), arms);
  411. strcopy(RanksArms[Arms_Count], sizeof(RanksArms[]), level);
  412. strcopy(NameArms[Arms_Count], sizeof(NameArms[]), section);
  413.  
  414. Arms_Count++;
  415.  
  416. PrecacheModel(arms, true);
  417. }
  418. else SetFailState("Player arms for \"%s\" is incorrect!", section);
  419. }
  420. while (KvGotoNextKey(kv_skins_gloves));
  421. }
  422. else SetFailState("Fatal error: Missing section!");
  423.  
  424. KvRewind(kv_skins_gloves);
  425. CloseHandle(kv_skins_gloves);
  426. }
  427.  
  428. // Hooks Integer ConVars - Give
  429. public OnGiveKillExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveKillUsuallyExp = GetConVarInt(hCvar);
  430. public OnGiveKillAssisterChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveKillAssisterExp = GetConVarInt(hCvar);
  431. public OnGiveKillHeadShotChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveKillHeadshotExp = GetConVarInt(hCvar);
  432. public OnLoseKillExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iLoseKillUsuallyExp = GetConVarInt(hCvar);
  433. public OnGiveTaserExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveTaserExp = GetConVarInt(hCvar);
  434. public OnGiveDoubleExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveDoubleExp = GetConVarInt(hCvar);
  435. public OnGiveTripleExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveTripleExp = GetConVarInt(hCvar);
  436. public OnGiveQuadroExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveQuadroExp = GetConVarInt(hCvar);
  437. public OnGivePentaExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGivePentaExp = GetConVarInt(hCvar);
  438. public OnGiveGrenadeExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveGrenadeExp = GetConVarInt(hCvar);
  439. public OnGiveMolotovExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveMolotovExp = GetConVarInt(hCvar);
  440. public OnGiveBombPlantedChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveBombPlanted = GetConVarInt(hCvar);
  441. public OnGiveBombDefusedChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveBombDefused = GetConVarInt(hCvar);
  442. public OnGiveBombPickupChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveBombPickup = GetConVarInt(hCvar);
  443. public OnGiveRoundWinChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveRoundWin = GetConVarInt(hCvar);
  444. public OnGiveRoundMVPChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iGiveRoundMVP = GetConVarInt(hCvar);
  445.  
  446. // Hooks Integer ConVars - Lose
  447. public OnLoseSuicideExpChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iLoseSuicideExp = GetConVarInt(hCvar);
  448. public OnLoseBombDroppedChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iLoseBombDropped = GetConVarInt(hCvar);
  449. public OnLoseRoundLoseChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iLoseRoundLose = GetConVarInt(hCvar);
  450.  
  451. // Hooks Bool ConVars
  452. public OnSpawnMessageChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iSpawnMessage = GetConVarBool(hCvar);
  453. public OnSpawnMenuChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iSpawnMenu = GetConVarBool(hCvar);
  454. public OnActiveGlovesChange(Handle:hCvar, const String:oldValue[], const String:newValue[]) g_iActiveGloves = GetConVarBool(hCvar);
  455. public OnActiveKnifeChange(Handle:hCvar, const String:oldValue[], const String:newValue[])
  456. {
  457. g_iActiveKnife = GetConVarBool(hCvar);
  458.  
  459. if(g_iActiveKnife)
  460. {
  461. for(new i = 1; i <= MaxClients; i++)
  462. {
  463. if(IsClientInGame(i))
  464. {
  465. SDKHook(i, SDKHook_WeaponEquipPost, OnPostWeaponEquip);
  466. }
  467. }
  468. }
  469. else
  470. {
  471. for(new i = 1; i <= MaxClients; i++)
  472. {
  473. SDKUnhook(i, SDKHook_WeaponEquipPost, OnPostWeaponEquip);
  474. }
  475. }
  476. }
  477.  
  478. stock FakePrecacheSound( const String:szPath[] )
  479. {
  480. AddToStringTable(FindStringTable("soundprecache"), szPath);
  481. }
  482.  
  483. ///////////////////////////////////////////////////////////////////////
  484. ///////////////////////////////////////////////////////////////////////
  485. ////////////////////////// HOOKS //////////////////////////////////////
  486. ///////////////////////////////////////////////////////////////////////
  487. ///////////////////////////////////////////////////////////////////////
  488.  
  489. public PlayerTeam(Handle:event, const String:name[], bool:silent)
  490. {
  491. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  492. ClientTeam[client] = GetClientTeam(client);
  493. }
  494.  
  495. public PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
  496. {
  497. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  498. new arms = SelectedArms[client];
  499.  
  500. if(g_iSpawnMenu)
  501. {
  502. MainMenu(client);
  503. }
  504.  
  505. if(IsValidClient(client) && g_iActiveGloves)
  506. {
  507. if (-1 < arms < Arms_Count)
  508. {
  509. SetEntPropString(client, Prop_Send, "m_szArmsModel", UseArms[arms]);
  510. }
  511. }
  512.  
  513. if(client && GetClientTeam(client) > 1)
  514. {
  515. if(g_iActiveKnife)
  516. {
  517. new iWeapon = GetPlayerWeaponSlot(client, 2);
  518. new iItem;
  519.  
  520. switch(c_zIDKnife[client])
  521. {
  522. case 1: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knifegg");}
  523. case 2: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_gut");}
  524. case 3: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_flip");}
  525. case 4: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_bayonet");}
  526. case 5: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_m9_bayonet");}
  527. case 6: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_karambit");}
  528. case 7: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_tactical");}
  529. case 8: if(IsValidEntity(iWeapon) && iWeapon != INVALID_ENT_REFERENCE) {RemovePlayerItem(client, iWeapon), RemoveEdict(iWeapon), iItem = GivePlayerItem(client, "weapon_knife_butterfly");}
  530. default: {return;}
  531. }
  532.  
  533. EquipPlayerWeapon(client, iItem);
  534. }
  535. }
  536. }
  537.  
  538. public PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
  539. {
  540. new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  541. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  542. new assist = GetClientOfUserId(GetEventInt(event, "assister"));
  543. new bool:headshot = GetEventBool(event, "headshot");
  544.  
  545. if(!attacker || !client)
  546. return;
  547.  
  548. SetGlobalTransTarget(attacker);
  549.  
  550. decl String:weapon[64];
  551. GetEventString(event, "weapon", weapon, sizeof(weapon));
  552. // decl String:classname[64];
  553. // GetEdictClassname(weapon, classname, sizeof(classname));
  554.  
  555. if((attacker == client) && g_iLoseSuicideExp)
  556. {
  557. SetGlobalTransTarget(client);
  558. c_zExp[client] -= g_iLoseSuicideExp;
  559. PrintToChat(client, " \x02[LR] %t", "Suicide", DEFAULT, RED, c_zExp[client], g_iLoseSuicideExp);
  560. SavePlayer(client);
  561. }
  562. else
  563. {
  564. if(g_iLoseKillUsuallyExp)
  565. {
  566. SetGlobalTransTarget(client);
  567. c_zExp[client] -= g_iLoseKillUsuallyExp;
  568. PrintToChat(client, " \x02[LR] %t", "MyDeath", DEFAULT, RED, c_zExp[client], g_iLoseKillUsuallyExp);
  569. }
  570.  
  571. SetGlobalTransTarget(attacker);
  572.  
  573. if(StrEqual(weapon, "taser") && g_iGiveTaserExp)
  574. {
  575. c_zExp[attacker] += g_iGiveTaserExp;
  576. PrintToChat(attacker, " \x02[LR] %t", "TaserKill", DEFAULT, GREEN, c_zExp[attacker], g_iGiveTaserExp);
  577. }
  578. else if(StrEqual(weapon, "hegrenade") && g_iGiveGrenadeExp)
  579. {
  580. c_zExp[attacker] += g_iGiveGrenadeExp;
  581. PrintToChat(attacker, " \x02[LR] %t", "HEKill", DEFAULT, GREEN, c_zExp[attacker], g_iGiveGrenadeExp);
  582. }
  583. else if(StrEqual(weapon, "inferno") && g_iGiveMolotovExp)
  584. {
  585. c_zExp[attacker] += g_iGiveMolotovExp;
  586. PrintToChat(attacker, " \x02[LR] %t", "MolotovKill", DEFAULT, GREEN, c_zExp[attacker], g_iGiveMolotovExp);
  587. }
  588. else if(!StrEqual(weapon, "hegrenade") && !StrEqual(weapon, "inferno") && !StrEqual(weapon, "taser"))
  589. {
  590. if(g_iGiveKillUsuallyExp)
  591. {
  592. SetGlobalTransTarget(attacker);
  593. c_zExp[attacker] += g_iGiveKillUsuallyExp;
  594. PrintToChat(attacker, " \x02[LR] %t", "Kill", DEFAULT, GREEN, c_zExp[attacker], g_iGiveKillUsuallyExp);
  595. }
  596.  
  597. if(headshot && g_iGiveKillHeadshotExp)
  598. {
  599. c_zExp[attacker] += g_iGiveKillHeadshotExp;
  600. PrintToChat(attacker, " \x02[LR] %t", "HeadShotKill", DEFAULT, ORANGE, c_zExp[attacker], g_iGiveKillHeadshotExp);
  601. }
  602. }
  603.  
  604. SavePlayer(attacker);
  605.  
  606. if(assist && g_iGiveKillAssisterExp)
  607. {
  608. SetGlobalTransTarget(assist);
  609. c_zExp[assist] += g_iGiveKillAssisterExp;
  610. PrintToChat(assist, " \x02[LR] %t", "AssisterKill", DEFAULT, ORANGE, c_zExp[assist], g_iGiveKillAssisterExp);
  611. SavePlayer(assist);
  612. }
  613. }
  614.  
  615. return;
  616. }
  617.  
  618. public PlayerDeathMulti(Handle:event, const String:name[], bool:dontBroadcast)
  619. {
  620. new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  621. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  622.  
  623. if(!attacker || !client)
  624. return;
  625.  
  626. SetGlobalTransTarget(client);
  627. SetGlobalTransTarget(attacker);
  628. GameTime[attacker] = GetGameTime();
  629.  
  630. if(attacker != client)
  631. {
  632. if(!doublekill[attacker] && !triplekill[attacker] && !quadrokill[attacker] && !pentakill[attacker])
  633. {
  634. doublekill[attacker] = true;
  635. KillTime[attacker] = GameTime[attacker];
  636. }
  637. else if(doublekill[attacker])
  638. {
  639. if((GameTime[attacker] - KillTime[attacker] < 2.0) && g_iGiveDoubleExp)
  640. {
  641. c_zExp[attacker] += g_iGiveDoubleExp;
  642. PrintToChat(attacker, " \x02[LR] %t", "DoubleKill", DEFAULT, PURPLE, c_zExp[attacker], g_iGiveDoubleExp);
  643. doublekill[attacker] = false;
  644. triplekill[attacker] = true;
  645. KillTime[attacker] = GameTime[attacker];
  646. }
  647. else doublekill[attacker] = true, KillTime[attacker] = GameTime[attacker];
  648. }
  649. else if(triplekill[attacker])
  650. {
  651. if((GameTime[attacker] - KillTime[attacker] < 2.0) && g_iGiveTripleExp)
  652. {
  653. c_zExp[attacker] += g_iGiveTripleExp;
  654. PrintToChat(attacker, " \x02[LR] %t", "TripleKill", DEFAULT, PURPLE, c_zExp[attacker], g_iGiveTripleExp);
  655. triplekill[attacker] = false;
  656. quadrokill[attacker] = true;
  657. KillTime[attacker] = GameTime[attacker];
  658. }
  659. else triplekill[attacker] = false, doublekill[attacker] = true, KillTime[attacker] = GameTime[attacker];
  660. }
  661. else if(quadrokill[attacker])
  662. {
  663. if((GameTime[attacker] - KillTime[attacker] < 2.0) && g_iGiveQuadroExp)
  664. {
  665. c_zExp[attacker] += g_iGiveQuadroExp;
  666. PrintToChat(attacker, " \x02[LR] %t", "QuadroKill", DEFAULT, PURPLE, c_zExp[attacker], g_iGiveQuadroExp);
  667. quadrokill[attacker] = false;
  668. pentakill[attacker] = true;
  669. KillTime[attacker] = GameTime[attacker];
  670. }
  671. else quadrokill[attacker] = false, doublekill[attacker] = true, KillTime[attacker] = GameTime[attacker];
  672. }
  673. else if(pentakill[attacker])
  674. {
  675. if((GameTime[attacker] - KillTime[attacker] < 2.0) && g_iGivePentaExp)
  676. {
  677. c_zExp[attacker] += g_iGivePentaExp;
  678. PrintToChat(attacker, " \x02[LR] %t", "PentaKill", DEFAULT, PURPLE, c_zExp[attacker], g_iGivePentaExp);
  679. pentakill[attacker] = false;
  680. doublekill[attacker] = false;
  681. KillTime[attacker] = 0.0;
  682. }
  683. else pentakill[attacker] = false, doublekill[attacker] = true, KillTime[attacker] = GameTime[attacker];
  684. }
  685.  
  686. SavePlayer(attacker);
  687. }
  688. return;
  689. }
  690.  
  691. public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
  692. {
  693. if(g_iSpawnMessage)
  694. {
  695. for(new i = 1; i <= MaxClients; i++)
  696. {
  697. if(IsClientInGame(i))
  698. {
  699. SetGlobalTransTarget(i);
  700. PrintToChat(i, " \x02[LR] %t", "RoundStartMessageRanks", DEFAULT, GREEN, DEFAULT);
  701. if(g_iActiveKnife)
  702. {
  703. PrintToChat(i, " \x02[LR] %t", "RoundStartMessageKnife", DEFAULT, GREEN, DEFAULT);
  704. }
  705. }
  706. }
  707. }
  708.  
  709. return Plugin_Continue;
  710. }
  711.  
  712. public Action:RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
  713. {
  714. new checkteam = GetEventInt(event, "winner");
  715.  
  716. for(new i = 1; i <= MaxClients; i++)
  717. {
  718. if(IsClientInGame(i))
  719. {
  720. SetGlobalTransTarget(i);
  721. ClientTeam[i] = GetClientTeam(i);
  722.  
  723. if(checkteam != 0 && checkteam != 1)
  724. {
  725. if((checkteam == ClientTeam[i]) && g_iGiveRoundWin)
  726. {
  727. c_zExp[i] += g_iGiveRoundWin;
  728. PrintToChat(i, " \x02[LR] %t", "RoundWin", DEFAULT, GREEN, c_zExp[i], g_iGiveRoundWin);
  729. }
  730. else if((checkteam != ClientTeam[i]) && g_iLoseRoundLose)
  731. {
  732. c_zExp[i] -= g_iLoseRoundLose;
  733. PrintToChat(i, " \x02[LR] %t", "RoundLose", DEFAULT, RED, c_zExp[i], g_iLoseRoundLose);
  734. }
  735. }
  736. }
  737. }
  738.  
  739. return Plugin_Continue;
  740. }
  741.  
  742. public Action:RoundMVP(Handle:event, const String:name[], bool:dontBroadcast)
  743. {
  744. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  745.  
  746. if(g_iGiveRoundMVP && client)
  747. {
  748. SetGlobalTransTarget(client);
  749. c_zExp[client] += g_iGiveRoundMVP;
  750. PrintToChat(client, " \x02[LR] %t", "RoundMVP", DEFAULT, GREEN, c_zExp[client], g_iGiveRoundMVP);
  751. SavePlayer(client);
  752. }
  753. }
  754.  
  755. ///////////////////////////////////////////////////////////////////////
  756. ///////////////////////////////////////////////////////////////////////
  757. ///////////////////////// Hooks Bomb //////////////////////////////////
  758. ///////////////////////////////////////////////////////////////////////
  759. ///////////////////////////////////////////////////////////////////////
  760.  
  761. public Hook_BombPlanted(Handle:event, const String:name[], bool:dontBroadcast)
  762. {
  763. if(g_iGiveBombPlanted)
  764. {
  765. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  766. SetGlobalTransTarget(client);
  767. c_zExp[client] += g_iGiveBombPlanted;
  768. PrintToChat(client, " \x02[LR] %t", "BombPlanted", DEFAULT, GREEN, c_zExp[client], g_iGiveBombPlanted);
  769. SavePlayer(client);
  770. }
  771. }
  772.  
  773. public Hook_BombDefused(Handle:event, const String:name[], bool:dontBroadcast)
  774. {
  775. if(g_iGiveBombDefused)
  776. {
  777. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  778. SetGlobalTransTarget(client);
  779. c_zExp[client] += g_iGiveBombDefused;
  780. PrintToChat(client, " \x02[LR] %t", "BombDefused", DEFAULT, GREEN, c_zExp[client], g_iGiveBombDefused);
  781. SavePlayer(client);
  782. }
  783. }
  784.  
  785. public Hook_BombPickup(Handle:event, const String:name[], bool:dontBroadcast)
  786. {
  787. if(g_iGiveBombPickup)
  788. {
  789. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  790. SetGlobalTransTarget(client);
  791. c_zExp[client] += g_iGiveBombPickup;
  792. PrintToChat(client, " \x02[LR] %t", "BombPickup", DEFAULT, GREEN, c_zExp[client], g_iGiveBombPickup);
  793. SavePlayer(client);
  794. }
  795. }
  796.  
  797. public Hook_BombDropped(Handle:event, const String:name[], bool:dontBroadcast)
  798. {
  799. if(g_iLoseBombDropped)
  800. {
  801. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  802. SetGlobalTransTarget(client);
  803. c_zExp[client] -= g_iLoseBombDropped;
  804. PrintToChat(client, " \x02[LR] %t", "BombDropped", DEFAULT, RED, c_zExp[client], g_iLoseBombDropped);
  805. SavePlayer(client);
  806. }
  807. }
  808.  
  809. public Action:ActivatedTrigger(client, const String:command[], arg)
  810. {
  811. new String:KnifeMenuStr[][] = {"!лтшау", "knife" , "!knife"},
  812. String:MainMenuStr[][] = {"!думуд", "level" , "!level", "!lvl", "!дмд"};
  813.  
  814. decl String:text[192];
  815. GetCmdArgString(text, sizeof(text));
  816. StripQuotes(text);
  817. TrimString(text);
  818.  
  819. if(client && IsClientInGame(client))
  820. {
  821. if(g_iActiveKnife)
  822. {
  823. for(new i = 0; i < sizeof(KnifeMenuStr); i++)
  824. {
  825. if(StrEqual(text, KnifeMenuStr[i], false))
  826. {
  827. KnifeMenu(client);
  828. return Plugin_Handled;
  829. }
  830. }
  831. }
  832.  
  833. for(new i = 0; i < sizeof(MainMenuStr); i++)
  834. {
  835. if(StrEqual(text, MainMenuStr[i], false))
  836. {
  837. MakePlace(client);
  838. return Plugin_Handled;
  839. }
  840. }
  841. }
  842.  
  843. return Plugin_Continue;
  844. }
  845.  
  846. ///////////////////////////////////////////////////////////////////////
  847. ///////////////////////////////////////////////////////////////////////
  848. ////////////////////////// MENUS ALL //////////////////////////////////
  849. ///////////////////////////////////////////////////////////////////////
  850. ///////////////////////////////////////////////////////////////////////
  851.  
  852. public Action:MainMenu(client)
  853. {
  854. decl String:text[64];
  855. SetGlobalTransTarget(client);
  856. new Handle:menu = CreateMenu(MainMenuHandler);
  857. new rank_client = c_zRank[client];
  858. SavePlayer(client);
  859. if(c_zRank[client] < 21)
  860. {
  861. 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);
  862. }
  863. else if(c_zRank[client] == 21)
  864. {
  865. SetMenuTitle(menu, "%t", "MainMenuHighRank", PLUGIN_NAME, PLUGIN_VERSION, AllRanksMenu[rank_client], c_zExp[client], c_zRank[client], myplace[client], g_player_count);
  866. }
  867.  
  868. Format(text, sizeof(text), "%t", "AllRanks");
  869. AddMenuItem(menu, "0", text);
  870.  
  871. Format(text, sizeof(text), "%t", "TOP");
  872. AddMenuItem(menu, "1", text);
  873.  
  874. if(g_iActiveKnife)
  875. {
  876. Format(text, sizeof(text), "%t", "Knifes");
  877. AddMenuItem(menu, "2", text);
  878. }
  879.  
  880. if(g_iActiveGloves)
  881. {
  882. Format(text, sizeof(text), "%t", "Gloves");
  883. AddMenuItem(menu, "3", text);
  884. }
  885.  
  886. Format(text, sizeof(text), "%t", "Functions");
  887. AddMenuItem(menu, "4", text);
  888.  
  889. SetMenuExitButton(menu, true);
  890. DisplayMenu(menu, client, 9);
  891. }
  892.  
  893. public MainMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
  894. {
  895. if(action == MenuAction_Select)
  896. {
  897. decl String:info[4];
  898. GetMenuItem(menu, itemNum, info, sizeof(info));
  899.  
  900. switch(StringToInt(info))
  901. {
  902. case 0: AllRankMenu(client);
  903. case 1: PrintTop(client);
  904. case 2: KnifeMenu(client);
  905. case 3: ArmsMenu(client);
  906. case 4: FuncMenu(client);
  907. }
  908. }
  909. else if(action == MenuAction_End)
  910. {
  911. CloseHandle(menu);
  912. }
  913. }
  914.  
  915. public Action:AllRankMenu(client)
  916. {
  917. decl String:text[192];
  918. SetGlobalTransTarget(client);
  919. new Handle:menu = CreateMenu(AllRankMenuHandler);
  920.  
  921. Format(text, sizeof(text), "%t", "AllRanks");
  922. SetMenuTitle(menu, "%s | %s\n ", PLUGIN_NAME, text);
  923.  
  924. for(new i = 0; i <= 21; i++)
  925. {
  926. if(i == 0)
  927. {
  928. Format(text, sizeof(text), "%s [0 exp]", AllRanksMenu[i]);
  929. AddMenuItem(menu, "", text, ITEMDRAW_DISABLED);
  930. }
  931. else if(i > 0)
  932. {
  933. Format(text, sizeof(text), "%s [%s exp]", AllRanksMenu[i], AllExp[i-1]);
  934. AddMenuItem(menu, "", text, ITEMDRAW_DISABLED);
  935. }
  936. }
  937.  
  938. SetMenuExitButton(menu, true);
  939. DisplayMenu(menu, client, 9);
  940. }
  941.  
  942. public AllRankMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
  943. {
  944. if(action == MenuAction_End)
  945. {
  946. CloseHandle(menu);
  947. }
  948. }
  949.  
  950. public FuncMenu(client)
  951. {
  952. decl String:text[64];
  953. SetGlobalTransTarget(client);
  954. new flags = GetUserFlagBits(client);
  955. new Handle:menu = CreateMenu(FuncMenuHandler);
  956.  
  957. Format(text, sizeof(text), "%t", "Functions");
  958. SetMenuTitle(menu, "%s | %s\n ", PLUGIN_NAME, text);
  959.  
  960. Format(text, sizeof(text), "%t", "GivePoints");
  961. if(flags & ADMFLAG_PASSWORD || flags & ADMFLAG_ROOT)
  962. {
  963. AddMenuItem(menu, "0", text);
  964. }
  965. else
  966. {
  967. AddMenuItem(menu, "0", text, ITEMDRAW_DISABLED);
  968. }
  969.  
  970. SetMenuExitButton(menu, true);
  971. DisplayMenu(menu, client, 9);
  972. }
  973.  
  974. public FuncMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
  975. {
  976. if(action == MenuAction_Select)
  977. {
  978. decl String:info[4];
  979. GetMenuItem(menu, itemNum, info, sizeof(info));
  980.  
  981. switch(StringToInt(info))
  982. {
  983. case 0: GivePointsPlayers(client);
  984. }
  985. }
  986. else if(action == MenuAction_End)
  987. {
  988. CloseHandle(menu);
  989. }
  990. }
  991.  
  992. ///////////////////////////////////////////////////////////////////////
  993. ///////////////////////////////////////////////////////////////////////
  994. ////////////////////////// KNIFECHOOSE ////////////////////////////////
  995. ///////////////////////////////////////////////////////////////////////
  996. ///////////////////////////////////////////////////////////////////////
  997.  
  998. public Action:KnifeMenu(client)
  999. {
  1000. decl String:text[64];
  1001. SetGlobalTransTarget(client);
  1002. new Handle:menu = CreateMenu(KnifeMenuHandler);
  1003. Format(text, sizeof(text), "%t", "UsuallyKnife");
  1004. SetMenuTitle(menu, "%s | %s\n ", PLUGIN_NAME, text);
  1005.  
  1006. Format(text, sizeof(text), "%t", "KnifeUsual");
  1007. if(c_zIDKnife[client] == 0) Format(text, sizeof(text), "[x] %t", "KnifeUsual"), AddMenuItem(menu, "", text, ITEMDRAW_DISABLED);
  1008. else AddMenuItem(menu, "", text);
  1009.  
  1010. Format(text, sizeof(text), "%t", "KnifeGold");
  1011. if(c_zIDKnife[client] == 1) Format(text, sizeof(text), "[x] %t", "KnifeGold"), AddMenuItem(menu, "", text, ITEMDRAW_DISABLED);
  1012. else AddMenuItem(menu, "", text);
  1013.  
  1014. Format(text, sizeof(text), "%t", "KnifeGut");
  1015. if(c_zIDKnife[client] == 2) Format(text, sizeof(text), "[x] %t", "KnifeGut"), AddMenuItem(menu, "", text);
  1016. else AddMenuItem(menu, "", text);
  1017.  
  1018. Format(text, sizeof(text), "%t", "KnifeFlip");
  1019. if(c_zIDKnife[client] == 3) Format(text, sizeof(text), "[x] %t", "KnifeFlip"), AddMenuItem(menu, "", text);
  1020. else AddMenuItem(menu, "", text);
  1021.  
  1022. Format(text, sizeof(text), "%t", "KnifeBayonet");
  1023. if(c_zIDKnife[client] == 4) Format(text, sizeof(text), "[x] %t", "KnifeBayonet"), AddMenuItem(menu, "", text);
  1024. else AddMenuItem(menu, "", text);
  1025.  
  1026. Format(text, sizeof(text), "%t", "KnifeM9");
  1027. if(c_zIDKnife[client] == 5) Format(text, sizeof(text), "[x] %t", "KnifeM9"), AddMenuItem(menu, "", text);
  1028. else AddMenuItem(menu, "", text);
  1029.  
  1030. Format(text, sizeof(text), "%t", "KnifeKarambit");
  1031. if(c_zIDKnife[client] == 6) Format(text, sizeof(text), "[x] %t", "KnifeKarambit"), AddMenuItem(menu, "", text);
  1032. else AddMenuItem(menu, "", text);
  1033.  
  1034. Format(text, sizeof(text), "%t", "KnifeHuntsman");
  1035. if(c_zIDKnife[client] == 7) Format(text, sizeof(text), "[x] %t", "KnifeHuntsman"), AddMenuItem(menu, "", text);
  1036. else AddMenuItem(menu, "", text);
  1037.  
  1038. Format(text, sizeof(text), "%t", "KnifeButterfly");
  1039. if(c_zIDKnife[client] == 8) Format(text, sizeof(text), "[x] %t", "KnifeButterfly"), AddMenuItem(menu, "", text);
  1040. else AddMenuItem(menu, "", text);
  1041.  
  1042. SetMenuExitBackButton(menu, true);
  1043. DisplayMenu(menu, client, 15);
  1044. }
  1045.  
  1046. public KnifeMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
  1047. {
  1048. if(action == MenuAction_Select)
  1049. {
  1050. if(IsPlayerAlive(client) && GetClientTeam(client) > 1)
  1051. {
  1052. new knife;
  1053. new currentknife = GetPlayerWeaponSlot(client, 2);
  1054. if(IsValidEntity(currentknife) && currentknife != INVALID_ENT_REFERENCE)
  1055. {
  1056. RemovePlayerItem(client, currentknife);
  1057. RemoveEdict(currentknife);
  1058. }
  1059.  
  1060. switch(itemNum)
  1061. {
  1062. case 0: knife = GivePlayerItem(client, "weapon_knife");
  1063. case 1: knife = GivePlayerItem(client, "weapon_knifegg");
  1064. case 2: knife = GivePlayerItem(client, "weapon_knife_gut"), KnifeMenuSpec(client, 0);
  1065. case 3: knife = GivePlayerItem(client, "weapon_knife_flip"), KnifeMenuSpec(client, 0);
  1066. case 4: knife = GivePlayerItem(client, "weapon_bayonet"), KnifeMenuSpec(client, 0);
  1067. case 5: knife = GivePlayerItem(client, "weapon_knife_m9_bayonet"), KnifeMenuSpec(client, 0);
  1068. case 6: knife = GivePlayerItem(client, "weapon_knife_karambit"), KnifeMenuSpec(client, 0);
  1069. case 7: knife = GivePlayerItem(client, "weapon_knife_tactical"), KnifeMenuSpec(client, 0);
  1070. case 8: knife = GivePlayerItem(client, "weapon_knife_butterfly"), KnifeMenuSpec(client, 0);
  1071. }
  1072.  
  1073. c_zIDKnife[client] = itemNum;
  1074. EquipPlayerWeapon(client, knife);
  1075. }
  1076. }
  1077. else if(action == MenuAction_Cancel && itemNum == MenuCancel_ExitBack)
  1078. {
  1079. MainMenu(client);
  1080. }
  1081. }
  1082.  
  1083. ///////////////////////////////////////////////////////////////////////
  1084. ///////////////////////////////////////////////////////////////////////
  1085. ////////////////////////// Skins Knife ////////////////////////////////
  1086. ///////////////////////////////////////////////////////////////////////
  1087. ///////////////////////////////////////////////////////////////////////
  1088.  
  1089. public KnifeMenuSpec(client, item)
  1090. {
  1091. decl String:text[64];
  1092. SetGlobalTransTarget(client);
  1093. new Handle:menu = CreateMenu(KnifeMenuSpecHandler);
  1094.  
  1095. Format(text, sizeof(text), "%t", "SpecialKnife");
  1096. SetMenuTitle(menu, "%s | %s\n ", PLUGIN_NAME, text);
  1097.  
  1098. for(new i = 1; i < g_aPaintCount; i++)
  1099. {
  1100. new normal = g_iChooseSkinKnife[i][knife_level];
  1101. decl String:itemknife[4];
  1102. Format(itemknife, 4, "%i", i);
  1103.  
  1104. if(c_zRank[client] >= normal)
  1105. {
  1106. AddMenuItem(menu, itemknife, g_iChooseSkinKnife[i][knife_name]);
  1107. }
  1108. else
  1109. {
  1110. AddMenuItem(menu, itemknife, g_iChooseSkinKnife[i][knife_name], ITEMDRAW_DISABLED);
  1111. }
  1112. }
  1113.  
  1114. SetMenuExitButton(menu, true);
  1115. DisplayMenuAtItem(menu, client, item, 9);
  1116. }
  1117.  
  1118. public KnifeMenuSpecHandler(Handle:menu, MenuAction:action, client, itemNum)
  1119. {
  1120. if(action == MenuAction_Select)
  1121. {
  1122. decl String:info[4];
  1123.  
  1124. GetMenuItem(menu, itemNum, info, sizeof(info));
  1125. new theindex = StringToInt(info);
  1126. new windex = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  1127.  
  1128. if(windex < 1)
  1129. {
  1130. KnifeMenuSpec(client, GetMenuSelectionPosition());
  1131. return;
  1132. }
  1133.  
  1134. decl String:Classname[64];
  1135. GetEdictClassname(windex, Classname, 64);
  1136.  
  1137. new weaponindex = GetEntProp(windex, Prop_Send, "m_iItemDefinitionIndex");
  1138.  
  1139. if(weaponindex == 42 || weaponindex == 59)
  1140. {
  1141. KnifeMenuSpec(client, GetMenuSelectionPosition());
  1142. return;
  1143. }
  1144.  
  1145. if(GetPlayerWeaponSlot(client, 2) == windex)
  1146. {
  1147. switch(weaponindex)
  1148. {
  1149. case 506: strcopy(Classname, 64, "weapon_knife_gut");
  1150. case 505: strcopy(Classname, 64, "weapon_knife_flip");
  1151. case 500: strcopy(Classname, 64, "weapon_bayonet");
  1152. case 508: strcopy(Classname, 64, "weapon_knife_m9_bayonet");
  1153. case 507: strcopy(Classname, 64, "weapon_knife_karambit");
  1154. case 509: strcopy(Classname, 64, "weapon_knife_tactical");
  1155. case 515: strcopy(Classname, 64, "weapon_knife_butterfly");
  1156. }
  1157.  
  1158. if(arbol[client] != INVALID_HANDLE)
  1159. {
  1160. SetTrieValue(arbol[client], Classname, theindex);
  1161. ChangePaint(client, windex, Classname, weaponindex);
  1162. FakeClientCommand(client, "use %s", Classname);
  1163. }
  1164. }
  1165. }
  1166. }
  1167.  
  1168. ChangePaint(client, windex, String:Classname[64], weaponindex)
  1169. {
  1170. if(g_iActiveKnife)
  1171. {
  1172. new bool:knife = false;
  1173. if(StrContains(Classname, "weapon_knife", false) == 0 || StrContains(Classname, "weapon_bayonet", false) == 0)
  1174. {
  1175. knife = true;
  1176. }
  1177.  
  1178. new clip;
  1179. if(!knife)
  1180. {
  1181. clip = GetEntProp(windex, Prop_Send, "m_iClip1");
  1182. }
  1183. RemovePlayerItem(client, windex);
  1184. AcceptEntityInput(windex, "Kill");
  1185.  
  1186. new Handle:pack;
  1187. new entity = GivePlayerItem(client, Classname);
  1188.  
  1189. if(knife)
  1190. {
  1191. if (weaponindex != 42 && weaponindex != 59)
  1192. EquipPlayerWeapon(client, entity);
  1193. }
  1194. else
  1195. {
  1196. SetEntProp(entity, Prop_Send, "m_iClip1", clip);
  1197. }
  1198.  
  1199. if(arbol[client] == INVALID_HANDLE)
  1200. {
  1201. return;
  1202. }
  1203.  
  1204. new theindex;
  1205. GetTrieValue(arbol[client], Classname, theindex);
  1206. if(theindex == 0) return;
  1207.  
  1208. if(theindex == -1)
  1209. {
  1210. theindex = GetRandomInt(1, g_aPaintCount-1);
  1211. }
  1212.  
  1213. new m_iItemIDHigh = GetEntProp(entity, Prop_Send, "m_iItemIDHigh");
  1214. new m_iItemIDLow = GetEntProp(entity, Prop_Send, "m_iItemIDLow");
  1215.  
  1216. SetEntProp(entity,Prop_Send,"m_iItemIDLow",2048);
  1217. SetEntProp(entity,Prop_Send,"m_iItemIDHigh",0);
  1218. SetEntProp(entity,Prop_Send,"m_nFallbackPaintKit", g_iChooseSkinKnife[theindex][knife_paint]);
  1219. SetEntProp(entity,Prop_Send,"m_nFallbackStatTrak", c_zExp[client]);
  1220. SetEntProp(entity,Prop_Send,"m_iEntityQuality", 3);
  1221. SetEntPropFloat(entity,Prop_Send,"m_flFallbackWear", 0.0);
  1222.  
  1223. CreateDataTimer(0.2, RestoreItemID, pack);
  1224. WritePackCell(pack,EntIndexToEntRef(entity));
  1225. WritePackCell(pack,m_iItemIDHigh);
  1226. WritePackCell(pack,m_iItemIDLow);
  1227. }
  1228. }
  1229.  
  1230. public Action:RestoreItemID(Handle:timer, Handle:pack)
  1231. {
  1232. if(g_iActiveKnife)
  1233. {
  1234. new entity;
  1235. new m_iItemIDHigh;
  1236. new m_iItemIDLow;
  1237.  
  1238. ResetPack(pack);
  1239. entity = EntRefToEntIndex(ReadPackCell(pack));
  1240. m_iItemIDHigh = ReadPackCell(pack);
  1241. m_iItemIDLow = ReadPackCell(pack);
  1242.  
  1243. if(entity != INVALID_ENT_REFERENCE)
  1244. {
  1245. SetEntProp(entity,Prop_Send,"m_iItemIDHigh",m_iItemIDHigh);
  1246. SetEntProp(entity,Prop_Send,"m_iItemIDLow",m_iItemIDLow);
  1247. }
  1248. }
  1249. }
  1250.  
  1251. ReadPaints()
  1252. {
  1253. BuildPath(Path_SM, Paints_Path, sizeof(Paints_Path), "configs/levels_ranks/knifes.ini");
  1254.  
  1255. decl Handle:kv;
  1256. g_aPaintCount = 1;
  1257.  
  1258. kv = CreateKeyValues("KnifeSkins");
  1259. FileToKeyValues(kv, Paints_Path);
  1260.  
  1261. if(!KvGotoFirstSubKey(kv)) {
  1262.  
  1263. SetFailState("CFG File not found: %s", Paints_Path);
  1264. CloseHandle(kv);
  1265. }
  1266.  
  1267. do
  1268. {
  1269. KvGetSectionName(kv, g_iChooseSkinKnife[g_aPaintCount][knife_name], 64);
  1270. g_iChooseSkinKnife[g_aPaintCount][knife_paint] = KvGetNum(kv, "paint", -2);
  1271. g_iChooseSkinKnife[g_aPaintCount][knife_level] = KvGetNum(kv, "level", -2);
  1272.  
  1273. g_aPaintCount++;
  1274. }
  1275. while (KvGotoNextKey(kv));
  1276. CloseHandle(kv);
  1277. }
  1278.  
  1279. ///////////////////////////////////////////////////////////////////////
  1280. ///////////////////////////////////////////////////////////////////////
  1281. ////////////////////////// Gloves ///////////////////////////////////
  1282. ///////////////////////////////////////////////////////////////////////
  1283. ///////////////////////////////////////////////////////////////////////
  1284.  
  1285. public Action:ArmsMenu(client)
  1286. {
  1287. decl String:text[64];
  1288. SetGlobalTransTarget(client);
  1289.  
  1290. new Handle:menu = CreateMenu(ArmsMenuHandler);
  1291. Format(text, sizeof(text), "%t", "Gloves");
  1292. SetMenuTitle(menu, "%s | %s\n ", PLUGIN_NAME, text);
  1293.  
  1294. Format(text, sizeof(text), "%t", "GloveUsual");
  1295. AddMenuItem(menu, "-1", text);
  1296.  
  1297. for(new i=0; i < Arms_Count; i++)
  1298. {
  1299. new normal = StringToInt(RanksArms[i]);
  1300. new String:g_MsgArms[192];
  1301.  
  1302. if(c_zRank[client] >= normal)
  1303. {
  1304. Format(g_MsgArms, 192, "%s", NameArms[i]);
  1305. AddMenuItem(menu, IDArms[i], g_MsgArms);
  1306. }
  1307. else
  1308. {
  1309. Format(g_MsgArms, 192, "%s", NameArms[i]);
  1310. AddMenuItem(menu, IDArms[i], g_MsgArms, ITEMDRAW_DISABLED);
  1311. }
  1312. }
  1313.  
  1314. SetMenuExitButton(menu, true);
  1315. DisplayMenu(menu, client, 9);
  1316.  
  1317. return Plugin_Handled;
  1318. }
  1319.  
  1320. public ArmsMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
  1321. {
  1322. if (action == MenuAction_Select)
  1323. {
  1324. decl String:arms_id[10];
  1325. GetMenuItem(menu, itemNum, arms_id, sizeof(arms_id));
  1326.  
  1327. new arms = StringToInt(arms_id, sizeof(arms_id));
  1328.  
  1329. SelectedArms[client] = arms;
  1330.  
  1331. if (IsValidClient(client))
  1332. {
  1333. if (-1 < arms < Arms_Count)
  1334. {
  1335. SetEntPropString(client, Prop_Send, "m_szArmsModel", UseArms[arms]);
  1336. }
  1337. }
  1338.  
  1339. PrintToChat(client, " \x02[LR] %t", "ChooseGlove", DEFAULT);
  1340. }
  1341. }
  1342.  
  1343. ///////////////////////////////////////////////////////////////////////
  1344. ///////////////////////////////////////////////////////////////////////
  1345. ////////////////////////// GIVE EXP ///////////////////////////////////
  1346. ///////////////////////////////////////////////////////////////////////
  1347. ///////////////////////////////////////////////////////////////////////
  1348.  
  1349. GivePointsPlayers(client, item = 0)
  1350. {
  1351. decl String:givepp_id[15], String:givepp_nick[32], String:text[64];
  1352. new Handle:menu = CreateMenu(GivePointsPlayers_CallBack);
  1353. new flags = GetUserFlagBits(client);
  1354. SetGlobalTransTarget(client);
  1355.  
  1356. Format(text, sizeof(text), "%t", "GivePoints");
  1357. SetMenuTitle(menu, "%s | %s:\n ", PLUGIN_NAME, text);
  1358. for (new i = 1; i <= MaxClients; i++)
  1359. {
  1360. if(IsClientInGame(i) && !IsFakeClient(i) && (flags & ADMFLAG_ROOT))
  1361. {
  1362. IntToString(GetClientUserId(i), givepp_id, 15);
  1363. givepp_nick[0] = '\0';
  1364. GetClientName(i, givepp_nick, 32);
  1365. AddMenuItem(menu, givepp_id, givepp_nick);
  1366. }
  1367. else if(IsClientInGame(i) && !IsFakeClient(i))
  1368. {
  1369. IntToString(GetClientUserId(i), givepp_id, 15);
  1370. givepp_nick[0] = '\0';
  1371. GetClientName(i, givepp_nick, 32);
  1372. AddMenuItem(menu, givepp_id, givepp_nick, i != client ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED);
  1373. }
  1374. }
  1375.  
  1376. DisplayMenuAtItem(menu, client, item, 0);
  1377. }
  1378.  
  1379. public GivePointsPlayers_CallBack(Handle:menu, MenuAction:action, client, item)
  1380. {
  1381. if(action == MenuAction_Select)
  1382. {
  1383. decl String:givepp_id[15];
  1384. if(!GetMenuItem(menu, item, givepp_id, 15))
  1385. return;
  1386.  
  1387. IDGivePP = GetClientOfUserId(StringToInt(givepp_id));
  1388. GivePointsPlayers2(client, 0);
  1389. }
  1390. else if(action == MenuAction_End)
  1391. {
  1392. CloseHandle(menu);
  1393. }
  1394. }
  1395.  
  1396. public GivePointsPlayers2(client, item)
  1397. {
  1398. decl String:text[64];
  1399. SetGlobalTransTarget(client);
  1400. Format(text, sizeof(text), "%t", "GivePoints");
  1401. new Handle:menu = CreateMenu(GivePointsPlayers2Handler);
  1402.  
  1403. SetMenuTitle(menu, "%s | %s\n ", PLUGIN_NAME, text);
  1404. AddMenuItem(menu, "opt1", "10");
  1405. AddMenuItem(menu, "opt2", "50");
  1406. AddMenuItem(menu, "opt3", "100");
  1407. AddMenuItem(menu, "opt4", "500");
  1408. AddMenuItem(menu, "opt5", "1000");
  1409. AddMenuItem(menu, "opt6", "5000");
  1410. AddMenuItem(menu, "opt7", "-5000");
  1411. AddMenuItem(menu, "opt8", "-1000");
  1412. AddMenuItem(menu, "opt9", "-500");
  1413. AddMenuItem(menu, "opt10", "-100");
  1414. AddMenuItem(menu, "opt11", "-50");
  1415. AddMenuItem(menu, "opt12", "-10");
  1416. SetMenuExitButton(menu, true);
  1417. DisplayMenuAtItem(menu, client, item, 15);
  1418. }
  1419.  
  1420. public GivePointsPlayers2Handler(Handle:menu, MenuAction:action, client, itemNum)
  1421. {
  1422. if(action == MenuAction_Select)
  1423. {
  1424. new String:info[32], String:s_buffer[32];
  1425.  
  1426. GetMenuItem(menu, itemNum, info, sizeof(info), _ , s_buffer, sizeof(s_buffer));
  1427. new i_buffer = StringToInt(s_buffer);
  1428.  
  1429. c_zExp[IDGivePP] += i_buffer;
  1430. GivePointsPlayers2(client, GetMenuSelectionPosition());
  1431. SetGlobalTransTarget(client);
  1432.  
  1433. if(i_buffer > 0)
  1434. {
  1435. PrintToChat(client, "%t", "AdminGiveExp", GREEN, DEFAULT, GREEN, i_buffer, DEFAULT, IDGivePP, LIME);
  1436. }
  1437. else if(i_buffer < 0)
  1438. {
  1439. PrintToChat(client, "%t", "AdminTookExp", GREEN, DEFAULT, GREEN, i_buffer, DEFAULT, IDGivePP, LIME);
  1440. }
  1441. }
  1442. else if(action == MenuAction_End)
  1443. {
  1444. CloseHandle(menu);
  1445. }
  1446. }
  1447.  
  1448. /////////////////////////////////////////////
  1449. /////////////////////////////////////////////
  1450. ///////// MAIN FUNCT ////////////////////////
  1451. /////////////////////////////////////////////
  1452. /////////////////////////////////////////////
  1453.  
  1454. public Hook_OnThinkPost(iEnt)
  1455. {
  1456. SetEntDataArray(iEnt, iRankOffset, c_zCompetitiveRank, MaxClients+1);
  1457. new Handle:hBuffer = StartMessageAll("ServerRankRevealAll");
  1458.  
  1459. if(hBuffer == INVALID_HANDLE)
  1460. {
  1461. PrintToServer("ServerRankRevealAll = INVALID_HANDLE");
  1462. }
  1463. else
  1464. {
  1465. EndMessage();
  1466. }
  1467. }
  1468.  
  1469. public OnPostThinkPost(client)
  1470. {
  1471. SetGlobalTransTarget(client);
  1472. if(c_zRank[client] < 21)
  1473. {
  1474. if(c_zExp[client] >= StringToInt(AllExp[c_zRank[client]]))
  1475. {
  1476. EmitSoundToClient(client, EmitSound_Path);
  1477. c_zRank[client] += 1;
  1478. PrintToChat(client, " \x02[LR] %t", "LevelUp", DEFAULT, GREEN, AllRanksMenu[c_zRank[client]]);
  1479. }
  1480. else if(c_zRank[client] > 0 && c_zExp[client] < StringToInt(AllExp[c_zRank[client] - 1]))
  1481. {
  1482. EmitSoundToClient(client, EmitSound_Path2);
  1483. c_zRank[client] -= 1;
  1484. PrintToChat(client, " \x02[LR] %t", "LevelDown", DEFAULT, RED, AllRanksMenu[c_zRank[client]]);
  1485. }
  1486. }
  1487. else if(c_zRank[client] == 21)
  1488. {
  1489. if(c_zExp[client] < StringToInt(AllExp[c_zRank[client] - 1]))
  1490. {
  1491. c_zRank[client] -= 1;
  1492. EmitSoundToClient(client, EmitSound_Path2);
  1493. PrintToChat(client, " \x02[LR] %t", "LevelDown", DEFAULT, RED, AllRanksMenu[c_zRank[client]]);
  1494. }
  1495. }
  1496.  
  1497. if(c_zRank[client] <= 18)
  1498. {
  1499. c_zCompetitiveRank[client] = c_zRank[client];
  1500. }
  1501. else if(c_zRank[client] > 18)
  1502. {
  1503. c_zCompetitiveRank[client] = 18;
  1504. }
  1505. }
  1506.  
  1507. public Action:OnPostWeaponEquip(client, weapon)
  1508. {
  1509. new Handle:pack;
  1510. CreateDataTimer(0.0, Pasado, pack);
  1511. WritePackCell(pack,EntIndexToEntRef(weapon));
  1512. WritePackCell(pack, client);
  1513. }
  1514.  
  1515. public Action:Pasado(Handle:timer, Handle:pack)
  1516. {
  1517. if(g_iActiveKnife)
  1518. {
  1519. new weapon;
  1520. new client;
  1521.  
  1522. ResetPack(pack);
  1523. weapon = EntRefToEntIndex(ReadPackCell(pack));
  1524. client = ReadPackCell(pack);
  1525.  
  1526. if(weapon == INVALID_ENT_REFERENCE || !IsClientInGame(client) || !IsPlayerAlive(client))
  1527. {
  1528. return;
  1529. }
  1530.  
  1531. if(weapon < 1 || !IsValidEdict(weapon) || !IsValidEntity(weapon))
  1532. {
  1533. return;
  1534. }
  1535.  
  1536. if (GetEntProp(weapon, Prop_Send, "m_hPrevOwner") > 0 || (GetEntProp(weapon, Prop_Send, "m_iItemIDHigh") == 0 && GetEntProp(weapon, Prop_Send, "m_iItemIDLow") == 2048))
  1537. return;
  1538.  
  1539. decl String:Classname[64];
  1540. GetEdictClassname(weapon, Classname, 64);
  1541.  
  1542. new weaponindex = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
  1543.  
  1544. if(weaponindex == 42 || weaponindex == 59)
  1545. {
  1546. return;
  1547. }
  1548.  
  1549. if(GetPlayerWeaponSlot(client, 2) == weapon)
  1550. {
  1551. switch (weaponindex)
  1552. {
  1553. case 506: strcopy(Classname, 64, "weapon_knife_gut");
  1554. case 505: strcopy(Classname, 64, "weapon_knife_flip");
  1555. case 500: strcopy(Classname, 64, "weapon_bayonet");
  1556. case 508: strcopy(Classname, 64, "weapon_knife_m9_bayonet");
  1557. case 507: strcopy(Classname, 64, "weapon_knife_karambit");
  1558. case 509: strcopy(Classname, 64, "weapon_knife_tactical");
  1559. case 515: strcopy(Classname, 64, "weapon_knife_butterfly");
  1560. }
  1561.  
  1562. if(arbol[client] == INVALID_HANDLE)
  1563. {
  1564. return;
  1565. }
  1566.  
  1567. new valor = 0;
  1568. GetTrieValue(arbol[client], Classname, valor);
  1569.  
  1570. if(valor == 0)
  1571. {
  1572. return;
  1573. }
  1574.  
  1575. ChangePaint(client, weapon, Classname, weaponindex);
  1576. }
  1577. }
  1578. }
  1579.  
  1580. public OnClientPostAdminCheck(client)
  1581. {
  1582. doublekill[client] = false;
  1583. triplekill[client] = false;
  1584. quadrokill[client] = false;
  1585. pentakill[client] = false;
  1586. SelectedArms[client] = -1;
  1587.  
  1588. if(g_iActiveKnife)
  1589. {
  1590. SDKHook(client, SDKHook_WeaponEquipPost, OnPostWeaponEquip);
  1591. }
  1592.  
  1593. SDKHook(client, SDKHook_PostThinkPost, OnPostThinkPost);
  1594. }
  1595.  
  1596. public OnClientCookiesCached(client)
  1597. {
  1598. decl String:SaveString[100], String:cookie1[100];
  1599. GetClientCookie(client, g_mPaintsSkin, cookie1, sizeof(cookie1));
  1600.  
  1601. if(strlen(cookie1) < 3) Format(cookie1, sizeof(cookie1), "0;0;0;0;0;0;0;");
  1602.  
  1603. SetTrieValue_Arbol(client, cookie1);
  1604.  
  1605. GetClientCookie(client, g_mExp, SaveString, sizeof(SaveString));
  1606. c_zExp[client] = StringToInt(SaveString);
  1607.  
  1608. GetClientCookie(client, g_mRank, SaveString, sizeof(SaveString));
  1609. c_zRank[client] = StringToInt(SaveString);
  1610.  
  1611. GetClientCookie(client, g_mSaveKnife, SaveString, sizeof(SaveString));
  1612. c_zIDKnife[client] = StringToInt(SaveString);
  1613. }
  1614.  
  1615. SetTrieValue_Arbol(client, String:cookie1[100])
  1616. {
  1617. arbol[client] = CreateTrie();
  1618.  
  1619. decl String:parte1[7][4];
  1620. ExplodeString(cookie1, ";", parte1, sizeof(parte1), sizeof(parte1[]));
  1621.  
  1622. SetTrieValue(arbol[client], "weapon_knife_gut", StringToInt(parte1[0]));
  1623. SetTrieValue(arbol[client], "weapon_knife_flip", StringToInt(parte1[1]));
  1624. SetTrieValue(arbol[client], "weapon_bayonet", StringToInt(parte1[2]));
  1625. SetTrieValue(arbol[client], "weapon_knife_m9_bayonet", StringToInt(parte1[3]));
  1626. SetTrieValue(arbol[client], "weapon_knife_karambit", StringToInt(parte1[4]));
  1627. SetTrieValue(arbol[client], "weapon_knife_tactical", StringToInt(parte1[5]));
  1628. SetTrieValue(arbol[client], "weapon_knife_butterfly", StringToInt(parte1[6]));
  1629. }
  1630.  
  1631. SaveCookies(client)
  1632. {
  1633. decl String:cookie1[100];
  1634. new valor;
  1635.  
  1636. GetTrieValue(arbol[client], "weapon_knife_gut", valor);
  1637. Format(cookie1, sizeof(cookie1), "%i", valor);
  1638.  
  1639. GetTrieValue(arbol[client], "weapon_knife_flip", valor);
  1640. Format(cookie1, sizeof(cookie1), "%s;%i", cookie1, valor);
  1641.  
  1642. GetTrieValue(arbol[client], "weapon_bayonet", valor);
  1643. Format(cookie1, sizeof(cookie1), "%s;%i", cookie1, valor);
  1644.  
  1645. GetTrieValue(arbol[client], "weapon_knife_m9_bayonet", valor);
  1646. Format(cookie1, sizeof(cookie1), "%s;%i", cookie1, valor);
  1647.  
  1648. GetTrieValue(arbol[client], "weapon_knife_karambit", valor);
  1649. Format(cookie1, sizeof(cookie1), "%s;%i", cookie1, valor);
  1650.  
  1651. GetTrieValue(arbol[client], "weapon_knife_tactical", valor);
  1652. Format(cookie1, sizeof(cookie1), "%s;%i", cookie1, valor);
  1653.  
  1654. GetTrieValue(arbol[client], "weapon_knife_butterfly", valor);
  1655. Format(cookie1, sizeof(cookie1), "%s;%i", cookie1, valor);
  1656.  
  1657. SetClientCookie(client, g_mPaintsSkin, cookie1);
  1658. }
  1659.  
  1660. public OnClientAuthorized(client, const String:steamid[])
  1661. {
  1662. if(!IsFakeClient(client))
  1663. {
  1664. Format(g_steamid[client], Max_Length, steamid);
  1665. GetClientName(client, g_name[client], MAX_NAME_LENGTH);
  1666. GetPlayerBySteamId(steamid, LoadPlayerCallback, client);
  1667. }
  1668. }
  1669.  
  1670. public OnPluginEnd()
  1671. {
  1672. for(new client = 1; client <= MaxClients; client++)
  1673. {
  1674. if(IsClientInGame(client) && client > 0)
  1675. {
  1676. OnClientDisconnect(client);
  1677. }
  1678. }
  1679. }
  1680.  
  1681. public OnClientDisconnect(client)
  1682. {
  1683. if(AreClientCookiesCached(client))
  1684. {
  1685. SaveCookies(client);
  1686. }
  1687.  
  1688. if(g_initialized[client] == true)
  1689. {
  1690. SavePlayer(client);
  1691. g_initialized[client] = false;
  1692. }
  1693.  
  1694. if(arbol[client] != INVALID_HANDLE)
  1695. {
  1696. ClearTrie(arbol[client]);
  1697. CloseHandle(arbol[client]);
  1698. arbol[client] = INVALID_HANDLE;
  1699. }
  1700.  
  1701. if(g_iActiveKnife)
  1702. {
  1703. SDKUnhook(client, SDKHook_WeaponEquipPost, OnPostWeaponEquip);
  1704. }
  1705.  
  1706. SDKUnhook(client, SDKHook_PostThinkPost, OnPostThinkPost);
  1707.  
  1708. if(AreClientCookiesCached(client))
  1709. {
  1710. decl String:SaveString[15];
  1711.  
  1712. Format(SaveString, sizeof(SaveString), "%i", c_zExp[client]);
  1713. SetClientCookie(client, g_mExp, SaveString);
  1714.  
  1715. Format(SaveString, sizeof(SaveString), "%i", c_zRank[client]);
  1716. SetClientCookie(client, g_mRank, SaveString);
  1717.  
  1718. Format(SaveString, sizeof(SaveString), "%i", c_zIDKnife[client]);
  1719. SetClientCookie(client, g_mSaveKnife, SaveString);
  1720. }
  1721.  
  1722. doublekill[client] = false;
  1723. triplekill[client] = false;
  1724. quadrokill[client] = false;
  1725. pentakill[client] = false;
  1726. c_zExp[client] = 0;
  1727. c_zCompetitiveRank[client] = 0;
  1728. c_zRank[client] = 0;
  1729. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement