|
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
|

05-09-2016
, 12:05
Re: Equip WEAPON_NONE
|
#8
|
I made it for you:
PHP Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #include <hamsandwich> #include <engine> #include <cstrike> #include <fun>
#define PLUGIN "Hide Weapon" #define VERSION "1.0" #define AUTHOR "siriusmd99"
new const g_WeaponNames[33][] = { "", "p228", "", "scout", "hegrenade", "xm1014", "", "mac10", "aug", "smokegrenade", "elite", "fiveseven", "ump45", "sg550", "galil", "famas", "usp", "glock18", "awp", "mp5navy", "m249", "m3", "m4a1", "tmp", "g3sg1", "flashbang", "deagle", "sg552", "ak47", "", "p90", "", ""};
new const Slots[] = { 0, // NULL 2, // CSW_P228 0, // NULL 1, // CSW_SCOUT 4, // CSW_HEGRENADE 1, // CSW_XM1014 5, // CSW_C4 1, // CSW_MAC10 1, // CSW_AUG 4, // CSW_SMOKEGRENADE 2, // CSW_ELITE 2, // CSW_FIVESEVEN 1, // CSW_UMP45 1, // CSW_SG550 1, // CSW_GALIL 1, // CSW_FAMAS 2, // CSW_USP 2, // CSW_GLOCK 1, // CSW_AWP 1, // CSW_MP5NAVY 1, // CSW_M249 1, // CSW_M3 1, // CSW_M4A1 1, // CSW_TMP 1, // CSW_G3SG1 4, // CSW_FLASHBANG 2, // CSW_DEAGLE 1, // CSW_SG552 1, // CSW_AK47 3, // CSW_KNIFE 1 // CSW_P90 }
new equip[33][3] new g_MaxClients;
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /switch","switch_function") register_event("DeathMsg", "death", "a") register_forward( FM_Touch, "Block_Pickup" ); g_MaxClients = global_get( glb_maxClients ); }
public client_disconnect(id){
equip[id][0] = 0;
}
public client_connect(id){
equip[id][0] = 0;
}
public death(){
equip[read_data(2)][0] = 0; }
public switch_function(player){
if(!is_user_alive(player) || !is_user_connected(player)) return; if(equip[player][0]){ new wname[24], id get_weaponname(equip[player][0],wname,23) id = give_item(player, wname) cs_set_weapon_ammo(id, equip[player][1]) cs_set_user_bpammo( player , equip[player][0], equip[player][2] ) equip[player][0] = 0; }else{ new clip,ammo, wn[24] new weapon = get_user_weapon(player,clip,ammo) equip[player][0] = weapon equip[player][1] = clip equip[player][2] = ammo strip_user_weapons(player) get_weaponname(weapon,wn,23) ham_strip_weapon(player,wn); } }
stock ham_strip_weapon(id,weapon[]) { if(!equal(weapon,"weapon_",7)) return 0 new wId = get_weaponid(weapon) if(!wId) return 0 new wEnt while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {} if(!wEnt) return 0 if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt) if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0 ExecuteHamB(Ham_Item_Kill,wEnt); set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId)) return 1 }
public Block_Pickup( iEnt , iPlayer ) { if ( !( 1 <= iPlayer <= g_MaxClients ) || !pev_valid(iEnt ) || !( pev( iEnt , pev_flags ) & FL_ONGROUND ) || !equip[iPlayer][0]) return FMRES_IGNORED; static szEntModel[32]; pev( iEnt , pev_model , szEntModel , 31 ); return ( GetSlotNumber(equip[iPlayer][0]) == GetSlotNumber( GetWeaponIndex( szEntModel )) ) ? FMRES_SUPERCEDE : FMRES_IGNORED; }
GetSlotNumber( Wep ) return ( 0 <= Wep < sizeof Slots ) ? Slots[Wep] : 0; public GetWeaponIndex(szPartial[]) { for( new i = 0; i < 33; i++ ) if ( containi( szPartial , g_WeaponNames[i] ) != -1 ) return i; return 0; }
Haven't tested but it shall work like this :
1. Hidding/Adding back weapon by typing in chat /switch
2. Blocking Weapon Pickup (weapon slot block)
3. Hidden_Weapon = 0 - if player is dead, disconnected ,softly connected or got the weapon back. (safety checks)
Thats it. Hope it works.
P.S. I made /switch because i don't know how are you planning to use it. If you want you can explain and i'll made it to work how it were supposed...
Last edited by siriusmd99; 05-09-2016 at 12:07.
|
|