HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2.   Fordította: BBk
  3. */
  4.  
  5. /**
  6. *Tag protection Plugin
  7. *
  8. * by InstantDeath
  9. *customizable flag
  10. *setable ban time
  11. *add or remove tags from in game
  12. *kick or ban option + in game
  13. *
  14. *
  15. *
  16. * sm_addtag
  17. * sm_removetag
  18. * sm_tagcfg
  19. */
  20.  
  21. #include <sourcemod>
  22. #include <sdktools>
  23.  
  24. #pragma semicolon 1
  25.  
  26. #define PLUGIN_VERSION "1.21"
  27.  
  28. #define RED 0
  29. #define GREEN 255
  30. #define BLUE 0
  31. #define ALPHA 255
  32.  
  33. #define ADMFLAG_TAGPROT ADMFLAG_CUSTOM1
  34.  
  35. new Handle:tagfile = INVALID_HANDLE;
  36. new Handle:tagwarntime = INVALID_HANDLE;
  37. new Handle:tagKicktimer[MAXPLAYERS+1] = INVALID_HANDLE;
  38. new Handle:tagfileloc = INVALID_HANDLE;
  39. new String:taglistfile[PLATFORM_MAX_PATH];
  40. new String:fileloc[255];
  41. new bool:tagfile_exist = false;
  42. new bool:kicktimerActive[MAXPLAYERS+1];
  43. new bool:StillHasTag[MAXPLAYERS+1] = false;
  44. new String:WearingTag[255];
  45. new bool:ClientisReady[MAXPLAYERS+1];
  46.  
  47. new Float:gTimeLeft[MAXPLAYERS+1];
  48.  
  49. public Plugin:myinfo =
  50. {
  51. name = "Tag Protection",
  52. author = "InstantDeath",
  53. description = "Megakadalyozza a nem kivant cimkek hasznalatat a nevekben.",
  54. version = PLUGIN_VERSION,
  55. url = "http://www.xpgaming.net"
  56. };
  57.  
  58. public OnPluginStart()
  59. {
  60. CreateConVar("sm_tagprotection_version", PLUGIN_VERSION, "Tag Protection Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  61. tagfileloc = CreateConVar("sm_tagcfg" , "configs/taglist.cfg" , "A fajl betoltese es cimkek elmentese.", FCVAR_PLUGIN);
  62. tagwarntime = CreateConVar("sm_tagwarntime" , "60.0" , "A jatekosok figyelmeztetese az illegalis cimkek hasznalatara masodpercben", FCVAR_PLUGIN);
  63. RegAdminCmd("sm_addtag", Command_AddTag, ADMFLAG_BAN, "[SM] Cimkek hozzaadasa a listahoz. Hasznalat: sm_addtag <cimke> (ban ideje, -1 a kickhez)");
  64. RegAdminCmd("sm_removetag", Command_RemoveTag, ADMFLAG_BAN, "[SM] Cimkek eltavolitasa a listabol. Hasznalat: sm_removetag <cimke>");
  65. }
  66. public OnMapStart()
  67. {
  68. GetConVarString(tagfileloc, fileloc, sizeof(fileloc));
  69. BuildPath(Path_SM,taglistfile,sizeof(taglistfile), fileloc);
  70. tagfile = CreateKeyValues("taglist");
  71. FileToKeyValues(tagfile,taglistfile);
  72. if(!FileExists(taglistfile))
  73. {
  74. LogMessage("[SM] taglist.cfg nem hasznalhato...a fajl nem letezik!");
  75. SetFailState("[SM] taglist.cfg nem hasznalhato...a fajl nem letezik! Pontosan telepitsd fel a plugint...");
  76. tagfile_exist = false;
  77. }
  78. else
  79. {
  80. tagfile_exist = true;
  81. }
  82. }
  83.  
  84. public Action:Command_AddTag(client, args)
  85. {
  86. if (args < 2)
  87. {
  88. ReplyToCommand(client, "[SM] Hasznalat: sm_addtag <cimke> (ban ideje, -1 a kickhez)");
  89. return Plugin_Handled;
  90. }
  91. decl String:tag[64];
  92. decl String:kbtime[32];
  93. new time;
  94.  
  95. GetCmdArg(1, tag, sizeof(tag));
  96. GetCmdArg(2, kbtime, sizeof(kbtime));
  97.  
  98. if(tagExistCheck(tag) == 1)
  99. {
  100. PrintToConsole(client, "[SM] Ez a cimke mar letezik!");
  101. return Plugin_Handled;
  102. }
  103. time = StringToInt(kbtime);
  104.  
  105. KvRewind(tagfile);
  106. KvJumpToKey(tagfile, tag, true);
  107. KvSetNum(tagfile, "time", time);
  108. if(tagExistCheck(tag) == 1)
  109. {
  110. PrintToConsole(client, "[SM] '%s' cimke sikeresen hozzaadva. Palyavaltasig nem fog effektet beallitani.", tag);
  111. return Plugin_Handled;
  112. }
  113.  
  114. return Plugin_Handled;
  115. }
  116.  
  117. public Action:Command_RemoveTag(client, args)
  118. {
  119. if (args < 1)
  120. {
  121. ReplyToCommand(client, "[SM] Hasznalat: sm_removetag <cimke>");
  122. return Plugin_Handled;
  123. }
  124. decl String:Arguments[256];
  125.  
  126. GetCmdArgString(Arguments, sizeof(Arguments));
  127.  
  128. if(tagExistCheck(Arguments) == 1)
  129. {
  130.  
  131. KvRewind(tagfile);
  132. KvJumpToKey(tagfile, Arguments, false);
  133. KvDeleteThis(tagfile);
  134. if(tagExistCheck(Arguments) == 0)
  135. {
  136. PrintToConsole(client, "[SM] A cimke sikeresen torolve.");
  137. return Plugin_Handled;
  138. }
  139. else
  140. PrintToConsole(client, "[SM] A cimke nem talalhato.");
  141. }
  142. return Plugin_Handled;
  143. }
  144.  
  145. public OnClientDisonnect(client)
  146. {
  147. ClientisReady[client] = false;
  148. }
  149.  
  150. public OnClientPostAdminCheck(client)
  151. {
  152. ClientisReady[client] = true;
  153. }
  154. public OnMapEnd()
  155. {
  156. KvRewind(tagfile);
  157. KeyValuesToFile(tagfile, taglistfile);
  158. CloseHandle(tagfile);
  159. }
  160.  
  161. public OnClientPutInServer(client)
  162. {
  163. StillHasTag[client] = true;
  164. }
  165.  
  166. /*
  167. public OnClientAuthorized(client, const String:auth[])
  168. {
  169. new Float:timer = 10.5;
  170. if(!IsFakeClient(client))
  171. {
  172. if(client != 0)
  173. {
  174. if(tagfile_exist == true)
  175. CreateTimer(timer,tagCheck, client,TIMER_FLAG_NO_MAPCHANGE);
  176. }
  177. }
  178. }
  179. */
  180.  
  181. public OnClientSettingsChanged(client)
  182. {
  183. if(!IsFakeClient(client) && ClientisReady[client])
  184. {
  185. if(client != 0 && IsClientInGame(client))
  186. {
  187. if(tagfile_exist)
  188. tagCheckChange(client);
  189. }
  190. }
  191. }
  192.  
  193. /*
  194. public Action:tagCheck(Handle: timer, any:client)
  195. {
  196. decl String:clientName[64];
  197. decl String:buffer[255];
  198. new time;
  199. new clientid = GetClientUserId(client);
  200. GetClientName(client,clientName,64);
  201.  
  202. KvRewind(tagfile);
  203. KvGotoFirstSubKey(tagfile);
  204. gTimeLeft[client] = GetConVarFloat(tagwarntime);
  205. new flags = GetUserFlagBits(client);
  206.  
  207. do{
  208. KvGetSectionName(tagfile, buffer, sizeof(buffer));
  209. if (StrContains(clientName, buffer,false) != -1)
  210. {
  211. time = KvGetNum(tagfile, "time");
  212. if(time == -1)
  213. {
  214. if(flags & ADMFLAG_TAGPROT || flags & ADMFLAG_ROOT)
  215. {
  216. return Plugin_Handled;
  217. }
  218. else
  219. {
  220. tagKicktimer[client] = CreateTimer(1.0, OnTagKick, client, TIMER_REPEAT);
  221. //TriggerTimer(tagKicktimer, true);
  222. kicktimerActive[client] = true;
  223. PrintToChat(client, "[SM] Nincs jogosultsagod ezt a cimket '%s' viselni.", buffer);
  224. PrintToChat(client, "[SM] Kileszel rugva %f masodperc mulva, ha nem tavolitod el", gTimeLeft[client]);
  225. StillHasTag[client] = true;
  226. break;
  227. }
  228. }
  229. else if(time > -1)
  230. {
  231. new String: bName[64];
  232. new String: bAuth[64];
  233. GetClientName(client, bName, sizeof(bName));
  234. GetClientAuthString(client, bAuth, sizeof(bAuth));
  235. ServerCommand("sm_ban #%d %s Illegalis cimke", clientid, time);
  236. LogMessage("[SM] %s kitiltva illegalis cimke miatt, SteamID: %s", bName, bAuth);
  237. }
  238. }
  239. }while (KvGotoNextKey(tagfile));
  240.  
  241.  
  242. return Plugin_Handled;
  243. }
  244. */
  245.  
  246. public Action:tagCheckChange(client)
  247. {
  248. decl String:clientName[64];
  249. decl String:buffer[255];
  250. new time;
  251. new clientid = GetClientUserId(client);
  252. GetClientName(client,clientName,64);
  253. gTimeLeft[client] = GetConVarFloat(tagwarntime);
  254. new kicktime = FloatToInt(gTimeLeft[client]);
  255.  
  256. KvRewind(tagfile);
  257. KvGotoFirstSubKey(tagfile);
  258. new flags = GetUserFlagBits(client);
  259.  
  260. //timer is still active, but player has removed illegal tag
  261. if(kicktimerActive[client] && !StillHasTag[client])
  262. {
  263. PrintToChat(client,"[SM] Koszonjuk, hogy eltavolitja a %s cimket", WearingTag);
  264. //KillTimer(tagKicktimer, false);
  265. kicktimerActive[client] = false;
  266. }
  267.  
  268. do{
  269. KvGetSectionName(tagfile, buffer, sizeof(buffer));
  270. if (StrContains(clientName, buffer,false) != -1)
  271. {
  272. WearingTag = buffer;
  273. time = KvGetNum(tagfile, "time");
  274. if(time == -1)
  275. {
  276. //timer is active, we dont need to start the timer again
  277. if(!kicktimerActive[client] && IsClientInGame(client))
  278. {
  279. if(flags & ADMFLAG_TAGPROT || flags & ADMFLAG_ROOT)
  280. {
  281. return Plugin_Handled;
  282. }
  283. else
  284. {
  285. tagKicktimer[client] = CreateTimer(1.0, OnTagKick, client, TIMER_REPEAT);
  286. //TriggerTimer(tagKicktimer, true);
  287. kicktimerActive[client] = true;
  288. StillHasTag[client] = true;
  289. PrintToChat(client, "[SM] \x04Nincs jogosultsagod ezt a cimket '%s\x04' viselni.", buffer);
  290. PrintToChat(client, "[SM] \x04Kileszel rugva %d\x04 masodperc mulva ha nem tavolitod el", kicktime);
  291. return Plugin_Handled;
  292. }
  293. }
  294.  
  295. }
  296. if(time > -1)
  297. {
  298. new String: bName[64];
  299. new String: bAuth[64];
  300. GetClientName(client, bName, sizeof(bName));
  301. GetClientAuthString(client, bAuth, sizeof(bAuth));
  302. ServerCommand("sm_ban #%d %d Illegalis cimke", clientid, time);
  303. LogMessage("[SM] %s kitiltva illegalis cimke miatt, SteamID: %s", bName, bAuth);
  304. return Plugin_Handled;
  305. }
  306.  
  307. }
  308. else if (StrContains(clientName, buffer,false) == -1)
  309. {
  310. StillHasTag[client] = false;
  311. }
  312. } while (KvGotoNextKey(tagfile));
  313.  
  314. return Plugin_Handled;
  315. }
  316.  
  317. public Action:OnTagKick(Handle:timer, any:index)
  318. {
  319. new time = FloatToInt(GetConVarFloat(tagwarntime)/2);
  320. new time2 = FloatToInt(GetConVarFloat(tagwarntime)/4);
  321. //PrintToChatAll("time left to kick: %f", gTimeLeft[index]);
  322. if(GetConVarFloat(tagwarntime)/2 == gTimeLeft[index])
  323. {
  324. PrintToChat(index, "\x01\x04[SM] Kileszel rugva %f masodperc mulva, ha nem tavolitod el", time);
  325.  
  326. }
  327. if(GetConVarFloat(tagwarntime)/4 == gTimeLeft[index])
  328. {
  329. PrintToChat(index, "\x01\x04[SM] Kileszel rugva %f masodperc mulva, ha nem tavolitod el", time2);
  330. }
  331. if(gTimeLeft[index] == 10)
  332. {
  333. PrintToChat(index, "\x01\x04[SM] Kileszel rugva %f masodperc mulva, ha nem tavolitod el", 10);
  334. }
  335. if(gTimeLeft[index] == 5)
  336. {
  337. PrintToChat(index, "\x01\x04[SM] Kileszel rugva %f masodperc mulva, ha nem tavolitod el", 5);
  338. }
  339. if (!index || !IsClientInGame(index))
  340. {
  341. kicktimerActive[index] = false;
  342. return Plugin_Stop;
  343. }
  344.  
  345. gTimeLeft[index] = gTimeLeft[index] - 1;
  346.  
  347. if(gTimeLeft[index]<=0)
  348. {
  349. kicktimerActive[index] = false;
  350. new String: kName[64];
  351. new String: kAuth[64];
  352. GetClientName(index, kName, sizeof(kName));
  353. GetClientAuthString(index, kAuth, sizeof(kAuth));
  354. KickClient(index, "%s", "Illegalis cimke");
  355. LogMessage("[SM] %s kirugva illegalis cimke miatt, SteamID: %s", kName, kAuth);
  356. return Plugin_Stop;
  357. }
  358. else if(kicktimerActive[index] == false)
  359. return Plugin_Stop;
  360.  
  361. return Plugin_Continue;
  362. }
  363.  
  364. public tagExistCheck(String:Tag[])
  365. {
  366. KvRewind(tagfile);
  367. KvGotoFirstSubKey(tagfile);
  368. decl String:buffer[255];
  369. do{
  370. KvGetSectionName(tagfile, buffer, sizeof(buffer));
  371. if (StrContains(Tag, buffer,false) != -1)
  372. return 1;
  373.  
  374. } while (KvGotoNextKey(tagfile));
  375. return 0;
  376. }
  377.  
  378. public FloatToInt(Float: num)
  379. {
  380. new String:temp[32];
  381. FloatToString(num, temp, sizeof(temp));
  382. return StringToInt(temp);
  383. }
  384.  
  385. public OnPluginEnd()
  386. {
  387. CloseHandle(tagfile);
  388. }