Raised This Month: $ Target: $400
 0% 

Equip WEAPON_NONE


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 05-02-2016 , 10:31   Equip WEAPON_NONE
Reply With Quote #1

Hello

I want to know if there's a way to force the "unequip" of the current weapon (regardless of the player's current equipment).

I know there's an index called "WEAPON_NONE" referring to no weapon equipped.

Thanks in advance.
__________________
gabuch2 is offline
Kowalsky
Senior Member
Join Date: Mar 2015
Location: Poland
Old 05-03-2016 , 05:58   Re: Equip WEAPON_NONE
Reply With Quote #2

engfunc_cmd drop weapon_name?
__________________
I ONLY LOVE STEAM, NON-STEAM IS VERY BAD FOR YOUR HEALTH!
Kowalsky is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 05-03-2016 , 07:55   Re: Equip WEAPON_NONE
Reply With Quote #3

Quote:
Originally Posted by Kowalsky View Post
engfunc_cmd drop weapon_name?
Thing is, I don't want to drop the players equipment. I don't know if it's possible.
__________________
gabuch2 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-03-2016 , 08:22   Re: Equip WEAPON_NONE
Reply With Quote #4

Unequip as destroy the item in their inventory?
klippy is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 05-03-2016 , 11:27   Re: Equip WEAPON_NONE
Reply With Quote #5

Just unequip them, setting their current weapon index to 0 maybe? Having no weapon means the player will play its idle animation. The player may select their weapon again to equip it and send a custom client command to unequip it.
__________________

Last edited by gabuch2; 05-03-2016 at 11:27.
gabuch2 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-04-2016 , 06:24   Re: Equip WEAPON_NONE
Reply With Quote #6

Quote:
Originally Posted by Shattered Heart Lynx View Post
Just unequip them, setting their current weapon index to 0 maybe? Having no weapon means the player will play its idle animation. The player may select their weapon again to equip it and send a custom client command to unequip it.
You mean: force player to put current weapon in inventory and have no weapon in hand?
__________________

Last edited by HamletEagle; 05-04-2016 at 06:24.
HamletEagle is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 05-09-2016 , 09:15   Re: Equip WEAPON_NONE
Reply With Quote #7

Quote:
Originally Posted by HamletEagle View Post
You mean: force player to put current weapon in inventory and have no weapon in hand?
Yes

Note that I DONT want to just "hide" the current weapon (hiding the models or something) because the player models will still use the current weapon anims.
__________________
gabuch2 is offline
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
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 05-09-2016 , 14:06   Re: Equip WEAPON_NONE
Reply With Quote #9

and you can try this !

PHP Code:
    new iEquipEnt create_entity("game_player_equip");
            
            if (
iEquipEnt)
            {
                
remove_entity(iEquipEnt);
            } 
__________________

Last edited by abdobiskra; 05-09-2016 at 14:06.
abdobiskra is offline
Send a message via Skype™ to abdobiskra
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-09-2016 , 15:38   Re: Equip WEAPON_NONE
Reply With Quote #10

Sorry but i was thinking and my code it's not enough good.

I mean that it will remove weapon and even if you'll have nothing in hands then if you will change weapon and then change back to primary slot , it won't appear because it will be empty, or not.
I don't know , test it.
I know that there is an strip stock (fm, ham , engine... i dont know exactly) which strips the gun but it stays red weapon in primary slot and you can select it but nothing appears.It's what you need.
If someone knows how to do that then i can add it to my code.
siriusmd99 is offline
Reply



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:36.


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