Guest User

Untitled

a guest
Mar 30th, 2020
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.61 KB | None | 0 0
  1. /*
  2. Plugin antiroxx:source 3.8 (zz1crazyxx & MorgenDavid)
  3. plugin de diminution des degats en fonction du niveau des joueurs.(classement par ratio)
  4. systeme de protection des joueurs tres faible (luciolle)
  5. */
  6.  
  7. /*
  8. // La table stock le ratio des joueurs sous forme kill/death
  9. // Ip et lastconnected juste pour info.
  10. // Si plx=x le joueur peut se co sans risque d'etre redirige x=1 low, x=2 high , x=3 les deux.
  11.  
  12. CVars:
  13. * antiroxx_active" (default:"1") "(Des)active antiroxx"
  14. * antiroxx_minimum_player" (default:"4") "Nbres Joueurs minimum pour etre actif"
  15. * antiroxx_serveur (default:"0") "0 = Normal | 1 = Serveur Low (kick/redirige si trop fort): 2 = Serveur High (kick/redirige si trop faible)"
  16. * antiroxx_ratio_auth (default:"1.00") "Si 'Serveur Low' alors ratio maximum avant kick | Si 'Serveur High':ratio minimum sinon kick"
  17. * antiroxx_new_server" (default:"127.0.0.1:27015") "Ip du serveur vers lequel on redirigera le joueur (Serveur Low/High)."
  18. * antiroxx_max_cumul" (default:"80") "Nombre de frags ou deaths limite, on divise par 2 une fois cette limite atteinte."
  19. * antiroxx_ratio_snipe" (default:"1.00") "A partir de ce ratio: on a plus le droit aux snipes (except scout)"
  20. * antiroxx_ratio_flash" (default:"1.00") "A partir de ce ratio: on a plus le droit aux flash (a l'achat)"
  21. * antiroxx_frags_default" (default:"8") "Nombre de frag donné a chaque joueur a la premiere connection"
  22. * antiroxx_deaths_default" (default:"10") "Nombre de morts donne a chaque joueur a la premiere connection"
  23.  
  24. Commande:
  25. * Liste des ratios des joueurs: sm_antiroxx
  26. * Modifier le ratio d'un joueurs: sm_antiroxx <name|#userid> <frag> <death>
  27.  
  28. Inclut:
  29. * Simple Anti AFK.
  30. * 15000 a chaque round.
  31. */
  32.  
  33. #pragma semicolon 1
  34.  
  35. #include <sourcemod>
  36. #include <cstrike>
  37. #include <sdktools>
  38. #include <sdkhooks>
  39. #include <colors>
  40.  
  41. // --------------------------------------------------------------------------------------------------------
  42. // Les definitions.
  43. // (Ne pas toucher sans une bonne raison)
  44. // --------------------------------------------------------------------------------------------------------
  45. #define PL_VERSION "3.8"
  46. #define GAME_CSS 1
  47. #define GAME_CSGO 2
  48. #define MAX_AUTHID_LENGTH 20
  49.  
  50. #define RATIO_LUCIOLE -0.05+RATIO_JUNIOR
  51. #define RATIO_JUNIOR -0.10+RATIO_DEBUTANT
  52. #define RATIO_DEBUTANT -0.10+RATIO_DEBUTANT_PLUS
  53. #define RATIO_DEBUTANT_PLUS -0.10+RATIO_CONFIRME
  54. #define RATIO_CONFIRME 1.00
  55. #define RATIO_CONFIRME_PLUS 0.05+RATIO_CONFIRME
  56. #define RATIO_AVANCE 0.05+RATIO_CONFIRME_PLUS
  57. #define RATIO_AVANCE_PLUS 0.05+RATIO_AVANCE
  58. #define RATIO_PRO 0.05+RATIO_AVANCE_PLUS
  59. #define RATIO_PRO_PLUS 0.05+RATIO_PRO
  60. #define RATIO_PGM 0.10+RATIO_PRO_PLUS
  61.  
  62. #define START_MONEY 15000
  63. #define HP_LUCIOLE 200
  64. #define HP_JUNIOR 150
  65. #define HP_PGM_CSS 500
  66. #define HP_PGM_CSGO 200
  67.  
  68. #define HANDICAP 0.7
  69.  
  70. #define GROUP_SNIPE 5
  71. #define GROUP_FLASH 6
  72. #define GROUP_WORLD 7
  73. #define GROUP_OTHERS 0
  74.  
  75. // --------------------------------------------------------------------------------------------------------
  76. //- Infos Plugins
  77. // --------------------------------------------------------------------------------------------------------
  78. public Plugin:myinfo =
  79. {
  80. name = "Antiroxx:Source",
  81. author = "zz1crazyxx & MorgenDavid",
  82. description = "Plugins d'aide aux nouveaux joueurs",
  83. version = PL_VERSION,
  84. url = ""
  85. }
  86.  
  87. // --------------------------------------------------------------------------------------------------------
  88. //- Variables
  89. // --------------------------------------------------------------------------------------------------------
  90. new Player_Frags[MAXPLAYERS+1];
  91. new Player_Deaths[MAXPLAYERS+1];
  92. new Float:Player_Ratio[MAXPLAYERS+1];
  93. new isPlayerLuciole[MAXPLAYERS+1];
  94. new isPlayerPgm[MAXPLAYERS+1];
  95. new isPunished[MAXPLAYERS+1];
  96. new plx[MAXPLAYERS+1];
  97. new bool:isConfigDownload[MAXPLAYERS+1];
  98. new Handle:hDatabase = INVALID_HANDLE;
  99.  
  100. new TimePlayed[MAXPLAYERS+1];
  101.  
  102. new Handle:g_hAfkCheckSpawn[MAXPLAYERS+1] = INVALID_HANDLE;
  103. new Handle:g_hAfkCheckTimer[MAXPLAYERS+1] = INVALID_HANDLE;
  104. new Float:SpawnPos[MAXPLAYERS+1][3];
  105. new Float:CurrentPos[MAXPLAYERS+1][3];
  106.  
  107. // new g_iAccount = -1;
  108. new Float:g_handicap = HANDICAP;
  109.  
  110. new Handle:gServeur;
  111. new Handle:gActive;
  112. new Handle:gMinimumPly;
  113. new Handle:gMaxCumul;
  114. new Handle:gRatioAuth;
  115. new Handle:gNewServer;
  116.  
  117. new gametype = -1;
  118.  
  119. new bool:cvar_Active;
  120. new cvar_MinimumPly;
  121.  
  122. new g_FreezeSprite;
  123.  
  124. new Handle:gRatio_snipe;
  125. new Float:cvar_snipe;
  126.  
  127. new Handle:gRatio_flash;
  128. new Float:cvar_flash;
  129.  
  130. new Handle:gFrags_default;
  131. new Handle:gDeaths_default;
  132.  
  133. // --------------------------------------------------------------------------------------------------------
  134. //- appelé quand le plugin démarre.
  135. // --------------------------------------------------------------------------------------------------------
  136. public OnPluginStart()
  137. {
  138. LoadTranslations ("antiroxx.phrases");
  139.  
  140. new String:game_description[64];
  141. GetGameDescription(game_description, sizeof(game_description), true);
  142. if(StrContains(game_description, "Counter-Strike", false) != -1) { gametype = GAME_CSS; }
  143. if(StrContains(game_description, "Counter-Strike: Global Offensive", false) != -1) { gametype = GAME_CSGO; }
  144. if(gametype == -1) { SetFailState("Plugin for CS:S or CS:GO only"); }
  145.  
  146. //CVar
  147. CreateConVar("antiroxx_version", PL_VERSION, "Antiroxx system", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  148. gServeur = CreateConVar("antiroxx_serveur", "0", "0 = Normal | 1 = Low : 2 = High", _, true, 0.0, true, 2.0);
  149. gRatioAuth = CreateConVar("antiroxx_ratio_auth", "1.00", "Si 'Low' alors ratio maximum avant kick | Si 'High':ratio minimum sinon kick", _, true, RATIO_LUCIOLE, true, RATIO_PGM);
  150. gNewServer = CreateConVar("antiroxx_new_server", "127.0.0.1:27015", "Ip du serveur vers lequel on redirigera le joueur.", _);
  151. gActive = CreateConVar("antiroxx_active", "1", "(Des)active antiroxx", _, true, 0.0, true, 1.0);
  152. gMinimumPly = CreateConVar("antiroxx_minimum_player", "4", "Nbres Joueurs minimum pour etre actif", _, true, 1.0, true, 8.0);
  153. gMaxCumul = CreateConVar("antiroxx_max_cumul", "80", "Nombre de frags ou deaths limite, on divise par 2 une fois cette limite atteinte.", _, true, 60.0, true, 1000.0);
  154. gRatio_snipe = CreateConVar("antiroxx_ratio_snipe", "1.00", "A partir de ce ratio: on a plus le droit aux snipes", _, true, RATIO_LUCIOLE, true, RATIO_PGM);
  155. gRatio_flash = CreateConVar("antiroxx_ratio_flash", "1.00", "A partir de ce ratio: on a plus le droit aux flash", _, true, RATIO_LUCIOLE, true, RATIO_PGM);
  156. gFrags_default = CreateConVar("antiroxx_frags_default", "8", "Nombre de frag donné a chaque joueur a la premiere connection", _, true, 1.0, true, 100.0);
  157. gDeaths_default = CreateConVar("antiroxx_deaths_default", "10", "Nombre de morts donne a chaque joueur a la premiere connection", _, true, 1.0, true, 29.0);
  158.  
  159. //Events
  160. HookEvent("item_pickup", Event_ItemPickup, EventHookMode_Pre);
  161. HookEvent("player_death", Event_PlayerDeath);
  162. HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Post);
  163. HookEvent("player_spawn", Event_PlayerSpawn);
  164. HookEvent("round_start", Event_RoundStart);
  165. HookEvent("round_end", Event_RoundEnd);
  166.  
  167. // g_iAccount = FindSendPropOffs("CCSPlayer", "m_iAccount");
  168.  
  169. //Commandes
  170. RegAdminCmd("sm_antiroxx", Antiroxx_List, ADMFLAG_BAN);
  171.  
  172. AutoExecConfig(true, "antiroxx_source", "sourcemod");
  173.  
  174. new String:error[255];
  175. if(SQL_CheckConfig("antiroxx"))
  176. {
  177. hDatabase = SQL_Connect( "antiroxx", true, error, sizeof(error));
  178. }
  179. else
  180. {
  181. // hDatabase=SQL_DefConnect( error, sizeof(error), true);
  182. new Handle:kv = INVALID_HANDLE;
  183. kv = CreateKeyValues("");
  184. KvSetString(kv, "driver", "mysql");
  185. KvSetString(kv, "database", "");
  186. KvSetString(kv, "host", "");
  187. KvSetString(kv, "port", "3306");
  188. KvSetString(kv, "user", "");
  189. KvSetString(kv, "pass", "");
  190. hDatabase = SQL_ConnectCustom(kv, error, sizeof(error), true);
  191. CloseHandle(kv);
  192. }
  193.  
  194. if(hDatabase==INVALID_HANDLE)
  195. {
  196. PrintToServer("[ANTIROXX] Could not connect: %s", error);
  197. LogError("[ANTIROXX] Database failure: %s", error);
  198. }
  199. else
  200. {
  201. decl String:query[512];
  202. Format(query,sizeof(query), "%s%s%s%s%s%s%s%s%s%s%s",
  203. "CREATE TABLE IF NOT EXISTS `css_players` (",
  204. " `steamid` varchar(12) NOT NULL,",
  205. " `pseudo` tinytext,",
  206. " `frag` smallint(5) unsigned NOT NULL,",
  207. " `death` smallint(5) unsigned NOT NULL,",
  208. " `ip` varchar(15) DEFAULT NULL,",
  209. " `LastConnected` timestamp NULL DEFAULT NULL,",
  210. " `timeplayed` timestamp NOT NULL DEFAULT 0,",
  211. " `plx` tinyint(3) unsigned NOT NULL DEFAULT '0',",
  212. " PRIMARY KEY (`steamid`)",
  213. ") TYPE=InnoDB;");
  214. SQL_TQuery(hDatabase, SQLErrorCheckCallback, query);
  215. }
  216.  
  217. if(GetConVarInt(gServeur)!=0) g_handicap -= 0.1;
  218. if(gametype == GAME_CSGO) g_handicap -= 0.2;
  219. }
  220.  
  221. // --------------------------------------------------------------------------------------------------------
  222. //- Error Query
  223. // --------------------------------------------------------------------------------------------------------
  224. public SQLErrorCheckCallback(Handle:owner, Handle:hndl, const String:error[], any:data) {
  225. if(!StrEqual("", error)) {
  226. LogError("Query failed: %s", error);
  227. }
  228. }
  229.  
  230. // --------------------------------------------------------------------------------------------------------
  231. //- Au chargement de la map
  232. // --------------------------------------------------------------------------------------------------------
  233. public OnMapStart()
  234. {
  235. if(gametype == GAME_CSS)
  236. {
  237. // tinkywinky_css
  238. AddFileToDownloadsTable("models/player/vad36santa/blue.dx80.vtx");
  239. AddFileToDownloadsTable("models/player/vad36santa/blue.dx90.vtx");
  240. AddFileToDownloadsTable("models/player/vad36santa/blue.mdl");
  241. AddFileToDownloadsTable("models/player/vad36santa/blue.phy");
  242. AddFileToDownloadsTable("models/player/vad36santa/blue.sw.vtx");
  243. AddFileToDownloadsTable("models/player/vad36santa/blue.vvd");
  244. PrecacheModel("models/player/vad36santa/blue.mdl");
  245.  
  246. // po_css
  247. AddFileToDownloadsTable("models/player/vad36santa/red.dx80.vtx");
  248. AddFileToDownloadsTable("models/player/vad36santa/red.dx90.vtx");
  249. AddFileToDownloadsTable("models/player/vad36santa/red.mdl");
  250. AddFileToDownloadsTable("models/player/vad36santa/red.phy");
  251. AddFileToDownloadsTable("models/player/vad36santa/red.sw.vtx");
  252. AddFileToDownloadsTable("models/player/vad36santa/red.vvd");
  253. AddFileToDownloadsTable("materials/models/player/vad36santa/Santa_N.vtf");
  254. AddFileToDownloadsTable("materials/models/player/vad36santa/Santa_D.vmt");
  255. AddFileToDownloadsTable("materials/models/player/vad36santa/Santa_D.vtf");
  256. AddFileToDownloadsTable("materials/models/player/vad36santa/Santa_D_B.vmt");
  257. AddFileToDownloadsTable("materials/models/player/vad36santa/Santa_D_B.vtf");
  258. PrecacheModel("models/player/vad36santa/red.mdl");
  259.  
  260. // pgm_ct
  261. AddFileToDownloadsTable("models/player/vad36lollipop/lolli.sw.vtx");
  262. AddFileToDownloadsTable("models/player/vad36lollipop/lolli.vvd");
  263. AddFileToDownloadsTable("models/player/vad36lollipop/lolli.dx80.vtx");
  264. AddFileToDownloadsTable("models/player/vad36lollipop/lolli.dx90.vtx");
  265. AddFileToDownloadsTable("models/player/vad36lollipop/lolli.mdl");
  266. AddFileToDownloadsTable("models/player/vad36lollipop/lolli.phy");
  267. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_skin_d_cos11.vtf");
  268. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_skin_n_cos11.vtf");
  269. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_cloth_d_cos11.vmt");
  270. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_cloth_d_cos11.vtf");
  271. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_cloth_n_cos11.vtf");
  272. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_hair_d_cos11.vmt");
  273. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_hair_d_cos11.vtf");
  274. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_hair_n_cos11.vtf");
  275. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_skin_d_cos11.vmt");
  276. PrecacheModel("models/player/vad36lollipop/lolli.mdl");
  277.  
  278. /// pgm_t
  279. AddFileToDownloadsTable("models/player/vad36lollipop/lolli_new.vvd");
  280. AddFileToDownloadsTable("models/player/vad36lollipop/lolli_new.dx80.vtx");
  281. AddFileToDownloadsTable("models/player/vad36lollipop/lolli_new.dx90.vtx");
  282. AddFileToDownloadsTable("models/player/vad36lollipop/lolli_new.mdl");
  283. AddFileToDownloadsTable("models/player/vad36lollipop/lolli_new.phy");
  284. AddFileToDownloadsTable("models/player/vad36lollipop/lolli_new.sw.vtx");
  285. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_skin_d_cos11.vtf");
  286. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_skin_n_cos11.vtf");
  287. AddFileToDownloadsTable("materials/models/player/vad36lollipop/hat.vmt");
  288. AddFileToDownloadsTable("materials/models/player/vad36lollipop/hat.vtf");
  289. AddFileToDownloadsTable("materials/models/player/vad36lollipop/hat_n.vtf");
  290. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_cloth.vmt");
  291. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_cloth.vtf");
  292. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_cloth_n.vtf");
  293. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_hair_d_cos11.vmt");
  294. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_hair_d_cos11.vtf");
  295. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_hair_n_cos11.vtf");
  296. AddFileToDownloadsTable("materials/models/player/vad36lollipop/tx_ch_main_juliet_skin_d_cos11.vmt");
  297. PrecacheModel("models/player/vad36lollipop/lolli_new.mdl");
  298. }
  299.  
  300. // if(gametype == GAME_CSGO)
  301. // {
  302. // // luciolle_red
  303. // AddFileToDownloadsTable("models/player/luciolle_red/luciolle_red.dx80.vtx");
  304. // AddFileToDownloadsTable("models/player/luciolle_red/luciolle_red.dx90.vtx");
  305. // AddFileToDownloadsTable("models/player/luciolle_red/luciolle_red.mdl");
  306. // AddFileToDownloadsTable("models/player/luciolle_red/luciolle_red.sw.vtx");
  307. // AddFileToDownloadsTable("models/player/luciolle_red/luciolle_red.vvd");
  308. // AddFileToDownloadsTable("materials/models/player/luciolle_red/luciolle_red.vtf");
  309. // AddFileToDownloadsTable("materials/models/player/luciolle_red/luciolle_red_normal.vtf");
  310. // AddFileToDownloadsTable("materials/models/player/luciolle_red/lightwarp2.vtf");
  311. // AddFileToDownloadsTable("materials/models/player/luciolle_red/luciolle_red.vmt");
  312. // PrecacheModel("models/player/luciolle_red/luciolle_red.mdl");
  313. //
  314. // // luciolle_blue
  315. // AddFileToDownloadsTable("models/player/luciolle_blue/luciolle_blue.dx80.vtx");
  316. // AddFileToDownloadsTable("models/player/luciolle_blue/luciolle_blue.dx90.vtx");
  317. // AddFileToDownloadsTable("models/player/luciolle_blue/luciolle_blue.mdl");
  318. // AddFileToDownloadsTable("models/player/luciolle_blue/luciolle_blue.sw.vtx");
  319. // AddFileToDownloadsTable("models/player/luciolle_blue/luciolle_blue.vvd");
  320. // AddFileToDownloadsTable("materials/models/player/luciolle_blue/luciolle_blue.vtf");
  321. // AddFileToDownloadsTable("materials/models/player/luciolle_blue/luciolle_blue_normal.vtf");
  322. // AddFileToDownloadsTable("materials/models/player/luciolle_blue/lightwarp2.vtf");
  323. // AddFileToDownloadsTable("materials/models/player/luciolle_blue/luciolle_blue.vmt");
  324. // PrecacheModel("models/player/luciolle_blue/luciolle_blue.mdl");
  325. // }
  326.  
  327. AddFileToDownloadsTable("sound/fr/rougbleu.wav");
  328. PrecacheSound("fr/rougbleu.wav", true);
  329.  
  330. g_FreezeSprite=PrecacheModel("sprites/blueglow2.vmt");
  331. PrecacheSound("physics/glass/glass_impact_bullet4.wav", true);
  332. }
  333.  
  334. // --------------------------------------------------------------------------------------------------------
  335. //- Hook sur dommages recus
  336. // --------------------------------------------------------------------------------------------------------
  337. public OnClientPutInServer( client)
  338. {
  339. SDKHook( client, SDKHook_OnTakeDamage, OnTakeDamage);
  340. SDKHook( client, SDKHook_WeaponCanUse, OnWeaponCanUse);
  341. }
  342.  
  343. // --------------------------------------------------------------------------------------------------------
  344. //- Charge les informations de ratio du joueur.
  345. // --------------------------------------------------------------------------------------------------------
  346. public T_CheckSteamID( Handle:owner, Handle:hndl, const String:error[], any:client)
  347. {
  348. if(!IsClientConnected( client)) return;
  349. if(hndl == INVALID_HANDLE)
  350. {
  351. LogError("[ANTIROXX] Query failed! %s", error);
  352. KickClient(client, "[ANTIROXX] Authorization failed");
  353. return;
  354. }
  355. else if(!SQL_GetRowCount(hndl))
  356. {
  357. decl String:auth[MAX_AUTHID_LENGTH];
  358. GetClientAuthString(client, auth, sizeof(auth));
  359. decl String:steamid[MAX_AUTHID_LENGTH-8];
  360. Format(steamid,sizeof(steamid),"%s",auth[8]);
  361.  
  362. new String:query[150];
  363. Format(query, sizeof(query), "insert into css_players (steamid, frag, death) values ('%s',%d, %d)", steamid, Player_Frags[client], Player_Deaths[client]);
  364. SQL_LockDatabase(hDatabase);
  365. if(!SQL_FastQuery(hDatabase, query))
  366. {
  367. new String:errorsql[255];
  368. SQL_GetError(hDatabase, errorsql, sizeof(errorsql));
  369. PrintToServer("[ANTIROXX] Failed to query (error: %s)", errorsql);
  370. LogError("[ANTIROXX] %s", query);
  371. }
  372. SQL_UnlockDatabase(hDatabase);
  373. plx[client] = 0;
  374. }
  375. else
  376. {
  377. SQL_FetchRow(hndl);
  378. Player_Frags[client] = SQL_FetchInt(hndl,0);
  379. Player_Deaths[client] = SQL_FetchInt(hndl,1);
  380. plx[client] = SQL_FetchInt(hndl,2);
  381. }
  382. Player_Ratio[client]=float(Player_Frags[client])/float(Player_Deaths[client]);
  383. CheckKick(client);
  384. isConfigDownload[client] = true;
  385. }
  386.  
  387. // --------------------------------------------------------------------------------------------------------
  388. //- Lance la requete de chargement du ratio du joueur.
  389. // --------------------------------------------------------------------------------------------------------
  390. CheckSteamID(userid, const String:auth[])
  391. {
  392. decl String:query[255];
  393. Format(query, sizeof(query), "SELECT frag, death, plx FROM css_players WHERE steamid = '%s'", auth);
  394. SQL_TQuery(hDatabase, T_CheckSteamID, query, userid);
  395. }
  396.  
  397. // --------------------------------------------------------------------------------------------------------
  398. //- Interdit les armes pour le PGM
  399. // --------------------------------------------------------------------------------------------------------
  400. public Action:OnWeaponCanUse(client, weapon)
  401. {
  402. if(isPlayerPgm[client])
  403. {
  404. new String:gweapon[64];
  405. GetEntityClassname(weapon, gweapon, sizeof(gweapon));
  406. if(!StrEqual(gweapon,"weapon_knife")
  407. && !StrEqual(gweapon,"weapon_hegrenade")
  408. && !StrEqual(gweapon,"weapon_smokegrenade")
  409. && !StrEqual(gweapon,"weapon_flashbang")
  410. && !StrEqual(gweapon,"weapon_c4"))
  411. return Plugin_Handled;
  412. }
  413. return Plugin_Continue;
  414. }
  415.  
  416. // --------------------------------------------------------------------------------------------------------
  417. //- Quand on recois des dommages (AVANT application des dommages)
  418. // --------------------------------------------------------------------------------------------------------
  419. public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
  420. {
  421. if((attacker>0 && attacker<=MaxClients) && (victim>0 && victim<=MaxClients))
  422. {
  423. decl String:Weapon[32];
  424. GetClientWeapon(attacker, Weapon, sizeof(Weapon));
  425. if(StrEqual(Weapon, "weapon_knife")) return Plugin_Continue;
  426. if(!(damagetype & DMG_BULLET)) return Plugin_Continue;
  427. if(Player_Ratio[attacker]>RATIO_CONFIRME)
  428. {
  429. if(Player_Ratio[attacker]>Player_Ratio[victim])
  430. {
  431. new Float:NewDamage=(g_handicap-(Player_Ratio[attacker]-Player_Ratio[victim]))*damage;
  432. if(NewDamage<0.0) NewDamage=0.0;
  433. // CPrintToChat(attacker, "{green}[ANTIROXX] {olive} Damage: %5.0f NewDamage: %5.0f", damage, NewDamage);
  434. damage=NewDamage;
  435. return Plugin_Changed;
  436. }
  437. }
  438. }
  439. return Plugin_Continue;
  440. }
  441.  
  442. // --------------------------------------------------------------------------------------------------------
  443. //- Affiche la liste des ratio des joueurs et permets de les modifier.
  444. // --------------------------------------------------------------------------------------------------------
  445. public Action:Antiroxx_List(client, args)
  446. {
  447. if(!cvar_Active) return Plugin_Continue;
  448.  
  449. new AdminId:targetAdmin = GetUserAdmin(client);
  450.  
  451. if (targetAdmin != INVALID_ADMIN_ID)
  452. {
  453. if(args>=3 && (GetAdminImmunityLevel(targetAdmin) >= 90))
  454. {
  455. new String:arg1[32], String:arg2[32], String:arg3[32];
  456. new Frag, Death;
  457. if(GetCmdArg(1, arg1, sizeof(arg1)) && GetCmdArg(2, arg2, sizeof(arg2)) && GetCmdArg(3, arg3, sizeof(arg3)))
  458. {
  459. new target=FindTarget(client, arg1);
  460. if(target == -1)
  461. {
  462. return Plugin_Handled;
  463. }
  464. Frag = StringToInt(arg2);
  465. Death = StringToInt(arg3);
  466. new cvar_deaths_default=GetConVarInt(gDeaths_default);
  467. if(Death<=(cvar_deaths_default+10))
  468. {
  469. ReplyToCommand(client,"Le nombre de Death DOIT etre superieur a %d", cvar_deaths_default+10);
  470. return Plugin_Handled;
  471. }
  472. Player_Frags[target]=Frag;
  473. Player_Deaths[target]=Death;
  474. if(Death>0) Player_Ratio[target]=float(Frag)/float(Death);
  475. }
  476. }
  477. else
  478. {
  479. ReplyToCommand(client," id : uid : Player :Ratio: Frag: Death");
  480. for( new i=1; i<MaxClients; i++)
  481. {
  482. if(IsClientInGame(i))
  483. {
  484. new String:Name[MAX_NAME_LENGTH];
  485. GetClientName(i, Name, sizeof(Name));
  486. ReplyToCommand(client,"%4d: %4d: %25s: %5.2f, %4d, %4d", i, GetClientUserId(i), Name, Player_Ratio[i], Player_Frags[i], Player_Deaths[i]);
  487. }
  488. }
  489. ReplyToCommand(client,"--------------------------------------------");
  490. ReplyToCommand(client,"Autre Usage: sm_antiroxx <name|#userid> <frag> <death>");
  491. ReplyToCommand(client,"--------------------------------------------");
  492. }
  493. }
  494. return Plugin_Handled;
  495. }
  496.  
  497. // --------------------------------------------------------------------------------------------------------
  498. //- Des que l'on ramasse quelque chose
  499. // --------------------------------------------------------------------------------------------------------
  500. public Action:Event_ItemPickup(Handle:event, const String:name[], bool:dontbroadcoast)
  501. {
  502. if(!cvar_Active) return Plugin_Continue;
  503. if(GetRealClientCount()<cvar_MinimumPly) return Plugin_Continue;
  504. new userid = GetEventInt(event, "userid");
  505. new String:weapon[64];
  506. GetEventString(event, "item", weapon, sizeof(weapon));
  507. new client = GetClientOfUserId(userid);
  508. if(!IsClientInGame(client)) return Plugin_Continue;
  509. new group_weapon = getGroupWeapon(weapon);
  510. if(isPlayerPgm[client])
  511. {
  512. if(!StrEqual(weapon, "knife", false))
  513. {
  514. FakeClientCommand(client, "use weapon_knife");
  515. new Handle:pack = CreateDataPack();
  516. WritePackCell(pack, client);
  517. WritePackString(pack, weapon);
  518. CreateTimer(0.1, DelayWeapon, pack);
  519. }
  520.  
  521. }
  522. else if((Player_Ratio[client] >= cvar_snipe) && (group_weapon == GROUP_SNIPE))
  523. CS_DropWeapon(client, GetPlayerWeaponSlot(client, 0), true);
  524. return Plugin_Continue;
  525. }
  526.  
  527. // --------------------------------------------------------------------------------------------------------
  528. //- Pas touche..
  529. // --------------------------------------------------------------------------------------------------------
  530. public Action:DelayWeapon(Handle:timer, any:data)
  531. {
  532. new Handle:pack = data;
  533. ResetPack(pack);
  534. new client = ReadPackCell(pack);
  535. new String:item[64];
  536. ReadPackString(pack, item, sizeof(item));
  537. CloseHandle(pack);
  538. for( new i=0; i<2; i++)
  539. {
  540. new ent = GetPlayerWeaponSlot(client, i);
  541. if(ent != -1)
  542. {
  543. RemovePlayerItem(client, ent);
  544. RemoveEdict(ent);
  545. }
  546. }
  547. }
  548.  
  549. // --------------------------------------------------------------------------------------------------------
  550. //- A la mort d'un joueur
  551. // --------------------------------------------------------------------------------------------------------
  552. public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontbroadcoast)
  553. {
  554. if(!cvar_Active) return Plugin_Continue;
  555. if(GetRealClientCount()<cvar_MinimumPly) return Plugin_Continue;
  556. new attackerID=GetEventInt(event, "attacker");
  557. attackerID=GetClientOfUserId(attackerID);
  558. new victimID=GetEventInt(event, "userid");
  559. victimID=GetClientOfUserId(victimID);
  560. new String:weapon[10];
  561. GetEventString(event, "weapon", weapon, 10);
  562. if((isPlayerLuciole[victimID]) && (attackerID > 0) && (!isPlayerLuciole[attackerID]))
  563. {
  564. if(!((StrContains(weapon, "knife", true) != -1) || (StrContains(weapon, "hegrenade", true) != -1)))
  565. {
  566. PrintCenterText(attackerID, "[ANTIROXX] %t", "Kill_Luciole");
  567. CPrintToChat(attackerID, "{green}[ANTIROXX] {red}%t", "Kill_Luciole");
  568. isPunished[attackerID] = 1;
  569. }
  570. }
  571. if((attackerID > 0) && (IsClientInGame(attackerID)) && (!IsFakeClient(victimID)) && (!IsFakeClient(attackerID))) Player_Frags[attackerID]++;
  572. if((IsClientInGame(victimID)) && (!IsFakeClient(attackerID)) && (!IsFakeClient(victimID))) Player_Deaths[victimID]++;
  573. return Plugin_Continue;
  574. }
  575. // --------------------------------------------------------------------------------------------------------
  576. // Kill le tueur de luciolle.
  577. // --------------------------------------------------------------------------------------------------------
  578. public Action:killattaqueur(Handle:timer, any:client)
  579. {
  580. ForcePlayerSuicide(client);
  581. }
  582.  
  583. // --------------------------------------------------------------------------------------------------------
  584. // Slap du joueur en cas d'attaque de la luciole
  585. // --------------------------------------------------------------------------------------------------------
  586. public Action:Event_PlayerHurt(Handle:event,const String:name[],bool:dontBroadcast)
  587. {
  588. if(!cvar_Active) return Plugin_Continue;
  589. if(GetRealClientCount()<cvar_MinimumPly) return Plugin_Continue;
  590. new attackerID = GetEventInt ( event, "attacker" ) ; // ID de l'attaquant
  591. if(GetClientOfUserId(attackerID) > 0)
  592. {
  593. if(IsFakeClient(GetClientOfUserId(attackerID))) return Plugin_Continue;
  594. new victimID = GetEventInt(event, "userid" ); // ID de la victime
  595. victimID = GetClientOfUserId(victimID);
  596. if(isPlayerLuciole[victimID])
  597. {
  598. attackerID = GetClientOfUserId (attackerID);
  599. if(!isPlayerLuciole[attackerID] )
  600. {
  601. new String:weapon[32];
  602. GetEventString(event, "weapon", weapon, sizeof(weapon)); // Arme utilisé
  603. if(!((StrContains(weapon, "knife", true) != -1) || (StrContains(weapon, "hegrenade", true) != -1)))
  604. {
  605. new Damage=GetEventInt(event, "dmg_health");
  606. if (GetClientHealth(attackerID) <= Damage) { CreateTimer(1.0, killattaqueur, attackerID); } else { SlapPlayer(attackerID, Damage); }
  607. }
  608. }
  609. }
  610. }
  611. return Plugin_Continue;
  612. }
  613.  
  614. // --------------------------------------------------------------------------------------------------------
  615. //- Au respawn du joueur
  616. // --------------------------------------------------------------------------------------------------------
  617. public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
  618. {
  619. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  620. if(IsFakeClient(client)) return Plugin_Continue;
  621. SetClanTag(client);
  622. if(!cvar_Active) return Plugin_Continue;
  623. SetEntProp(client, Prop_Send, "m_iAccount", START_MONEY);
  624. g_hAfkCheckSpawn[client] = CreateTimer(0.2, TakeEyePosition, client);
  625. if(GetRealClientCount()<cvar_MinimumPly) return Plugin_Continue;
  626. new String:auth[MAX_AUTHID_LENGTH];
  627. GetClientAuthString(client, auth, sizeof(auth));
  628. decl String:steamid[MAX_AUTHID_LENGTH-8];
  629. Format(steamid,sizeof(steamid),"%s",auth[8]);
  630. if(Player_Ratio[client]<RATIO_JUNIOR)
  631. {
  632. SetEntityHealth(client, HP_LUCIOLE);
  633. isPlayerLuciole[client]=1;
  634. CreateTimer(2.0, SkinLuciole, client);
  635. PrintCenterText(client, "[ANTIROXX] %t", "You_Are_Luciole");
  636. CPrintToChat(client, "{green}[ANTIROXX] {olive}%t", "You_Are_Luciole");
  637. }
  638. else if(Player_Ratio[client]<RATIO_DEBUTANT)
  639. {
  640. SetEntityHealth(client, HP_JUNIOR);
  641. PrintCenterText(client, "[ANTIROXX] %t", "You_Are_Junior");
  642. CPrintToChat(client, "{green}[ANTIROXX] {olive}%t", "You_Are_Junior");
  643. }
  644. else if(Player_Ratio[client]<RATIO_PGM)
  645. {
  646. if( Player_Ratio[client]>=cvar_snipe )
  647. {
  648. new weapon = GetPlayerWeaponSlot(client, 0);
  649. if(weapon != -1)
  650. {
  651. new String:weapon_name[64];
  652. GetEdictClassname(weapon, weapon_name, 64);
  653. if(getGroupWeapon(weapon_name) == GROUP_SNIPE)
  654. CS_DropWeapon(client, GetPlayerWeaponSlot(client, 0), true);
  655. }
  656. CPrintToChat(client, "{green}[ANTIROXX] {olive}%t", "Snipe_Restrict");
  657. }
  658. }
  659. else
  660. {
  661. if(gametype==GAME_CSS) { SetEntityHealth(client, HP_PGM_CSS); }
  662. else if(gametype==GAME_CSGO) { SetEntityHealth(client, HP_PGM_CSGO); }
  663. isPlayerPgm[client] = 1;
  664. for(new i=0; i<2; i++)
  665. {
  666. new ent = GetPlayerWeaponSlot(client, i);
  667. if(ent != -1)
  668. {
  669. RemovePlayerItem(client, ent);
  670. RemoveEdict(ent);
  671. }
  672. }
  673. FakeClientCommand(client, "use weapon_knife");
  674. SetEntPropFloat( client, Prop_Data, "m_flLaggedMovementValue", 0.8);
  675. CreateTimer(2.0, SkinPgm, client);
  676. CPrintToChat(client, "{green}[ANTIROXX] {olive}%t", "You_Are_PGM");
  677. }
  678. if(isPunished[client])
  679. {
  680. isPunished[client]=0;
  681. CPrintToChat(client, "{green}[ANTIROXX] {red} %t", "You_Are_Punish");
  682. CreateTimer(1.0, killattaqueur, client);
  683. }
  684. return Plugin_Continue;
  685. }
  686.  
  687. // --------------------------------------------------------------------------------------------------------
  688. //- Met en place le niveau du joueur.
  689. // --------------------------------------------------------------------------------------------------------
  690. SetClanTag(client)
  691. {
  692. new cvar_deaths_default=GetConVarInt(gDeaths_default);
  693. if(Player_Deaths[client]>(cvar_deaths_default+10))
  694. {
  695. if(Player_Ratio[client]<RATIO_JUNIOR) { CS_SetClientClanTag( client,"[ LUCIOLE ]"); return; }
  696. if(Player_Ratio[client]<RATIO_DEBUTANT) { CS_SetClientClanTag( client,"[ JUNIOR ]"); return; }
  697. if(Player_Ratio[client]<RATIO_DEBUTANT_PLUS) { CS_SetClientClanTag( client,"[DEBUTANT ]"); return; }
  698. if(Player_Ratio[client]<RATIO_CONFIRME) { CS_SetClientClanTag( client,"[DEBUTANT+]"); return; }
  699. if(Player_Ratio[client]<RATIO_CONFIRME_PLUS) { CS_SetClientClanTag( client,"[CONFIRME ]"); return; }
  700. if(Player_Ratio[client]<RATIO_AVANCE) { CS_SetClientClanTag( client,"[CONFIRME+]"); return; }
  701. if(Player_Ratio[client]<RATIO_AVANCE_PLUS) { CS_SetClientClanTag( client,"[ AVANCE ]"); return; }
  702. if(Player_Ratio[client]<RATIO_PRO) { CS_SetClientClanTag( client,"[ AVANCE+ ]"); return; }
  703. if(Player_Ratio[client]<RATIO_PRO_PLUS) { CS_SetClientClanTag( client,"[ PRO ]"); return; }
  704. if(Player_Ratio[client]<RATIO_PGM) { CS_SetClientClanTag( client,"[ PRO+ ]"); return; }
  705. CS_SetClientClanTag( client,"[ -=PGM=- ]");
  706. }
  707. else { CS_SetClientClanTag( client,""); }
  708. return;
  709. }
  710.  
  711. // --------------------------------------------------------------------------------------------------------
  712. //- Met le skin luciole après 2 seconde de jeu.
  713. // --------------------------------------------------------------------------------------------------------
  714. public Action:SkinLuciole(Handle:timer, any:client)
  715. {
  716. if(gametype==GAME_CSS)
  717. {
  718. if(GetClientTeam(client)==CS_TEAM_CT) SetEntityModel(client, "models/player/vad36santa/blue.mdl");
  719. else SetEntityModel(client, "models/player/vad36santa/red.mdl");
  720. }
  721. if(gametype==GAME_CSGO)
  722. {
  723. // if(GetClientTeam(client)==CS_TEAM_CT) SetEntityModel(client, "models/player/luciolle_blue/luciolle_blue.mdl");
  724. // else SetEntityModel(client, "models/player/luciolle_red/luciolle_red.mdl");
  725.  
  726. SetEntityRenderFx(client, RENDERFX_GLOWSHELL);
  727. SetEntityRenderMode(client, RENDER_WORLDGLOW);
  728. if(GetClientTeam(client)==CS_TEAM_CT) { SetEntityRenderColor(client, 100, 200, 255, 255); }
  729. else { SetEntityRenderColor(client, 255, 100, 100, 255); }
  730. }
  731. }
  732.  
  733. // --------------------------------------------------------------------------------------------------------
  734. //- Met le skin Pgm après 2 seconde de jeu.
  735. // --------------------------------------------------------------------------------------------------------
  736. public Action:SkinPgm(Handle:timer, any:client)
  737. {
  738. if(gametype==GAME_CSS)
  739. {
  740. if(GetClientTeam(client) == CS_TEAM_CT) SetEntityModel(client, "models/player/vad36lollipop/lolli.mdl");
  741. else SetEntityModel(client, "models/player/vad36lollipop/lolli_new.mdl");
  742. }
  743. }
  744.  
  745. // --------------------------------------------------------------------------------------------------------
  746. // congeler un joueur
  747. // --------------------------------------------------------------------------------------------------------
  748. public Action:FreezePlayer(Handle:timer, any:client)
  749. {
  750. for(new i=0; i<4; i++)
  751. {
  752. new ent = GetPlayerWeaponSlot(client, i);
  753. if(ent != -1)
  754. {
  755. RemovePlayerItem(client, ent);
  756. RemoveEdict(ent);
  757. }
  758. }
  759. new Float:vec[3];
  760. GetClientAbsOrigin(client, vec);
  761. EmitAmbientSound("physics/glass/glass_impact_bullet4.wav", vec, client);
  762. TE_SetupGlowSprite(vec, g_FreezeSprite, 0.95, 1.5, 50);
  763. TE_SendToAll();
  764. SetEntityMoveType(client, MOVETYPE_NONE);
  765. CloseHandle(timer);
  766. }
  767.  
  768. // --------------------------------------------------------------------------------------------------------
  769. //- Au debut du round
  770. // --------------------------------------------------------------------------------------------------------
  771. public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontbroadcoast)
  772. {
  773. cvar_Active=GetConVarBool(gActive);
  774. if(!cvar_Active) { return Plugin_Continue; }
  775. cvar_MinimumPly=GetConVarInt(gMinimumPly);
  776. if(GetRealClientCount()<cvar_MinimumPly) { return Plugin_Continue; }
  777. cvar_snipe=GetConVarFloat(gRatio_snipe);
  778. cvar_flash=GetConVarFloat(gRatio_flash);
  779. new thereIsLuciole=0;
  780. for( new i=1; i<MaxClients; i++)
  781. {
  782. if((IsClientInGame(i))&&(GetClientTeam(i)>CS_TEAM_SPECTATOR)&&(Player_Ratio[i]<RATIO_JUNIOR)) { thereIsLuciole=1; }
  783. }
  784. if(thereIsLuciole)
  785. {
  786. CPrintToChatAll("{green}[ANTIROXX] {olive}%t", "Luciole_InGame");
  787. CreateTimer(5.0, LucioleInGame);
  788. }
  789. return Plugin_Continue;
  790. }
  791.  
  792. // --------------------------------------------------------------------------------------------------------
  793. //- A la fin du round
  794. // --------------------------------------------------------------------------------------------------------
  795. public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontbroadcoast)
  796. {
  797. if(!cvar_Active) return Plugin_Continue;
  798. for( new client=1; client<MaxClients; client++)
  799. {
  800. if(IsClientInGame(client))
  801. {
  802. new cvar_maxcumul=GetConVarInt(gMaxCumul);
  803. if(Player_Deaths[client]>=cvar_maxcumul)
  804. {
  805. Player_Deaths[client] /= 2;
  806. Player_Frags[client] /= 2;
  807. }
  808. Player_Ratio[client] = float(Player_Frags[client])/float(Player_Deaths[client]);
  809. isPlayerLuciole[client]=0;
  810. isPlayerPgm[client]=0;
  811. if(!IsFakeClient(client))
  812. {
  813. new String:auth[MAX_AUTHID_LENGTH];
  814. GetClientAuthString(client, auth, sizeof(auth));
  815. decl String:steamid[MAX_AUTHID_LENGTH-8];
  816. Format(steamid,sizeof(steamid),"%s",auth[8]);
  817.  
  818. if(isConfigDownload[client])
  819. {
  820. decl String:pseudo[MAX_NAME_LENGTH], String:pseudo_esc[128];
  821. GetClientName(client, pseudo, sizeof(pseudo));
  822. SQL_EscapeString(hDatabase, pseudo, pseudo_esc, sizeof(pseudo_esc));
  823.  
  824. new String:query[150];
  825. Format(query, sizeof(query), "UPDATE css_players SET pseudo='%s' ,frag='%d', death='%d' WHERE steamid='%s'", pseudo_esc, Player_Frags[client], Player_Deaths[client], steamid);
  826. SQL_LockDatabase(hDatabase);
  827. if(!SQL_FastQuery(hDatabase, query))
  828. {
  829. new String:error[255];
  830. SQL_GetError(hDatabase, error, sizeof(error));
  831. PrintToServer("[ANTIROXX] Failed to query (error: %s)", error);
  832. LogError("[ANTIROXX] %s", query);
  833. }
  834. SQL_UnlockDatabase(hDatabase);
  835. }
  836. else { CheckSteamID(client, steamid); }
  837. }
  838. }
  839. }
  840. return Plugin_Continue;
  841. }
  842.  
  843. // --------------------------------------------------------------------------------------------------------
  844. //- Au moment de l'achat
  845. // --------------------------------------------------------------------------------------------------------
  846. public Action:CS_OnBuyCommand(client, const String:weapon[])
  847. {
  848. if((!cvar_Active) || (!IsClientInGame(client))) { return Plugin_Continue; }
  849. if(GetRealClientCount()<cvar_MinimumPly) { return Plugin_Continue; }
  850. new group_weapon = getGroupWeapon(weapon);
  851. if(isPlayerPgm[client]) { return Plugin_Handled; }
  852. if((Player_Ratio[client] >= cvar_snipe) && (group_weapon == GROUP_SNIPE)) { return Plugin_Handled; }
  853. if((Player_Ratio[client] >= cvar_flash) && (group_weapon == GROUP_FLASH)) { return Plugin_Handled; }
  854. else { return Plugin_Continue; }
  855. }
  856.  
  857. // --------------------------------------------------------------------------------------------------------
  858. //- Recupere le type de l'arme
  859. // --------------------------------------------------------------------------------------------------------
  860. getGroupWeapon(const String:weapon[])
  861. {
  862. if((StrContains(weapon, "awp", true) != -1) ||
  863. (StrContains(weapon, "sg550", true) != -1) ||
  864. (StrContains(weapon, "g3sg1", true) != -1)) { return GROUP_SNIPE; }
  865. else if(StrContains(weapon, "flashbang", true) != -1) { return GROUP_FLASH; }
  866. else if(StrContains(weapon, "world", true) != -1) { return GROUP_WORLD; }
  867. else { return GROUP_OTHERS; }
  868. }
  869.  
  870. // --------------------------------------------------------------------------------------------------------
  871. //- Une fois le client authentifié
  872. // --------------------------------------------------------------------------------------------------------
  873. public OnClientAuthorized(client)
  874. {
  875. reset_infos(client);
  876. if(IsFakeClient(client)) { return; }
  877. decl String:auth[MAX_AUTHID_LENGTH];
  878. GetClientAuthString(client, auth, sizeof(auth));
  879. decl String:steamid[MAX_AUTHID_LENGTH-8];
  880. Format(steamid,sizeof(steamid),"%s",auth[8]);
  881. CheckSteamID(client, steamid);
  882. }
  883.  
  884. // --------------------------------------------------------------------------------------------------------
  885. //- Reset des informations(pour être sûr)
  886. // --------------------------------------------------------------------------------------------------------
  887. reset_infos(client)
  888. {
  889. new cvar_frags_default=GetConVarInt(gFrags_default);
  890. new cvar_deaths_default=GetConVarInt(gDeaths_default);
  891. Player_Frags[client]=cvar_frags_default;
  892. Player_Deaths[client]=cvar_deaths_default;
  893. Player_Ratio[client]=float(Player_Frags[client])/float(Player_Deaths[client]);
  894. isPlayerLuciole[client]=0;
  895. isPunished[client]=0;
  896. isConfigDownload[client]=false;
  897. TimePlayed[client] = GetTime();
  898. }
  899.  
  900. // --------------------------------------------------------------------------------------------------------
  901. //- Emet de temps en temps un message d'avertissement luciole.
  902. // --------------------------------------------------------------------------------------------------------
  903. public Action:LucioleInGame(Handle:timer)
  904. {
  905. if(GetRandomInt(1,16)>12) EmitSoundToAll("fr/rougbleu.wav");
  906. }
  907.  
  908. // --------------------------------------------------------------------------------------------------------
  909. //- Prends la position des yeux.
  910. // --------------------------------------------------------------------------------------------------------
  911. public Action:TakeEyePosition(Handle:timer, any:client)
  912. {
  913. if(g_hAfkCheckTimer[client]!=INVALID_HANDLE) KillTimer(g_hAfkCheckTimer[client]);
  914. GetClientEyePosition(client, SpawnPos[client]);
  915. g_hAfkCheckTimer[client]=CreateTimer(25.0, CheckForAfk, client);
  916. g_hAfkCheckSpawn[client]=INVALID_HANDLE;
  917. }
  918.  
  919. // --------------------------------------------------------------------------------------------------------
  920. //- Verifie la position des yeux.
  921. // --------------------------------------------------------------------------------------------------------
  922. public Action:CheckForAfk(Handle:timer, any:client)
  923. {
  924. GetClientEyePosition(client, CurrentPos[client]);
  925. if(SpawnPos[client][0] == CurrentPos[client][0] && SpawnPos[client][1] == CurrentPos[client][1] && SpawnPos[client][2] == CurrentPos[client][2])
  926. {
  927. decl String:name[MAX_NAME_LENGTH];
  928. GetClientName(client, name, sizeof(name));
  929. SlapPlayer(client, 200, false);
  930. PrintToChatAll("\x04Le joueur %s a ete tue (raison:AFK) .", name);
  931. }
  932. g_hAfkCheckTimer[client]=INVALID_HANDLE;
  933. }
  934.  
  935. // --------------------------------------------------------------------------------------------------------
  936. //- A la deconnexion du joueur
  937. // --------------------------------------------------------------------------------------------------------
  938. public OnClientDisconnect(client)
  939. {
  940. if(!cvar_Active) return;
  941. if(g_hAfkCheckTimer[client] != INVALID_HANDLE)
  942. {
  943. KillTimer(g_hAfkCheckTimer[client]);
  944. g_hAfkCheckTimer[client] = INVALID_HANDLE;
  945. }
  946. new cvar_maxcumul = GetConVarInt(gMaxCumul);
  947. if(Player_Deaths[client] >= cvar_maxcumul)
  948. {
  949. Player_Deaths[client] /= 2;
  950. Player_Frags[client] /= 2;
  951. }
  952. Player_Ratio[client]=float(Player_Frags[client])/float(Player_Deaths[client]);
  953. isPlayerLuciole[client]=0;
  954. isPlayerPgm[client]=0;
  955. if(!IsFakeClient(client))
  956. {
  957. new String:auth[MAX_AUTHID_LENGTH];
  958. new String:query[150];
  959. new String:ClientIP[17];
  960. GetClientIP(client, ClientIP, sizeof(ClientIP));
  961. GetClientAuthString(client, auth, sizeof(auth));
  962. decl String:steamid[MAX_AUTHID_LENGTH-8];
  963. Format(steamid,sizeof(steamid),"%s",auth[8]);
  964.  
  965. TimePlayed[client] = GetTime() - TimePlayed[client];
  966.  
  967. Format(query, sizeof(query), "UPDATE css_players SET `frag`='%d', `death`='%d', `ip`='%s', `timeplayed`=`timeplayed`+%d WHERE `steamid`='%s'", Player_Frags[client], Player_Deaths[client], ClientIP, TimePlayed[client], steamid);
  968. if(isConfigDownload[client])
  969. {
  970. SQL_LockDatabase(hDatabase);
  971. if(!SQL_FastQuery(hDatabase, query))
  972. {
  973. new String:error[255];
  974. SQL_GetError(hDatabase, error, sizeof(error));
  975. PrintToServer("[ANTIROXX] Failed to query (error: %s)", error);
  976. LogError("[ANTIROXX] %s", query);
  977. }
  978. SQL_UnlockDatabase(hDatabase);
  979. }
  980. else CheckSteamID(client, steamid);
  981. }
  982. }
  983.  
  984. // --------------------------------------------------------------------------------------------------------
  985. //- Retourne le nombre réel de joueurs connectés.
  986. // --------------------------------------------------------------------------------------------------------
  987. GetRealClientCount()
  988. {
  989. new clients = 0;
  990. for( new i = 1; i <= MaxClients; i++ )
  991. {
  992. if((IsClientInGame(i)) && (!IsFakeClient(i)) && (GetClientTeam(i)>CS_TEAM_SPECTATOR) ) { clients++; }
  993. }
  994. return clients;
  995. }
  996.  
  997. // --------------------------------------------------------------------------------------------------------
  998. //- Verification si le joueurs est autorisé a se connecter.
  999. // --------------------------------------------------------------------------------------------------------
  1000. CheckKick(client)
  1001. {
  1002. new cvar_deaths_default=GetConVarInt(gDeaths_default);
  1003. if(Player_Deaths[client]>(cvar_deaths_default+10))
  1004. {
  1005. if(GetConVarInt(gServeur)==1 && !(plx[client]&1))
  1006. {
  1007. decl String:NewServer[24];
  1008. decl String:KickMessage[128];
  1009. GetConVarString(gNewServer,NewServer,sizeof(NewServer));
  1010. Format(KickMessage, sizeof(KickMessage), "%t %s", "Too_Strong", NewServer);
  1011. if(Player_Ratio[client]>=GetConVarFloat(gRatioAuth)) { KickClient(client, KickMessage); }
  1012. }
  1013. else if(GetConVarInt(gServeur)==2 && !(plx[client]&2))
  1014. {
  1015. decl String:NewServer[24];
  1016. decl String:KickMessage[128];
  1017. GetConVarString(gNewServer,NewServer,sizeof(NewServer));
  1018. Format(KickMessage, sizeof(KickMessage), "%t %s", "Too_Low", NewServer);
  1019. if(Player_Ratio[client]<=GetConVarFloat(gRatioAuth)) { KickClient(client, KickMessage); }
  1020. }
  1021. }
  1022. return;
  1023. }
Add Comment
Please, Sign In to add comment