Advertisement
Guest User

asdasd

a guest
Oct 18th, 2017
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 60.94 KB | None | 0 0
  1. public PlVers:__version =
  2. {
  3. version = 5,
  4. filevers = "1.7.3-dev+5265",
  5. date = "18/10/2017",
  6. time = "23:43:06"
  7. };
  8. new Float:NULL_VECTOR[3];
  9. new String:NULL_STRING[4];
  10. public Extension:__ext_core =
  11. {
  12. name = "Core",
  13. file = "core",
  14. autoload = 0,
  15. required = 0,
  16. };
  17. new MaxClients;
  18. new TFHoliday:TFHoliday_Birthday;
  19. new TFHoliday:TFHoliday_Halloween;
  20. new TFHoliday:TFHoliday_Christmas;
  21. new TFHoliday:TFHoliday_EndOfTheLine;
  22. new TFHoliday:TFHoliday_CommunityUpdate;
  23. new TFHoliday:TFHoliday_ValentinesDay;
  24. new TFHoliday:TFHoliday_MeetThePyro;
  25. new TFHoliday:TFHoliday_SpyVsEngyWar;
  26. new TFHoliday:TFHoliday_FullMoon;
  27. new TFHoliday:TFHoliday_HalloweenOrFullMoon;
  28. new TFHoliday:TFHoliday_HalloweenOrFullMoonOrValentines;
  29. new TFHoliday:TFHoliday_AprilFools;
  30. public Extension:__ext_tf2 =
  31. {
  32. name = "TF2 Tools",
  33. file = "game.tf2.ext",
  34. autoload = 0,
  35. required = 1,
  36. };
  37. public Extension:__ext_sdktools =
  38. {
  39. name = "SDKTools",
  40. file = "sdktools.ext",
  41. autoload = 1,
  42. required = 1,
  43. };
  44. new String:TFResourceNames[18][0];
  45. public Extension:__ext_regex =
  46. {
  47. name = "Regex Extension",
  48. file = "regex.ext",
  49. autoload = 1,
  50. required = 1,
  51. };
  52. new bool:CSkipList[66] =
  53. {
  54. 0, 4, 13421772, 5077314, 16728128, 1635151433, 543451500, 1701407843, 1763734638, 2019910766, 6890784, 1701407811, 622883950, 1936269417, 1953459744, 544106784, 1701667175, 0, 7546113, 1417240915, 846493797, 0, 6582116, 3, 4, 909124871, 88, 3, 29477, 1417240915, 846493797, 0, 1433691463, 1299342707, 1634956133, 2035574119, 25968, 1601465957, 7890025, 1952540771, 0, 1600615277, 1701667182, 0, 1634886000, 29549, 0, 1634886000, 29549, 0, 1634886000, 29549, 0, 1634886000, 29549, 0, 1717920891, 1953264993, 125, 1, 1717920891, 1953264993, 125, 0, 1634038907, 1819239277
  55. };
  56. new Handle:CTrie;
  57. new CTeamColors[1][3] =
  58. {
  59. {
  60. 13421772, 5077314, 16728128
  61. }
  62. };
  63. public Extension:__ext_tf2items =
  64. {
  65. name = "TF2Items",
  66. file = "tf2items.ext.2.ep2v",
  67. autoload = 0,
  68. required = 1,
  69. };
  70. public SharedPlugin:__pl_tf2idb =
  71. {
  72. name = "tf2idb",
  73. file = "tf2idb.smx",
  74. required = 1,
  75. };
  76. public SharedPlugin:__pl_unusual =
  77. {
  78. name = "unusual",
  79. file = "unusual.smx",
  80. required = 1,
  81. };
  82. public SharedPlugin:__pl_FF2 =
  83. {
  84. name = "freak_fortress_2",
  85. file = "freak_fortress_2.smx",
  86. required = 0,
  87. };
  88. new ClientItemData[66][10][3];
  89. new String:SteamUsed[66][64];
  90. new String:ClientSteamID[66][64];
  91. new String:EffectsList[256];
  92. new String:PermissionsFile[256];
  93. new Effect[66];
  94. new Quality[66];
  95. new ClientItems[66];
  96. new NbOfEffect[66];
  97. new ItemDataInLoad[66];
  98. new bool:SQLite;
  99. new bool:IsFF2Enabled;
  100. new bool:StopItemLoading[66];
  101. new bool:AT_Choice_add[66];
  102. new Permission[22];
  103. new FlagsList[21] =
  104. {
  105. 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 32768, 65536, 131072, 262144, 524288, 1048576, 16384
  106. };
  107. new Handle:db;
  108. new Handle:c_tag;
  109. new Handle:c_TeamRest;
  110. new Handle:c_PanelFlag;
  111. new Handle:c_FF2;
  112. new Handle:g_hItem;
  113. public Plugin:myinfo =
  114. {
  115. name = "Unusual - 2017",
  116. description = "Add Unusual effects on your weapons",
  117. author = "Erreur 500 and StoKer",
  118. version = "2.19",
  119. url = "bramrekots@gmail.com"
  120. };
  121. public __ext_core_SetNTVOptional()
  122. {
  123. MarkNativeAsOptional("GetFeatureStatus");
  124. MarkNativeAsOptional("RequireFeature");
  125. MarkNativeAsOptional("AddCommandListener");
  126. MarkNativeAsOptional("RemoveCommandListener");
  127. MarkNativeAsOptional("BfWriteBool");
  128. MarkNativeAsOptional("BfWriteByte");
  129. MarkNativeAsOptional("BfWriteChar");
  130. MarkNativeAsOptional("BfWriteShort");
  131. MarkNativeAsOptional("BfWriteWord");
  132. MarkNativeAsOptional("BfWriteNum");
  133. MarkNativeAsOptional("BfWriteFloat");
  134. MarkNativeAsOptional("BfWriteString");
  135. MarkNativeAsOptional("BfWriteEntity");
  136. MarkNativeAsOptional("BfWriteAngle");
  137. MarkNativeAsOptional("BfWriteCoord");
  138. MarkNativeAsOptional("BfWriteVecCoord");
  139. MarkNativeAsOptional("BfWriteVecNormal");
  140. MarkNativeAsOptional("BfWriteAngles");
  141. MarkNativeAsOptional("BfReadBool");
  142. MarkNativeAsOptional("BfReadByte");
  143. MarkNativeAsOptional("BfReadChar");
  144. MarkNativeAsOptional("BfReadShort");
  145. MarkNativeAsOptional("BfReadWord");
  146. MarkNativeAsOptional("BfReadNum");
  147. MarkNativeAsOptional("BfReadFloat");
  148. MarkNativeAsOptional("BfReadString");
  149. MarkNativeAsOptional("BfReadEntity");
  150. MarkNativeAsOptional("BfReadAngle");
  151. MarkNativeAsOptional("BfReadCoord");
  152. MarkNativeAsOptional("BfReadVecCoord");
  153. MarkNativeAsOptional("BfReadVecNormal");
  154. MarkNativeAsOptional("BfReadAngles");
  155. MarkNativeAsOptional("BfGetNumBytesLeft");
  156. MarkNativeAsOptional("BfWrite.WriteBool");
  157. MarkNativeAsOptional("BfWrite.WriteByte");
  158. MarkNativeAsOptional("BfWrite.WriteChar");
  159. MarkNativeAsOptional("BfWrite.WriteShort");
  160. MarkNativeAsOptional("BfWrite.WriteWord");
  161. MarkNativeAsOptional("BfWrite.WriteNum");
  162. MarkNativeAsOptional("BfWrite.WriteFloat");
  163. MarkNativeAsOptional("BfWrite.WriteString");
  164. MarkNativeAsOptional("BfWrite.WriteEntity");
  165. MarkNativeAsOptional("BfWrite.WriteAngle");
  166. MarkNativeAsOptional("BfWrite.WriteCoord");
  167. MarkNativeAsOptional("BfWrite.WriteVecCoord");
  168. MarkNativeAsOptional("BfWrite.WriteVecNormal");
  169. MarkNativeAsOptional("BfWrite.WriteAngles");
  170. MarkNativeAsOptional("BfRead.ReadBool");
  171. MarkNativeAsOptional("BfRead.ReadByte");
  172. MarkNativeAsOptional("BfRead.ReadChar");
  173. MarkNativeAsOptional("BfRead.ReadShort");
  174. MarkNativeAsOptional("BfRead.ReadWord");
  175. MarkNativeAsOptional("BfRead.ReadNum");
  176. MarkNativeAsOptional("BfRead.ReadFloat");
  177. MarkNativeAsOptional("BfRead.ReadString");
  178. MarkNativeAsOptional("BfRead.ReadEntity");
  179. MarkNativeAsOptional("BfRead.ReadAngle");
  180. MarkNativeAsOptional("BfRead.ReadCoord");
  181. MarkNativeAsOptional("BfRead.ReadVecCoord");
  182. MarkNativeAsOptional("BfRead.ReadVecNormal");
  183. MarkNativeAsOptional("BfRead.ReadAngles");
  184. MarkNativeAsOptional("BfRead.GetNumBytesLeft");
  185. MarkNativeAsOptional("PbReadInt");
  186. MarkNativeAsOptional("PbReadFloat");
  187. MarkNativeAsOptional("PbReadBool");
  188. MarkNativeAsOptional("PbReadString");
  189. MarkNativeAsOptional("PbReadColor");
  190. MarkNativeAsOptional("PbReadAngle");
  191. MarkNativeAsOptional("PbReadVector");
  192. MarkNativeAsOptional("PbReadVector2D");
  193. MarkNativeAsOptional("PbGetRepeatedFieldCount");
  194. MarkNativeAsOptional("PbSetInt");
  195. MarkNativeAsOptional("PbSetFloat");
  196. MarkNativeAsOptional("PbSetBool");
  197. MarkNativeAsOptional("PbSetString");
  198. MarkNativeAsOptional("PbSetColor");
  199. MarkNativeAsOptional("PbSetAngle");
  200. MarkNativeAsOptional("PbSetVector");
  201. MarkNativeAsOptional("PbSetVector2D");
  202. MarkNativeAsOptional("PbAddInt");
  203. MarkNativeAsOptional("PbAddFloat");
  204. MarkNativeAsOptional("PbAddBool");
  205. MarkNativeAsOptional("PbAddString");
  206. MarkNativeAsOptional("PbAddColor");
  207. MarkNativeAsOptional("PbAddAngle");
  208. MarkNativeAsOptional("PbAddVector");
  209. MarkNativeAsOptional("PbAddVector2D");
  210. MarkNativeAsOptional("PbRemoveRepeatedFieldValue");
  211. MarkNativeAsOptional("PbReadMessage");
  212. MarkNativeAsOptional("PbReadRepeatedMessage");
  213. MarkNativeAsOptional("PbAddMessage");
  214. MarkNativeAsOptional("Protobuf.ReadInt");
  215. MarkNativeAsOptional("Protobuf.ReadFloat");
  216. MarkNativeAsOptional("Protobuf.ReadBool");
  217. MarkNativeAsOptional("Protobuf.ReadString");
  218. MarkNativeAsOptional("Protobuf.ReadColor");
  219. MarkNativeAsOptional("Protobuf.ReadAngle");
  220. MarkNativeAsOptional("Protobuf.ReadVector");
  221. MarkNativeAsOptional("Protobuf.ReadVector2D");
  222. MarkNativeAsOptional("Protobuf.GetRepeatedFieldCount");
  223. MarkNativeAsOptional("Protobuf.SetInt");
  224. MarkNativeAsOptional("Protobuf.SetFloat");
  225. MarkNativeAsOptional("Protobuf.SetBool");
  226. MarkNativeAsOptional("Protobuf.SetString");
  227. MarkNativeAsOptional("Protobuf.SetColor");
  228. MarkNativeAsOptional("Protobuf.SetAngle");
  229. MarkNativeAsOptional("Protobuf.SetVector");
  230. MarkNativeAsOptional("Protobuf.SetVector2D");
  231. MarkNativeAsOptional("Protobuf.AddInt");
  232. MarkNativeAsOptional("Protobuf.AddFloat");
  233. MarkNativeAsOptional("Protobuf.AddBool");
  234. MarkNativeAsOptional("Protobuf.AddString");
  235. MarkNativeAsOptional("Protobuf.AddColor");
  236. MarkNativeAsOptional("Protobuf.AddAngle");
  237. MarkNativeAsOptional("Protobuf.AddVector");
  238. MarkNativeAsOptional("Protobuf.AddVector2D");
  239. MarkNativeAsOptional("Protobuf.RemoveRepeatedFieldValue");
  240. MarkNativeAsOptional("Protobuf.ReadMessage");
  241. MarkNativeAsOptional("Protobuf.ReadRepeatedMessage");
  242. MarkNativeAsOptional("Protobuf.AddMessage");
  243. VerifyCoreVersion();
  244. return 0;
  245. }
  246.  
  247. Float:operator*(Float:,_:)(Float:oper1, oper2)
  248. {
  249. return oper1 * float(oper2);
  250. }
  251.  
  252. bool:StrEqual(String:str1[], String:str2[], bool:caseSensitive)
  253. {
  254. return strcmp(str1, str2, caseSensitive) == 0;
  255. }
  256.  
  257. CharToLower(chr)
  258. {
  259. if (IsCharUpper(chr))
  260. {
  261. return chr | 32;
  262. }
  263. return chr;
  264. }
  265.  
  266. Handle:StartMessageOne(String:msgname[], client, flags)
  267. {
  268. new players[1];
  269. players[0] = client;
  270. return StartMessage(msgname, players, 1, flags);
  271. }
  272.  
  273. ShowMOTDPanel(client, String:title[], String:msg[], type)
  274. {
  275. new String:num[4];
  276. IntToString(type, num, 3);
  277. new KeyValues:kv = KeyValues.KeyValues("data", "", "");
  278. KeyValues.SetString(kv, "title", title);
  279. KeyValues.SetString(kv, "type", num);
  280. KeyValues.SetString(kv, "msg", msg);
  281. ShowVGUIPanel(client, "info", kv, true);
  282. CloseHandle(kv);
  283. kv = MissingTAG:0;
  284. return 0;
  285. }
  286.  
  287. SetEntityHealth(entity, amount)
  288. {
  289. static bool:gotconfig;
  290. static String:prop[32];
  291. if (!gotconfig)
  292. {
  293. new Handle:gc = LoadGameConfigFile("core.games");
  294. new bool:exists = GameConfGetKeyValue(gc, "m_iHealth", prop, 32);
  295. CloseHandle(gc);
  296. if (!exists)
  297. {
  298. strcopy(prop, 32, "m_iHealth");
  299. }
  300. gotconfig = true;
  301. }
  302. decl String:cls[64];
  303. new PropFieldType:type;
  304. new offset;
  305. if (!GetEntityNetClass(entity, cls, 64))
  306. {
  307. ThrowError("SetEntityHealth not supported by this mod: Could not get serverclass name");
  308. return 0;
  309. }
  310. offset = FindSendPropInfo(cls, prop, type, 0, 0);
  311. if (0 >= offset)
  312. {
  313. ThrowError("SetEntityHealth not supported by this mod");
  314. return 0;
  315. }
  316. if (type == PropFieldType:2)
  317. {
  318. SetEntDataFloat(entity, offset, float(amount), false);
  319. }
  320. else
  321. {
  322. SetEntProp(entity, PropType:0, prop, amount, 4, 0);
  323. }
  324. return 0;
  325. }
  326.  
  327. TFClassType:TF2_GetPlayerClass(client)
  328. {
  329. return GetEntProp(client, PropType:0, TFResourceNames, 4, 0);
  330. }
  331.  
  332. TF2_RemoveWeaponSlot(client, slot)
  333. {
  334. new weaponIndex;
  335. while ((weaponIndex = GetPlayerWeaponSlot(client, slot)) != -1)
  336. {
  337. new extraWearable = GetEntPropEnt(weaponIndex, PropType:0, "m_hExtraWearable", 0);
  338. if (extraWearable != -1)
  339. {
  340. TF2_RemoveWearable(client, extraWearable);
  341. }
  342. extraWearable = GetEntPropEnt(weaponIndex, PropType:0, "m_hExtraWearableViewModel", 0);
  343. if (extraWearable != -1)
  344. {
  345. TF2_RemoveWearable(client, extraWearable);
  346. }
  347. RemovePlayerItem(client, weaponIndex);
  348. AcceptEntityInput(weaponIndex, "Kill", -1, -1, 0);
  349. }
  350. return 0;
  351. }
  352.  
  353. CPrintToChat(client, String:message[])
  354. {
  355. CCheckTrie();
  356. new var1;
  357. if (client <= 0 || client > MaxClients)
  358. {
  359. ThrowError("Invalid client index %i", client);
  360. }
  361. if (!IsClientInGame(client))
  362. {
  363. ThrowError("Client %i is not in game", client);
  364. }
  365. decl String:buffer[1024];
  366. decl String:buffer2[1024];
  367. SetGlobalTransTarget(client);
  368. Format(buffer, 1024, "\x01%s", message);
  369. VFormat(buffer2, 1024, buffer, 3);
  370. CReplaceColorCodes(buffer2, 0, false, 1024);
  371. CSendMessage(client, buffer2, 0);
  372. return 0;
  373. }
  374.  
  375. CSendMessage(client, String:message[], author)
  376. {
  377. if (!author)
  378. {
  379. author = client;
  380. }
  381. decl String:buffer[256];
  382. decl String:game[16];
  383. GetGameFolderName(game, 16);
  384. strcopy(buffer, 256, message);
  385. new UserMsg:index = GetUserMessageId("SayText2");
  386. if (index == UserMsg:-1)
  387. {
  388. if (StrEqual(game, "dod", true))
  389. {
  390. new team = GetClientTeam(author);
  391. if (team)
  392. {
  393. decl String:temp[16];
  394. new var2 = CTeamColors;
  395. Format(temp, 16, "\x07%06X", var2[0][var2][team + -1]);
  396. ReplaceString(buffer, 256, "\x03", temp, false);
  397. }
  398. else
  399. {
  400. ReplaceString(buffer, 256, "\x03", "\x04", false);
  401. }
  402. }
  403. PrintToChat(client, "%s", buffer);
  404. return 0;
  405. }
  406. new Handle:buf = StartMessageOne("SayText2", client, 132);
  407. new var1;
  408. if (GetFeatureStatus(FeatureType:0, "GetUserMessageType") && GetUserMessageType() == 1)
  409. {
  410. PbSetInt(buf, "ent_idx", author, -1);
  411. PbSetBool(buf, "chat", true, -1);
  412. PbSetString(buf, "msg_name", buffer, -1);
  413. PbAddString(buf, "params", "");
  414. PbAddString(buf, "params", "");
  415. PbAddString(buf, "params", "");
  416. PbAddString(buf, "params", "");
  417. }
  418. else
  419. {
  420. BfWriteByte(buf, author);
  421. BfWriteByte(buf, 1);
  422. BfWriteString(buf, buffer);
  423. }
  424. EndMessage();
  425. return 0;
  426. }
  427.  
  428. CCheckTrie()
  429. {
  430. if (!CSkipList[0])
  431. {
  432. CSkipList[0] = InitColorTrie();
  433. }
  434. return 0;
  435. }
  436.  
  437. CReplaceColorCodes(String:buffer[], author, bool:removeTags, maxlen)
  438. {
  439. CCheckTrie();
  440. if (!removeTags)
  441. {
  442. ReplaceString(buffer, maxlen, "{default}", "\x01", false);
  443. }
  444. else
  445. {
  446. ReplaceString(buffer, maxlen, "{default}", "", false);
  447. ReplaceString(buffer, maxlen, "{teamcolor}", "", false);
  448. }
  449. new var1;
  450. if (author && !removeTags)
  451. {
  452. new var2;
  453. if (author < 0 || author > MaxClients)
  454. {
  455. ThrowError("Invalid client index %i", author);
  456. }
  457. if (!IsClientInGame(author))
  458. {
  459. ThrowError("Client %i is not in game", author);
  460. }
  461. ReplaceString(buffer, maxlen, "{teamcolor}", "\x03", false);
  462. }
  463. new cursor;
  464. new value;
  465. decl String:tag[32];
  466. decl String:buff[32];
  467. decl output[maxlen];
  468. strcopy(output, maxlen, buffer);
  469. new Handle:regex = CompileRegex("{[a-zA-Z0-9]+}", 0, "", 0, 0);
  470. new i;
  471. while (i < 1000)
  472. {
  473. if (MatchRegex(regex, buffer[cursor], 0) < 1)
  474. {
  475. CloseHandle(regex);
  476. strcopy(buffer, maxlen, output);
  477. return 0;
  478. }
  479. GetRegexSubString(regex, 0, tag, 32);
  480. CStrToLower(tag);
  481. cursor = StrContains(buffer[cursor], tag, false) + cursor + 1;
  482. strcopy(buff, 32, tag);
  483. ReplaceString(buff, 32, "{", "", true);
  484. ReplaceString(buff, 32, "}", "", true);
  485. if (GetTrieValue(CSkipList[0], buff, value))
  486. {
  487. if (removeTags)
  488. {
  489. ReplaceString(output, maxlen, tag, "", false);
  490. }
  491. else
  492. {
  493. Format(buff, 32, "\x07%06X", value);
  494. ReplaceString(output, maxlen, tag, buff, false);
  495. }
  496. }
  497. i++;
  498. }
  499. LogError("[MORE COLORS] Infinite loop broken.");
  500. return 0;
  501. }
  502.  
  503. CStrToLower(String:buffer[])
  504. {
  505. new len = strlen(buffer);
  506. new i;
  507. while (i < len)
  508. {
  509. buffer[i] = CharToLower(buffer[i]);
  510. i++;
  511. }
  512. return 0;
  513. }
  514.  
  515. Handle:InitColorTrie()
  516. {
  517. new Handle:hTrie = CreateTrie();
  518. SetTrieValue(hTrie, "aliceblue", any:15792383, true);
  519. SetTrieValue(hTrie, "allies", any:5077314, true);
  520. SetTrieValue(hTrie, "ancient", any:15420235, true);
  521. SetTrieValue(hTrie, "antiquewhite", any:16444375, true);
  522. SetTrieValue(hTrie, "aqua", any:65535, true);
  523. SetTrieValue(hTrie, "aquamarine", any:8388564, true);
  524. SetTrieValue(hTrie, "arcana", any:11396444, true);
  525. SetTrieValue(hTrie, "axis", any:16728128, true);
  526. SetTrieValue(hTrie, "azure", any:32767, true);
  527. SetTrieValue(hTrie, "beige", any:16119260, true);
  528. SetTrieValue(hTrie, "bisque", any:16770244, true);
  529. SetTrieValue(hTrie, "black", any:0, true);
  530. SetTrieValue(hTrie, "blanchedalmond", any:16772045, true);
  531. SetTrieValue(hTrie, "blue", any:10079487, true);
  532. SetTrieValue(hTrie, "blueviolet", any:9055202, true);
  533. SetTrieValue(hTrie, "brown", any:10824234, true);
  534. SetTrieValue(hTrie, "burlywood", any:14596231, true);
  535. SetTrieValue(hTrie, "cadetblue", any:6266528, true);
  536. SetTrieValue(hTrie, "chartreuse", any:8388352, true);
  537. SetTrieValue(hTrie, "chocolate", any:13789470, true);
  538. SetTrieValue(hTrie, "collectors", any:11141120, true);
  539. SetTrieValue(hTrie, "common", any:11584473, true);
  540. SetTrieValue(hTrie, "community", any:7385162, true);
  541. SetTrieValue(hTrie, "coral", any:16744272, true);
  542. SetTrieValue(hTrie, "cornflowerblue", any:6591981, true);
  543. SetTrieValue(hTrie, "cornsilk", any:16775388, true);
  544. SetTrieValue(hTrie, "corrupted", any:10693678, true);
  545. SetTrieValue(hTrie, "crimson", any:14423100, true);
  546. SetTrieValue(hTrie, "cyan", any:65535, true);
  547. SetTrieValue(hTrie, "darkblue", any:139, true);
  548. SetTrieValue(hTrie, "darkcyan", any:35723, true);
  549. SetTrieValue(hTrie, "darkgoldenrod", any:12092939, true);
  550. SetTrieValue(hTrie, "darkgray", any:11119017, true);
  551. SetTrieValue(hTrie, "darkgrey", any:11119017, true);
  552. SetTrieValue(hTrie, "darkgreen", any:25600, true);
  553. SetTrieValue(hTrie, "darkkhaki", any:12433259, true);
  554. SetTrieValue(hTrie, "darkmagenta", any:9109643, true);
  555. SetTrieValue(hTrie, "darkolivegreen", any:5597999, true);
  556. SetTrieValue(hTrie, "darkorange", any:16747520, true);
  557. SetTrieValue(hTrie, "darkorchid", any:10040012, true);
  558. SetTrieValue(hTrie, "darkred", any:9109504, true);
  559. SetTrieValue(hTrie, "darksalmon", any:15308410, true);
  560. SetTrieValue(hTrie, "darkseagreen", any:9419919, true);
  561. SetTrieValue(hTrie, "darkslateblue", any:4734347, true);
  562. SetTrieValue(hTrie, "darkslategray", any:3100495, true);
  563. SetTrieValue(hTrie, "darkslategrey", any:3100495, true);
  564. SetTrieValue(hTrie, "darkturquoise", any:52945, true);
  565. SetTrieValue(hTrie, "darkviolet", any:9699539, true);
  566. SetTrieValue(hTrie, "deeppink", any:16716947, true);
  567. SetTrieValue(hTrie, "deepskyblue", any:49151, true);
  568. SetTrieValue(hTrie, "dimgray", any:6908265, true);
  569. SetTrieValue(hTrie, "dimgrey", any:6908265, true);
  570. SetTrieValue(hTrie, "dodgerblue", any:2003199, true);
  571. SetTrieValue(hTrie, "exalted", any:13421773, true);
  572. SetTrieValue(hTrie, "firebrick", any:11674146, true);
  573. SetTrieValue(hTrie, "floralwhite", any:16775920, true);
  574. SetTrieValue(hTrie, "forestgreen", any:2263842, true);
  575. SetTrieValue(hTrie, "frozen", any:4817843, true);
  576. SetTrieValue(hTrie, "fuchsia", any:16711935, true);
  577. SetTrieValue(hTrie, "fullblue", any:255, true);
  578. SetTrieValue(hTrie, "fullred", any:16711680, true);
  579. SetTrieValue(hTrie, "gainsboro", any:14474460, true);
  580. SetTrieValue(hTrie, "genuine", any:5076053, true);
  581. SetTrieValue(hTrie, "ghostwhite", any:16316671, true);
  582. SetTrieValue(hTrie, "gold", any:16766720, true);
  583. SetTrieValue(hTrie, "goldenrod", any:14329120, true);
  584. SetTrieValue(hTrie, "gray", any:13421772, true);
  585. SetTrieValue(hTrie, "grey", any:13421772, true);
  586. SetTrieValue(hTrie, "green", any:4128574, true);
  587. SetTrieValue(hTrie, "greenyellow", any:11403055, true);
  588. SetTrieValue(hTrie, "haunted", any:3732395, true);
  589. SetTrieValue(hTrie, "honeydew", any:15794160, true);
  590. SetTrieValue(hTrie, "hotpink", any:16738740, true);
  591. SetTrieValue(hTrie, "immortal", any:14986803, true);
  592. SetTrieValue(hTrie, "indianred", any:13458524, true);
  593. SetTrieValue(hTrie, "indigo", any:4915330, true);
  594. SetTrieValue(hTrie, "ivory", any:16777200, true);
  595. SetTrieValue(hTrie, "khaki", any:15787660, true);
  596. SetTrieValue(hTrie, "lavender", any:15132410, true);
  597. SetTrieValue(hTrie, "lavenderblush", any:16773365, true);
  598. SetTrieValue(hTrie, "lawngreen", any:8190976, true);
  599. SetTrieValue(hTrie, "legendary", any:13839590, true);
  600. SetTrieValue(hTrie, "lemonchiffon", any:16775885, true);
  601. SetTrieValue(hTrie, "lightblue", any:11393254, true);
  602. SetTrieValue(hTrie, "lightcoral", any:15761536, true);
  603. SetTrieValue(hTrie, "lightcyan", any:14745599, true);
  604. SetTrieValue(hTrie, "lightgoldenrodyellow", any:16448210, true);
  605. SetTrieValue(hTrie, "lightgray", any:13882323, true);
  606. SetTrieValue(hTrie, "lightgrey", any:13882323, true);
  607. SetTrieValue(hTrie, "lightgreen", any:10092441, true);
  608. SetTrieValue(hTrie, "lightpink", any:16758465, true);
  609. SetTrieValue(hTrie, "lightsalmon", any:16752762, true);
  610. SetTrieValue(hTrie, "lightseagreen", any:2142890, true);
  611. SetTrieValue(hTrie, "lightskyblue", any:8900346, true);
  612. SetTrieValue(hTrie, "lightslategray", any:7833753, true);
  613. SetTrieValue(hTrie, "lightslategrey", any:7833753, true);
  614. SetTrieValue(hTrie, "lightsteelblue", any:11584734, true);
  615. SetTrieValue(hTrie, "lightyellow", any:16777184, true);
  616. SetTrieValue(hTrie, "lime", any:65280, true);
  617. SetTrieValue(hTrie, "limegreen", any:3329330, true);
  618. SetTrieValue(hTrie, "linen", any:16445670, true);
  619. SetTrieValue(hTrie, "magenta", any:16711935, true);
  620. SetTrieValue(hTrie, "maroon", any:8388608, true);
  621. SetTrieValue(hTrie, "mediumaquamarine", any:6737322, true);
  622. SetTrieValue(hTrie, "mediumblue", any:205, true);
  623. SetTrieValue(hTrie, "mediumorchid", any:12211667, true);
  624. SetTrieValue(hTrie, "mediumpurple", any:9662680, true);
  625. SetTrieValue(hTrie, "mediumseagreen", any:3978097, true);
  626. SetTrieValue(hTrie, "mediumslateblue", any:8087790, true);
  627. SetTrieValue(hTrie, "mediumspringgreen", any:64154, true);
  628. SetTrieValue(hTrie, "mediumturquoise", any:4772300, true);
  629. SetTrieValue(hTrie, "mediumvioletred", any:13047173, true);
  630. SetTrieValue(hTrie, "midnightblue", any:1644912, true);
  631. SetTrieValue(hTrie, "mintcream", any:16121850, true);
  632. SetTrieValue(hTrie, "mistyrose", any:16770273, true);
  633. SetTrieValue(hTrie, "moccasin", any:16770229, true);
  634. SetTrieValue(hTrie, "mythical", any:8931327, true);
  635. SetTrieValue(hTrie, "navajowhite", any:16768685, true);
  636. SetTrieValue(hTrie, "navy", any:128, true);
  637. SetTrieValue(hTrie, "normal", any:11711154, true);
  638. SetTrieValue(hTrie, "oldlace", any:16643558, true);
  639. SetTrieValue(hTrie, "olive", any:10404687, true);
  640. SetTrieValue(hTrie, "olivedrab", any:7048739, true);
  641. SetTrieValue(hTrie, "orange", any:16753920, true);
  642. SetTrieValue(hTrie, "orangered", any:16729344, true);
  643. SetTrieValue(hTrie, "orchid", any:14315734, true);
  644. SetTrieValue(hTrie, "palegoldenrod", any:15657130, true);
  645. SetTrieValue(hTrie, "palegreen", any:10025880, true);
  646. SetTrieValue(hTrie, "paleturquoise", any:11529966, true);
  647. SetTrieValue(hTrie, "palevioletred", any:14184595, true);
  648. SetTrieValue(hTrie, "papayawhip", any:16773077, true);
  649. SetTrieValue(hTrie, "peachpuff", any:16767673, true);
  650. SetTrieValue(hTrie, "peru", any:13468991, true);
  651. SetTrieValue(hTrie, "pink", any:16761035, true);
  652. SetTrieValue(hTrie, "plum", any:14524637, true);
  653. SetTrieValue(hTrie, "powderblue", any:11591910, true);
  654. SetTrieValue(hTrie, "purple", any:8388736, true);
  655. SetTrieValue(hTrie, "rare", any:4942335, true);
  656. SetTrieValue(hTrie, "red", any:16728128, true);
  657. SetTrieValue(hTrie, "rosybrown", any:12357519, true);
  658. SetTrieValue(hTrie, "royalblue", any:4286945, true);
  659. SetTrieValue(hTrie, "saddlebrown", any:9127187, true);
  660. SetTrieValue(hTrie, "salmon", any:16416882, true);
  661. SetTrieValue(hTrie, "sandybrown", any:16032864, true);
  662. SetTrieValue(hTrie, "seagreen", any:3050327, true);
  663. SetTrieValue(hTrie, "seashell", any:16774638, true);
  664. SetTrieValue(hTrie, "selfmade", any:7385162, true);
  665. SetTrieValue(hTrie, "sienna", any:10506797, true);
  666. SetTrieValue(hTrie, "silver", any:12632256, true);
  667. SetTrieValue(hTrie, "skyblue", any:8900331, true);
  668. SetTrieValue(hTrie, "slateblue", any:6970061, true);
  669. SetTrieValue(hTrie, "slategray", any:7372944, true);
  670. SetTrieValue(hTrie, "slategrey", any:7372944, true);
  671. SetTrieValue(hTrie, "snow", any:16775930, true);
  672. SetTrieValue(hTrie, "springgreen", any:65407, true);
  673. SetTrieValue(hTrie, "steelblue", any:4620980, true);
  674. SetTrieValue(hTrie, "strange", any:13593138, true);
  675. SetTrieValue(hTrie, "tan", any:13808780, true);
  676. SetTrieValue(hTrie, "teal", any:32896, true);
  677. SetTrieValue(hTrie, "thistle", any:14204888, true);
  678. SetTrieValue(hTrie, "tomato", any:16737095, true);
  679. SetTrieValue(hTrie, "turquoise", any:4251856, true);
  680. SetTrieValue(hTrie, "uncommon", any:11584473, true);
  681. SetTrieValue(hTrie, "unique", any:16766720, true);
  682. SetTrieValue(hTrie, "unusual", any:8802476, true);
  683. SetTrieValue(hTrie, "valve", any:10817401, true);
  684. SetTrieValue(hTrie, "vintage", any:4678289, true);
  685. SetTrieValue(hTrie, "violet", any:15631086, true);
  686. SetTrieValue(hTrie, "wheat", any:16113331, true);
  687. SetTrieValue(hTrie, "white", any:16777215, true);
  688. SetTrieValue(hTrie, "whitesmoke", any:16119285, true);
  689. SetTrieValue(hTrie, "yellow", any:16776960, true);
  690. SetTrieValue(hTrie, "yellowgreen", any:10145074, true);
  691. return hTrie;
  692. }
  693.  
  694. public __pl_FF2_SetNTVOptional()
  695. {
  696. MarkNativeAsOptional("FF2_IsFF2Enabled");
  697. MarkNativeAsOptional("FF2_GetBossUserId");
  698. MarkNativeAsOptional("FF2_GetBossIndex");
  699. MarkNativeAsOptional("FF2_GetBossTeam");
  700. MarkNativeAsOptional("FF2_GetBossSpecial");
  701. MarkNativeAsOptional("FF2_GetBossMaxHealth");
  702. MarkNativeAsOptional("FF2_GetBossCharge");
  703. MarkNativeAsOptional("FF2_SetBossCharge");
  704. MarkNativeAsOptional("FF2_GetClientDamage");
  705. MarkNativeAsOptional("FF2_GetRoundState");
  706. MarkNativeAsOptional("FF2_GetRageDist");
  707. MarkNativeAsOptional("FF2_HasAbility");
  708. MarkNativeAsOptional("FF2_GetAbilityArgument");
  709. MarkNativeAsOptional("FF2_GetAbilityArgumentFloat");
  710. MarkNativeAsOptional("FF2_GetAbilityArgumentString");
  711. MarkNativeAsOptional("FF2_RandomSound");
  712. MarkNativeAsOptional("FF2_StopMusic");
  713. MarkNativeAsOptional("FF2_GetSpecialKV");
  714. MarkNativeAsOptional("FF2_GetQueuePoints");
  715. MarkNativeAsOptional("FF2_SetQueuePoints");
  716. MarkNativeAsOptional("FF2_GetFF2flags");
  717. MarkNativeAsOptional("FF2_SetFF2flags");
  718. MarkNativeAsOptional("FF2_DoAbility");
  719. return 0;
  720. }
  721.  
  722. public void:OnPluginStart()
  723. {
  724. CreateConVar("unusual_version", "2.19", "Unusual version", 270592, false, 0.0, false, 0.0);
  725. c_tag = CreateConVar("unusual_tag", "1", "Enable 'unusual' tag", 262144, true, 0.0, true, 1.0);
  726. c_TeamRest = CreateConVar("unusual_team_restriction", "0", "0 = no restriction, 1 = red, 2 = blue can't have unusual effects", 262144, true, 0.0, true, 2.0);
  727. c_PanelFlag = CreateConVar("unusual_panel_flag", "0", "0 = ADMFLAG_ROOT, 1 = ADMFLAG_GENERIC", 262144, true, 0.0, true, 1.0);
  728. c_FF2 = CreateConVar("unusual_fix_ff2boss", "1", "0 = boss can have unusual effects, 1 = boss can't", 262144, true, 0.0, true, 1.0);
  729. RegConsoleCmd("unusual", OpenMenu, "Get unusual effect on your weapons", 0);
  730. RegAdminCmd("unusual_control", ControlPlayer, 2, "", "", 0);
  731. RegAdminCmd("unusual_permissions", reloadPermissions, 2, "", "", 0);
  732. LoadTranslations("unusual.phrases");
  733. Connect();
  734. BuildPath(PathType:0, EffectsList, 256, "configs/%s", "unusual_list.cfg");
  735. BuildPath(PathType:0, PermissionsFile, 256, "configs/%s", "unusual_permissions.cfg");
  736. decl String:PlayerInfo[64];
  737. new i = 1;
  738. while (i < MaxClients)
  739. {
  740. if (IsValidClient(i))
  741. {
  742. GetClientAuthId(i, AuthIdType:1, PlayerInfo, 64, true);
  743. strcopy(ClientSteamID[i], 64, PlayerInfo);
  744. }
  745. new j;
  746. while (j < 10)
  747. {
  748. ClientItemData[i][j][0] = -1;
  749. j++;
  750. }
  751. i++;
  752. }
  753. g_hItem = TF2Items_CreateItem(48);
  754. TF2Items_SetNumAttributes(g_hItem, 1);
  755. return void:0;
  756. }
  757.  
  758. public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
  759. {
  760. CreateNative("UE_RemoveEffect", Native_RemoveEffect);
  761. CreateNative("UE_RemovePlayerEffects", Native_RemovePlayerEffects);
  762. CreateNative("UE_GetUnusualEffectPermission", Native_GetUnusualEffectPermission);
  763. CreateNative("UE_SetUnusualEffectPermission", Native_SetUnusualEffectPermission);
  764. return APLRes:0;
  765. }
  766.  
  767. public void:OnMapStart()
  768. {
  769. if (LoadPermissions())
  770. {
  771. LogMessage("Unusual effects permissions loaded !");
  772. if (LibraryExists("freak_fortress_2"))
  773. {
  774. IsFF2Enabled = FF2_IsFF2Enabled();
  775. }
  776. }
  777. else
  778. {
  779. LogMessage("Error while charging permissions !");
  780. IsFF2Enabled = false;
  781. }
  782. return void:0;
  783. }
  784.  
  785. public void:OnConfigsExecuted()
  786. {
  787. if (GetConVarBool(c_tag))
  788. {
  789. TagsCheck("unusual");
  790. }
  791. return void:0;
  792. }
  793.  
  794. TagsCheck(String:tag[])
  795. {
  796. new Handle:hTags = FindConVar("sv_tags");
  797. decl String:tags[256];
  798. GetConVarString(hTags, tags, 255);
  799. if (!StrContains(tags, tag, false) > -1)
  800. {
  801. decl String:newTags[256];
  802. Format(newTags, 255, "%s,%s", tags, tag);
  803. SetConVarString(hTags, newTags, false, false);
  804. }
  805. CloseHandle(hTags);
  806. return 0;
  807. }
  808.  
  809. public void:OnClientAuthorized(iClient, String:auth[])
  810. {
  811. strcopy(ClientSteamID[iClient], 64, auth);
  812. new j;
  813. while (j < 10)
  814. {
  815. ClientItemData[iClient][j][0] = -1;
  816. j++;
  817. }
  818. return void:0;
  819. }
  820.  
  821. Connect()
  822. {
  823. if (SQL_CheckConfig("unusual"))
  824. {
  825. SQL_TConnect(Connected, "unusual", any:0);
  826. }
  827. else
  828. {
  829. new String:error[256];
  830. SQLite = true;
  831. new Handle:kv = CreateKeyValues("", "", "");
  832. KvSetString(kv, "driver", "sqlite");
  833. KvSetString(kv, "database", "unusual");
  834. db = SQL_ConnectCustom(kv, error, 255, false);
  835. CloseHandle(kv);
  836. if (db)
  837. {
  838. LogMessage("Loading : Connected to SQLite Database");
  839. CreateDbSQLite();
  840. }
  841. else
  842. {
  843. LogMessage("Loading : Failed to connect: %s", error);
  844. }
  845. }
  846. return 0;
  847. }
  848.  
  849. public Connected(Handle:owner, Handle:hndl, String:error[], any:data)
  850. {
  851. if (hndl)
  852. {
  853. LogMessage("Loading : Connected to MySQL Database");
  854. SQL_TQuery(hndl, SQLErrorCheckCallback, "SET NAMES 'utf8'", any:0, DBPriority:1);
  855. db = hndl;
  856. SQL_CreateTables();
  857. return 0;
  858. }
  859. LogError("Failed to connect! Error: %s", error);
  860. LogMessage("Loading : Failed to connect! Error: %s", error);
  861. SetFailState("SQL Error. See error logs for details.");
  862. return 0;
  863. }
  864.  
  865. SQL_CreateTables()
  866. {
  867. new len;
  868. decl String:query[512];
  869. len = Format(query[len], 512 - len, "CREATE TABLE IF NOT EXISTS `unusual_data` (") + len;
  870. len = Format(query[len], 512 - len, "`ue_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, ") + len;
  871. len = Format(query[len], 512 - len, "`user_steamID` VARCHAR(64) NOT NULL, ") + len;
  872. len = Format(query[len], 512 - len, "`item_ID` int(11) NOT NULL DEFAULT '-1', ") + len;
  873. len = Format(query[len], 512 - len, "`effect_ID` int(11) NOT NULL DEFAULT '-1', ") + len;
  874. len = Format(query[len], 512 - len, "`quality_ID` int(11) NOT NULL DEFAULT '-1', ") + len;
  875. len = Format(query[len], 512 - len, "PRIMARY KEY (`ue_ID`)") + len;
  876. len = Format(query[len], 512 - len, ") ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;") + len;
  877. if (SQL_FastQuery(db, query, -1))
  878. {
  879. LogMessage("Loading : Table Created");
  880. }
  881. return 0;
  882. }
  883.  
  884. CreateDbSQLite()
  885. {
  886. new len;
  887. decl String:query[512];
  888. len = Format(query[len], 512 - len, "CREATE TABLE IF NOT EXISTS `unusual_data` (") + len;
  889. len = Format(query[len], 512 - len, " `ID` INTEGER PRIMARY KEY AUTOINCREMENT,") + len;
  890. len = Format(query[len], 512 - len, " `user_steamID` VARCHAR(64),") + len;
  891. len = Format(query[len], 512 - len, " `item_ID` INTEGER DEFAULT -1,") + len;
  892. len = Format(query[len], 512 - len, " `effect_ID` INTEGER DEFAULT -1,") + len;
  893. len = Format(query[len], 512 - len, " `quality_ID` INTEGER DEFAULT -1") + len;
  894. len = Format(query[len], 512 - len, ");") + len;
  895. if (SQL_FastQuery(db, query, -1))
  896. {
  897. LogMessage("Loading : Table Created");
  898. }
  899. return 0;
  900. }
  901.  
  902. public SQLErrorCheckCallback(Handle:owner, Handle:hndl, String:error[], any:data)
  903. {
  904. if (!StrEqual("", error, true))
  905. {
  906. LogError("SQL Error: %s", error);
  907. }
  908. return 0;
  909. }
  910.  
  911. GetClientID(String:PlayerSteamID[64])
  912. {
  913. if (StrEqual(PlayerSteamID, "", true))
  914. {
  915. return -1;
  916. }
  917. new iClient = -1;
  918. new i = 1;
  919. while (i < MaxClients)
  920. {
  921. if (IsValidClient(i))
  922. {
  923. if (StrEqual(ClientSteamID[i], PlayerSteamID, true))
  924. {
  925. iClient = i;
  926. i++;
  927. }
  928. }
  929. i++;
  930. }
  931. return iClient;
  932. }
  933.  
  934. bool:IsValidClient(iClient)
  935. {
  936. if (0 >= iClient)
  937. {
  938. return false;
  939. }
  940. if (iClient > MaxClients)
  941. {
  942. return false;
  943. }
  944. return IsClientInGame(iClient);
  945. }
  946.  
  947. public Action:OpenMenu(iClient, Args)
  948. {
  949. FirstMenu(iClient);
  950. return Action:0;
  951. }
  952.  
  953. public Action:ControlPlayer(iClient, Args)
  954. {
  955. new i = 1;
  956. while (i < MaxClients)
  957. {
  958. if (IsClientInGame(i))
  959. {
  960. Updating(i);
  961. }
  962. i++;
  963. }
  964. if (IsValidClient(iClient))
  965. {
  966. PrintToChat(iClient, "All Players have been controlled !");
  967. }
  968. else
  969. {
  970. LogMessage("All Players have been controlled !");
  971. }
  972. return Action:0;
  973. }
  974.  
  975. public Action:reloadPermissions(iClient, Args)
  976. {
  977. if (LoadPermissions())
  978. {
  979. if (IsValidClient(iClient))
  980. {
  981. PrintToChat(iClient, "Unusual effects permissions reloaded !");
  982. }
  983. else
  984. {
  985. LogMessage("Unusual effects permissions reloaded !");
  986. }
  987. }
  988. else
  989. {
  990. if (IsValidClient(iClient))
  991. {
  992. PrintToChat(iClient, "Error while recharging permissions !");
  993. }
  994. LogMessage("Error while recharging permissions !");
  995. }
  996. return Action:0;
  997. }
  998.  
  999. bool:LoadPermissions()
  1000. {
  1001. new Handle:kv = CreateKeyValues("Unusual_permissions", "", "");
  1002. if (!FileToKeyValues(kv, PermissionsFile))
  1003. {
  1004. LogError("Can't open %s file", "unusual_permissions.cfg");
  1005. CloseHandle(kv);
  1006. return false;
  1007. }
  1008. KvGotoFirstSubKey(kv, true);
  1009. Permission[0] = KvGetNum(kv, "0", 0);
  1010. Permission[1] = KvGetNum(kv, "a", 0);
  1011. Permission[2] = KvGetNum(kv, "b", 0);
  1012. Permission[3] = KvGetNum(kv, "c", 0);
  1013. Permission[4] = KvGetNum(kv, "d", 0);
  1014. Permission[5] = KvGetNum(kv, "e", 0);
  1015. Permission[6] = KvGetNum(kv, "f", 0);
  1016. Permission[7] = KvGetNum(kv, "g", 0);
  1017. Permission[8] = KvGetNum(kv, "h", 0);
  1018. Permission[9] = KvGetNum(kv, "i", 0);
  1019. Permission[10] = KvGetNum(kv, "j", 0);
  1020. Permission[11] = KvGetNum(kv, "k", 0);
  1021. Permission[12] = KvGetNum(kv, "l", 0);
  1022. Permission[13] = KvGetNum(kv, "m", 0);
  1023. Permission[14] = KvGetNum(kv, "n", 0);
  1024. Permission[15] = KvGetNum(kv, "o", 0);
  1025. Permission[16] = KvGetNum(kv, "p", 0);
  1026. Permission[17] = KvGetNum(kv, "q", 0);
  1027. Permission[18] = KvGetNum(kv, "r", 0);
  1028. Permission[19] = KvGetNum(kv, "s", 0);
  1029. Permission[20] = KvGetNum(kv, "t", 0);
  1030. Permission[21] = KvGetNum(kv, "z", 0);
  1031. CloseHandle(kv);
  1032. return true;
  1033. }
  1034.  
  1035. bool:isAuthorized(iClient, bool:Strict)
  1036. {
  1037. new Limit = GetLimit(GetUserFlagBits(iClient));
  1038. if (Limit == -1)
  1039. {
  1040. return true;
  1041. }
  1042. new var1;
  1043. if (Strict && NbOfEffect[iClient] < Limit)
  1044. {
  1045. return true;
  1046. }
  1047. new var2;
  1048. if (!Strict && NbOfEffect[iClient] <= Limit)
  1049. {
  1050. return true;
  1051. }
  1052. return false;
  1053. }
  1054.  
  1055. GetLimit(flags)
  1056. {
  1057. new Limit;
  1058. new i;
  1059. if (!flags)
  1060. {
  1061. return Permission[0];
  1062. }
  1063. do {
  1064. new var2;
  1065. if (FlagsList[i] & flags && (Limit < Permission[i + 1] || Permission[i + 1] == -1))
  1066. {
  1067. Limit = Permission[i + 1];
  1068. }
  1069. i++;
  1070. new var3;
  1071. if (!(Limit != -1 && i < 21))
  1072. {
  1073. return Limit;
  1074. }
  1075. } while (var3);
  1076. return Limit;
  1077. }
  1078.  
  1079. public void:OnClientDisconnect(iClient)
  1080. {
  1081. if (!IsValidClient(iClient))
  1082. {
  1083. return void:0;
  1084. }
  1085. new i;
  1086. while (i < 10)
  1087. {
  1088. ClientItemData[iClient][i][0] = -1;
  1089. i++;
  1090. }
  1091. return void:0;
  1092. }
  1093.  
  1094. Updating(iClient)
  1095. {
  1096. new String:buffer[128];
  1097. Format(buffer, 128, "SELECT COUNT(`user_steamID`) AS NB FROM unusual_data WHERE `user_steamID` = '%s'", ClientSteamID[iClient]);
  1098. SQL_TQuery(db, T_ClientControl, buffer, iClient, DBPriority:1);
  1099. return 0;
  1100. }
  1101.  
  1102. public T_ClientControl(Handle:owner, Handle:hndl, String:error[], any:iClient)
  1103. {
  1104. if (!SQL_GetRowCount(hndl))
  1105. {
  1106. NbOfEffect[iClient] = 0;
  1107. return 0;
  1108. }
  1109. while (SQL_FetchRow(hndl))
  1110. {
  1111. NbOfEffect[iClient] = SQL_FetchInt(hndl, 0, 0);
  1112. }
  1113. if (!isAuthorized(iClient, false))
  1114. {
  1115. CPrintToChat(iClient, "%t", "Sent6");
  1116. RemoveEffect(iClient, ClientSteamID[iClient], "-1");
  1117. }
  1118. else
  1119. {
  1120. new String:buffer[128];
  1121. Format(buffer, 128, "SELECT DISTINCT `effect_ID` FROM unusual_data WHERE `user_steamID` = '%s'", ClientSteamID[iClient]);
  1122. SQL_TQuery(db, T_ClientControl2, buffer, iClient, DBPriority:1);
  1123. }
  1124. return 0;
  1125. }
  1126.  
  1127. public T_ClientControl2(Handle:owner, Handle:hndl, String:error[], any:iClient)
  1128. {
  1129. if (!SQL_GetRowCount(hndl))
  1130. {
  1131. return 0;
  1132. }
  1133. new Handle:kv = CreateKeyValues("Unusual_effects", "", "");
  1134. if (!FileToKeyValues(kv, EffectsList))
  1135. {
  1136. LogError("[UNUSUAL] Could not open file %s", "unusual_list.cfg");
  1137. CloseHandle(kv);
  1138. return 0;
  1139. }
  1140. new EffectID;
  1141. new String:EffectFlag[4];
  1142. new String:str_EffectID[8];
  1143. while (SQL_FetchRow(hndl))
  1144. {
  1145. EffectID = SQL_FetchInt(hndl, 0, 0);
  1146. Format(str_EffectID, 8, "%i", EffectID);
  1147. if (!KvJumpToKey(kv, str_EffectID, false))
  1148. {
  1149. LogMessage("DB contain effectID that do not exist: %i", EffectID);
  1150. KvRewind(kv);
  1151. }
  1152. KvGetString(kv, "flag", EffectFlag, 2, "");
  1153. KvRewind(kv);
  1154. if (!IsClientUEAllowed(iClient, EffectFlag))
  1155. {
  1156. new String:buffer[128];
  1157. Format(buffer, 128, "SELECT `item_ID` FROM unusual_data WHERE `user_steamID` = '%s' AND `effect_ID` = %i", ClientSteamID[iClient], EffectID);
  1158. SQL_TQuery(db, T_ClientRemoveEffect, buffer, iClient, DBPriority:1);
  1159. }
  1160. }
  1161. CloseHandle(kv);
  1162. return 0;
  1163. }
  1164.  
  1165. public T_ClientRemoveEffect(Handle:owner, Handle:hndl, String:error[], any:iClient)
  1166. {
  1167. if (!SQL_GetRowCount(hndl))
  1168. {
  1169. return 0;
  1170. }
  1171. while (SQL_FetchRow(hndl))
  1172. {
  1173. new String:str_ItemID[12];
  1174. Format(str_ItemID, 10, "%i", SQL_FetchInt(hndl, 0, 0));
  1175. RemoveEffect(iClient, ClientSteamID[iClient], str_ItemID);
  1176. }
  1177. return 0;
  1178. }
  1179.  
  1180. FixItemSlot(iItemDefinitionIndex, TFClassType:Class)
  1181. {
  1182. if (Class == TFClassType:9)
  1183. {
  1184. if (iItemDefinitionIndex == 1141)
  1185. {
  1186. return 0;
  1187. }
  1188. if (iItemDefinitionIndex == 15003)
  1189. {
  1190. return 0;
  1191. }
  1192. if (iItemDefinitionIndex == 15016)
  1193. {
  1194. return 0;
  1195. }
  1196. if (iItemDefinitionIndex == 15044)
  1197. {
  1198. return 0;
  1199. }
  1200. if (iItemDefinitionIndex == 15047)
  1201. {
  1202. return 0;
  1203. }
  1204. }
  1205. if (iItemDefinitionIndex == 1141)
  1206. {
  1207. return 1;
  1208. }
  1209. if (iItemDefinitionIndex == 15003)
  1210. {
  1211. return 1;
  1212. }
  1213. if (iItemDefinitionIndex == 15016)
  1214. {
  1215. return 1;
  1216. }
  1217. if (iItemDefinitionIndex == 15044)
  1218. {
  1219. return 1;
  1220. }
  1221. if (iItemDefinitionIndex == 15047)
  1222. {
  1223. return 1;
  1224. }
  1225. return -1;
  1226. }
  1227.  
  1228. public Action:TF2Items_OnGiveNamedItem(iClient, String:classname[], iItemDefinitionIndex, &Handle:hItem)
  1229. {
  1230. if (!IsValidClient(iClient))
  1231. {
  1232. return Action:0;
  1233. }
  1234. if (IsFakeClient(iClient))
  1235. {
  1236. return Action:0;
  1237. }
  1238. new TeamRestriction = GetConVarInt(c_TeamRest);
  1239. if (TeamRestriction + 1 == GetClientTeam(iClient))
  1240. {
  1241. return Action:0;
  1242. }
  1243. new var1;
  1244. if (GetConVarInt(c_FF2) && IsFF2Enabled)
  1245. {
  1246. if (iClient == FF2_GetBossUserId(0))
  1247. {
  1248. return Action:0;
  1249. }
  1250. }
  1251. new var2;
  1252. if (iItemDefinitionIndex == 739 || iItemDefinitionIndex == 142)
  1253. {
  1254. return Action:0;
  1255. }
  1256. if (StrEqual(classname, "tf_wearable", true))
  1257. {
  1258. return Action:0;
  1259. }
  1260. new String:strItemDefSlot[4];
  1261. Format(strItemDefSlot, 3, "%i", TF2IDB_GetItemSlot(iItemDefinitionIndex));
  1262. new ItemDefSlot = FixItemSlot(iItemDefinitionIndex, TF2_GetPlayerClass(iClient));
  1263. if (0 > ItemDefSlot)
  1264. {
  1265. ItemDefSlot = StringToInt(strItemDefSlot, 10);
  1266. }
  1267. new var3;
  1268. if (ItemDefSlot >= 10 || ItemDefSlot < 0)
  1269. {
  1270. return Action:0;
  1271. }
  1272. if (iItemDefinitionIndex != ClientItemData[iClient][ItemDefSlot][0])
  1273. {
  1274. if (ItemDataInLoad[iClient])
  1275. {
  1276. if (ItemDataInLoad[iClient] >= 3)
  1277. {
  1278. StopItemLoading[iClient] = 1;
  1279. ItemDataInLoad[iClient] = 1;
  1280. }
  1281. }
  1282. else
  1283. {
  1284. ItemDataInLoad[iClient] = 1;
  1285. }
  1286. ClientItemData[iClient][ItemDefSlot][0] = iItemDefinitionIndex;
  1287. ClientItemData[iClient][ItemDefSlot][1] = -1;
  1288. ClientItemData[iClient][ItemDefSlot][2] = -1;
  1289. if (ItemDataInLoad[iClient] != 2)
  1290. {
  1291. CreateTimer(0.2, TimerUpdateWeapon, iClient, 0);
  1292. ItemDataInLoad[iClient] = 2;
  1293. }
  1294. return Action:0;
  1295. }
  1296. new var4;
  1297. if (ItemDataInLoad[iClient] && ClientItemData[iClient][ItemDefSlot][1] > -1)
  1298. {
  1299. TF2Items_SetAttribute(g_hItem, 0, 134, 1065353216 * ClientItemData[iClient][ItemDefSlot][1]);
  1300. if (ClientItemData[iClient][ItemDefSlot][2] > -1)
  1301. {
  1302. TF2Items_SetQuality(g_hItem, ClientItemData[iClient][ItemDefSlot][2]);
  1303. hItem = g_hItem;
  1304. return Action:1;
  1305. }
  1306. }
  1307. return Action:0;
  1308. }
  1309.  
  1310. public Action:TimerUpdateWeapon(Handle:timer, any:iClient)
  1311. {
  1312. ItemDataInLoad[iClient] = 3;
  1313. new String:itembuffer[1024];
  1314. new i;
  1315. while (GetMaximumNumberSlot(iClient) >= i)
  1316. {
  1317. if (StrEqual(itembuffer, "", true))
  1318. {
  1319. Format(itembuffer, 1024, "`item_ID` = '%i'", ClientItemData[iClient][i]);
  1320. }
  1321. else
  1322. {
  1323. Format(itembuffer, 1024, "%s OR `item_ID` = '%i'", itembuffer, ClientItemData[iClient][i]);
  1324. }
  1325. i++;
  1326. }
  1327. if (StopItemLoading[iClient] == true)
  1328. {
  1329. StopItemLoading[iClient] = 0;
  1330. ItemDataInLoad[iClient] = 0;
  1331. return Action:0;
  1332. }
  1333. new String:PlayerInfo[64];
  1334. GetClientAuthId(iClient, AuthIdType:1, PlayerInfo, 64, true);
  1335. new String:buffer[1024];
  1336. Format(buffer, 1024, "SELECT `item_ID`, `effect_ID`, `quality_ID` FROM unusual_data WHERE `user_steamID` = '%s' AND ( %s )", PlayerInfo, itembuffer);
  1337. SQL_TQuery(db, T_UpdateClientItemDataSlot, buffer, iClient, DBPriority:1);
  1338. return Action:0;
  1339. }
  1340.  
  1341. public T_UpdateClientItemDataSlot(Handle:owner, Handle:hndl, String:error[], any:iClient)
  1342. {
  1343. if (!SQL_GetRowCount(hndl))
  1344. {
  1345. ItemDataInLoad[iClient] = 0;
  1346. return 0;
  1347. }
  1348. new String:strItemDefSlot[4];
  1349. new ItemDefSlot;
  1350. while (SQL_FetchRow(hndl))
  1351. {
  1352. Format(strItemDefSlot, 3, "%i", TF2IDB_GetItemSlot(SQL_FetchInt(hndl, 0, 0)));
  1353. ItemDefSlot = FixItemSlot(SQL_FetchInt(hndl, 0, 0), TF2_GetPlayerClass(iClient));
  1354. if (0 > ItemDefSlot)
  1355. {
  1356. ItemDefSlot = StringToInt(strItemDefSlot, 10);
  1357. }
  1358. new var1;
  1359. if (ItemDefSlot >= 10 || ItemDefSlot < 0)
  1360. {
  1361. ItemDataInLoad[iClient] = 0;
  1362. return 0;
  1363. }
  1364. if (StopItemLoading[iClient] == true)
  1365. {
  1366. StopItemLoading[iClient] = 0;
  1367. ItemDataInLoad[iClient] = 0;
  1368. return 0;
  1369. }
  1370. if (SQL_FetchInt(hndl, 0, 0) != ClientItemData[iClient][ItemDefSlot][0])
  1371. {
  1372. ItemDataInLoad[iClient] = 0;
  1373. return 0;
  1374. }
  1375. ClientItemData[iClient][ItemDefSlot][1] = SQL_FetchInt(hndl, 1, 0);
  1376. ClientItemData[iClient][ItemDefSlot][2] = SQL_FetchInt(hndl, 2, 0);
  1377. }
  1378. UpdateWeapon(iClient);
  1379. return 0;
  1380. }
  1381.  
  1382. UpdateWeapon(iClient)
  1383. {
  1384. if (!IsValidClient(iClient))
  1385. {
  1386. ItemDataInLoad[iClient] = 0;
  1387. new i;
  1388. while (i < 10)
  1389. {
  1390. ClientItemData[iClient][i][0] = -1;
  1391. ClientItemData[iClient][i][1] = -1;
  1392. ClientItemData[iClient][i][2] = -1;
  1393. i++;
  1394. }
  1395. return 0;
  1396. }
  1397. new Clip[6];
  1398. new Ammo[6];
  1399. new SlotMax = GetMaximumNumberSlot(iClient);
  1400. new i;
  1401. while (i <= SlotMax)
  1402. {
  1403. Clip[i] = GetClip(iClient, i);
  1404. Ammo[i] = GetAmmo(iClient, i);
  1405. TF2_RemoveWeaponSlot(iClient, i);
  1406. i++;
  1407. }
  1408. ItemDataInLoad[iClient] = 0;
  1409. TF2_RegeneratePlayer(iClient);
  1410. new iHealth = GetClientHealth(iClient);
  1411. if (GetClientHealth(iClient) > iHealth)
  1412. {
  1413. SetEntityHealth(iClient, iHealth);
  1414. }
  1415. new i;
  1416. while (i <= SlotMax)
  1417. {
  1418. new var1;
  1419. if (Clip[i] != -1 && Clip[i] < GetClip(iClient, i))
  1420. {
  1421. SetClip(iClient, i, Clip[i]);
  1422. }
  1423. new var2;
  1424. if (Ammo[i] != -1 && Ammo[i] < GetAmmo(iClient, i))
  1425. {
  1426. SetAmmo(iClient, i, Ammo[i]);
  1427. }
  1428. i++;
  1429. }
  1430. Updating(iClient);
  1431. return 0;
  1432. }
  1433.  
  1434. GetMaximumNumberSlot(iClient)
  1435. {
  1436. new TFClassType:Class = TF2_GetPlayerClass(iClient);
  1437. if (TFClassType:0 >= Class)
  1438. {
  1439. return 0;
  1440. }
  1441. new SlotMax = 2;
  1442. if (Class == TFClassType:8)
  1443. {
  1444. SlotMax = 4;
  1445. }
  1446. else
  1447. {
  1448. if (Class == TFClassType:9)
  1449. {
  1450. SlotMax = 5;
  1451. }
  1452. }
  1453. return SlotMax;
  1454. }
  1455.  
  1456. GetClip(iClient, WeapSlot)
  1457. {
  1458. new weapon = GetPlayerWeaponSlot(iClient, WeapSlot);
  1459. if (IsValidEntity(weapon))
  1460. {
  1461. new iAmmo = FindSendPropInfo("CTFWeaponBase", "m_iClip1", 0, 0, 0);
  1462. return GetEntData(weapon, iAmmo, 4);
  1463. }
  1464. return -1;
  1465. }
  1466.  
  1467. GetAmmo(iClient, WeapSlot)
  1468. {
  1469. new weapon = GetPlayerWeaponSlot(iClient, WeapSlot);
  1470. if (IsValidEntity(weapon))
  1471. {
  1472. new iOffset = GetEntProp(weapon, PropType:0, "m_iPrimaryAmmoType", 1, 0) * 4;
  1473. new iAmmo = FindSendPropInfo("CTFPlayer", "m_iAmmo", 0, 0, 0);
  1474. return GetEntData(iClient, iOffset + iAmmo, 4);
  1475. }
  1476. return -1;
  1477. }
  1478.  
  1479. SetClip(iClient, WeapSlot, newAmmo)
  1480. {
  1481. new weapon = GetPlayerWeaponSlot(iClient, WeapSlot);
  1482. if (IsValidEntity(weapon))
  1483. {
  1484. new iAmmoTable = FindSendPropInfo("CTFWeaponBase", "m_iClip1", 0, 0, 0);
  1485. SetEntData(weapon, iAmmoTable, newAmmo, 4, true);
  1486. }
  1487. return 0;
  1488. }
  1489.  
  1490. SetAmmo(iClient, WeapSlot, newAmmo)
  1491. {
  1492. new weapon = GetPlayerWeaponSlot(iClient, WeapSlot);
  1493. if (IsValidEntity(weapon))
  1494. {
  1495. new iOffset = GetEntProp(weapon, PropType:0, "m_iPrimaryAmmoType", 1, 0) * 4;
  1496. new iAmmoTable = FindSendPropInfo("CTFPlayer", "m_iAmmo", 0, 0, 0);
  1497. SetEntData(iClient, iOffset + iAmmoTable, newAmmo, 4, true);
  1498. }
  1499. return 0;
  1500. }
  1501.  
  1502. FirstMenu(iClient)
  1503. {
  1504. if (IsValidClient(iClient))
  1505. {
  1506. new TeamRestriction = GetConVarInt(c_TeamRest);
  1507. if (TeamRestriction + 1 == GetClientTeam(iClient))
  1508. {
  1509. if (TeamRestriction == 1)
  1510. {
  1511. CPrintToChat(iClient, "%t", "Sent1", "Red");
  1512. return 0;
  1513. }
  1514. if (TeamRestriction == 2)
  1515. {
  1516. CPrintToChat(iClient, "%t", "Sent1", "Blue");
  1517. return 0;
  1518. }
  1519. }
  1520. new var1;
  1521. if (GetConVarInt(c_FF2) && IsFF2Enabled)
  1522. {
  1523. if (iClient == FF2_GetBossUserId(0))
  1524. {
  1525. CPrintToChat(iClient, "%t", "Sent1", "Boss");
  1526. return 0;
  1527. }
  1528. }
  1529. new String:PlayerInfo[64];
  1530. GetClientAuthId(iClient, AuthIdType:1, PlayerInfo, 64, true);
  1531. strcopy(SteamUsed[iClient], 64, PlayerInfo);
  1532. new Handle:Menu1 = CreateMenu(Menu1_1, MenuAction:28);
  1533. SetMenuTitle(Menu1, "What do you want ?");
  1534. AddMenuItem(Menu1, "0", "Add/modify weapons", 0);
  1535. AddMenuItem(Menu1, "1", "Delete effects", 0);
  1536. AddMenuItem(Menu1, "2", "Show effects", 0);
  1537. new var2;
  1538. if ((GetConVarInt(c_PanelFlag) && GetUserFlagBits(iClient) & 16384) || (GetConVarInt(c_PanelFlag) == 1 && (GetUserFlagBits(iClient) & 2 || GetUserFlagBits(iClient) & 16384)))
  1539. {
  1540. AddMenuItem(Menu1, "3", "Admin tools: Add/modify", 0);
  1541. AddMenuItem(Menu1, "4", "Admin tools: Delete", 0);
  1542. }
  1543. SetMenuExitButton(Menu1, true);
  1544. DisplayMenu(Menu1, iClient, 0);
  1545. }
  1546. return 0;
  1547. }
  1548.  
  1549. public Menu1_1(Handle:menu, MenuAction:action, iClient, args)
  1550. {
  1551. if (action == MenuAction:16)
  1552. {
  1553. CloseHandle(menu);
  1554. }
  1555. else
  1556. {
  1557. if (action == MenuAction:4)
  1558. {
  1559. if (args)
  1560. {
  1561. if (args == 1)
  1562. {
  1563. DeleteWeapPanel(iClient);
  1564. }
  1565. if (args == 2)
  1566. {
  1567. FirstMenu(iClient);
  1568. ShowMOTDPanel(iClient, "Unusual effects", "https://wiki.teamfortress.com/wiki/Unusual/", 2);
  1569. }
  1570. if (args == 3)
  1571. {
  1572. AT_Choice_add[iClient] = 1;
  1573. AT_OnlinePlayers_Menu(iClient);
  1574. }
  1575. if (args == 4)
  1576. {
  1577. AT_Choice_add[iClient] = 0;
  1578. AT_First_Menu(iClient);
  1579. }
  1580. }
  1581. QualityMenu(iClient);
  1582. }
  1583. }
  1584. return 0;
  1585. }
  1586.  
  1587. DeleteWeapPanel(iClient)
  1588. {
  1589. new String:buffer[256];
  1590. Format(buffer, 255, "SELECT `item_ID` FROM unusual_data WHERE `user_steamID` = '%s'", SteamUsed[iClient]);
  1591. SQL_TQuery(db, T_DeleteWeapPanel, buffer, iClient, DBPriority:1);
  1592. return 0;
  1593. }
  1594.  
  1595. public T_DeleteWeapPanel(Handle:owner, Handle:hndl, String:error[], any:iClient)
  1596. {
  1597. new Handle:YourItemsMenu = CreateMenu(YourItemsMenuAnswer, MenuAction:28);
  1598. SetMenuTitle(YourItemsMenu, "What items ?");
  1599. if (!SQL_GetRowCount(hndl))
  1600. {
  1601. CPrintToChat(iClient, "%t", "Sent3");
  1602. return 0;
  1603. }
  1604. new WeapID;
  1605. new String:ItemsName[64];
  1606. new String:strWeapID[12];
  1607. AddMenuItem(YourItemsMenu, "-1", "All", 0);
  1608. while (SQL_FetchRow(hndl))
  1609. {
  1610. WeapID = SQL_FetchInt(hndl, 0, 0);
  1611. Format(strWeapID, 10, "%i", WeapID);
  1612. TF2IDB_GetItemName(WeapID, ItemsName, 64);
  1613. AddMenuItem(YourItemsMenu, strWeapID, ItemsName, 0);
  1614. }
  1615. SetMenuExitButton(YourItemsMenu, true);
  1616. DisplayMenu(YourItemsMenu, iClient, 0);
  1617. return 0;
  1618. }
  1619.  
  1620. public YourItemsMenuAnswer(Handle:menu, MenuAction:action, iClient, args)
  1621. {
  1622. if (action == MenuAction:16)
  1623. {
  1624. CloseHandle(menu);
  1625. }
  1626. else
  1627. {
  1628. if (action == MenuAction:4)
  1629. {
  1630. new String:WeapID[12];
  1631. GetMenuItem(menu, args, WeapID, 10, 0, "", 0);
  1632. if (IsValidClient(iClient))
  1633. {
  1634. RemoveEffect(iClient, SteamUsed[iClient], WeapID);
  1635. }
  1636. }
  1637. }
  1638. return 0;
  1639. }
  1640.  
  1641. bool:RemoveEffect(iClient, String:PlayerSteamID[64], String:WeapID[])
  1642. {
  1643. new clientControled = GetClientID(PlayerSteamID);
  1644. if (StrEqual(WeapID, "-1", true))
  1645. {
  1646. new String:buffer[256];
  1647. Format(buffer, 255, "DELETE FROM unusual_data WHERE `user_steamID` = '%s'", PlayerSteamID);
  1648. SQL_TQuery(db, SQLErrorCheckCallback, buffer, any:0, DBPriority:1);
  1649. new var1;
  1650. if (iClient != clientControled && IsValidClient(iClient))
  1651. {
  1652. if (IsValidClient(clientControled))
  1653. {
  1654. CPrintToChat(iClient, "%t", "Sent11", clientControled);
  1655. }
  1656. CPrintToChat(iClient, "%t", "Sent4", PlayerSteamID);
  1657. }
  1658. if (clientControled != -1)
  1659. {
  1660. new i;
  1661. while (i < 10)
  1662. {
  1663. ClientItemData[clientControled][i][1] = -1;
  1664. ClientItemData[clientControled][i][2] = -1;
  1665. i++;
  1666. }
  1667. if (IsValidClient(clientControled))
  1668. {
  1669. CPrintToChat(clientControled, "%t", "Sent10");
  1670. }
  1671. }
  1672. }
  1673. else
  1674. {
  1675. new String:buffer[256];
  1676. Format(buffer, 255, "DELETE FROM unusual_data WHERE `user_steamID` = '%s' AND `item_ID` = %i", PlayerSteamID, StringToInt(WeapID, 10));
  1677. SQL_TQuery(db, SQLErrorCheckCallback, buffer, any:0, DBPriority:1);
  1678. new var2;
  1679. if (iClient != clientControled && IsValidClient(iClient))
  1680. {
  1681. CPrintToChat(iClient, "%t", "Sent12", StringToInt(WeapID, 10));
  1682. }
  1683. if (clientControled != -1)
  1684. {
  1685. new var3;
  1686. if (GetClientTeam(clientControled) == 2 || GetClientTeam(clientControled) == 3)
  1687. {
  1688. new String:strItemDefSlot[4];
  1689. Format(strItemDefSlot, 2, "%i", TF2IDB_GetItemSlot(StringToInt(WeapID, 10)));
  1690. new ItemDefSlot = FixItemSlot(StringToInt(WeapID, 10), TF2_GetPlayerClass(clientControled));
  1691. if (0 > ItemDefSlot)
  1692. {
  1693. ItemDefSlot = StringToInt(strItemDefSlot, 10);
  1694. }
  1695. ClientItemData[clientControled][ItemDefSlot][1] = -1;
  1696. ClientItemData[clientControled][ItemDefSlot][2] = -1;
  1697. }
  1698. if (IsValidClient(clientControled))
  1699. {
  1700. CPrintToChat(clientControled, "%t", "Sent12", StringToInt(WeapID, 10));
  1701. }
  1702. }
  1703. }
  1704. if (clientControled != -1)
  1705. {
  1706. new var4;
  1707. if (GetClientTeam(clientControled) == 2 || GetClientTeam(clientControled) == 3)
  1708. {
  1709. UpdateWeapon(clientControled);
  1710. }
  1711. new var5;
  1712. if (IsValidClient(iClient) && IsValidClient(clientControled))
  1713. {
  1714. if (clientControled == iClient)
  1715. {
  1716. DeleteWeapPanel(iClient);
  1717. }
  1718. FirstMenu(iClient);
  1719. }
  1720. }
  1721. return true;
  1722. }
  1723.  
  1724. QualityMenu(iClient)
  1725. {
  1726. new clientControled = GetClientID(SteamUsed[iClient]);
  1727. if (clientControled == -1)
  1728. {
  1729. CPrintToChat(iClient, "%t", "Sent9");
  1730. return 0;
  1731. }
  1732. if (!isAuthorized(clientControled, true))
  1733. {
  1734. CPrintToChat(iClient, "%t", "Sent7");
  1735. FirstMenu(iClient);
  1736. return 0;
  1737. }
  1738. new EntitiesID = GetEntPropEnt(clientControled, PropType:1, "m_hActiveWeapon", 0);
  1739. if (0 > EntitiesID)
  1740. {
  1741. CPrintToChat(iClient, "%t", "Sent14");
  1742. return 0;
  1743. }
  1744. ClientItems[iClient] = GetEntProp(EntitiesID, PropType:0, "m_iItemDefinitionIndex", 4, 0);
  1745. new var1;
  1746. if (ClientItems[iClient] == 739 || ClientItems[iClient] == 142)
  1747. {
  1748. CPrintToChat(iClient, "%t", "Sent13");
  1749. FirstMenu(iClient);
  1750. return 0;
  1751. }
  1752. decl String:Title[64];
  1753. decl String:WeapName[64];
  1754. new Handle:Qltymenu = CreateMenu(QltymenuAnswer, MenuAction:28);
  1755. TF2IDB_GetItemName(ClientItems[iClient], WeapName, 64);
  1756. Format(Title, 64, "Select a quality: %s", WeapName);
  1757. SetMenuTitle(Qltymenu, Title);
  1758. AddMenuItem(Qltymenu, "0", "normal", 0);
  1759. AddMenuItem(Qltymenu, "1", "rarity1", 0);
  1760. AddMenuItem(Qltymenu, "2", "rarity2", 0);
  1761. AddMenuItem(Qltymenu, "3", "vintage", 0);
  1762. AddMenuItem(Qltymenu, "4", "rarity3", 0);
  1763. AddMenuItem(Qltymenu, "5", "rarity4", 0);
  1764. AddMenuItem(Qltymenu, "6", "unique", 0);
  1765. AddMenuItem(Qltymenu, "7", "community", 0);
  1766. AddMenuItem(Qltymenu, "8", "developer", 0);
  1767. AddMenuItem(Qltymenu, "9", "selfmade", 0);
  1768. AddMenuItem(Qltymenu, "10", "customized", 0);
  1769. AddMenuItem(Qltymenu, "11", "strange", 0);
  1770. AddMenuItem(Qltymenu, "12", "completed", 0);
  1771. AddMenuItem(Qltymenu, "13", "haunted", 0);
  1772. SetMenuExitButton(Qltymenu, true);
  1773. DisplayMenu(Qltymenu, iClient, 0);
  1774. return 0;
  1775. }
  1776.  
  1777. public QltymenuAnswer(Handle:menu, MenuAction:action, iClient, args)
  1778. {
  1779. if (action == MenuAction:16)
  1780. {
  1781. CloseHandle(menu);
  1782. }
  1783. else
  1784. {
  1785. if (action == MenuAction:4)
  1786. {
  1787. Quality[iClient] = args;
  1788. PanelEffect(iClient);
  1789. }
  1790. }
  1791. return 0;
  1792. }
  1793.  
  1794. PanelEffect(iClient)
  1795. {
  1796. new String:EffectID[8];
  1797. new String:EffectName[128];
  1798. new String:EffectFlag[4];
  1799. new Handle:UnusualMenu = CreateMenu(UnusualMenuAnswer, MenuAction:28);
  1800. SetMenuTitle(UnusualMenu, "Select an unusual effect:");
  1801. AddMenuItem(UnusualMenu, "0", "Show effects", 0);
  1802. new Handle:kv = CreateKeyValues("Unusual_effects", "", "");
  1803. if (!FileToKeyValues(kv, EffectsList))
  1804. {
  1805. LogError("[UNUSUAL] Could not open file %s", "unusual_list.cfg");
  1806. CloseHandle(kv);
  1807. return 0;
  1808. }
  1809. if (!KvGotoFirstSubKey(kv, true))
  1810. {
  1811. LogMessage("ERROR: Can't find unusual effects in %s", "unusual_list.cfg");
  1812. CloseHandle(kv);
  1813. return 0;
  1814. }
  1815. do {
  1816. KvGetSectionName(kv, EffectID, 8);
  1817. KvGetString(kv, "name", EffectName, 128, "");
  1818. KvGetString(kv, "flag", EffectFlag, 2, "");
  1819. if (IsClientUEAllowed(iClient, EffectFlag))
  1820. {
  1821. AddMenuItem(UnusualMenu, EffectID, EffectName, 0);
  1822. }
  1823. } while (KvGotoNextKey(kv, true));
  1824. CloseHandle(kv);
  1825. SetMenuExitButton(UnusualMenu, true);
  1826. DisplayMenu(UnusualMenu, iClient, 0);
  1827. return 0;
  1828. }
  1829.  
  1830. public UnusualMenuAnswer(Handle:menu, MenuAction:action, iClient, args)
  1831. {
  1832. if (action == MenuAction:16)
  1833. {
  1834. CloseHandle(menu);
  1835. }
  1836. else
  1837. {
  1838. if (action == MenuAction:4)
  1839. {
  1840. if (args)
  1841. {
  1842. new String:strEffect[8];
  1843. GetMenuItem(menu, args, strEffect, 8, 0, "", 0);
  1844. Effect[iClient] = StringToInt(strEffect, 10);
  1845. if (IsValidClient(iClient))
  1846. {
  1847. AddUnusualEffect(iClient);
  1848. }
  1849. }
  1850. PanelEffect(iClient);
  1851. ShowMOTDPanel(iClient, "Unusual effects", "http://bit.ly/l77777", 2);
  1852. return 0;
  1853. }
  1854. }
  1855. return 0;
  1856. }
  1857.  
  1858. bool:IsClientUEAllowed(iClient, String:EffectFlag[])
  1859. {
  1860. new var1;
  1861. if (StrEqual(EffectFlag, "0", true) || StrEqual(EffectFlag, "", true) || StrEqual(EffectFlag, "-1", true))
  1862. {
  1863. return true;
  1864. }
  1865. new flag = GetUserFlagBits(iClient);
  1866. new var2;
  1867. if (flag & 2 || flag & 16384)
  1868. {
  1869. return true;
  1870. }
  1871. if (GetUEFlag(EffectFlag) & flag)
  1872. {
  1873. return true;
  1874. }
  1875. return false;
  1876. }
  1877.  
  1878. GetUEFlag(String:Value[])
  1879. {
  1880. new String:FlagsLetter[21][4] = "T";
  1881. new i;
  1882. while (i < 21)
  1883. {
  1884. if (StrEqual(Value, FlagsLetter[i], true))
  1885. {
  1886. return FlagsList[i];
  1887. }
  1888. i++;
  1889. }
  1890. return -1;
  1891. }
  1892.  
  1893. bool:AddUnusualEffect(iClient)
  1894. {
  1895. if (0 > ClientItems[iClient])
  1896. {
  1897. return false;
  1898. }
  1899. new var1;
  1900. if (ClientItems[iClient] == 739 || ClientItems[iClient] == 142)
  1901. {
  1902. CPrintToChat(iClient, "%t", "Sent13");
  1903. return false;
  1904. }
  1905. if (TF2IDB_GetItemSlot(ClientItems[iClient]) >= 5)
  1906. {
  1907. return false;
  1908. }
  1909. if (StrEqual(SteamUsed[iClient], "", true))
  1910. {
  1911. CPrintToChat(iClient, "%t", "Sent5");
  1912. }
  1913. new String:buffer[256];
  1914. Format(buffer, 255, "SELECT * FROM unusual_data WHERE `user_steamID` = '%s' AND `item_ID` = '%i'", SteamUsed[iClient], ClientItems[iClient]);
  1915. SQL_TQuery(db, T_UpdateClient, buffer, iClient, DBPriority:1);
  1916. return false;
  1917. }
  1918.  
  1919. public T_UpdateClient(Handle:owner, Handle:hndl, String:error[], any:iClient)
  1920. {
  1921. new clientControled = GetClientID(SteamUsed[iClient]);
  1922. new var1;
  1923. if (clientControled == -1 || !IsValidClient(clientControled))
  1924. {
  1925. CPrintToChat(iClient, "%t", "Sent9");
  1926. return 0;
  1927. }
  1928. if (!isAuthorized(clientControled, true))
  1929. {
  1930. CPrintToChat(iClient, "%t", "Sent7");
  1931. return 0;
  1932. }
  1933. if (!SQL_GetRowCount(hndl))
  1934. {
  1935. new String:buffer[256];
  1936. if (!SQLite)
  1937. {
  1938. Format(buffer, 256, "INSERT INTO unusual_data (`user_steamID`,`item_ID`,`effect_ID`,`quality_ID`) VALUES ('%s','%i','%i','%i')", SteamUsed[iClient], ClientItems[iClient], Effect[iClient], Quality[iClient]);
  1939. SQL_TQuery(db, SQLErrorCheckCallback, buffer, any:0, DBPriority:1);
  1940. }
  1941. else
  1942. {
  1943. Format(buffer, 256, "INSERT INTO unusual_data VALUES ('%s','%i','%i','%i')", SteamUsed[iClient], ClientItems[iClient], Effect[iClient], Quality[iClient]);
  1944. SQL_TQuery(db, SQLErrorCheckCallback, buffer, any:0, DBPriority:1);
  1945. }
  1946. if (IsValidClient(clientControled))
  1947. {
  1948. NbOfEffect[clientControled]++;
  1949. }
  1950. }
  1951. else
  1952. {
  1953. new String:buffer[256];
  1954. while (SQL_FetchRow(hndl))
  1955. {
  1956. Format(buffer, 256, "UPDATE unusual_data SET `effect_ID` = %i, `quality_ID` = %i WHERE `user_steamID` = '%s' AND `item_ID` = %i", Effect[iClient], Quality[iClient], SteamUsed[iClient], ClientItems[iClient]);
  1957. SQL_TQuery(db, SQLErrorCheckCallback, buffer, any:0, DBPriority:1);
  1958. }
  1959. }
  1960. new var2;
  1961. if (GetClientTeam(clientControled) == 2 || GetClientTeam(clientControled) == 3)
  1962. {
  1963. new String:strItemDefSlot[4];
  1964. Format(strItemDefSlot, 2, "%i", TF2IDB_GetItemSlot(ClientItems[iClient]));
  1965. new ItemDefSlot = FixItemSlot(ClientItems[iClient], TF2_GetPlayerClass(clientControled));
  1966. if (0 > ItemDefSlot)
  1967. {
  1968. ItemDefSlot = StringToInt(strItemDefSlot, 10);
  1969. }
  1970. ClientItemData[clientControled][ItemDefSlot][1] = Effect[iClient];
  1971. ClientItemData[clientControled][ItemDefSlot][2] = Quality[iClient];
  1972. }
  1973. if (IsValidClient(clientControled))
  1974. {
  1975. UpdateWeapon(clientControled);
  1976. }
  1977. if (IsValidClient(iClient))
  1978. {
  1979. CPrintToChat(iClient, "%t", "Sent8");
  1980. }
  1981. new var3;
  1982. if (clientControled != iClient && IsValidClient(clientControled))
  1983. {
  1984. CPrintToChat(clientControled, "%t", "Sent8");
  1985. }
  1986. new var4;
  1987. if (IsValidClient(iClient) && IsValidClient(clientControled))
  1988. {
  1989. FirstMenu(iClient);
  1990. }
  1991. return 0;
  1992. }
  1993.  
  1994. AT_First_Menu(iClient)
  1995. {
  1996. new Handle:AdMenu = CreateMenu(AT_First_Menu_Ans, MenuAction:28);
  1997. SetMenuTitle(AdMenu, "Admin Tools: Which kind of player ?");
  1998. AddMenuItem(AdMenu, "0", "Players on the server", 0);
  1999. AddMenuItem(AdMenu, "1", "Players from the BD", 0);
  2000. SetMenuExitButton(AdMenu, true);
  2001. DisplayMenu(AdMenu, iClient, 0);
  2002. return 0;
  2003. }
  2004.  
  2005. public AT_First_Menu_Ans(Handle:menu, MenuAction:action, iClient, args)
  2006. {
  2007. if (action == MenuAction:16)
  2008. {
  2009. CloseHandle(menu);
  2010. }
  2011. else
  2012. {
  2013. if (action == MenuAction:4)
  2014. {
  2015. if (args)
  2016. {
  2017. AT_BDPlayers_Menu(iClient);
  2018. }
  2019. AT_OnlinePlayers_Menu(iClient);
  2020. }
  2021. }
  2022. return 0;
  2023. }
  2024.  
  2025. AT_OnlinePlayers_Menu(iClient)
  2026. {
  2027. new Handle:AdMenu = CreateMenu(AT_OnlinePlayers_Menu_Ans, MenuAction:28);
  2028. new String:str_PlayerID[8];
  2029. new String:str_PlayerName[128];
  2030. new count;
  2031. SetMenuTitle(AdMenu, "Admin Tools: Player selection");
  2032. new i;
  2033. while (i < MaxClients)
  2034. {
  2035. new var1;
  2036. if (IsValidClient(i) && iClient != i && IsClientInGame(i) && !IsFakeClient(i))
  2037. {
  2038. Format(str_PlayerID, 5, "%d", i);
  2039. GetClientName(i, str_PlayerName, 128);
  2040. AddMenuItem(AdMenu, str_PlayerID, str_PlayerName, 0);
  2041. count++;
  2042. }
  2043. i++;
  2044. }
  2045. if (count)
  2046. {
  2047. SetMenuExitButton(AdMenu, true);
  2048. DisplayMenu(AdMenu, iClient, 0);
  2049. return 0;
  2050. }
  2051. CPrintToChat(iClient, "%t", "Sent2");
  2052. CloseHandle(AdMenu);
  2053. FirstMenu(iClient);
  2054. return 0;
  2055. }
  2056.  
  2057. public AT_OnlinePlayers_Menu_Ans(Handle:menu, MenuAction:action, iClient, args)
  2058. {
  2059. if (action == MenuAction:16)
  2060. {
  2061. CloseHandle(menu);
  2062. }
  2063. else
  2064. {
  2065. if (action == MenuAction:4)
  2066. {
  2067. new String:str_PlayerID[8];
  2068. new String:PlayerInfo[64];
  2069. GetMenuItem(menu, args, str_PlayerID, 5, 0, "", 0);
  2070. GetClientAuthId(StringToInt(str_PlayerID, 10), AuthIdType:1, PlayerInfo, 64, true);
  2071. strcopy(SteamUsed[iClient], 64, PlayerInfo);
  2072. if (!IsValidClient(StringToInt(str_PlayerID, 10)))
  2073. {
  2074. CPrintToChat(iClient, "%t", "Sent9");
  2075. AT_OnlinePlayers_Menu(iClient);
  2076. }
  2077. else
  2078. {
  2079. if (AT_Choice_add[iClient])
  2080. {
  2081. QualityMenu(iClient);
  2082. }
  2083. DeleteWeapPanel(iClient);
  2084. }
  2085. }
  2086. }
  2087. return 0;
  2088. }
  2089.  
  2090. AT_BDPlayers_Menu(iClient)
  2091. {
  2092. new String:buffer[256];
  2093. Format(buffer, 255, "SELECT DISTINCT `user_steamID` FROM unusual_data ORDER BY `user_steamID`");
  2094. SQL_TQuery(db, AT_BDPlayers_Menu_2, buffer, iClient, DBPriority:1);
  2095. return 0;
  2096. }
  2097.  
  2098. public AT_BDPlayers_Menu_2(Handle:owner, Handle:hndl, String:error[], any:iClient)
  2099. {
  2100. if (!SQL_GetRowCount(hndl))
  2101. {
  2102. CPrintToChat(iClient, "%t", "Sent2");
  2103. FirstMenu(iClient);
  2104. return 0;
  2105. }
  2106. new Handle:AdMenu = CreateMenu(AT_BDPlayers_Menu_Ans, MenuAction:28);
  2107. SetMenuTitle(AdMenu, "Admin Tools: Player selection");
  2108. new String:PlayerInfo[64];
  2109. while (SQL_FetchRow(hndl))
  2110. {
  2111. SQL_FetchString(hndl, 0, PlayerInfo, 64, 0);
  2112. AddMenuItem(AdMenu, PlayerInfo, PlayerInfo, 0);
  2113. }
  2114. SetMenuExitButton(AdMenu, true);
  2115. DisplayMenu(AdMenu, iClient, 0);
  2116. return 0;
  2117. }
  2118.  
  2119. public AT_BDPlayers_Menu_Ans(Handle:menu, MenuAction:action, iClient, args)
  2120. {
  2121. if (action == MenuAction:16)
  2122. {
  2123. CloseHandle(menu);
  2124. }
  2125. else
  2126. {
  2127. if (action == MenuAction:4)
  2128. {
  2129. new String:PlayerInfo[64];
  2130. GetMenuItem(menu, args, PlayerInfo, 64, 0, "", 0);
  2131. strcopy(SteamUsed[iClient], 64, PlayerInfo);
  2132. DeleteWeapPanel(iClient);
  2133. }
  2134. }
  2135. return 0;
  2136. }
  2137.  
  2138. public Native_RemoveEffect(Handle:plugin, numParams)
  2139. {
  2140. new String:PlayerSteamID[64];
  2141. new String:WeapID[12];
  2142. GetNativeString(1, PlayerSteamID, 64, 0);
  2143. if (0 > GetNativeCell(2))
  2144. {
  2145. return 0;
  2146. }
  2147. Format(WeapID, 10, "%d", GetNativeCell(2));
  2148. return RemoveEffect(-1, PlayerSteamID, WeapID);
  2149. }
  2150.  
  2151. public Native_RemovePlayerEffects(Handle:plugin, numParams)
  2152. {
  2153. new String:PlayerSteamID[64];
  2154. GetNativeString(1, PlayerSteamID, 64, 0);
  2155. return RemoveEffect(-1, PlayerSteamID, "-1");
  2156. }
  2157.  
  2158. public Native_GetUnusualEffectPermission(Handle:plugin, numParams)
  2159. {
  2160. new Bit = GetNativeCell(1);
  2161. if (Bit == -1)
  2162. {
  2163. return Permission[0];
  2164. }
  2165. new i;
  2166. while (Bit != FlagsList[i] && i < 21)
  2167. {
  2168. i++;
  2169. }
  2170. if (i < 21)
  2171. {
  2172. return Permission[i + 1];
  2173. }
  2174. LogError("INVALID FLAGBIT !");
  2175. return -2;
  2176. }
  2177.  
  2178. public Native_SetUnusualEffectPermission(Handle:plugin, numParams)
  2179. {
  2180. new Bit = GetNativeCell(1);
  2181. new Limit = GetNativeCell(2);
  2182. if (Limit < -1)
  2183. {
  2184. LogError("INVALID LIMIT !");
  2185. return 0;
  2186. }
  2187. new String:FlagBitToLetter[22][4] = "X";
  2188. new Handle:kv = CreateKeyValues("Unusual_permissions", "", "");
  2189. if (!FileToKeyValues(kv, PermissionsFile))
  2190. {
  2191. LogError("Can't open %s file", "unusual_permissions.cfg");
  2192. CloseHandle(kv);
  2193. return 0;
  2194. }
  2195. KvGotoFirstSubKey(kv, true);
  2196. if (Bit == -1)
  2197. {
  2198. KvSetNum(kv, "0", Limit);
  2199. }
  2200. else
  2201. {
  2202. new i;
  2203. while (Bit != FlagsList[i] && i < 21)
  2204. {
  2205. i++;
  2206. }
  2207. if (i < 21)
  2208. {
  2209. KvSetNum(kv, FlagBitToLetter[i + 1], Limit);
  2210. }
  2211. CloseHandle(kv);
  2212. LogError("INVALID FLAGBIT !");
  2213. return 0;
  2214. }
  2215. KvRewind(kv);
  2216. if (!KeyValuesToFile(kv, PermissionsFile))
  2217. {
  2218. CloseHandle(kv);
  2219. LogError("Plugin ERROR : Can't save %s modifications !", "unusual_permissions.cfg");
  2220. return 0;
  2221. }
  2222. CloseHandle(kv);
  2223. return LoadPermissions();
  2224. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement