AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Equip WEAPON_NONE (https://forums.alliedmods.net/showthread.php?t=282240)

gabuch2 05-02-2016 10:31

Equip WEAPON_NONE
 
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.

Kowalsky 05-03-2016 05:58

Re: Equip WEAPON_NONE
 
engfunc_cmd drop weapon_name?

gabuch2 05-03-2016 07:55

Re: Equip WEAPON_NONE
 
Quote:

Originally Posted by Kowalsky (Post 2416217)
engfunc_cmd drop weapon_name?

Thing is, I don't want to drop the players equipment. I don't know if it's possible.

klippy 05-03-2016 08:22

Re: Equip WEAPON_NONE
 
Unequip as destroy the item in their inventory?

gabuch2 05-03-2016 11:27

Re: Equip WEAPON_NONE
 
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.

HamletEagle 05-04-2016 06:24

Re: Equip WEAPON_NONE
 
Quote:

Originally Posted by Shattered Heart Lynx (Post 2416309)
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?

gabuch2 05-09-2016 09:15

Re: Equip WEAPON_NONE
 
Quote:

Originally Posted by HamletEagle (Post 2416488)
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.

siriusmd99 05-09-2016 12:05

Re: Equip WEAPON_NONE
 
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...

abdobiskra 05-09-2016 14:06

Re: Equip WEAPON_NONE
 
and you can try this !

PHP Code:

    new iEquipEnt create_entity("game_player_equip");
            
            if (
iEquipEnt)
            {
                
remove_entity(iEquipEnt);
            } 


siriusmd99 05-09-2016 15:38

Re: Equip WEAPON_NONE
 
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.


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

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