Raised This Month: $ Target: $400
 0% 

Equip WEAPON_NONE


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-09-2016 , 12:05   Re: Equip WEAPON_NONE
Reply With Quote #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
    
// CSW_P90
}

new 
equip[33][3]
new 
g_MaxClients;   

public 
plugin_init() {
register_plugin(PLUGINVERSIONAUTHOR)

register_clcmd("say /switch","switch_function")
register_event("DeathMsg""death""a")
register_forwardFM_Touch"Block_Pickup" );
g_MaxClients global_getglb_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(playerwname)
        
cs_set_weapon_ammo(idequip[player][1]) 
        
cs_set_user_bpammoplayer equip[player][0], equip[player][2] )
        
equip[player][0] = 0;
        }else{
        new 
clip,ammown[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) == wIdExecuteHamB(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_PickupiEnt iPlayer 

    if ( !( 
<= iPlayer <= g_MaxClients ) || !pev_valid(iEnt ) || !( peviEnt pev_flags ) & FL_ONGROUND ) ||  !equip[iPlayer][0])
        return 
FMRES_IGNORED;
    
    static 
szEntModel[32];
    
peviEnt  pev_model szEntModel 31 );
    
    return ( 
GetSlotNumber(equip[iPlayer][0]) == GetSlotNumberGetWeaponIndexszEntModel )) ) ? FMRES_SUPERCEDE FMRES_IGNORED;
}

GetSlotNumberWep )
    return ( 
<= Wep sizeof Slots ) ? Slots[Wep] : 0;
    
public 
GetWeaponIndex(szPartial[])
{
    
    for( new 
033i++ )
        if ( 
containiszPartial g_WeaponNames[i] ) != -)
        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.
siriusmd99 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:35.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode