Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.88 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <cstrike>
  3. #include <clientprefs>
  4. #include <multicolors>
  5. #include <basecomm>
  6.  
  7.  
  8. #pragma semicolon 1
  9. #pragma newdecls required
  10.  
  11. StringMap tagClan;
  12. StringMap flagClan;
  13. StringMap cienClan;
  14. StringMap colorChatTag;
  15. StringMap colorChatNick;
  16.  
  17. int ilosctagow;
  18.  
  19. char TagClient[MAXPLAYERS + 1][64];
  20. char TagColor[MAXPLAYERS + 1][64];
  21. char NickColor[MAXPLAYERS + 1][64];
  22.  
  23. bool AkceptTag[MAXPLAYERS + 1];
  24. bool TrybCieniaTag[MAXPLAYERS + 1];
  25.  
  26. Handle iClientCookieTag;
  27.  
  28. public Plugin myinfo =
  29. {
  30. name = "Tag Clan",
  31. author = "Yellon",
  32. description = "",
  33. };
  34.  
  35. public void OnPluginStart()
  36. {
  37. if(GetEngineVersion() != Engine_CSGO)
  38. {
  39. SetFailState("This plugin works only on CS:GO");
  40. }
  41.  
  42. tagClan = new StringMap();
  43. flagClan = new StringMap();
  44. cienClan = new StringMap();
  45. colorChatTag = new StringMap();
  46. colorChatNick = new StringMap();
  47.  
  48. RegConsoleCmd("sm_trybcienia", TrybCienia);
  49. RegConsoleCmd("say", Command_SendToAll);
  50. RegAdminCmd("sm_reloadtag", ReloadTagAdmin, ADMFLAG_ROOT);
  51. iClientCookieTag = RegClientCookie("tag_tryb_cienia", "Tryb Cienia TAG", CookieAccess_Private);
  52. }
  53.  
  54. public Action ReloadTagAdmin(int iClient, int iArg)
  55. {
  56. FileTag();
  57. SetClientClanTag(iClient);
  58. }
  59.  
  60. public Action TrybCienia(int iClient, int iArg)
  61. {
  62. TrybCieniaTag[iClient] = !TrybCieniaTag[iClient];
  63. SetClientClanTag(iClient);
  64. if(TrybCieniaTag[iClient] == true)
  65. SetClientCookie(iClient, iClientCookieTag, "true");
  66. else SetClientCookie(iClient, iClientCookieTag, "false");
  67. PrintToChat(iClient, "\x01[\x0E TAG\x01 ]%s\x08 tryb Cienia", TrybCieniaTag[iClient] == true ? "\x06 Włączyłeś" : "\x07 Wyłączyłeś");
  68. }
  69.  
  70. public void OnClientCookiesCached(int iClient) {
  71. char szBuffer[64];
  72. GetClientCookie(iClient, iClientCookieTag, szBuffer, sizeof(szBuffer));
  73.  
  74. if(StrEqual(szBuffer, "") || StrEqual(szBuffer, "false"))
  75. {
  76. TrybCieniaTag[iClient] = false;
  77. }
  78. else if(StrEqual(szBuffer, "true"))
  79. {
  80. TrybCieniaTag[iClient] = true;
  81. }
  82. }
  83.  
  84. public void OnConfigsExecuted()
  85. {
  86. FileTag();
  87. }
  88.  
  89. public void OnClientDisconnect(int iClient)
  90. {
  91. strcopy(TagClient[iClient], 64, "");
  92. strcopy(TagColor[iClient], 64, "");
  93. strcopy(NickColor[iClient], 64, "");
  94. TrybCieniaTag[iClient] = false;
  95. AkceptTag[iClient] = false;
  96. }
  97.  
  98. public void OnMapStart()
  99. {
  100. ilosctagow = 0;
  101. CreateTimer(2.0, Timer_SetClanTags, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
  102. }
  103.  
  104. public void OnMapEnd()
  105. {
  106. ilosctagow = 0;
  107. }
  108.  
  109. public void OnClientPostAdminCheck(int iClient)
  110. {
  111. SetClientClanTag(iClient);
  112. }
  113.  
  114. public Action Timer_SetClanTags(Handle hTimer)
  115. {
  116. for(int i = 1; i <= MaxClients; i++)
  117. {
  118. if (IsClientInGame(i) && !IsFakeClient(i))
  119. {
  120. SetClientClanTag(i);
  121. }
  122. }
  123. return Plugin_Continue;
  124. }
  125.  
  126. public Action SetClientClanTag(int iClient)
  127. {
  128. if(!IsFakeClient(iClient) && IsClientInGame(iClient))
  129. {
  130. AkceptTag[iClient] = false;
  131. char idtag[10], SID[64], TAG[64], FLAG[64], CIEN[10], NKOLOR[64], TKOLOR[64];
  132. char ExplodeFlag[25][64];
  133. GetClientAuthId(iClient, AuthId_Engine, SID, sizeof(SID));
  134. for (int i = 1; i <= ilosctagow; i++)
  135. {
  136. Format(idtag, 9, "%i", i);
  137. tagClan.GetString(idtag, TAG, sizeof(TAG));
  138. flagClan.GetString(idtag, FLAG, sizeof(FLAG));
  139. cienClan.GetString(idtag, CIEN, sizeof(CIEN));
  140.  
  141. colorChatTag.GetString(idtag, TKOLOR, sizeof(TKOLOR));
  142. colorChatNick.GetString(idtag, NKOLOR, sizeof(NKOLOR));
  143.  
  144. ExplodeString(FLAG, ";", ExplodeFlag, sizeof(ExplodeFlag), sizeof(ExplodeFlag[]));
  145.  
  146. for (int j = 0; j < 25; j++)
  147. {
  148. if(AkceptTag[iClient] == false)
  149. {
  150. bool isFlag = CheckFlag(iClient, ExplodeFlag[j]);
  151. if(TrybCieniaTag[iClient] == false)
  152. {
  153. if(StrEqual(SID, ExplodeFlag[j]))
  154. {
  155. strcopy(TagClient[iClient], 64, TAG);
  156.  
  157. strcopy(TagColor[iClient], 64, TKOLOR);
  158. strcopy(NickColor[iClient], 64, NKOLOR);
  159. AkceptTag[iClient] = true;
  160. }
  161. else if(isFlag == true)
  162. {
  163. strcopy(TagClient[iClient], 64, TAG);
  164.  
  165. strcopy(TagColor[iClient], 64, TKOLOR);
  166. strcopy(NickColor[iClient], 64, NKOLOR);
  167. AkceptTag[iClient] = true;
  168. }
  169. else if(StrEqual(FLAG, ""))
  170. {
  171. strcopy(TagClient[iClient], 64, TAG);
  172.  
  173. strcopy(TagColor[iClient], 64, TKOLOR);
  174. strcopy(NickColor[iClient], 64, NKOLOR);
  175. AkceptTag[iClient] = true;
  176. }
  177. }
  178. else
  179. {
  180. if(StrEqual(CIEN, "true"))
  181. {
  182. if(StrEqual(SID, ExplodeFlag[j]))
  183. {
  184. strcopy(TagClient[iClient], 64, TAG);
  185.  
  186. strcopy(TagColor[iClient], 64, TKOLOR);
  187. strcopy(NickColor[iClient], 64, NKOLOR);
  188. AkceptTag[iClient] = true;
  189. }
  190. else if(isFlag == true)
  191. {
  192. strcopy(TagClient[iClient], 64, TAG);
  193.  
  194. strcopy(TagColor[iClient], 64, TKOLOR);
  195. strcopy(NickColor[iClient], 64, NKOLOR);
  196. AkceptTag[iClient] = true;
  197. }
  198. else if(StrEqual(FLAG, ""))
  199. {
  200. strcopy(TagClient[iClient], 64, TAG);
  201.  
  202. strcopy(TagColor[iClient], 64, TKOLOR);
  203. strcopy(NickColor[iClient], 64, NKOLOR);
  204. AkceptTag[iClient] = true;
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211.  
  212. CS_SetClientClanTag(iClient, TagClient[iClient]);
  213. }
  214. return Plugin_Continue;
  215. }
  216.  
  217. public Action Command_SendToAll(int client, int args)
  218. {
  219. if (IsValidClient(client))
  220. {
  221. char text[256];
  222. GetCmdArg(1, text, sizeof(text));
  223.  
  224. if (text[0] == '/' || text[0] == '@' || text[0] == '!' || text[0] == 0 || IsChatTrigger() || BaseComm_IsClientGagged(client))
  225. {
  226. return Plugin_Handled;
  227. }
  228. if(IsPlayerAlive(client) && GetClientTeam(client) != 1)
  229. {
  230. CPrintToChatAll("\x01 {%s}%s\x01 {%s}%N: \x01%s",TagColor[client], TagClient[client], NickColor[client], client, text);
  231. return Plugin_Handled;
  232. }
  233. else if(!IsPlayerAlive(client) && GetClientTeam(client) != 1)
  234. {
  235. CPrintToChatAll("\x01*NIE ZYJE* {%s}%s\x01 {%s}%N: \x01%s",TagColor[client], TagClient[client], NickColor[client], client, text);
  236. return Plugin_Handled;
  237. }
  238. else if(!IsPlayerAlive(client) && GetClientTeam(client) == 1)
  239. {
  240. CPrintToChatAll("\x01*OBSERWATOR* {%s}%s\x01 {%s}%N: \x01%s",TagColor[client], TagClient[client], NickColor[client], client, text);
  241. return Plugin_Handled;
  242. }
  243. }
  244. return Plugin_Continue;
  245. }
  246.  
  247.  
  248. public void FileTag()
  249. {
  250. tagClan.Clear();
  251. flagClan.Clear();
  252. cienClan.Clear();
  253. colorChatTag.Clear();
  254. colorChatNick.Clear();
  255.  
  256. char sPath[PLATFORM_MAX_PATH];
  257. Format(sPath, sizeof(sPath), "configs/TagClan.cfg");
  258. BuildPath(Path_SM, sPath, sizeof(sPath), sPath);
  259.  
  260. if (!FileExists(sPath))
  261. return;
  262.  
  263. KeyValues hKeyValues = CreateKeyValues("Tag");
  264. if (!hKeyValues.ImportFromFile(sPath))
  265. return;
  266.  
  267. if(hKeyValues.GotoFirstSubKey())
  268. {
  269. do
  270. {
  271. char sSectionName[255];
  272. char stag[255];
  273. char sflag[255];
  274. char scien[10];
  275. char stagcolor[10];
  276. char snickcolor[10];
  277.  
  278. hKeyValues.GetSectionName(sSectionName, sizeof(sSectionName));
  279. hKeyValues.GetString("tag", stag, sizeof(stag));
  280. hKeyValues.GetString("flag", sflag, sizeof(sflag));
  281. hKeyValues.GetString("cien", scien, sizeof(scien));
  282. hKeyValues.GetString("tag_color", stagcolor, sizeof(stagcolor));
  283. hKeyValues.GetString("nick_color", snickcolor, sizeof(snickcolor));
  284.  
  285. tagClan.SetString(sSectionName, stag);
  286. flagClan.SetString(sSectionName, sflag);
  287. cienClan.SetString(sSectionName, scien);
  288. colorChatTag.SetString(sSectionName, stagcolor);
  289. colorChatNick.SetString(sSectionName, snickcolor);
  290.  
  291. ilosctagow++;
  292. }
  293. while(hKeyValues.GotoNextKey(false));
  294. }
  295. hKeyValues.Close();
  296. }
  297.  
  298. stock bool CheckFlag(int iClient, char[] flag)
  299. {
  300. if(StrEqual(flag, "a"))
  301. {
  302. if(GetUserFlagBits(iClient) & ADMFLAG_RESERVATION)
  303. return true;
  304. else return false;
  305. } else if(StrEqual(flag, "b"))
  306. {
  307. if(GetUserFlagBits(iClient) & ADMFLAG_GENERIC)
  308. return true;
  309. else return false;
  310. } else if(StrEqual(flag, "c"))
  311. {
  312. if(GetUserFlagBits(iClient) & ADMFLAG_KICK)
  313. return true;
  314. else return false;
  315. } else if(StrEqual(flag, "d"))
  316. {
  317. if(GetUserFlagBits(iClient) & ADMFLAG_BAN)
  318. return true;
  319. else return false;
  320. } else if(StrEqual(flag, "e"))
  321. {
  322. if(GetUserFlagBits(iClient) & ADMFLAG_UNBAN)
  323. return true;
  324. else return false;
  325. } else if(StrEqual(flag, "f"))
  326. {
  327. if(GetUserFlagBits(iClient) & ADMFLAG_SLAY)
  328. return true;
  329. else return false;
  330. } else if(StrEqual(flag, "g"))
  331. {
  332. if(GetUserFlagBits(iClient) & ADMFLAG_CHANGEMAP)
  333. return true;
  334. else return false;
  335. } else if(StrEqual(flag, "h"))
  336. {
  337. if(GetUserFlagBits(iClient) & ADMFLAG_CONVARS)
  338. return true;
  339. else return false;
  340. } else if(StrEqual(flag, "i"))
  341. {
  342. if(GetUserFlagBits(iClient) & ADMFLAG_CONFIG)
  343. return true;
  344. else return false;
  345. } else if(StrEqual(flag, "j"))
  346. {
  347. if(GetUserFlagBits(iClient) & ADMFLAG_CHAT)
  348. return true;
  349. else return false;
  350. } else if(StrEqual(flag, "k"))
  351. {
  352. if(GetUserFlagBits(iClient) & ADMFLAG_VOTE)
  353. return true;
  354. else return false;
  355. } else if(StrEqual(flag, "l"))
  356. {
  357. if(GetUserFlagBits(iClient) & ADMFLAG_PASSWORD)
  358. return true;
  359. else return false;
  360. } else if(StrEqual(flag, "m"))
  361. {
  362. if(GetUserFlagBits(iClient) & ADMFLAG_RCON)
  363. return true;
  364. else return false;
  365. } else if(StrEqual(flag, "n"))
  366. {
  367. if(GetUserFlagBits(iClient) & ADMFLAG_CHEATS)
  368. return true;
  369. else return false;
  370. } else if(StrEqual(flag, "z"))
  371. {
  372. if(GetUserFlagBits(iClient) & ADMFLAG_ROOT)
  373. return true;
  374. else return false;
  375. } else if(StrEqual(flag, "o"))
  376. {
  377. if(GetUserFlagBits(iClient) & ADMFLAG_CUSTOM1)
  378. return true;
  379. else return false;
  380. } else if(StrEqual(flag, "p"))
  381. {
  382. if(GetUserFlagBits(iClient) & ADMFLAG_CUSTOM2)
  383. return true;
  384. else return false;
  385. } else if(StrEqual(flag, "q"))
  386. {
  387. if(GetUserFlagBits(iClient) & ADMFLAG_CUSTOM3)
  388. return true;
  389. else return false;
  390. } else if(StrEqual(flag, "r"))
  391. {
  392. if(GetUserFlagBits(iClient) & ADMFLAG_CUSTOM4)
  393. return true;
  394. else return false;
  395. } else if(StrEqual(flag, "s"))
  396. {
  397. if(GetUserFlagBits(iClient) & ADMFLAG_CUSTOM5)
  398. return true;
  399. else return false;
  400. } else if(StrEqual(flag, "t"))
  401. {
  402. if(GetUserFlagBits(iClient) & ADMFLAG_CUSTOM6)
  403. return true;
  404. else return false;
  405. }
  406.  
  407. return false;
  408. }
  409.  
  410. stock bool IsValidClient(int client)
  411. {
  412. if(client >= 1 && client <= MaxClients && IsClientInGame(client) && !IsFakeClient(client))
  413. return true;
  414. return false;
  415. }
  416.  
  417. public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
  418. {
  419. CreateNative("TagClan_Reload", Native_TagClanReload);
  420.  
  421. return APLRes_Success;
  422. }
  423.  
  424. public int Native_TagClanReload(Handle plugin, int numParams) {
  425. int client = GetNativeCell(1);
  426.  
  427. FileTag();
  428. SetClientClanTag(client);
  429. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement