Raised This Month: $ Target: $400
 0% 

set weaponanim by entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gian_Yagami
Member
Join Date: Apr 2014
Old 01-27-2016 , 01:44   set weaponanim by entity
Reply With Quote #1

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.
Gian_Yagami is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 01-27-2016 , 05:20   Re: set weaponanim by entity
Reply With Quote #2

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()

__________________
JusTGo is offline
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 01-27-2016 , 06:42   Re: set weaponanim by entity
Reply With Quote #3

Arent the codes just the same?
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
JusTGo
Veteran Member
Join Date: Mar 2013
Old 01-27-2016 , 06:58   Re: set weaponanim by entity
Reply With Quote #4

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)"
__________________
JusTGo is offline
Gian_Yagami
Member
Join Date: Apr 2014
Old 01-27-2016 , 16:32   Re: set weaponanim by entity
Reply With Quote #5

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.

Last edited by Gian_Yagami; 01-27-2016 at 17:59.
Gian_Yagami is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-28-2016 , 09:33   Re: set weaponanim by entity
Reply With Quote #6

A right stock is something like that : https://forums.alliedmods.net/showpo...7&postcount=26
__________________
Arkshine is offline
Gian_Yagami
Member
Join Date: Apr 2014
Old 01-28-2016 , 10:24   Re: set weaponanim by entity
Reply With Quote #7

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 View Post
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.
Gian_Yagami is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-29-2016 , 06:17   Re: set weaponanim by entity
Reply With Quote #8

If 0, it will retrieve value automatically.
__________________
Arkshine is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 01-29-2016 , 06:44   Re: set weaponanim by entity
Reply With Quote #9

AFAIK proper weapon holster system was never implemented in Half-Life.
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Gian_Yagami
Member
Join Date: Apr 2014
Old 01-29-2016 , 15:39   Re: set weaponanim by entity
Reply With Quote #10

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 View Post
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
Gian_Yagami 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 09:32.


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