Help - Search - Members - Calendar
Full Version: Recherche Plugin
Forum 17B > Counter Strike 1.6 > General discussion
freddechnord
Bonjour a Tous et Toutes,

Voila je suis a la recherche d un Plugin qui permet de Gerer les Joeurs trop Fort sur mon debutant d etres automatiquement rediriger vers mon autre serveur Fun pour Joueurs Fort !! voir aussi le contraire, joueurs Faible basculerai automatiquement sur le serveur debutant ??

d Avance Merci
Blueberry
J'ai aussi cherché un tel plugin mais je n'ai pas trouvé.
Par contre, un plugin utile (Antiroxx v2) permet de limiter les joueurs trop fort en plusieurs étapes d'abord en leur interdisant les snipes, puis en les limitant au SMG (MP5, P90, etc...), puis au pistolet, et endin au couteau.

voici le code :
QUOTE
/********************************************************************************
*
* Plugin : AntiRoxx v2.0
*
* Ce plugin a été réalisé par KRoT@L.
* Ce plugin ne peut être utilisé sans le consentement écrit de l'auteur et il ne
* peut en aucun cas être utilisé à des fins commerciales, c'est-à-dire soit vendu
* à des tiers, soit utilisé sur des sites ou des serveurs payants pour les utilisateurs.
*
* © Copyright 2006
*
* ********************************************************************************
*
* Commandes:
*
* say /antiroxx : affiche l'aide du plugin AntiRoxx
* antiroxx_motd : affiche les joueurs et leur ratio dans un MOTD (ADMIN_LEVEL_B)
* antiroxx_con : affiche les joueurs et leur ratio dans la console (ADMIN_LEVEL_B)
*
* --------------------------------------------------------------------------------
*
* Variables:
*
* antiroxx_active 1 // plugin activé ou non
*
* antiroxx_maxcumul 100 // nombre max de frags ou deaths, après c'est divisé par 2 (permet de ne pas avoir de trop grands nombres dans les logs)
*
* antiroxx_ratio_ban 999999999 // ratio de frags/morts au delà duquel le joueur est kické et ne peut plus se reconnecter
* // (mettez une valeur inférieure à ratio_nothing sinon le joueur n'atteindra jamais ce ratio)
* // (mettez une valeur très haute comme 99999 pour désactiver)
* antiroxx_ratio_nothing 4.0 // ratio de frags/morts pour n'avoir aucune arme
* antiroxx_ratio_knife 3.0 // ratio frags/morts pour être limité au couteau
* antiroxx_ratio_gun 2.0 // ratio frags/morts pour être limité au g_gun défini dans antiroxx_gun
* antiroxx_ratio_smg 1.5 // ratio frags/morts pour être limité aux smgs
* antiroxx_ratio_snipe 1.3 // ratio frags/morts pour ne plus pouvoir utiliser les fusils de snipe
* antiroxx_ratio_debutant 0.6 // ratio frags/morts sous lequel le joueur est protégé (il ne peut être tué que par le couteau)
* // et colorié en rouge (mettez une valeur très basse comme -99999 pour désactiver)
*
* antiroxx_debutant_punition 0 // enterrer et exécuter la punition ou non au round suivant sur le joueur qui tue un débutant avec des balles
* antiroxx_punition "" // commande exécutée pour la punition (nécessite un plugin externe)
* // ex: "amx_sprite %player% idiot" (utilisez %player% là où l'id du joueur est nécessaire dans la commande)
* antiroxx_suppr_punition "" // commande exécutée pour la désactivation de la punition (nécessite un plugin externe)
* // ex: "amx_unsprite %player%" (utilisez %player% là où l'id du joueur est nécessaire dans la commande)
*
* antiroxx_ban_min_frags 100 // nombre de frags minimum que le joueur doit avoir pour se faire bannir s'il dépasse le ratio_ban
*
* antiroxx_frags_defaut 0 // nombre de frags attribué par défaut à un nouveau joueur sur le serveur
* antiroxx_morts_defaut 0 // nombre de morts attribué par défaut à un nouveau joueur sur le serveur
*
* antiroxx_weapons_mode 1 // 0/1 : désactive ou active le mode où les joueurs sont limités en arme
* antiroxx_gun "glock18" // Valeurs possibles: usp, glock18, deagle, p228, fiveseven, elite
* antiroxx_allow1 0 // arme autorisée quel que soit le score, pour les maps awp ou scout par exemple
* antiroxx_allow2 0 // (voir amxconst.inc pour les numéros des armes)
*
* antiroxx_health_mode 0 // 0/1 : désactive ou active le mode qui modifie les points de vie des joueurs
* antiroxx_health_nothing 100 // points de vie donnés aux joueurs qui dépassent le ratio_nothing
* antiroxx_health_knife 100 // les points de vie donnés aux joueurs qui dépassent le ratio_knife seront entre antiroxx_health_knife et antiroxx_health_nothing
* antiroxx_health_gun 100 // les points de vie donnés aux joueurs qui dépassent le ratio_gun seront entre antiroxx_health_gun et antiroxx_health_knife
* antiroxx_health_smg 100 // les points de vie donnés aux joueurs qui dépassent le ratio_smg seront entre antiroxx_health_smg et antiroxx_health_gun
* antiroxx_health_snipe 100 // les points de vie donnés aux joueurs qui dépassent le ratio_snipe seront entre antiroxx_health_snipe et antiroxx_health_smg
* antiroxx_health_debutant 100 // points de vie donnés aux joueurs qui sont en dessous du ratio_debutant
*
* antiroxx_armor_mode 0 // 0/1 : désactive ou active le mode qui modifie les points d'armure des joueurs
* antiroxx_armor_nothing -1 // points d'armure donnés aux joueurs qui dépassent le ratio_nothing (-1 = pas de changement)
* antiroxx_armor_knife -1 // les points d'armure aux joueurs qui dépassent le ratio_knife seront entre antiroxx_armor_knife et antiroxx_armor_nothing (-1 = pas de changement)
* antiroxx_armor_gun -1 // les points d'armure aux joueurs qui dépassent le ratio_gun seront entre antiroxx_armor_gun et antiroxx_armor_knife (-1 = pas de changement)
* antiroxx_armor_smg -1 // les points d'armure aux joueurs qui dépassent le ratio_smg seront entre antiroxx_armor_smg et antiroxx_armor_gun (-1 = pas de changement)
* antiroxx_armor_snipe -1 // les points d'armure aux joueurs qui dépassent le ratio_snipe seront entre antiroxx_armor_snipe et antiroxx_armor_smg (-1 = pas de * changement)
* antiroxx_armor_debutant -1 // points d'armure aux joueurs qui sont en dessous du ratio_debutant (-1 = pas de changement)
*
* --------------------------------------------------------------------------------
*
* Installation:
*
* Créez un dossier antiroxx_logs ici : addons/amxmodx/configs/antiroxx_logs/
* ou modifiez la valeur de g_path[] ci-dessous.
* Désactivez le plugin restmenu.amxx (il est intégré à ce plugin antiroxx car
* il y a un conflit entre les deux plugins pour la restriction des armes).
* TODO: FrontEnd AntiRoxx à la place de RestMenu
* TODO: Check if the included restmenu is exploit-proof
*
*
* --------------------------------------------------------------------------------
*
* Vous pouvez copier-coller ceci dans votre amx.cfg (modifiez les valeurs comme bon vous semble):
*/
/*
antiroxx_active 1

antiroxx_maxcumul 100

antiroxx_ratio_ban 9999999999999999
antiroxx_ratio_nothing 3.3
antiroxx_ratio_knife 2.7
antiroxx_ratio_gun 2.3
antiroxx_ratio_smg 1.9
antiroxx_ratio_snipe 1.5
antiroxx_ratio_debutant -99999999999999

antiroxx_debutant_punition 0
antiroxx_punition ""
antiroxx_suppr_punition ""

antiroxx_ban_min_frags 100

antiroxx_frags_defaut 0
antiroxx_morts_defaut 0

antiroxx_weapons_mode 1
antiroxx_gun "usp, glock18"
antiroxx_allow1 0
antiroxx_allow2 0

antiroxx_health_mode 0
antiroxx_health_nothing 100
antiroxx_health_knife 100
antiroxx_health_gun 100
antiroxx_health_smg 100
antiroxx_health_snipe 100
antiroxx_health_debutant 100

antiroxx_armor_mode 0
antiroxx_armor_nothing -1
antiroxx_armor_knife -1
antiroxx_armor_gun -1
antiroxx_armor_smg -1
antiroxx_armor_snipe -1
antiroxx_armor_debutant -1
*/
/*
*
* --------------------------------------------------------------------------------
*
* Remerciements:
*
* Sacripan pour les demandes, les tests et les remarques,
* et pour le calcul du ratio progressif health/armor.
*
* ********************************************************************************
*
* Liens:
*
* Forum d'AMX : http://amxmod.net/forums/
* Site sur CS pour les débutants : http://perso.wanadoo.fr/cspoires/
*
*
* Ported to AMX Mod X by NiLuJe <niluje@ak-team.com>
* $Id$
*
********************************************************************************/

#pragma semicolon 1

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>

new g_banMsg[] = "Tu es trop fort pour ce serveur";
new g_path[] = "addons/amxmodx/configs/antiroxx_logs";

// Uncomment if you want to have separate settings for each map (restmenu)
//#define MAPSETTINGS

/******************************************************************************/

#define PLUGIN_NOM "AntiRoxx"
#define PLUGIN_VERSION "2.0.X"
#define PLUGIN_AUTEUR "KRoTaL"

new bool:g_nothing_only[33];
new bool:g_knife_only[33];
new bool:g_gun_only[33];
new bool:g_smg_only[33];
new bool:g_nosnipe[33];
new bool:g_debutant[33];
new g_isPunished[33];
new g_weapons_mode;
new Float:g_ratio_ban, Float:g_ratio_nothing, Float:g_ratio_knife, Float:g_ratio_gun, Float:g_ratio_smg, Float:g_ratio_snipe, Float:g_ratio_debutant;
new g_health_mode, g_health_nothing, g_health_knife, g_health_gun, g_health_smg, g_health_snipe, g_health_debutant;
new g_armor_mode, g_armor_nothing, g_armor_knife, g_armor_gun, g_armor_smg, g_armor_snipe, g_armor_debutant;
new g_gun = 1;
new g_kills[33], g_deaths[33];
new g_last_kills[33], g_last_deaths[33];
new g_info_count;
new g_maxplayers;

new weapon_csw[6] = {16,17,26,1,11,10};
new weapon_string[6][] = {"USP", "GLOCK18", "DEAGLE", "P228", "FIVE SEVEN", "ELITE"};
new weapon_gun_nom[6][] = {"weapon_usp", "weapon_glock18", "weapon_deagle", "weapon_p228", "weapon_fiveseven", "weapon_elite"};
new g_dummy1, g_dummy2;

new menuid_null=-1;
new menuid_buy=-1, menuid_buypistol=-1, menuid_buyshotgun=-1, menuid_buysub=-1, menuid_buyrifle=-1, menuid_buymachine=-1, menuid_buyitem=-1;
new vgui_menuid_buy=-1, vgui_menuid_buypistol=-1, vgui_menuid_buyshotgun=-1, vgui_menuid_buysub=-1, vgui_menuid_buyrifle=-1, vgui_menuid_buymachine=-1, vgui_menuid_buyitem=-1;

#define TASK_ARMOR 674414
#define TASK_RESETHUD 247741

#define MAX_BUFFER_LENGTH 1536
new g_buffer[MAX_BUFFER_LENGTH] = "";

/******************************************************************************/

#define MAXMENUPOS 34

new g_Position[33];
new g_Modified;
new g_blockPos[114];
new g_saveFile[128];

new g_szWeapRestr[27] = "00000000000000000000000000"; // KWo - stuff for bots weapon restrictions
new g_szEquipAmmoRestr[10] = "000000000"; // KWo - stuff for bots weapon restrictions

new g_menusNames[7][] = {
"pistol",
"shotgun",
"sub",
"rifle",
"machine",
"equip",
"ammo"
};

new g_MenuTitle[7][] = {
"Handguns",
"Shotguns",
"Sub-Machine Guns",
"Assault & Sniper Rifles",
"Machine Guns",
"Equipment",
"Ammunition"
};

new g_menusSets[7][2] = {
{0,6},{6,8},{8,13},{13,23},{23,24},{24,32},{32,34}
};

new g_AliasBlockNum;
new g_AliasBlock[MAXMENUPOS];

// First position is a position of menu (0 for ammo, 1 for pistols, 6 for equipment etc.)
// Second is a key for TERRORIST (all these keys are minus one, 1 is 0, 2 is 1 etc.)
// Third is a key for CT
// Position with -1 doesn't exist
new g_Keys[MAXMENUPOS][3] = {
{1,1,1}, // H&K USP .45 Tactical
{1,0,0}, // Glock18 Select Fire
{1,3,3}, // Desert Eagle .50AE
{1,2,2}, // SIG P228
{1,4,-1}, // Dual Beretta 96G Elite
{1,-1,4}, // FN Five-Seven
{2,0,0}, // Benelli M3 Super90
{2,1,1}, // Benelli XM1014
{3,1,1}, // H&K MP5-Navy
{3,-1,0}, // Steyr Tactical Machine Pistol
{3,3,3}, // FN P90
{3,0,-1}, // Ingram MAC-10
{3,2,2}, // H&K UMP45
{4,1,-1}, // AK-47
{4,0,-1}, // Galil
{4,-1,0}, // Famas
{4,3,-1}, // Sig SG-552 Commando
{4,-1,2}, // Colt M4A1 Carbine
{4,-1,3}, // Steyr Aug
{4,2,1}, // Steyr Scout
{4,4,5}, // AI Arctic Warfare/Magnum
{4,5,-1}, // H&K G3/SG-1 Sniper Rifle
{4,-1,4}, // Sig SG-550 Sniper
{5,0,0}, // FN M249 Para
{6,0,0}, // Kevlar Vest
{6,1,1}, // Kevlar Vest & Helmet
{6,2,2}, // Flashbang
{6,3,3}, // HE Grenade
{6,4,4}, // Smoke Grenade
{6,-1,6}, // Defuse Kit
{6,5,5}, // NightVision Goggles
{6,-1,7}, // Tactical Shield
{0,5,5}, // Primary weapon ammo
{0,6,6} // Secondary weapon ammo
};

new g_WeaponNames[MAXMENUPOS][] = {
"H&K USP .45 Tactical",
"Glock18 Select Fire",
"Desert Eagle .50AE",
"SIG P228",
"Dual Beretta 96G Elite",
"FN Five-Seven",
"Benelli M3 Super90",
"Benelli XM1014",
"H&K MP5-Navy",
"Steyr Tactical Machine Pistol",
"FN P90",
"Ingram MAC-10",
"H&K UMP45",
"AK-47",
"Galil",
"Famas",
"Sig SG-552 Commando",
"Colt M4A1 Carbine",
"Steyr Aug",
"Steyr Scout",
"AI Arctic Warfare/Magnum",
"H&K G3/SG-1 Sniper Rifle",
"Sig SG-550 Sniper",
"FN M249 Para",
"Kevlar Vest",
"Kevlar Vest & Helmet",
"Flashbang",
"HE Grenade",
"Smoke Grenade",
"Defuse Kit",
"NightVision Goggles",
"Tactical Shield",
"Primary weapon ammo",
"Secondary weapon ammo"
};

new g_MenuItem[MAXMENUPOS][] = {
"\yHandguns^n\w^n%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w^n",

"\yShotguns^n\w^n%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w^n",

"\ySub-Machine Guns^n\w^n%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w^n",

"\yAssault Rifles^n\w^n%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w^n",

"\ySniper Rifles^n\w^n%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w^n",

"\yMachine Guns^n\w^n%d. %s\y\R%s^n\w^n",

"\yEquipment^n\w^n%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w^n",

"\yAmmunition^n\w^n%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w"
};

new g_Aliases[MAXMENUPOS][] = {
"usp", //Pistols
"glock",
"deagle",
"p228",
"elites",
"fn57",

"m3", //Shotguns
"xm1014",

"mp5", //SMG
"tmp",
"p90",
"mac10",
"ump45",

"ak47", //Rifles
"galil",
"famas",
"sg552",
"m4a1",
"aug",
"scout",
"awp",
"g3sg1",
"sg550",

"m249", //Machine Gun

"vest", //Equipment
"vesthelm",
"flash",
"hegren",
"sgren",
"defuser",
"nvgs",
"shield",
"primammo", //Ammo
"secammo"
};

new g_Aliases2[MAXMENUPOS][] = {
"km45", //Pistols
"9x19mm",
"nighthawk",
"228compact",
"elites",
"fiveseven",

"12gauge", //Shotguns
"autoshotgun",

"smg", //SMG
"mp",
"c90",
"mac10",
"ump45",

"cv47", //Rifles
"defender",
"clarion",
"krieg552",
"m4a1",
"bullpup",
"scout",
"magnum",
"d3au1",
"krieg550",

"m249", //Machine Gun

"vest", //Equipment
"vesthelm",
"flash",
"hegren",
"sgren",
"defuser",
"nvgs",
"shield",
"primammo", //Ammo
"secammo"
};

/******************************************************************************/

public plugin_init()
{
register_dictionary("restmenu");
register_plugin(PLUGIN_NOM, PLUGIN_VERSION, PLUGIN_AUTEUR);

register_cvar("AntiRoxx", PLUGIN_VERSION, FCVAR_SERVER);

register_cvar("antiroxx_active", "1"); // plugin activé ou non

register_cvar("antiroxx_maxcumul", "200"); // nombre max de frags ou deaths, après c'est divisé par 2

register_cvar("antiroxx_ratio_ban", "9999999999999999"); // ratio de frags/morts au delà duquel le joueur est kické et ne peut plus se reconnecter
// (mettez une valeur inférieure à ratio_nothing sinon le joueur n'atteindra jamais ce ratio
register_cvar("antiroxx_ratio_nothing", "3.3"); // ratio de frags/morts pour n'avoir aucune arme
register_cvar("antiroxx_ratio_knife", "2.7"); // ratio frags/morts pour être limité au couteau
register_cvar("antiroxx_ratio_gun", "2.3"); // ratio frags/morts pour être limité au g_gun défini dans antiroxx_gun
register_cvar("antiroxx_ratio_smg", "1.9"); // ratio frags/morts pour être limité aux smgs
register_cvar("antiroxx_ratio_snipe", "1.5"); // ratio frags/morts pour ne plus pouvoir utiliser les fusils de snipe
register_cvar("antiroxx_ratio_debutant", "-999999999999999999"); // ratio frags/morts sous lequel le joueur est protégé et colorié en rouge
register_cvar("antiroxx_debutant_punition", "0"); // enterrer ou non au round suivant le joueur qui tue un débutant avec des balles
register_cvar("antiroxx_punition", ""); // commande exécutée pour la punition (nécessite un plugin externe)
register_cvar("antiroxx_suppr_punition", ""); // commande exécutée pour la désactivation de la punition (nécessite un plugin externe)
register_cvar("antiroxx_ban_min_frags", "100"); // nombre de frags minimum que le joueur doit avoir pour se faire bannir s'il dépasse le ratio_ban

register_cvar("antiroxx_frags_defaut", "0"); // nombre de frags attribué par défaut à un nouveau joueur sur le serveur
register_cvar("antiroxx_morts_defaut", "0"); // nombre de morts attribué par défaut à un nouveau joueur sur le serveur

register_cvar("antiroxx_weapons_mode", "1"); // 0/1 : désactive ou active le mode où les joueurs sont limités en arme
register_cvar("antiroxx_gun", "usp, glock18"); // usp, glock18, deagle, p228, fiveseven, elite
register_cvar("antiroxx_allow1", "0"); // arme autorisée quel que soit le score, pour les maps awp ou scout par exemple
register_cvar("antiroxx_allow2", "0"); // (voir amxconst.inc pour les numéros des armes)

register_cvar("antiroxx_health_mode", "0"); // 0/1 : désactive ou active le mode qui modifie les points de vie des joueurs
register_cvar("antiroxx_health_nothing", "100"); // points de vie donnés aux joueurs qui dépassent le ratio_nothing
register_cvar("antiroxx_health_knife", "100");
register_cvar("antiroxx_health_gun", "100");
register_cvar("antiroxx_health_smg", "100");
register_cvar("antiroxx_health_snipe", "100");
register_cvar("antiroxx_health_debutant", "100"); // points de vie donnés aux joueurs qui sont en dessous du ratio_debutant

register_cvar("antiroxx_armor_mode", "0"); // 0/1 : désactive ou active le mode qui modifie les points d'armure des joueurs
register_cvar("antiroxx_armor_nothing", "-1"); // points d'armure donnés aux joueurs qui dépassent le ratio_nothing (-1 = pas de changement)
register_cvar("antiroxx_armor_knife", "-1");
register_cvar("antiroxx_armor_gun", "-1");
register_cvar("antiroxx_armor_smg", "-1");
register_cvar("antiroxx_armor_snipe", "-1");
register_cvar("antiroxx_armor_debutant", "-1"); // points d'armure aux joueurs qui sont en dessous du ratio_debutant (-1 = pas de changement)

register_clcmd("say /antiroxx", "aide_antiroxx", 0, ": affiche l'aide du plugin AntiRoxx");
register_clcmd("antiroxx_motd", "cmdAntiroxxMotd", ADMIN_LEVEL_B, ": affiche les joueurs et leur ratio dans un MOTD");
register_concmd("antiroxx_con", "cmdAntiroxxCon", ADMIN_LEVEL_B, ": affiche les joueurs et leur ratio dans la console");

/****************************************************************************/

//register_event("SendAudio", "end_round", "a", "2&%!MRAD_terwin", "2&%!MRAD_ctwin", "2&%!MRAD_rounddraw");
register_event("HLTV","end_round","a","1=0","2=0");
register_event("TextMsg", "end_round", "a", "2&#Game_C", "2&#Game_w");
register_event("ResetHUD","reset_hud","be");
register_event("DeathMsg", "death_msg", "a");
register_event("Damage", "damage_event", "b", "2!0");
//register_event("ScoreInfo","score_info","a");
register_event("CurWeapon","check_weapon","be","1=1");
register_event("RoundTime", "start_round", "bc");

register_clcmd("buyammo1","ammoRest1");
register_clcmd("buyammo2","ammoRest2");
register_clcmd("cl_setautobuy","blockcommand");
register_clcmd("cl_autobuy","blockcommand");
register_clcmd("cl_setrebuy","blockcommand");
register_clcmd("cl_rebuy","blockcommand");
new ar_help_restrict[64];
formatex( ar_help_restrict, 63, "%L", LANG_PLAYER, "AR_HELP_RESTRICT" );
register_concmd("amx_restrict","cmdRest",ADMIN_CFG,ar_help_restrict);
new ar_help_restmenu[64];
formatex( ar_help_restmenu, 63, "%L", LANG_PLAYER, "AR_HELP_RESTMENUT" );
register_clcmd("amx_restmenu","cmdMenu",ADMIN_CFG,ar_help_restmenu);
register_cvar("amx_restrweapons", "00000000000000000000000000"); // KWo - stuff for bots weapon restrictions
register_cvar("amx_restrequipammo", "000000000"); // KWo - stuff for bots weapon restrictions
register_menucmd(register_menuid("\yRestrict Weapons"),1023,"actionMenu");
menuid_null = register_menuid("NULL");
menuid_buy = register_menuid("#Buy", 1);
menuid_buypistol = register_menuid("BuyPistol", 1);
menuid_buyshotgun = register_menuid("BuyShotgun", 1);
menuid_buysub = register_menuid("BuySub", 1);
menuid_buyrifle = register_menuid("BuyRifle", 1);
menuid_buymachine = register_menuid("BuyMachine", 1);
menuid_buyitem = register_menuid("BuyItem", 1);
vgui_menuid_buy = -28;
vgui_menuid_buypistol = -29;
vgui_menuid_buyshotgun = -30;
vgui_menuid_buysub = -32;
vgui_menuid_buyrifle = -31;
vgui_menuid_buymachine = -33;
vgui_menuid_buyitem = -34;
register_menucmd(menuid_buy,511,"menuBuy");
register_menucmd(menuid_buypistol,511,"menuPistol");
register_menucmd(menuid_buyshotgun,511,"menuShotgun");
register_menucmd(menuid_buysub,511,"menuSub");
register_menucmd(menuid_buyrifle,511,"menuRifle");
register_menucmd(menuid_buymachine,511,"menuMachine");
register_menucmd(menuid_buyitem,511,"menuItem");
register_menucmd(vgui_menuid_buy,511,"menuBuy");
register_menucmd(vgui_menuid_buypistol,511,"menuPistol");
register_menucmd(vgui_menuid_buyshotgun,511,"menuShotgun");
register_menucmd(vgui_menuid_buysub,511,"menuSub");
register_menucmd(vgui_menuid_buyrifle,511,"menuRifle");
register_menucmd(vgui_menuid_buymachine,511,"menuMachine");
register_menucmd(vgui_menuid_buyitem,511,"menuItem");

g_info_count = 0;
g_maxplayers = get_maxplayers();
getRatioValues();

#if defined MAPSETTINGS
new mapname[32];
get_mapname(mapname, 31);
get_customdir( g_saveFile, 127 );
format( g_saveFile, 127, "%s/weaprest_%s.ini", g_saveFile, mapname );
#else
get_customdir( g_saveFile, 127 );
format( g_saveFile, 127, "%s/weaprest.ini", g_saveFile );
#endif
loadSettings(g_saveFile);
}

public aide_antiroxx(id)
{
if(get_cvar_num("antiroxx_active")==0)
return PLUGIN_CONTINUE;

new n = 0;

n += copy(g_buffer[n],MAX_BUFFER_LENGTH-n,"<b>** AMX ANTIROXX **</b><br><br>");
n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"Si le joueur a un ratio kills/deaths >= %.2f,<br>", get_cvar_float("antiroxx_ratio_ban"));
n += copy(g_buffer[n],MAX_BUFFER_LENGTH-n,"il sera banni.<br>");
n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"Si le joueur a un ratio kills/deaths >= %.2f,<br>", get_cvar_float("antiroxx_ratio_nothing"));
n += copy(g_buffer[n],MAX_BUFFER_LENGTH-n,"il ne pourra utiliser aucune arme, pas même le couteau.<br>");
n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"Si le joueur a un ratio kills/deaths < %.2f et >= %.2f,<br>", get_cvar_float("antiroxx_ratio_nothing"), get_cvar_float("antiroxx_ratio_knife"));
n += copy(g_buffer[n],MAX_BUFFER_LENGTH-n,"il sera limité au couteau et aux grenades.<br>");
n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"Si le joueur a un ratio kills/deaths < %.2f et >= %.2f,<br>", get_cvar_float("antiroxx_ratio_knife"), get_cvar_float("antiroxx_ratio_gun"));
n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"il sera limité au couteau, au %s et aux grenades.<br>", (g_gun >= 0) ? weapon_string[g_gun] : "couteau");
n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"Si le joueur a un ratio kills/deaths < %.2f et >= %.2f,<br>", get_cvar_float("antiroxx_ratio_gun"), get_cvar_float("antiroxx_ratio_smg"));
n += copy(g_buffer[n],MAX_BUFFER_LENGTH-n,"il sera limité au couteau, aux pistolets, aux fusils à pompes, aux smgs et aux grenades.<br>");
n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"Si le joueur a un ratio kills/deaths < %.2f et >= %.2f,<br>", get_cvar_float("antiroxx_ratio_smg"), get_cvar_float("antiroxx_ratio_snipe"));
n += copy(g_buffer[n],MAX_BUFFER_LENGTH-n,"il ne pourra plus utiliser les snipes.<br><br>");
n += copy(g_buffer[n],MAX_BUFFER_LENGTH-n,"Plugin écrit par KRoT@L.<br>http://amxmod.net/forums/");

show_motd(id, g_buffer, "Aide AntiRoxx");

return PLUGIN_CONTINUE;
}

public cmdAntiroxxMotd(id,level,cid) {
if(!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED;

new n = 0;
new plname[32];
new Float:ratio;

n += copy(g_buffer[n],MAX_BUFFER_LENGTH-n,"<body bgcolor=#000000><font color=#FFB000>");
n += copy(g_buffer[n],MAX_BUFFER_LENGTH-n,"<b>** AMX ANTIROXX **</b><br><pre>");
n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"%-24.24s %8s %8s %8s^n^n", "Pseudo", "Frags", "Morts", "Ratio");
for(new i = 1; i <= g_maxplayers; ++i ) {
if(is_user_connected(i) && !is_user_bot(i)) {
plname[0] = '^0';
get_user_name(i, plname, 31);
if(g_deaths[i] == 0)
g_deaths[i] = 1;
ratio = float(g_kills[i]) / float(g_deaths[i]);
n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"%-24.24s %8d %8d %5.2f^n",
plname,g_kills[i],g_deaths[i],ratio);
}
}

n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"^nratio_nothing=%.2f^n",g_ratio_nothing);
n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"ratio_knife=%.2f^n",g_ratio_knife);
n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"ratio_gun=%.2f^n",g_ratio_gun);
n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"ratio_smg=%.2f^n",g_ratio_smg);
n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"ratio_snipe=%.2f^n",g_ratio_snipe);
n += format(g_buffer[n],MAX_BUFFER_LENGTH-n,"",g_ratio_debutant);

show_motd(id, g_buffer, "AntiRoxx : Liste des joueurs");

return PLUGIN_HANDLED;
}

public cmdAntiroxxCon(id,level,cid) {
if(!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED;

new plname[32];

console_print(id, "** AMX ANTIROXX **");
console_print(id, "%-32.32s %8s %8s %8s", "Pseudo", "Frags", "Morts", "Ratio");
for(new i = 1; i <= g_maxplayers; ++i) {
if(is_user_connected(i) && !is_user_bot(i)) {
plname[0] = '^0';
get_user_name(i, plname, 31);
console_print(id, "%-32.32s %8d %8d %5.2f",plname,g_kills[i],g_deaths[i],float(g_kills[i])/float(g_deaths[i]));
}
}
console_print(id, "^nratio_nothing=%.2f",g_ratio_nothing);
console_print(id, "ratio_knife=%.2f",g_ratio_knife);
console_print(id, "ratio_gun=%.2f",g_ratio_gun);
console_print(id, "ratio_smg=%.2f",g_ratio_smg);
console_print(id, "ratio_snipe=%.2f",g_ratio_snipe);
console_print(id, "ratio_debutant=%.2f",g_ratio_debutant);

return PLUGIN_HANDLED;
}

public client_authorized(id)
{
resetPlayer(id);
if(is_user_bot(id))
return PLUGIN_CONTINUE;

new authid[32];
get_user_authid(id, authid, 31);
replace_all(authid, 31, ":", "_");
new logfile[128];
format(logfile,127,"%s/%s.txt",g_path,authid);
new text[32];
new len;
new s_kills[6], s_deaths[6];
if(file_exists(logfile))
{
read_file(logfile,0,text,31,len);
parse(text, s_kills, 5, s_deaths, 5);
g_kills[id] = str_to_num(s_kills);
g_deaths[id] = str_to_num(s_deaths);
if(g_kills[id] == 0 && g_deaths[id] == 0) {
g_kills[id] = get_cvar_num("antiroxx_frags_defaut");
g_deaths[id] = get_cvar_num("antiroxx_morts_defaut");
}
if(g_deaths[id] == 0)
g_deaths[id] = 1;
if(!is_user_admin(id) && g_ratio_ban > 0.0 &&
((float(g_kills[id]) / float(g_deaths[id])) >= g_ratio_ban) &&
g_kills[id] >= get_cvar_num("antiroxx_ban_min_frags")) {
server_cmd("kick #%d %s", get_user_userid(id), g_banMsg);
}
}
else {
g_kills[id] = get_cvar_num("antiroxx_frags_defaut");
g_deaths[id] = get_cvar_num("antiroxx_morts_defaut");
}

return PLUGIN_CONTINUE;
}

public client_disconnect(id)
{
resetPlayer(id);
}

public start_round()
{
if(get_cvar_num("antiroxx_active") == 0)
return PLUGIN_CONTINUE;

if(read_data(1) == floatround(get_cvar_float("mp_roundtime")*60.0))
{
if(g_info_count == 2)
{
g_info_count = -1;
set_task(10.0, "display_info", 4541120);
}

++g_info_count;
}

return PLUGIN_CONTINUE;
}

public display_info()
{
if(get_cvar_num("antiroxx_active") == 0)
return PLUGIN_CONTINUE;

set_hudmessage(255, 255, 255, -1.0, 0.75, 0, 0.01, 8.0, 0.01, 0.01, 4);
show_hudmessage(0, "Ce serveur utilise AntiRoxx v%s.^nTapez /antiroxx dans le chat^npour connaitre son fonctionnement.", PLUGIN_VERSION);
show_hudmessage(0, "Ce serveur utilise AntiRoxx v%s.^nTapez /antiroxx dans le chat^npour connaitre son fonctionnement.", PLUGIN_VERSION);

return PLUGIN_CONTINUE;
}

public end_round()
{
getRatioValues();
}

/*
public score_info()
{
new id = read_data(1);
if(is_user_bot(id))
return PLUGIN_CONTINUE;
new kills = read_data(2);
new deaths = read_data(3);

if(g_last_kills[id] != kills)
{
if(kills != 0 && (kills - g_last_kills[id] != 3) && (kills - g_last_kills[id] != -1))
{
g_kills[id] += (kills - g_last_kills[id]);
}
g_last_kills[id] = kills;
}
if(g_last_deaths[id] != deaths && deaths != 0)
{
if(deaths != 0)
{
g_deaths[id] += (deaths - g_last_deaths[id]);
}
g_last_deaths[id] = deaths;
}

new antiroxx_maxcumul = get_cvar_num("antiroxx_maxcumul");
if(g_kills[id] > antiroxx_maxcumul || g_deaths[id] > antiroxx_maxcumul)
{
g_kills[id] = floatround(float(g_kills[id]) / 2);
g_deaths[id] = floatround(float(g_deaths[id]) / 2);
}

return PLUGIN_CONTINUE;
}
*/

public reset_hud(id)
{
g_nothing_only[id] = false;
g_knife_only[id] = false;
g_gun_only[id] = false;
g_smg_only[id] = false;
g_nosnipe[id] = false;
g_debutant[id] = false;

if(get_cvar_num("antiroxx_active") == 0 || is_user_bot(id))
return PLUGIN_CONTINUE;

set_task(0.3, "delayedResetHud", id+TASK_RESETHUD);
return PLUGIN_CONTINUE;
}

public delayedResetHud(id) {
id -= TASK_RESETHUD;
if(!is_user_connected(id) || is_user_bot(id))
return PLUGIN_CONTINUE;

//debug
if(g_kills[id] < get_cvar_num("antiroxx_frags_defaut") ||
g_deaths[id] < get_cvar_num("antiroxx_morts_defaut")) {
new steam[32];
get_user_authid(id, steam, 31);
new plname[32];
get_user_name(id, plname, 31);
new msg[128];
format(msg, 127, "NOM=%s, STEAMID=%s, G_KILLS=%d, G_DEATHS=%d", plname, steam, g_kills[id], g_deaths[id]);
log_to_file("addons/amx/DEBUG_ANTIROXX.txt", msg);
}
//fin debug

set_hudmessage(255, 255, 255, -1.0, 0.52, 0, 0.01, 5.0, 0.01, 0.01, 2);

if(g_deaths[id] == 0)
g_deaths[id] = 1;

new Float:player_ratio = float(g_kills[id]) / float(g_deaths[id]);
new new_health, new_armor;

if(player_ratio >= g_ratio_ban)
{
if(!is_user_admin(id) && g_kills[id] >= get_cvar_num("antiroxx_ban_min_frags")) {
server_cmd("kick #%d %s", get_user_userid(id), g_banMsg);
}
}
if(player_ratio >= g_ratio_nothing)
{
g_nothing_only[id] = true;
if(g_weapons_mode == 1) {
show_hudmessage(id, "TU ES TROP FORT !^nAUCUNE ARME AUTORISEE POUR TOI !");
client_cmd(id, "weapon_knife");
}
if(g_health_mode == 1) {
set_user_health(id, g_health_nothing);
}
if(g_armor_mode == 1 && g_armor_nothing >= 0) {
set_user_armor(id, g_armor_nothing);
}
}
else if(player_ratio >= g_ratio_knife)
{
g_knife_only[id] = true;
if(g_weapons_mode == 1) {
show_hudmessage(id, "TU ES TROP FORT !^nSEULE ARME AUTORISEE POUR TOI : COUTEAU !");
client_cmd(id, "weapon_knife");
}
if(g_health_mode == 1) {
// calcul du ratio par Sacripan
new_health = floatround(g_health_knife + ((g_health_nothing - g_health_knife) * ((player_ratio - g_ratio_knife) / (g_ratio_nothing - g_ratio_knife))));
if(new_health <= 0)
new_health = 1;
set_user_health(id, new_health);
//set_user_health(id, g_health_knife);
}
if(g_armor_mode == 1 && g_armor_knife >= 0) {
// calcul du ratio par Sacripan
new_armor = floatround(g_armor_knife + ((g_armor_nothing - g_armor_knife) * ((player_ratio - g_ratio_knife) / (g_ratio_nothing - g_ratio_knife))));
if(new_armor < 0)
new_armor = 0;
set_user_armor(id, new_armor);
//set_user_armor(id, g_armor_knife);
}
}
else if(player_ratio >= g_ratio_gun)
{
g_gun_only[id] = true;
if(g_weapons_mode == 1) {
new antiroxx_gun_string[12];
get_cvar_string("antiroxx_gun", antiroxx_gun_string, 11);
if(equali(antiroxx_gun_string, ""))
g_gun = -1;
else if(equali(antiroxx_gun_string, "usp"))
g_gun = 0;
else if(equali(antiroxx_gun_string, "glock18"))
g_gun = 1;
else if(equali(antiroxx_gun_string, "deagle"))
g_gun = 2;
else if(equali(antiroxx_gun_string, "p228"))
g_gun = 3;
else if(equali(antiroxx_gun_string, "fiveseven"))
g_gun = 4;
else if(equali(antiroxx_gun_string, "elite"))
g_gun = 5;
else {
set_cvar_string("antiroxx_gun", "glock18");
g_gun = 1;
}
if(g_gun == -1) {
show_hudmessage(id, "TU ES TROP FORT !^nSEULE ARME AUTORISEE POUR TOI : COUTEAU !");
}
else {
show_hudmessage(id, "TU ES TROP FORT !^nSEULES ARMES AUTORISEES POUR TOI : COUTEAU ET %s !", weapon_string[g_gun]);
if(entity_get_int(id, EV_INT_weapons) & (1<<weapon_csw[g_gun]))
{
client_cmd(id, weapon_gun_nom[g_gun]);
}
else
{
give_gun(id, g_gun);
}
}
}
if(g_health_mode == 1) {
// calcul du ratio par Sacripan
new_health = floatround(g_health_gun + ((g_health_knife - g_health_gun) * ((player_ratio - g_ratio_gun) / (g_ratio_knife - g_ratio_gun))));
if(new_health <= 0)
new_health = 1;
set_user_health(id, new_health);
//set_user_health(id, g_health_gun);
}
if(g_armor_mode == 1 && g_armor_gun >= 0) {
// calcul du ratio par Sacripan
new_armor = floatround(g_armor_gun + ((g_armor_knife - g_armor_gun) * ((player_ratio - g_ratio_gun) / (g_ratio_knife - g_ratio_gun))));
if(new_armor < 0)
new_armor = 0;
set_user_armor(id, new_armor);
//set_user_armor(id, g_armor_gun)
}
}
else if(player_ratio >= g_ratio_smg)
{
g_smg_only[id] = true;
if(g_weapons_mode == 1) {
show_hudmessage(id, "TU ES TROP FORT !^nSEULES ARMES AUTORISEES POUR TOI : COUTEAU, PISTOLETS,^nPOMPES ET SMGS");
client_cmd(id, "weapon_knife");
}
if(g_health_mode == 1) {
// calcul du ratio par Sacripan
new_health = floatround(g_health_smg + ((g_health_gun - g_health_smg) * ((player_ratio - g_ratio_smg) / (g_ratio_gun - g_ratio_smg))));
if(new_health <= 0)
new_health = 1;
set_user_health(id, new_health);
//set_user_health(id, g_health_smg);
}
if(g_armor_mode == 1 && g_armor_smg >= 0) {
// calcul du ratio par Sacripan
new_armor = floatround(g_armor_smg + ((g_armor_gun - g_armor_smg) * ((player_ratio - g_ratio_smg) / (g_ratio_gun - g_ratio_smg))));
if(new_armor < 0)
new_armor = 0;
set_user_armor(id, new_armor);
//set_user_armor(id, g_armor_smg);
}
}
else if(player_ratio >= g_ratio_snipe)
{
g_nosnipe[id] = true;
if(g_weapons_mode == 1) {
show_hudmessage(id, "TU ES TROP FORT !^nTU N'AS PLUS LE DROIT D'UTILISER LES SNIPES !");
client_cmd(id, "weapon_knife");
}
if(g_health_mode == 1) {
// calcul du ratio par Sacripan
new_health = floatround(g_health_snipe + ((g_health_smg - g_health_snipe) * ((player_ratio - g_ratio_snipe) / (g_ratio_smg - g_ratio_snipe))));
if(new_health <= 0)
new_health = 1;
set_user_health(id, new_health);
//set_user_health(id, g_health_smg);
}
if(g_armor_mode == 1 && g_armor_snipe >= 0) {
// calcul du ratio par Sacripan
new_armor = floatround(g_armor_snipe + ((g_armor_smg - g_armor_snipe) * ((player_ratio - g_ratio_snipe) / (g_ratio_smg - g_ratio_snipe))));
if(new_armor < 0)
new_armor = 0;
set_user_armor(id, new_armor);
//set_user_armor(id, g_armor_smg);
}
}
else if(player_ratio <= g_ratio_debutant && g_ratio_debutant > 0.0 && g_kills[id] > 0) {
g_debutant[id] = true;
if(g_health_mode == 1) {
set_user_health(id, g_health_debutant);
}
if(g_armor_mode == 1 && g_armor_debutant >= 0) {
set_user_armor(id, g_armor_debutant);
}
}

if(g_isPunished[id] == 1) {
strip_user_weapons(id);
new origin[3];
get_user_origin(id, origin);
origin[0] += 5;
origin[2] -= 40;
set_user_origin(id, origin);
g_isPunished[id] = 2;
set_hudmessage(255, 255, 255, -1.0, 0.60, 0, 0.01, 5.0, 0.01, 0.01, 3);
show_hudmessage(id, "TU AS TUE UN JOUEUR DEBUTANT AVEC DES BALLES !^nTU ES PUNI !");
set_hudmessage(255, 255, 255, -1.0, 0.68, 0, 0.01, 5.0, 0.01, 0.01, 4);
show_hudmessage(id, "TU AS TUE UN JOUEUR DEBUTANT AVEC DES BALLES !^nTU ES PUNI !");
new punition[128];
get_cvar_string("antiroxx_punition", punition, 127);
if(punition[0]) {
new text[32];
format(text, 31, "#%d", get_user_userid(id));
replace(punition, 127, "%player%", text);
server_cmd("%s", punition);
}
}
else if(g_isPunished[id] == 2) {
g_isPunished[id] = 0;
new suppr_punition[128];
get_cvar_string("antiroxx_suppr_punition", suppr_punition, 127);
if(suppr_punition[0]) {
new text[32];
format(text, 31, "#%d", get_user_userid(id));
replace(suppr_punition, 127, "%player%", text);
server_cmd("%s", suppr_punition);
}
}

if(g_debutant[id]) {
set_hudmessage(255, 255, 255, -1.0, 0.60, 0, 0.01, 5.0, 0.01, 0.01, 3);
show_hudmessage(id, "TU AS UN FAIBLE SCORE !^nLE PLUGIN VA TE COLORIER EN ROUGE OU BLEU ET TE PROTEGER DES TIRS !");
set_hudmessage(255, 255, 255, -1.0, 0.68, 0, 0.01, 5.0, 0.01, 0.01, 4);
show_hudmessage(id, "TU AS UN FAIBLE SCORE !^nLE PLUGIN VA TE COLORIER EN ROUGE OU BLEU ET TE PROTEGER DES TIRS !");
new team = get_user_team(id);
if(team == 1)
set_user_rendering(id,kRenderFxGlowShell,255,0,0,kRenderTransAlpha,255);
else if(team == 2)
set_user_rendering(id,kRenderFxGlowShell,0,0,255,kRenderTransAlpha,255);
}

new text[32];
format(text, 28, "%d %d", g_kills[id], g_deaths[id]);
text[30] = id;

set_task(random_float(0.1,4.0), "writeLog", 547777+id, text, 32);

return PLUGIN_CONTINUE;
}

findDebutant() {
for(new i = 1; i <= g_maxplayers; ++i) {
if(is_user_alive(i) && g_debutant[i])
return 1;
}
return 0;
}

public writeLog(text[32]) {
new id = text[30];
if(is_user_connected(id)) {
new authid[32];
get_user_authid(id, authid, 31);
if(equali(authid, "STEAM_ID_PENDING")) {
//server_cmd("kick #%d Tu as un STEAM_ID_PENDING", get_user_userid(id));
return;
}
replace_all(authid, 31, ":", "_");
new logfile[128];
format(logfile,127,"%s/%s.txt",g_path,authid);
if(file_exists(logfile))
delete_file(logfile);
text[30] = '^0';
write_file(logfile, text, 0);
if(is_user_alive(id) && !g_debutant[id] && findDebutant() == 1) {
set_hudmessage(255, 255, 255, -1.0, 0.60, 0, 0.01, 5.0, 0.01, 0.01, 3);
show_hudmessage(id, "NE TIREZ PAS SUR LE(S) JOUEUR(S) EN ROUGE OU BLEU^nTUEZ-LE(S) AU COUTEAU OU A LA GRENADE !");
set_hudmessage(255, 255, 255, -1.0, 0.68, 0, 0.01, 5.0, 0.01, 0.01, 4);
show_hudmessage(id, "NE TIREZ PAS SUR LE(S) JOUEUR(S) EN ROUGE OU BLEU^nTUEZ-LE(S) AU COUTEAU OU A LA GRENADE !");
}
}
}

public death_msg() {
new killer = read_data(1);
new victim = read_data(2);
if(is_user_connected(killer) && is_user_connected(victim) && !is_user_bot(victim) && killer != victim) {
if(g_debutant[victim] && !g_debutant[killer]) {
new weapon[32];
read_data(4, weapon, 31);
if(!equali(weapon, "grenade") && !equali(weapon, "knife")) {
if(get_cvar_num("antiroxx_debutant_punition") == 1) {
g_isPunished[killer] = 1;
new plname[32];
get_user_name(killer, plname, 31);
set_hudmessage(255, 255, 255, -1.0, 0.70, 0, 0.01, 5.0, 0.01, 0.01, 3);
show_hudmessage(0, "%s A TUE UN DEBUTANT AVEC AUTRE CHOSE QUE COUTEAU/GRENADE !^nIL SERA PUNI AU PROCHAIN ROUND !", plname);
set_hudmessage(255, 255, 255, -1.0, 0.78, 0, 0.01, 5.0, 0.01, 0.01, 4);
show_hudmessage(0, "%s A TUE UN DEBUTANT AVEC AUTRE CHOSE QUE COUTEAU/GRENADE !^nIL SERA PUNI AU PROCHAIN ROUND !", plname);
new health = get_user_health(killer);
health = floatround(float(health) / 2.0);
set_user_health(killer, health);
}
}
}
new antiroxx_maxcumul = get_cvar_num("antiroxx_maxcumul");
if(++g_kills[killer] > antiroxx_maxcumul)
{
g_kills[killer] = floatround(float(g_kills[killer]) / 2);
g_deaths[killer] = floatround(float(g_deaths[killer]) / 2);
}
if(++g_deaths[victim] > antiroxx_maxcumul)
{
g_kills[victim] = floatround(float(g_kills[victim]) / 2);
g_deaths[victim] = floatround(float(g_deaths[victim]) / 2);
}
}
}

public damage_event(id) {
if(is_user_connected(id) && !is_user_bot(id) && g_debutant[id]) {
new weapon, body, attacker = get_user_attacker(id, weapon, body);
if(weapon != CSW_KNIFE && is_user_alive(attacker) && !is_user_bot(attacker)) {
if(!g_debutant[attacker]) {
set_user_health(attacker, get_user_health(attacker) - read_data(2));
}
}
}
}

isCommandGun(arg[]) {
for(new i = 0; i <= 5; ++i) {
if(equali(arg, g_Aliases[i]) || equali(arg, g_Aliases2[i]))
return 1;
}
return 0;
}

isCommandShotgun(arg[]) {
for(new i = 6; i <= 7; ++i) {
if(equali(arg, g_Aliases[i]) || equali(arg, g_Aliases2[i]))
return 1;
}
return 0;
}

isCommandSMG(arg[]) {
for(new i = 8; i <= 12; ++i) {
if(equali(arg, g_Aliases[i]) || equali(arg, g_Aliases2[i]))
return 1;
}
return 0;
}

isCommandRifle(arg[]) {
for(new i = 13; i <= 23; ++i) {
if(equali(arg, g_Aliases[i]) || equali(arg, g_Aliases2[i]))
return 1;
}
return 0;
}

isCommandSnipe(arg[]) {
for(new i = 19; i <= 22; ++i) {
if(equali(arg, g_Aliases[i]) || equali(arg, g_Aliases2[i]))
return 1;
}
return 0;
}

/*
isCommandEquipment(arg[]) {
for(new i = 24; i <= 31; ++i) {
if(i == 27)
continue;
if(equali(arg, g_Aliases[i]) || equali(arg, g_Aliases2[i]))
return 1;
}
return 0;
}
*/

isCommandArmor(arg[]) {
for(new i = 25; i <= 26; ++i) {
if(equali(arg, g_Aliases[i]) || equali(arg, g_Aliases2[i]))
return 1;
}
return 0;
}

isCommandGrenade(arg[]) {
if(equali(arg, g_Aliases[27]) || equali(arg, g_Aliases2[27]))
return 1;
return 0;
}

isCommandShield(arg[]) {
if(equali(arg, g_Aliases[31]) || equali(arg, g_Aliases2[31]))
return 1;
return 0;
}

isCommandPrimAmmo(arg[]) {
if(equali(arg, g_Aliases[32]) || equali(arg, g_Aliases2[32]))
return 1;
return 0;
}

isCommandSecAmmo(arg[]) {
if(equali(arg, g_Aliases[33]) || equali(arg, g_Aliases2[33]))
return 1;
return 0;
}

public client_command(id)
{
if(is_user_bot(id))
return PLUGIN_CONTINUE;

if(get_cvar_num("antiroxx_active") == 0 || (g_weapons_mode == 0 && g_armor_mode == 0))
return PLUGIN_CONTINUE;

new arg[13];
if(read_argv(0, arg, 12) > 11)
return PLUGIN_CONTINUE;

if(equali(arg, "menuselect")) {
new arg1[8], key;
read_argv(1, arg1, 7);
key = str_to_num(arg1) - 1;
new menuid, keys, menu = -1;
get_user_menu(id, menuid, keys);
if(menuid == menuid_null) {
show_menu(id, 0, "NULL", 0, "NULL");
return PLUGIN_HANDLED;
}
if(menuid == menuid_buy || menuid == vgui_menuid_buy)
menu = 0;
if(menuid == menuid_buypistol || menuid == vgui_menuid_buypistol)
menu = 1;
if(menuid == menuid_buyshotgun || menuid == vgui_menuid_buyshotgun)
menu = 2;
if(menuid == menuid_buysub || menuid == vgui_menuid_buysub)
menu = 3;
if(menuid == menuid_buyrifle || menuid == vgui_menuid_buyrifle)
menu = 4;
if(menuid == menuid_buymachine || menuid == vgui_menuid_buymachine)
menu = 5;
if(menuid == menuid_buyitem || menuid == vgui_menuid_buyitem)
menu = 6;
if(menu != -1 ) {
show_menu(id, 0, "NULL", 0, "NULL");
return checkRest(id, menu, key);
}
return PLUGIN_CONTINUE;
}

if(g_weapons_mode == 1) {
if( ( (g_nothing_only[id] || g_knife_only[id])
&& (isCommandShield(arg)
|| isCommandGun(arg)
|| isCommandShotgun(arg)
|| isCommandSMG(arg)
|| isCommandRifle(arg)
|| isCommandGrenade(arg)
|| isCommandPrimAmmo(arg)
|| isCommandSecAmmo(arg) ))
||
( g_gun_only[id]
&& (isCommandShield(arg)
|| isCommandGun(arg)
|| isCommandShotgun(arg)
|| isCommandSMG(arg)
|| isCommandRifle(arg)
|| isCommandGrenade(arg)
|| isCommandPrimAmmo(arg) ))
||
( g_smg_only[id]
&& (isCommandShield(arg)
|| isCommandRifle(arg)
|| isCommandGrenade(arg) ))
||
( g_nosnipe[id]
&& (isCommandSnipe(arg) )))
{
client_print(id,print_center,"* TU ES TROP FORT ! LIMITATION DES ARMES ACTIVEE ! *");
return PLUGIN_HANDLED;
}
}

if(g_armor_mode == 1) {
if(isCommandArmor(arg)) {
set_task(0.1, "setArmorLevel", TASK_ARMOR+id);
}
}

if(g_AliasBlockNum) {
new a = 0;
do {
if(equali(g_Aliases[g_AliasBlock[a]], arg) ||
equali(g_Aliases2[g_AliasBlock[a]], arg)) {
client_print(id, print_center, "%L", LANG_PLAYER, "AR_ITEM_RESTRICTED");
return PLUGIN_HANDLED;
}
}
while(++a < g_AliasBlockNum);
}

return PLUGIN_CONTINUE;
}

public blockcommand(id)
{
if((get_cvar_num("antiroxx_active") == 1 && g_weapons_mode == 1) || g_AliasBlockNum > 0)
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}

checkRest(id,menu,key) {
if(!is_user_connected(id) || is_user_bot(id))
return PLUGIN_CONTINUE;
new team = get_user_team(id);
if(team != 1 && team != 2)
return PLUGIN_CONTINUE;
if(g_weapons_mode == 1) {
switch(menu) {
case 0: {
if(key == 5) {
if(g_nothing_only[id] || g_knife_only[id] || g_gun_only[id]) {
engclient_cmd(id, "menuselect", "10");
client_print(id, print_center, "* TU ES TROP FORT ! LIMITATION DES ARMES ACTIVEE ! *");
return PLUGIN_HANDLED;
}
}
else if(key == 6) {
if(g_nothing_only[id] || g_knife_only[id]) {
engclient_cmd(id, "menuselect", "10");
client_print(id, print_center, "* TU ES TROP FORT ! LIMITATION DES ARMES ACTIVEE ! *");
return PLUGIN_HANDLED;
}
}
}
case 1: {
if(g_nothing_only[id] || g_knife_only[id]) {
engclient_cmd(id, "menuselect", "10");
client_print(id, print_center, "* TU ES TROP FORT ! LIMITATION DES ARMES ACTIVEE ! *");
return PLUGIN_HANDLED;
}
}
case 2: {
if(g_nothing_only[id] || g_knife_only[id] || g_gun_only[id]) {
engclient_cmd(id, "menuselect", "10");
client_print(id, print_center, "* TU ES TROP FORT ! LIMITATION DES ARMES ACTIVEE ! *");
return PLUGIN_HANDLED;
}
}
case 3: {
if(g_nothing_only[id] || g_knife_only[id] || g_gun_only[id]) {
engclient_cmd(id, "menuselect", "10");
client_print(id, print_center, "* TU ES TROP FORT ! LIMITATION DES ARMES ACTIVEE ! *");
return PLUGIN_HANDLED;
}
if(g_nosnipe[id]) {
if(key == 4 || key == 5) {
engclient_cmd(id, "menuselect", "10");
client_print(id, print_center, "* TU ES TROP FORT ! LIMITATION DES ARMES ACTIVEE ! *");
return PLUGIN_HANDLED;
}
if((team == 2 && key == 1) || (team == 1 && key == 2)) {
engclient_cmd(id, "menuselect", "10");
client_print(id, print_center, "* TU ES TROP FORT ! LIMITATION DES ARMES ACTIVEE ! *");
return PLUGIN_HANDLED;
}
}
}
case 4: {
if(g_nothing_only[id] || g_knife_only[id] || g_gun_only[id] || g_smg_only[id]) {
engclient_cmd(id, "menuselect","10");
client_print(id, print_center, "* TU ES TROP FORT ! LIMITATION DES ARMES ACTIVEE ! *");
return PLUGIN_HANDLED;
}
}
case 5: {
if(g_nothing_only[id] || g_knife_only[id] || g_gun_only[id] || g_smg_only[id]) {
engclient_cmd(id, "menuselect","10");
client_print(id, print_center, "* TU ES TROP FORT ! LIMITATION DES ARMES ACTIVEE ! *");
return PLUGIN_HANDLED;
}
}
case 6: {
if((key == 3 || key == 7) && (g_nothing_only[id] || g_knife_only[id] || g_gun_only[id] || g_smg_only[id])) {
engclient_cmd(id, "menuselect", "10");
client_print(id, print_center, "* TU ES TROP FORT ! LIMITATION DES ARMES ACTIVEE ! *");
return PLUGIN_HANDLED;
}
}
}
}
if(g_armor_mode == 1 && menu == 6) {
if(key == 0 || key == 1) {
set_task(0.1, "setArmorLevel", TASK_ARMOR+id);
}
}
if(g_blockPos[(menu * 8 + key) + (get_user_team(id) - 1) * 56]) {
engclient_cmd(id, "menuselect", "10");
//client_cmd(id, "slot10");
client_print(id, print_center, "%L", LANG_PLAYER, "AR_ITEM_RESTRICTED");
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}

public ammoRest1(id)
return checkRest(id,0,5);
public ammoRest2(id)
return checkRest(id,0,6);
public menuBuy(id,key)
return checkRest(id,0,key);
public menuPistol(id,key)
return checkRest(id,1,key);
public menuShotgun(id,key)
return checkRest(id,2,key);
public menuSub(id,key)
return checkRest(id,3,key);
public menuRifle(id,key)
return checkRest(id,4,key);
public menuMachine(id,key)
return checkRest(id,5,key);
public menuItem(id,key)
return checkRest(id,6,key);

public give_gun(id, num_gun)
{
switch(num_gun)
{
case 0:
{
give_item(id, "weapon_usp");
give_item(id, "ammo_45acp");
give_item(id, "ammo_45acp");
give_item(id, "ammo_45acp");
give_item(id, "ammo_45acp");
give_item(id, "ammo_45acp");
give_item(id, "ammo_45acp");
give_item(id, "ammo_45acp");
give_item(id, "ammo_45acp");
give_item(id, "ammo_45acp");
client_cmd(id, "weapon_usp");
}
case 1:
{
give_item(id, "weapon_glock18");
give_item(id, "ammo_9mm");
give_item(id, "ammo_9mm");
give_item(id, "ammo_9mm");
give_item(id, "ammo_9mm");
client_cmd(id, "weapon_glock18");
}
case 2:
{
give_item(id, "weapon_deagle");
give_item(id, "ammo_50ae");
give_item(id, "ammo_50ae");
give_item(id, "ammo_50ae");
give_item(id, "ammo_50ae");
give_item(id, "ammo_50ae");
client_cmd(id, "weapon_deagle");
}
case 3:
{
give_item(id, "weapon_p228");
give_item(id, "ammo_357sig");
give_item(id, "ammo_357sig");
give_item(id, "ammo_357sig");
give_item(id, "ammo_357sig");
client_cmd(id, "weapon_p228");
}
case 4:
{
give_item(id, "weapon_fiveseven");
give_item(id, "ammo_57mm");
give_item(id, "ammo_57mm");
client_cmd(id, "weapon_fiveseven");
}
case 5:
{
give_item(id, "weapon_elite");
give_item(id, "ammo_9mm");
give_item(id, "ammo_9mm");
give_item(id, "ammo_9mm");
give_item(id, "ammo_9mm");
client_cmd(id, "weapon_elite");
}
default: {}
}
}

public check_weapon(id)
{
if(get_cvar_num("antiroxx_active") == 0 || is_user_bot(id))
return PLUGIN_CONTINUE;

if(g_isPunished[id] == 2) {
client_cmd(id, "weapon_knife");
}

if(g_weapons_mode == 0)
return PLUGIN_CONTINUE;

if(!g_nothing_only[id] && !g_knife_only[id] && !g_gun_only[id] && !g_smg_only[id] && !g_nosnipe[id])
return PLUGIN_CONTINUE;

new weaponTypeId = read_data(2);

new antiroxx_allow1 = get_cvar_num("antiroxx_allow1");
new antiroxx_allow2 = get_cvar_num("antiroxx_allow2");

if((g_nothing_only[id] || g_knife_only[id])
&& (weaponTypeId != CSW_HEGRENADE)
&& (weaponTypeId != CSW_SMOKEGRENADE)
&& (weaponTypeId != CSW_FLASHBANG)
&& (weaponTypeId != CSW_KNIFE)
&& (weaponTypeId != CSW_C4)
&& (weaponTypeId != antiroxx_allow1)
&& (weaponTypeId != antiroxx_allow2) )
{
client_cmd(id, "drop");
client_cmd(id, "weapon_knife");
}
if(g_gun_only[id]
&& (weaponTypeId != CSW_HEGRENADE)
&& (weaponTypeId != CSW_SMOKEGRENADE)
&& (weaponTypeId != CSW_FLASHBANG)
&& (weaponTypeId != CSW_KNIFE)
&& (weaponTypeId != CSW_C4)
&& ((g_gun >= 0 && weaponTypeId != weapon_csw[g_gun]) || (g_gun == -1))
&& (weaponTypeId != antiroxx_allow1)
&& (weaponTypeId != antiroxx_allow2) )
{
client_cmd(id, "drop");
if(g_gun >= 0)
client_cmd(id, weapon_gun_nom[g_gun]);
}
if(g_smg_only[id]
&& (weaponTypeId != CSW_HEGRENADE)
&& (weaponTypeId != CSW_SMOKEGRENADE)
&& (weaponTypeId != CSW_FLASHBANG)
&& (weaponTypeId != CSW_KNIFE)
&& (weaponTypeId != CSW_C4)
&& (weaponTypeId != CSW_P228)
&& (weaponTypeId != CSW_XM1014)
&& (weaponTypeId != CSW_MAC10)
&& (weaponTypeId != CSW_ELITE)
&& (weaponTypeId != CSW_FIVESEVEN)
&& (weaponTypeId != CSW_UMP45)
&& (weaponTypeId != CSW_USP)
&& (weaponTypeId != CSW_GLOCK18)
&& (weaponTypeId != CSW_MP5NAVY)
&& (weaponTypeId != CSW_M3)
&& (weaponTypeId != CSW_TMP)
&& (weaponTypeId != CSW_DEAGLE)
&& (weaponTypeId != CSW_P90)
&& (weaponTypeId != antiroxx_allow1)
&& (weaponTypeId != antiroxx_allow2) )
{
client_cmd(id, "drop");
}
if(g_nosnipe[id]
&& ((weaponTypeId == CSW_SCOUT)
|| (weaponTypeId == CSW_AWP)
|| (weaponTypeId == CSW_SG550)
|| (weaponTypeId == CSW_G3SG1))
&& (weaponTypeId != antiroxx_allow1)
&& (weaponTypeId != antiroxx_allow2) )
{
client_cmd(id, "drop");
}

if(g_nothing_only[id] && weaponTypeId == CSW_KNIFE)
{
entity_set_string(id, EV_SZ_viewmodel, "");
entity_set_string(id, EV_SZ_weaponmodel, "");
}

return PLUGIN_CONTINUE;
}

public client_prethink(id)
{
if(get_cvar_num("antiroxx_active") == 0 || g_weapons_mode == 0 || is_user_bot(id))
return PLUGIN_CONTINUE;

if(g_nothing_only[id] && is_user_alive(id))
{
if(get_user_weapon(id, g_dummy1, g_dummy2) == CSW_KNIFE)
{
new button = get_user_button(id);
button &= ~IN_ATTACK;
button &= ~IN_ATTACK2;
entity_set_int(id, EV_INT_button, button);
}
}

return PLUGIN_CONTINUE;
}

getRatioValues() {
g_ratio_ban = get_cvar_float("antiroxx_ratio_ban");
g_ratio_nothing = get_cvar_float("antiroxx_ratio_nothing");
g_ratio_knife = get_cvar_float("antiroxx_ratio_knife");
g_ratio_gun = get_cvar_float("antiroxx_ratio_gun");
g_ratio_smg = get_cvar_float("antiroxx_ratio_smg");
g_ratio_snipe = get_cvar_float("antiroxx_ratio_snipe");
g_ratio_debutant = get_cvar_float("antiroxx_ratio_debutant");
if(!( (g_ratio_nothing > g_ratio_knife)
&& (g_ratio_knife > g_ratio_gun)
&& (g_ratio_gun > g_ratio_smg)
&& (g_ratio_smg > g_ratio_snipe)
&& (g_ratio_debutant < g_ratio_snipe) ))
{
g_ratio_nothing = 6.5;
g_ratio_knife = 5.5;
g_ratio_gun = 4.5;
g_ratio_smg = 3.5;
g_ratio_snipe = 2.5;
g_ratio_debutant = -99999999999999;
set_cvar_float("antiroxx_ratio_nothing", 6.5);
set_cvar_float("antiroxx_ratio_knife", 5.5);
set_cvar_float("antiroxx_ratio_gun", 4.5);
set_cvar_float("antiroxx_ratio_smg", 3.5);
set_cvar_float("antiroxx_ratio_snipe", 2.5);
set_cvar_float("antiroxx_ratio_debutant", -99999999999999);
}

g_weapons_mode = get_cvar_num("antiroxx_weapons_mode");

g_health_mode = get_cvar_num("antiroxx_health_mode");
g_health_nothing = get_cvar_num("antiroxx_health_nothing");
g_health_knife = get_cvar_num("antiroxx_health_knife");
g_health_gun = get_cvar_num("antiroxx_health_gun");
g_health_smg = get_cvar_num("antiroxx_health_smg");
g_health_snipe = get_cvar_num("antiroxx_health_snipe");
g_health_debutant = get_cvar_num("antiroxx_health_debutant");

g_armor_mode = get_cvar_num("antiroxx_armor_mode");
g_armor_nothing = get_cvar_num("antiroxx_armor_nothing");
g_armor_knife = get_cvar_num("antiroxx_armor_knife");
g_armor_gun = get_cvar_num("antiroxx_armor_gun");
g_armor_smg = get_cvar_num("antiroxx_armor_smg");
g_armor_snipe = get_cvar_num("antiroxx_armor_snipe");
g_armor_debutant = get_cvar_num("antiroxx_armor_debutant");
}

resetPlayer(id) {
g_nothing_only[id] = false;
g_knife_only[id] = false;
g_gun_only[id] = false;
g_smg_only[id] = false;
g_nosnipe[id] = false;
g_debutant[id] = false;
g_isPunished[id] = 0;
g_kills[id] = 0;
g_deaths[id] = 0;
g_last_kills[id] = 0;
g_last_deaths[id] = 0;
}

public setArmorLevel(id) {
id -= TASK_ARMOR;
if(g_nothing_only[id]) {
set_user_armor(id, g_armor_nothing);
}
else if(g_knife_only[id]) {
if(g_deaths[id] == 0)
g_deaths[id] = 1;
new Float:player_ratio = float(g_kills[id]) / float(g_deaths[id]);
new new_armor = floatround(g_armor_knife + ((g_armor_nothing - g_armor_knife) * ((player_ratio - g_ratio_knife) / (g_ratio_nothing - g_ratio_knife))));
if(new_armor < 0)
new_armor = 0;
set_user_armor(id, new_armor);
}
else if(g_gun_only[id]) {
if(g_deaths[id] == 0)
g_deaths[id] = 1;
new Float:player_ratio = float(g_kills[id]) / float(g_deaths[id]);
new new_armor = floatround(g_armor_gun + ((g_armor_knife - g_armor_gun) * ((player_ratio - g_ratio_gun) / (g_ratio_knife - g_ratio_gun))));
if(new_armor < 0)
new_armor = 0;
set_user_armor(id, new_armor);
}
else if(g_smg_only[id]) {
if(g_deaths[id] == 0)
g_deaths[id] = 1;
new Float:player_ratio = float(g_kills[id]) / float(g_deaths[id]);
new new_armor = floatround(g_armor_smg + ((g_armor_gun - g_armor_smg) * ((player_ratio - g_ratio_smg) / (g_ratio_gun - g_ratio_smg))));
if(new_armor < 0)
new_armor = 0;
set_user_armor(id, new_armor);
}
else if(g_nosnipe[id]) {
if(g_deaths[id] == 0)
g_deaths[id] = 1;
new Float:player_ratio = float(g_kills[id]) / float(g_deaths[id]);
new new_armor = floatround(g_armor_snipe + ((g_armor_smg - g_armor_snipe) * ((player_ratio - g_ratio_snipe) / (g_ratio_smg - g_ratio_snipe))));
if(new_armor < 0)
new_armor = 0;
set_user_armor(id, new_armor);
}
else if(g_debutant[id]) {
set_user_armor(id, g_armor_debutant);
}
}

/******************************************************************************/

setWeapon(a, action) {
new b, m = g_Keys[a][0] * 8;
if(g_Keys[a][1] != -1) {
b = m + g_Keys[a][1];
if(action == 2)
g_blockPos[b] = 1 - g_blockPos[b];
else
g_blockPos[b] = action;
}
if(g_Keys[a][2] != -1) {
b = m + g_Keys[a][2] + 56;
if(action == 2)
g_blockPos[b] = 1 - g_blockPos[b];
else
g_blockPos[b] = action;
}
new i, j;
for(i = 0; i < g_AliasBlockNum; ++i) {
if(g_AliasBlock[i] == a) {
if(!action || action == 2) {
--g_AliasBlockNum;
for(j = i; j < g_AliasBlockNum; ++j)
g_AliasBlock[j] = g_AliasBlock[j + 1];
}
return;
}
}
if(action && g_AliasBlockNum < MAXMENUPOS)
g_AliasBlock[g_AliasBlockNum++] = a;
}

findMenuId(name[]) {
for(new i = 0; i < 7 ; ++i)
if(equali(name, g_menusNames[i]))
return i;
return -1;
}

findAliasId(name[]) {
for(new i = 0; i < MAXMENUPOS ; ++i)
if(equali(name, g_Aliases[i]))
return i;
return -1;
}

switchCommand(id, action) {
new c = read_argc();
if(c < 3) {
setc(g_blockPos, 114, action);
if(action == 0) {
g_AliasBlockNum = 0;
setc(g_AliasBlock, MAXMENUPOS, 0);
}
else {
g_AliasBlockNum = MAXMENUPOS;
for(new i = 0; i < MAXMENUPOS ; ++i) {
g_AliasBlock[i] = i;
}
}
console_print(id, "%L %L", LANG_PLAYER, "AR_RESTRICT_INTRO", LANG_PLAYER, action ? "AR_RESTRICTED" : "AR_UNRESTRICTED");
g_Modified = true;
}
else {
new arg[32], a, b, i;
new bool:found = false;
for(b = 2; b < c; ++b) {
read_argv(b, arg, 31);
if((a = findMenuId(arg)) != -1) {
c = g_menusSets[a][1];
for(i = g_menusSets[a][0]; i < c; ++i)
setWeapon(i, action);
console_print(id, "%s %L %L", g_MenuTitle[a], LANG_PLAYER, (a < 5) ? "AR_HAVE_BEEN" : "AR_HAS_BEEN", LANG_PLAYER, action ? "AR_RESTRICTED" : "AR_UNRESTRICTED");
g_Modified = found = true;
}
else if((a = findAliasId(arg)) != -1) {
g_Modified = found = true;
setWeapon(a, action);
console_print(id, "%s %L %L", g_WeaponNames[a], LANG_PLAYER, "AR_HAS_BEEN", LANG_PLAYER, action ? "AR_RESTRICTED" : "AR_UNRESTRICTED");
}
}
if(!found)
console_print(id, "%L", LANG_PLAYER, "AR_REST_COULDNT_FIND");
}
}

positionBlocked(a) {
new m = g_Keys[a][0] * 8;
new d = (g_Keys[a][1] == -1) ? 0 : g_blockPos[m + g_Keys[a][1]];
d += (g_Keys[a][2] == -1) ? 0 : g_blockPos[m + g_Keys[a][2] + 56];
return d;
}

public cmdRest(id,level,cid) {
if(!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED;

new cmd[8];
read_argv(1, cmd, 7);
if(equali("on", cmd))
switchCommand(id, 1);
else if(equali("off", cmd))
switchCommand(id, 0);
else if(equali("list", cmd)) {
new arg1[8];
new start = read_argv(2, arg1, 7) ? str_to_num(arg1) : 1;
if(--start < 0)
start = 0;
if(start >= MAXMENUPOS)
start = MAXMENUPOS - 1;
new end = start + 10;
if(end > MAXMENUPOS)
end = MAXMENUPOS;
console_print(id, "%L", LANG_PLAYER, "AR_REST_LIST_HEAD");
console_print(id, " %-32.31s %-10.9s %-9.8s", "%L", LANG_PLAYER, "AR_NAME", "%L", LANG_PLAYER, "AR_VALUE", "%L", LANG_PLAYER, "AR_STATUS");
if(start != -1) {
for(new a = start; a < end; ++a) {
console_print(id, "%3d: %-32.31s %-10.9s %-9.8s", a + 1,
g_WeaponNames[a], g_Aliases[a], "%L", LANG_PLAYER, positionBlocked(a) ? "AR_ON" :"AR_OFF");
}
}
console_print(id, "%L", LANG_PLAYER, "AR_REST_LIST_ENTRIES", start+1, end, MAXMENUPOS);
if(end < MAXMENUPOS)
console_print(id, "%L", LANG_PLAYER, "AR_REST_LIST_MORE", end+1);
else
console_print(id, "%L", LANG_PLAYER, "AR_REST_LIST_BEGIN");
}
else if(equali("save", cmd)) {
if(saveSettings(g_saveFile)) {
console_print(id, "%L", LANG_PLAYER, "AR_REST_CFG_SAVED", g_saveFile);
g_Modified = false;
}
else
console_print(id, "%L", LANG_PLAYER, "AR_REST_CFG_S_FAILED", g_saveFile);
}
else if(equali("load", cmd)) {
setc(g_blockPos, 114, 0); // Clear current settings
new arg1[128], bdir[128];
if(read_argv(2, arg1 , 127))
{
get_basedir( bdir, 127 );
format( arg1, 127, "%s/%s", bdir, arg1 );
}
else
copy(arg1, 127, g_saveFile);
if(loadSettings(arg1)) {
console_print(id, "%L", LANG_PLAYER, "AR_REST_CFG_LOADED", arg1);
g_Modified = true;
}
else
console_print(id, "%L", LANG_PLAYER, "AR_REST_CFG_L_FAILED", arg1);
}
else {
console_print(id, "%L", LANG_PLAYER, "AR_REST_USE_1");
console_print(id, "%L", LANG_PLAYER, "AR_REST_USE_2");
console_print(id, "%L", LANG_PLAYER, "AR_REST_USE_3");
console_print(id, "%L", LANG_PLAYER, "AR_REST_USE_4");
console_print(id, "%L", LANG_PLAYER, "AR_REST_USE_5");
console_print(id, "%L", LANG_PLAYER, "AR_REST_USE_6");
console_print(id, "%L", LANG_PLAYER, "AR_REST_USE_7");
console_print(id, "%L", LANG_PLAYER, "AR_REST_USE_8");
console_print(id, "%L", LANG_PLAYER, "AR_REST_USE_9");
console_print(id, "%L", LANG_PLAYER, "AR_REST_USE_10");
console_print(id, "%L", LANG_PLAYER, "AR_REST_USE_11");

}
return PLUGIN_HANDLED;
}

displayMenu(id,pos) {
if(pos < 0)
return;

new menubody[512], start = pos * 7;
if(start >= MAXMENUPOS)
start = pos = g_Position[id] = 0;
new len = format(menubody, 511, "%L", LANG_PLAYER, "AR_REST_MENU_TITLE", id, pos+1);
new end = start + 7, keys = (1<<9)|(1<<7), k = 0;
if(end > MAXMENUPOS)
end = MAXMENUPOS;
for(new a = start; a < end; ++a) {
keys |= (1<<k);
len += format(menubody[len], 511-len, g_MenuItem[a], ++k, g_WeaponNames[a], "%L", LANG_PLAYER, positionBlocked(a) ? "AR_ON" : "AR_OFF");
}
len += format(menubody[len], 511-len, "%L", LANG_PLAYER, "AR_REST_MENU_SAVE", g_Modified ? "*" : "");
if(end != MAXMENUPOS) {
format(menubody[len], 511-len,"%L", LANG_PLAYER, "AR_REST_MENU_MORE", "%L", LANG_PLAYER, pos ? "AR_BACK" : "AR_EXIT");
keys |= (1<<8);
}
else
format(menubody[len], 511-len, "^n0. %s", "%L", LANG_PLAYER, pos ? "AR_BACK" : "AR_EXIT");
show_menu(id, keys, menubody, -1, "\yRestrict Weapons");
}

public actionMenu(id,key) {
switch(key) {
case 7: {
if(saveSettings(g_saveFile)) {
g_Modified = false;
client_print(id, print_chat, "%L", LANG_PLAYER, "AR_CFG_SAVED");
}
else
client_print(id, print_chat, "%L", LANG_PLAYER, "AR_CFG_FALED");
displayMenu(id, g_Position[id]);
}
case 8:
displayMenu(id, ++g_Position[id]);
case 9:
displayMenu(id, --g_Position[id]);
default: {
setWeapon(g_Position[id] * 7 + key, 2);
g_Modified = true;
displayMenu(id, g_Position[id]);

// KWo stuff for support bots weapons restriction
new a = g_Position[id] * 7 + key;
new sz[1];
if(a < 24) {
sz[0] = g_szWeapRestr[a + 1];
g_szWeapRestr[a + 1] = (sz[0] == '0') ? '1' : '0'; // primary and secondary weapons
}
else if((a >= 24) && (a < 31)) {
sz[0] = g_szEquipAmmoRestr[a - 24];
g_szEquipAmmoRestr[a - 24] = (sz[0] == '0') ? '1' : '0'; // equipments
}
else if(a == 31) {
sz[0] = g_szWeapRestr[25];
g_szWeapRestr[25] = (sz[0] == '0') ? '1' : '0'; // shield
}
else if((a > 31) && (a < 34)) {
sz[0] = g_szEquipAmmoRestr[a - 25];
g_szEquipAmmoRestr[a - 25] = (sz[0] == '0') ? '1' : '0'; // primary and secondary ammo
}
set_cvar_string("amx_restrweapons", g_szWeapRestr);
set_cvar_string("amx_restrequipammo", g_szEquipAmmoRestr);
// End of KWo's stuff

}
}
return PLUGIN_HANDLED;
}

public cmdMenu(id,level,cid) {
if(cmd_access(id,level,cid,1))
displayMenu(id, g_Position[id] = 0);
return PLUGIN_HANDLED;
}

saveSettings(filename[]) {
if(file_exists(filename))
delete_file(filename);
new text[128];
format(text, 127, "; Generated by Restrict Weapons Plugin. Do not modify!^n%-16.15s ; %s", "; Value", "Name");
if(!write_file(filename, text))
return 0;
for(new a = 0; a < MAXMENUPOS; ++a) {
if(positionBlocked(a)) {
format(text, 127, "%-16.15s ; %s", g_Aliases[a], g_WeaponNames[a]);
write_file(filename, text);
}
}
return 1;
}

loadSettings(filename[]) {
if(!file_exists(filename))
return 0;
new text[16];
new a, pos = 0;
format(g_szEquipAmmoRestr, 9, "000000000"); // KWo - stuff for bots weapon restrictions
format(g_szWeapRestr, 26, "00000000000000000000000000"); // KWo - stuff for bots weapon restrictions
while((pos = read_file(filename, pos, text, 15, a))) {
if(text[0] == ';' || !a)
continue; // line is a comment
parse(text, text, 15);
if((a = findAliasId(text)) != -1) {
setWeapon(a, 1);
// KWo - stuff for bots weapon restrictions
if(a < 24)
g_szWeapRestr[a + 1] = '1'; // primary and secondary weapons
else if((a >= 24) && (a < 31))
g_szEquipAmmoRestr[a - 24] = '1'; // equipments
else if(a == 31)
g_szWeapRestr[25] = '1'; // shield
else if((a > 31) && (a < 34))
g_szEquipAmmoRestr[a - 25] = '1'; // primary and secondary ammo
}
}
set_cvar_string("amx_restrweapons", g_szWeapRestr); // KWo - stuff for bots weapon restrictions
set_cvar_string("amx_restrequipammo", g_szEquipAmmoRestr); // KWo - stuff for bots weapon restrictions
return 1;
}
Albator
A moins qu'un codeur passe par là et que l'idée l'intéresse siffle.gif
Blueberry
J'ai essayé car cela m'intéresserait aussi...
...mais au bout d'un jour entier de travail, je n'avais toujours pas avancé.
FlaToUneT
Il suffit de faire exécuter au joueur qui a atteint la limite min ou max, une clcmd qui le redirige vers le serveur en question (depuis une task, de manière à informer le joueur à l'avance comme quoi il va être redirigé, préférable).
Ensuite, tout dépend du plugin de restriction que vous souhaitez utiliser (antiroxx, funapache, mtl, etc.).

L'ip du serveur pouvant être intégrée au plugin via une variable interne ou encore une cvar modifiable en jeu.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.