AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   set weaponanim by entity (https://forums.alliedmods.net/showthread.php?t=278198)

Gian_Yagami 01-27-2016 01:44

set weaponanim by entity
 
I'm trying to show holster animation but the animation Doesn't play

Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Weapon"
#define VERSION "1.0"
#define AUTHOR "Gian Yagami"


new weapon [][] =
{
    "weapon_357",
    "weapon_9mmAR",
    "weapon_9mmhandgun",
    "weapom_crossbow",
    "weapon_crowbar",
    "weapon_egon",
    "weapon_gauss",
    "weapon_handgrenade",
    "weapon_hornetgun",
    "weapon_rpg",
    "weapon_satchel",
    "weapon_shotgun",
    "weapon_snark",
    "weapon_tripmine"
}


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
   
    for(new i = 0; i < sizeof weapon; i++)
    {
        RegisterHam(Ham_Item_Holster, weapon[i], "holster")
    }
}

public holster(ent)
{
    //message_begin(MSG_ONE, SVC_WEAPONANIM, _, ent)
    //write_byte(8) //Animation id
    //write_byte(pev(ent,pev_body))
    //message_end()
   
    //new playerid = get_pdata_cbase(ent, 41, 4)
    new id = pev(ent, pev_owner)
    set_pev(id, pev_weaponanim, 8)   
}

Using message_begin and get_pdata_cbase will make game crash.

JusTGo 01-27-2016 05:20

Re: set weaponanim by entity
 
try this stock:
PHP Code:

stock UTIL_SenwWeaponAnim(const pPlayer, const Sequence)
{
    
set_pev(pPlayerpev_weaponanimSequence)
    
    
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM, .player pPlayer)
    
write_byte(Sequence)
    
write_byte(pev(pPlayerpev_body))
    
message_end()



Chihuahuax 01-27-2016 06:42

Re: set weaponanim by entity
 
Arent the codes just the same?

JusTGo 01-27-2016 06:58

Re: set weaponanim by entity
 
he have: "message_begin(MSG_ONE, SVC_WEAPONANIM, _, ent)"
while that i used and tested and it works have : "message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = pPlayer)"

Gian_Yagami 01-27-2016 16:32

Re: set weaponanim by entity
 
Is still not works, your stock using player index, but ham_item_holster just have entity index.
EDIT: actualy it works but still incorrect, I'm just did not realize it. It's making deploy animation replaced. I think I must block player think to change weapon until the animation finish.

Arkshine 01-28-2016 09:33

Re: set weaponanim by entity
 
A right stock is something like that : https://forums.alliedmods.net/showpo...7&postcount=26

Gian_Yagami 01-28-2016 10:24

Re: set weaponanim by entity
 
until now, I have changed the codes many times and decided not to use ham_item_holster and ham_item_deploy because is not called when player use quick change to last weapon used button. This is my current code:
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <engine>

#define PLUGIN "Weapon"
#define VERSION "1.0"
#define AUTHOR "Gian Yagami"

new ent_hWpn[18]
new 
ent_dWpn[18]
new 
playerid


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("CurWeapon""Event_Cur_Weapon",  "b")
    


stock UTIL_SenwWeaponAnim(const playerid, const Sequence)
{
    
set_pev(playeridpev_weaponanimSequence)

    
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM, .player playerid)
    
write_byte(Sequence)
    
write_byte(pev(playeridpev_body))
    
message_end()
}

public 
Event_Cur_Weapon(ent// Always looping whenever player grab a weapon
{
    
playerid pev(entpev_owner)

    if (!
pev(playeridpev_weaponanim8)) //Checking if animation is still play or not. idk this work or not
        
set_pev(playeridpev_weaponsent_dWpn)

    for (new 
0sizeof ent_hWpni++)
    {
        for (new 
0sizeof ent_dWpnj++)
        {
            if (
ent_hWpn[i] != ent_dWpn[j] )
            {
                
set_pev(playeridpev_weaponsent_hWpn// change weapon to previous idk this work or not
                
UTIL_SenwWeaponAnim(playerid8)
                
sizeof ent_hWpnsizeof ent_dWpn;
            }
        }
    }


I'm still wonder how to use pev_weapons and checking animation

Quote:

Originally Posted by Arkshine (Post 2387576)
A right stock is something like that : https://forums.alliedmods.net/showpo...7&postcount=26

I see owner keyword and the value is zero, how I can input player index? because I want specific player meet the conditions. Who change the weapon.

Arkshine 01-29-2016 06:17

Re: set weaponanim by entity
 
If 0, it will retrieve value automatically.

NiHiLaNTh 01-29-2016 06:44

Re: set weaponanim by entity
 
AFAIK proper weapon holster system was never implemented in Half-Life.

Gian_Yagami 01-29-2016 15:39

Re: set weaponanim by entity
 
I found some function in half-life source code. Did this can be modified by fakemeta or something?

in weapons.cpp:

PHP Code:

void CBasePlayerItem::Holsterint skiplocal /* = 0 */ )

    
m_pPlayer->pev->viewmodel 0
    
m_pPlayer->pev->weaponmodel 0;
}

void CBasePlayerWeapon::Holsterint skiplocal /* = 0 */ )

    
m_fInReload FALSE// cancel any reload in progress.
    
m_pPlayer->pev->viewmodel 0
    
m_pPlayer->pev->weaponmodel 0;
}

void CBasePlayerWeapon::RetireWeaponvoid )
{
    
Holster();
    
// first, no viewmodel at all.
    
m_pPlayer->pev->viewmodel iStringNull;
    
m_pPlayer->pev->weaponmodel iStringNull;
    
//m_pPlayer->pev->viewmodelindex = NULL;

    
g_pGameRules->GetNextBestWeaponm_pPlayerthis );


in weapon_generic.cpp

PHP Code:

enum generic_e 
{
    
GENERIC_IDLE1 0,
    
GENERIC_IDLE2,
    
GENERIC_IDLE3,
    
GENERIC_SHOOT,
    
GENERIC_SHOOT2,
    
GENERIC_RELOAD,
    
GENERIC_RELOAD2,
    
GENERIC_DRAW,
    
GENERIC_HOLSTER,
    
GENERIC_SPECIAL
};

void CWpnGeneric::Holsterint skiplocal )
{
    
m_pPlayer->m_flNextAttack UTIL_WeaponTimeBase() + 1.0;
    
SendWeaponAnimGENERIC_HOLSTER );


Quote:

Originally Posted by NiHiLaNTh (Post 2387932)
AFAIK proper weapon holster system was never implemented in Half-Life.

Yes, but many view models have holster animation and it unused. Holster system implemented in mods like Firearms and Cry of Fear


All times are GMT -4. The time now is 09:32.

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