Advertisement
Thommen13

Untitled

Jan 30th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.29 KB | None | 0 0
  1. /****************************************************************************
  2. ** 1.0 Wydanie pierwszej wersji. *
  3. ** 1.1 Przejście na tablice dynamiczne. Dziękuję Magnetowi za pomoc *
  4. ** 1.2 Usunięcie cvarów. Przejście na konfigurację(usuniętych cvarów) w KV *
  5. ** Zmiana sposobu konfigurowania modeli (brak kv.JumpToKey) *
  6. ** Dodanie możliwości ustawienia jednego modelu w dwóch drużynach bez *
  7. ** konieczności dodawania tego samego modelu dwa razy. Aktualne tagi drużyn *
  8. ** [CT/TT/BOTH] wszystko musi być z dużych inaczej pominie model. *
  9. ** Dodanie "show_in_menu"(bool) 0 - Osoby, które nie mają danej flagi nie *
  10. ** widzą danej kategorii. 1 - Osoby, które nie mają danej flagi mają *
  11. ** pokazane w menu dane kategorię, ale nie mogą ich wybrać. *
  12. ** Dodano support SteamID(STEAM_X:X:XXXXXXXXX) wystarczy wpisać je w miejsce*
  13. ** flagi. Kategorie, które są tylko dla danego SteamID nie są wyświetlane *
  14. ** nikomu oprócz osoby z danym SteamID. *
  15. ** Dodano "no_category"(bool) Jeżeli jest tylko jedna kategoria to nie *
  16. ** wyskoczy jej wybór tylko od razu modele. Zabezpieczono przed możliwością *
  17. ** zmiany modelu na model do którego się nie ma dostępu. *
  18. ** 1.3 Fix błędu przy Flags.GetString *
  19. *****************************************************************************/
  20.  
  21. #include <sdktools>
  22. #include <clientprefs>
  23. #include <cstrike>
  24.  
  25. #pragma semicolon 1
  26. #pragma newdecls required
  27.  
  28. Handle Cookies_SectionCT, Cookies_SectionTT, Cookies_ModelCT, Cookies_ModelTT;
  29.  
  30. char MOD_TAG[64];
  31.  
  32. KeyValues kv;
  33.  
  34. ArrayList FlagList;
  35. ArrayList ModelNameCT, ModelNameTT;
  36. ArrayList ModelSectionCT, ModelSectionTT;
  37. ArrayList ModelDirCT, ModelDirTT;
  38. ArrayList ModelDirArmsCT, ModelDirArmsTT;
  39. ArrayList SectionList;
  40.  
  41. int ClientTempInt[MAXPLAYERS + 1];
  42. int ClientSectionCT[MAXPLAYERS + 1], ClientSectionTT[MAXPLAYERS + 1], ClientModelCT[MAXPLAYERS + 1], ClientModelTT[MAXPLAYERS + 1];
  43. bool g_bArmsEnabled, g_bShowInMenu, g_bNoCategory;
  44.  
  45. public Plugin myinfo =
  46. {
  47. name = "ADEPT --> Models",
  48. description = "Autorski Plugin StudioADEPT.net",
  49. author = "Brum Brum",
  50. version = "1.3",
  51. url = "http://www.StudioADEPT.net/forum",
  52. };
  53.  
  54. /***************************************
  55. **** OnPluginStart oraz OnMapStart *****
  56. ****************************************/
  57. public void OnPluginStart()
  58. {
  59. FlagList = new ArrayList(32);
  60. ModelNameCT = new ArrayList(32);
  61. ModelNameTT = new ArrayList(32);
  62. ModelSectionCT = new ArrayList(32);
  63. ModelSectionTT = new ArrayList(32);
  64. ModelDirCT = new ArrayList(128);
  65. ModelDirTT = new ArrayList(128);
  66. ModelDirArmsCT = new ArrayList(128);
  67. ModelDirArmsTT = new ArrayList(128);
  68. SectionList = new ArrayList(32);
  69. Cookies_SectionCT = RegClientCookie("sm_models_section_ct", "Zapisuje wybraną sekcje modelu po CT tzn. ADMIN, VIP itp.", CookieAccess_Public);
  70. Cookies_SectionTT = RegClientCookie("sm_models_section_tt", "Zapisuje wybraną sekcje modelu po TT tzn. ADMIN, VIP itp.", CookieAccess_Public);
  71. Cookies_ModelCT = RegClientCookie("sm_models_model_ct", "Zapisuje wybrany model gracza po stronie CT", CookieAccess_Public);
  72. Cookies_ModelTT = RegClientCookie("sm_models_model_tt", "Zapisuje wybrany model gracza po stronie TT", CookieAccess_Public);
  73. HookEvent("player_spawn", Event_PlayerSpawn);
  74. HookEvent("player_team", Event_PlayerTeam);
  75. RegConsoleCmd("sm_models", CMD_Models);
  76. RegConsoleCmd("sm_modele", CMD_Models);
  77. RegConsoleCmd("sm_model", CMD_Models);
  78. }
  79.  
  80. public void OnMapStart()
  81. {
  82. PrecacheModel("models/player/custom_player/legacy/ctm_st6_varianta.mdl", true);
  83. PrecacheModel("models/player/custom_player/legacy/tm_phoenix_varianta.mdl", true);
  84. PrecacheModel("models/weapons/ct_arms_st6.mdl", true);
  85. PrecacheModel("models/weapons/t_arms_phoenix.mdl", true);
  86. Download();
  87. LoadConfig();
  88. }
  89.  
  90. public void OnMapEnd()
  91. {
  92. ResetArrays();
  93. }
  94.  
  95. void ResetArrays()
  96. {
  97. FlagList.Clear();
  98. ModelNameCT.Clear();
  99. ModelNameTT.Clear();
  100. ModelSectionCT.Clear();
  101. ModelSectionTT.Clear();
  102. ModelDirCT.Clear();
  103. ModelDirTT.Clear();
  104. ModelDirArmsCT.Clear();
  105. ModelDirArmsTT.Clear();
  106. SectionList.Clear();
  107. }
  108.  
  109. /***************************************
  110. ****************** Eventy **************
  111. ****************************************/
  112. public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
  113. {
  114. int client = GetClientOfUserId(event.GetInt("userid"));
  115. if (!IsValidClient(client))return;
  116.  
  117. SetPlayerModel(client);
  118. }
  119. public Action Event_PlayerTeam(Event event, const char[] name, bool dontBroadcast)
  120. {
  121. int client = GetClientOfUserId(event.GetInt("userid"));
  122. if (!IsValidClient(client))return;
  123.  
  124. if (ClientTempInt[client] > 0)CMD_Models(client, 0);
  125.  
  126. }
  127. /****************************************
  128. **** Cookies oraz OnClientDisconnect ****
  129. ****************************************/
  130. public void OnClientCookiesCached(int client)
  131. {
  132. char value[16];
  133. GetClientCookie(client, Cookies_SectionCT, value, sizeof(value));
  134. ClientSectionCT[client] = StringToInt(value);
  135. GetClientCookie(client, Cookies_SectionTT, value, sizeof(value));
  136. ClientSectionTT[client] = StringToInt(value);
  137. GetClientCookie(client, Cookies_ModelCT, value, sizeof(value));
  138. ClientModelCT[client] = StringToInt(value);
  139. GetClientCookie(client, Cookies_ModelTT, value, sizeof(value));
  140. ClientModelTT[client] = StringToInt(value);
  141. }
  142.  
  143. public void OnClientDisconnect(int client)
  144. {
  145. if (AreClientCookiesCached(client))
  146. {
  147. char value[16];
  148. Format(value, sizeof(value), "%d", ClientSectionCT[client]);
  149. SetClientCookie(client, Cookies_SectionCT, value);
  150. Format(value, sizeof(value), "%d", ClientModelCT[client]);
  151. SetClientCookie(client, Cookies_ModelCT, value);
  152. Format(value, sizeof(value), "%d", ClientSectionTT[client]);
  153. SetClientCookie(client, Cookies_SectionTT, value);
  154. Format(value, sizeof(value), "%d", ClientModelTT[client]);
  155. SetClientCookie(client, Cookies_ModelTT, value);
  156. }
  157. ClientSectionCT[client] = 0;
  158. ClientSectionTT[client] = 0;
  159. ClientModelCT[client] = 0;
  160. ClientModelTT[client] = 0;
  161. }
  162.  
  163. /****************************************
  164. ************** Komendy ******************
  165. ****************************************/
  166. public Action CMD_Models(int client, int args)
  167. {
  168. if (client == 0)return Plugin_Handled;
  169. if (GetClientTeam(client) == CS_TEAM_SPECTATOR || GetClientTeam(client) == CS_TEAM_NONE)return Plugin_Handled;
  170.  
  171. Menu menu = new Menu(Menu_Handler);
  172. menu.SetTitle("[%s -> Models]", MOD_TAG);
  173. menu.AddItem("default", "Domyślny");
  174. if (g_bNoCategory) {
  175. if (SectionList.Length - 2 == 1) {
  176. ShowMenuWithModels(client, 1);
  177. return Plugin_Handled;
  178. }
  179. }
  180. for (int i = 1; i < SectionList.Length - 1; i++)
  181. {
  182. bool steamid = false;
  183. char buffer[256], id[16], flag[32];
  184. SectionList.GetString(i, buffer, sizeof(buffer));
  185. FlagList.GetString(i, flag, sizeof(flag));
  186. if (StrContains(flag, "STEAM_", false) != -1)steamid = true;
  187. Format(id, sizeof(id), "%d", i);
  188. if (g_bShowInMenu) {
  189. if (!steamid)menu.AddItem(id, buffer, CheckFlags(client, flag));
  190. else {
  191. if (IsClientSteamID(client, flag))menu.AddItem(id, buffer, CheckFlags(client, flag));
  192. }
  193. }
  194. else {
  195. if (CheckModelFlag(client, flag))menu.AddItem(id, buffer);
  196. }
  197. }
  198. menu.ExitButton = true;
  199. menu.Display(client, 60);
  200. return Plugin_Handled;
  201. }
  202.  
  203. /****************************************
  204. ************** Handlery *****************
  205. *****************************************/
  206. public int Menu_Handler(Menu menu, MenuAction action, int client, int item)
  207. {
  208. if (!IsValidClient(client))return;
  209. if (GetClientTeam(client) == CS_TEAM_SPECTATOR || GetClientTeam(client) == CS_TEAM_NONE)return;
  210.  
  211. switch (action)
  212. {
  213. case MenuAction_Select:
  214. {
  215. char info[32];
  216. menu.GetItem(item, info, sizeof(info));
  217. int sec = StringToInt(info);
  218. if (StrEqual(info, "default", false)) {
  219. if (GetClientTeam(client) == CS_TEAM_CT) {
  220. ClientSectionCT[client] = 0;
  221. ClientModelCT[client] = 0;
  222. }
  223. else if (GetClientTeam(client) == CS_TEAM_T) {
  224. ClientSectionTT[client] = 0;
  225. ClientModelTT[client] = 0;
  226. }
  227. ClientTempInt[client] = 0;
  228. SetPlayerModel(client);
  229. return;
  230. }
  231.  
  232. ShowMenuWithModels(client, sec);
  233. }
  234. case MenuAction_End:delete menu;
  235. }
  236. }
  237.  
  238. void ShowMenuWithModels(int client, int section)
  239. {
  240. if (!IsValidClient(client))return;
  241.  
  242. ClientTempInt[client] = section;
  243.  
  244. char bufferSection[64], buffer[64], bufferItem[8], flag[32];
  245. Menu menu = new Menu(SelectModel_Handler);
  246. menu.SetTitle("[%s -> Models] Wybierz model", MOD_TAG);
  247.  
  248. SectionList.GetString(section, bufferSection, sizeof(bufferSection));
  249. FlagList.GetString(section, flag, sizeof(flag));
  250.  
  251. if (g_bNoCategory) {
  252. if (SectionList.Length - 2 == 1)menu.AddItem("default", "Domyślny");
  253. }
  254.  
  255. if (GetClientTeam(client) == CS_TEAM_CT)
  256. {
  257. for (int i = 0; i < ModelSectionCT.Length - 1; i++)
  258. {
  259. ModelSectionCT.GetString(i, buffer, sizeof(buffer));
  260. if (StrEqual(buffer, bufferSection)) {
  261. char name[32];
  262. ModelNameCT.GetString(i, name, sizeof(name));
  263. Format(bufferItem, sizeof(bufferItem), "%d", i);
  264. menu.AddItem(bufferItem, name, CheckFlags(client, flag));
  265. }
  266. }
  267. }
  268. else if (GetClientTeam(client) == CS_TEAM_T)
  269. {
  270. for (int i = 0; i < ModelSectionTT.Length - 1; i++)
  271. {
  272. ModelSectionTT.GetString(i, buffer, sizeof(buffer));
  273. if (StrEqual(buffer, bufferSection)) {
  274. char name[32];
  275. ModelNameTT.GetString(i, name, sizeof(name));
  276. Format(bufferItem, sizeof(bufferItem), "%d", i);
  277. menu.AddItem(bufferItem, name, CheckFlags(client, flag));
  278. }
  279. }
  280. }
  281. menu.ExitButton = true;
  282. menu.Display(client, 60);
  283. }
  284.  
  285. public int SelectModel_Handler(Menu menu, MenuAction action, int client, int item)
  286. {
  287. if (!IsValidClient(client))return;
  288. if (GetClientTeam(client) == CS_TEAM_SPECTATOR || GetClientTeam(client) == CS_TEAM_NONE)return;
  289.  
  290. switch (action)
  291. {
  292. case MenuAction_Select:
  293. {
  294. char info[32], MName[32];
  295. menu.GetItem(item, info, sizeof(info));
  296. int model = StringToInt(info);
  297. int sec = ClientTempInt[client];
  298.  
  299. if (g_bNoCategory && StrEqual(info, "default", false)) {
  300. if (GetClientTeam(client) == CS_TEAM_CT) {
  301. ClientSectionCT[client] = 0;
  302. ClientModelCT[client] = 0;
  303. }
  304. else if (GetClientTeam(client) == CS_TEAM_T) {
  305. ClientSectionTT[client] = 0;
  306. ClientModelTT[client] = 0;
  307. }
  308. ClientTempInt[client] = 0;
  309. SetPlayerModel(client);
  310. PrintToChat(client, "\x01\x0B★ \x07[%s -> Models]\x04 Ustawiono twój model na\x02 Domyślny!", MOD_TAG);
  311. return;
  312. }
  313.  
  314. if (GetClientTeam(client) == CS_TEAM_CT) {
  315. ClientSectionCT[client] = sec;
  316. ClientModelCT[client] = model;
  317. ModelNameCT.GetString(ClientModelCT[client], MName, sizeof(MName));
  318. }
  319. else if (GetClientTeam(client) == CS_TEAM_T) {
  320. ClientSectionTT[client] = sec;
  321. ClientModelTT[client] = model;
  322. ModelNameTT.GetString(ClientModelTT[client], MName, sizeof(MName));
  323. }
  324.  
  325. PrintToChat(client, "\x01\x0B★ \x07[%s -> Models]\x04 Ustawiono twój model na \x02%s", MOD_TAG, MName);
  326. SetPlayerModel(client);
  327. }
  328. case MenuAction_End:delete menu;
  329. case MenuAction_Cancel:ClientTempInt[client] = 0;
  330. }
  331. }
  332.  
  333. /****************************************
  334. ************** KV i Download ************
  335. *****************************************/
  336. void LoadConfig()
  337. {
  338. delete kv;
  339. kv = CreateKeyValues("Models");
  340.  
  341. char sPath[PLATFORM_MAX_PATH];
  342. BuildPath(Path_SM, sPath, sizeof(sPath), "configs/ADEPT_Models.txt");
  343.  
  344. if (!FileExists(sPath))
  345. SetFailState("Nie znaleziono pliku: %s", sPath);
  346.  
  347. kv.ImportFromFile(sPath);
  348.  
  349. SectionList.PushString("Default");
  350. ModelSectionCT.PushString("Default");
  351. ModelSectionTT.PushString("Default");
  352. ModelNameCT.PushString("Domyślny CT");
  353. ModelNameTT.PushString("Domyślny TT");
  354. ModelDirCT.PushString("models/player/custom_player/legacy/ctm_st6_varianta.mdl");
  355. ModelDirTT.PushString("models/player/custom_player/legacy/tm_phoenix_varianta.mdl");
  356. ModelDirArmsCT.PushString("models/weapons/ct_arms_st6.mdl");
  357. ModelDirArmsTT.PushString("models/weapons/t_arms_phoenix.mdl");
  358. FlagList.PushString("");
  359.  
  360. char buffer[64], sbuffer[64];
  361. kv.GetString("MOD_TAG", buffer, sizeof(buffer));
  362. strcopy(MOD_TAG, sizeof(MOD_TAG), buffer);
  363. g_bArmsEnabled = view_as<bool>(kv.GetNum("arms_enabled", 1));
  364. g_bShowInMenu = view_as<bool>(kv.GetNum("show_in_menu", 1));
  365. g_bNoCategory = view_as<bool>(kv.GetNum("no_category", 1));
  366.  
  367. if (!kv.GotoFirstSubKey()) {
  368. delete kv;
  369. return;
  370. }
  371.  
  372. do
  373. {
  374. kv.GetSectionName(sbuffer, sizeof(sbuffer));
  375. SectionList.PushString(sbuffer);
  376. kv.GetString("flag", buffer, sizeof(buffer));
  377. FlagList.PushString(buffer);
  378. kv.GotoFirstSubKey();
  379. do
  380. {
  381. char Name[64], Model[128], Arms[128], Team[5];
  382. kv.GetSectionName(Name, sizeof(Name));
  383. kv.GetString("model", Model, sizeof(Model));
  384. kv.GetString("arms", Arms, sizeof(Arms));
  385. kv.GetString("team", Team, sizeof(Team));
  386. if (IsEmptyString(Name)) {
  387. LogError("[ADEPT_Modele] Nie podano nazwy do modelu! Pomijam go");
  388. continue;
  389. }
  390. if (IsEmptyString(Model)) {
  391. LogError("[ADEPT_Modele] Nie podano ścieżki do modelu %s | Pomijam go", Name);
  392. continue;
  393. }
  394. if (IsEmptyString(Arms) && g_bArmsEnabled) {
  395. LogError("[ADEPT_Modele] Nie podano ścieżki do rąk z modelu %s | Pomijam go", Name);
  396. continue;
  397. }
  398. if (IsEmptyString(Team) || !StrEqual(Team, "CT", true) && !StrEqual(Team, "TT", true) && !StrEqual(Team, "BOTH", true)) {
  399. LogError("[ADEPT_Modele] Nie podano żadnego teamu do modelu %s | Pomijam go", Name);
  400. continue;
  401. }
  402.  
  403. if (StrEqual(Team, "BOTH", true)) {
  404. ModelSectionCT.PushString(sbuffer);
  405. ModelSectionTT.PushString(sbuffer);
  406. ModelNameCT.PushString(Name);
  407. ModelNameTT.PushString(Name);
  408. ModelDirCT.PushString(Model);
  409. ModelDirTT.PushString(Model);
  410. if (StrEqual(Arms, "default", true)) {
  411. ModelDirArmsCT.PushString("models/weapons/ct_arms_st6.mdl");
  412. ModelDirArmsTT.PushString("models/weapons/t_arms_phoenix.mdl");
  413. continue;
  414. }
  415. ModelDirArmsCT.PushString(Arms);
  416. ModelDirArmsTT.PushString(Arms);
  417. }
  418. else if (StrEqual(Team, "CT", true)) {
  419. ModelSectionCT.PushString(sbuffer);
  420. ModelNameCT.PushString(Name);
  421. ModelDirCT.PushString(Model);
  422. if (StrEqual(Arms, "default", true)) {
  423. strcopy(Arms, sizeof(Arms), "models/weapons/ct_arms_st6.mdl");
  424. continue;
  425. }
  426. ModelDirArmsCT.PushString(Arms);
  427. }
  428. else if (StrEqual(Team, "TT", true)) {
  429. ModelSectionTT.PushString(sbuffer);
  430. ModelNameTT.PushString(Name);
  431. ModelDirTT.PushString(Model);
  432. if (StrEqual(Arms, "default", true)) {
  433. strcopy(Arms, sizeof(Arms), "models/weapons/t_arms_phoenix.mdl");
  434. continue;
  435. }
  436. ModelDirArmsTT.PushString(Arms);
  437. }
  438. }
  439. while (kv.GotoNextKey());
  440. kv.GoBack();
  441. }
  442. while (kv.GotoNextKey());
  443.  
  444. ModelSectionCT.PushString("X");
  445. ModelSectionTT.PushString("X");
  446. ModelNameCT.PushString("X");
  447. ModelNameTT.PushString("X");
  448. ModelDirCT.PushString("X");
  449. ModelDirTT.PushString("X");
  450. ModelDirArmsCT.PushString("X");
  451. ModelDirArmsTT.PushString("X");
  452. SectionList.PushString("X");
  453. FlagList.PushString("X");
  454. return;
  455. }
  456.  
  457. int Download()
  458. {
  459. char inFile[PLATFORM_MAX_PATH];
  460. char line[512];
  461. int i = 0;
  462. int totalLines = 0;
  463.  
  464. BuildPath(Path_SM, inFile, sizeof(inFile), "configs/ADEPT_Models_Download.txt");
  465.  
  466. Handle file = OpenFile(inFile, "rt");
  467. if (file != INVALID_HANDLE)
  468. {
  469. while (!IsEndOfFile(file))
  470. {
  471. if (!ReadFileLine(file, line, sizeof(line))) {
  472. break;
  473. }
  474.  
  475. TrimString(line);
  476. if (strlen(line) > 0)
  477. {
  478. if (StrContains(line, "//") != -1)
  479. continue;
  480.  
  481. AddFileToDownloadsTable(line);
  482. if (StrContains(line, ".mdl", true) != -1) {
  483. PrecacheModel(line);
  484. }
  485. else if (StrContains(line, ".wav", true) != -1 || StrContains(line, ".mp3", true) != -1) {
  486. ReplaceStringEx(line, sizeof(line), "sound/", "");
  487. PrecacheSound(line);
  488. }
  489. else if (StrContains(line, ".mdl", true) == -1 && StrContains(line, ".wav", true) == -1 && StrContains(line, ".mp3", true) == -1) {
  490. PrecacheDecal(line);
  491. }
  492. totalLines++;
  493. }
  494. i++;
  495. }
  496. CloseHandle(file);
  497. }
  498. return totalLines;
  499. }
  500.  
  501. /****************************************
  502. ************** Zmiana Modelu ************
  503. *****************************************/
  504. void SetPlayerModel(int client)
  505. {
  506. if (!IsValidClient(client))return;
  507.  
  508. switch (GetClientTeam(client))
  509. {
  510. case CS_TEAM_T:
  511. {
  512. if (ClientSectionTT[client] > ModelSectionTT.Length || ClientSectionTT[client] < 0)ClientSectionTT[client] = 0;
  513. if (ClientModelTT[client] > ModelDirTT.Length || ClientModelTT[client] < 0)ClientModelTT[client] = 0;
  514.  
  515. char flag[32];
  516. FlagList.GetString(ClientSectionTT[client], flag, sizeof(flag));
  517.  
  518. if (CheckModelFlag(client, flag))
  519. {
  520. char model[128], arms[128];
  521. ModelDirTT.GetString(ClientModelTT[client], model, sizeof(model));
  522. if (g_bArmsEnabled)ModelDirArmsTT.GetString(ClientModelTT[client], arms, sizeof(arms));
  523. //else ModelDirArmsTT.GetString(0, arms, sizeof(arms));
  524. SetEntityModel(client, model);
  525. SetEntityArms(client, arms);
  526. }
  527. }
  528. case CS_TEAM_CT:
  529. {
  530. if (ClientSectionCT[client] > ModelSectionCT.Length || ClientSectionCT[client] < 0)ClientSectionCT[client] = 0;
  531. if (ClientModelCT[client] > ModelDirCT.Length || ClientModelCT[client] < 0)ClientModelCT[client] = 0;
  532.  
  533. char flag[32];
  534. FlagList.GetString(ClientSectionCT[client], flag, sizeof(flag));
  535.  
  536. if (CheckModelFlag(client, flag))
  537. {
  538. char model[128], arms[128];
  539. ModelDirCT.GetString(ClientModelCT[client], model, sizeof(model));
  540. if (g_bArmsEnabled)ModelDirArmsCT.GetString(ClientModelCT[client], arms, sizeof(arms));
  541. //else ModelDirArmsCT.GetString(0, arms, sizeof(arms));
  542. SetEntityModel(client, model);
  543. SetEntityArms(client, arms);
  544. }
  545. }
  546. }
  547. }
  548. /****************************************
  549. ****************** Inne *****************
  550. *****************************************/
  551. int CheckFlags(int client, const char[] flag)
  552. {
  553. if (GetUserFlagBits(client) & ReadFlagString(flag))return ITEMDRAW_DEFAULT;
  554. if (GetUserFlagBits(client) & ADMFLAG_ROOT)return ITEMDRAW_DEFAULT;
  555. if (StrEqual(flag, "", true))return ITEMDRAW_DEFAULT;
  556.  
  557. if (IsClientSteamID(client, flag))return ITEMDRAW_DEFAULT;
  558.  
  559.  
  560. return ITEMDRAW_DISABLED;
  561. }
  562.  
  563. bool CheckModelFlag(int client, const char[] flag)
  564. {
  565. if (GetUserFlagBits(client) & ReadFlagString(flag))return true;
  566. if (GetUserFlagBits(client) & ADMFLAG_ROOT)return true;
  567. if (StrEqual(flag, "", true))return true;
  568.  
  569. if (IsClientSteamID(client, flag))return true;
  570.  
  571.  
  572. return false;
  573. }
  574.  
  575. bool IsClientSteamID(int client, const char[] steamid)
  576. {
  577. if (!IsValidClient(client))return false;
  578.  
  579. char SteamID[32];
  580. GetClientAuthId(client, AuthId_Steam2, SteamID, sizeof(SteamID));
  581. if (StrEqual(steamid, SteamID, true))return true;
  582.  
  583. return false;
  584. }
  585.  
  586. void SetEntityArms(int client, char[] arms)
  587. {
  588. SetEntPropString(client, Prop_Send, "m_szArmsModel", arms);
  589. }
  590.  
  591. bool IsValidClient(int client)
  592. {
  593. if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || !IsClientConnected(client) || IsFakeClient(client) || IsClientSourceTV(client))
  594. return false;
  595.  
  596. return true;
  597. }
  598.  
  599. bool IsEmptyString(const char[] string)
  600. {
  601. if (!string[0])return true;
  602. else return false;
  603. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement