Hello, I have created with the help of some coders, a plugin of limitation for my server, but I would like to block the buy of the weapon who are restricted to the player by his limitation, because, actually, the player can buy a weapon restricted, but the weapon will drop directly... How to make it ?
My others problems is:
1) I have a problem to the line (66):
Quote:
|
client_print_color(id, Grey, "^4[CSD]^3 Tu es au^4 niveau %d^3 de limitation.^4 (%s)", pl_level[id], g_levels_names[pl_level[id]]);
|
The plugin display in the chat:
- Level 1: [CSD] .......... (pistolets | fusils a pompe | mitraillettes | fusils d'assault | mitrailleuse)
- Level 2: [CSD] .......... (istolets | fusils a pompe | mitraillettes | fusils d'assault | mitrailleuse)
- Level 3: [CSD] .......... (stolets | fusils a pompe | mitraillettes | fusils d'assault | mitrailleuse)
- Level 4: [CSD] .......... (tolets | fusils a pompe | mitraillettes | fusils d'assault | mitrailleuse)
ETC...
But in level 2, it was normaly display: "pistolets | fusils a pompe | mitraillettes | fusils d'assault"...
What's the problem ?
2) I have a small problem in the boucle "current_weapon" (CurWeapon), If I buy a weapon restricted, it will display 2 times the message: "Tu n'as pas le droit a cette arme !", and it will drop 2 weapons, my weapon restricted (m4a1 for example) and my weapon not restricted (usp for example).
And when I'm in spectator (when I'm dead), when I switch of plyaer or when the player switch weapon and the weapon is restricted for me, it will display a message in the chat: "Tu n'as pas le droit a cette arme !", What the fuck ? It's not me ! Oo It's not my weapon.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <csx>
#include <fun>
#include <hamsandwich>
#include <fakemeta>
#include <chatcolor>
#tryinclude <cstrike_pdatas>
new g_maxplayers, g_disable_plugin, pl_level[33];
#define is_player(%0) (1 <= %0 <= g_maxplayers)
new const g_levels[] = {
(1<<CSW_SCOUT)|(1<<CSW_AWP)|(1<<CSW_SG550)|(1<<CSW_G3SG1),
(1<<CSW_M249),
(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_M4A1)|(1<<CSW_AK47)|(1<<CSW_AUG)|(1<<CSW_SG552),
(1<<CSW_MAC10)|(1<<CSW_TMP)|(1<<CSW_MP5NAVY)|(1<<CSW_UMP45)|(1<<CSW_P90),
(1<<CSW_M3)|(1<<CSW_XM1014),
(1<<CSW_P228)|(1<<CSW_DEAGLE)|(1<<CSW_FIVESEVEN)|(1<<CSW_ELITE),
(1<<CSW_USP)|(1<<CSW_GLOCK18)
}
new const g_levels_names[] = {
"pistolets | fusils a pompe | mitraillettes | fusils d'assault | mitrailleuse",
"pistolets | fusils a pompe | mitraillettes | fusils d'assault",
"pistolets | fusils a pompe | mitraillettes",
"pistolets | fusils a pompe",
"pistolets",
"usp et glock",
"couteau"
}
public plugin_init()
{
register_plugin("[ADDON] Limitation","1.0","Daminou");
RegisterHam(Ham_Spawn, "player", "client_spawn", 1);
RegisterHam(Ham_Touch, "armoury_entity", "armoury_entity_touch", false);
RegisterHam(Ham_Touch, "weaponbox", "weapon_box_touch", false);
register_event("CurWeapon", "current_weapon", "b");
g_disable_plugin = register_cvar("amx_limitation", "1");
g_maxplayers = get_maxplayers();
}
public bomb_explode(id, defuser)
{
set_user_frags(id, get_user_frags(id) - 3);
return PLUGIN_CONTINUE;
}
public bomb_defused(id)
{
set_user_frags(id, get_user_frags(id) - 3);
return PLUGIN_CONTINUE;
}
public check_ratio(id)
{
new ratio = (get_user_frags(id) - get_user_deaths(id));
if(ratio >= 16) { pl_level[id] = 6; }
else if(ratio >= 12) { pl_level[id] = 5; }
else if(ratio >= 10) { pl_level[id] = 4; }
else if(ratio >= 8) { pl_level[id] = 3; }
else if(ratio >= 6) { pl_level[id] = 2; }
else if(ratio >= 2) { pl_level[id] = 1; }
else if(ratio < 2) { pl_level[id] = 0; }
client_print_color(id, Grey, "^4[CSD]^3 Tu es au^4 niveau %d^3 de limitation.^4 (%s)", pl_level[id], g_levels_names[pl_level[id]]);
if(pl_level[id]) { check_weapons(id); }
}
public client_spawn(id)
{
if(!is_user_alive(id)) { return HAM_IGNORED; }
if(get_pcvar_num(g_disable_plugin)) { set_task(0.5, "check_ratio", id); }
return HAM_IGNORED;
}
public check_weapons(id)
{
if(get_pcvar_num(g_disable_plugin) && is_user_alive(id))
{
new weapon = get_user_weapon(id);
for(new i = 0; i <= pl_level[id] && i < sizeof(g_levels); i++)
{
if(g_levels[i] & (1 << weapon))
{
new weapon_name[32];
get_weaponname(weapon, weapon_name, charsmax(weapon_name));
engclient_cmd(id, "drop", weapon_name);
}
}
}
return PLUGIN_HANDLED;
}
public armoury_entity_touch(armoury, id)
{
if(get_pcvar_num(g_disable_plugin) && is_user_alive(id)) { if(is_player(id) && is_user_alive(id) && !user_pickup_weapon(id, cs_get_armoury_type(armoury))) { return HAM_SUPERCEDE; } }
return HAM_IGNORED;
}
public weapon_box_touch(weapon_box, id)
{
if(get_pcvar_num(g_disable_plugin) && is_user_alive(id)) { if(is_player(id) && is_user_alive(id) && (pev(weapon_box, pev_flags) & FL_ONGROUND) && !get_pdata_bool(id, m_bUsesShield) && !user_pickup_weapon(id, cs_get_weaponbox_type(weapon_box))) { return HAM_SUPERCEDE; } }
return HAM_IGNORED;
}
cs_get_weaponbox_type(weapon_box)
{
new weapon;
for(new i=1; i<=5; i++)
{
weapon = get_pdata_cbase(weapon_box, m_rgpPlayerItems_CWeaponBox[i], XO_CWEAPONBOX);
if(weapon > 0) { return cs_get_weapon_id(weapon); }
}
return 0;
}
bool:user_pickup_weapon(id, weapon_type)
{
for(new i = 0; i <= pl_level[id] && i < sizeof(g_levels); i++) { if(g_levels[i] & (1 << weapon_type)) { return false; } }
return true;
}
public current_weapon(id)
{
if(get_pcvar_num(g_disable_plugin))
{
new clip, ammo;
new weapon = get_user_weapon(id, clip, ammo);
for(new i = 0; i <= pl_level[id] && i < sizeof(g_levels); i++)
{
if(g_levels[i] & (1 << weapon) || cs_get_user_shield(id))
{
client_cmd(id, "drop");
client_print_color(id, Grey, "^4[CSD]^3 Tu n'as pas le droit a cette arme !");
}
}
}
return PLUGIN_HANDLED;
}
My greats salutations.
__________________