Senior Member
Join Date: Oct 2020
Location: Philippines from South K
|
04-16-2021
, 04:48
Custom player animations per weapons
|
#1
|
Hello, is it possible to have different player animations per different knife, weapons, and etc...
I ask this because I have different csnz knives and I want to use the player anims from CSNZ.
Sample codes:
Test1 Knife
PHP Code:
#define PLAYER_ANIM "test1"
public plugin_init()
{
register_event(FM_CmdStart, "fw_CmdStart")
}
public fw_CmdStart(id, uc_handle, seed)
{
if(!is_user_alive(id)) return FMRES_IGNORED
new button = get_uc(uc_handle, UC_Buttons)
if(button & IN_ATTACK)
{
new szAnim[64]
formatex(szAnim, charsmax(szAnim), pev(id, pev_flags) & FL_DUCKING ? "crouch_shoot_%s" : "ref_shoot_%s", PLAYER_ANIM)
UTIL_PlayerAnimation(id, szAnim)
}
}
stock UTIL_PlayerAnimation(id, szAnimation[])
{
static iAnimDesired, Float:fFrameRate, Float:fGroundSpeed, bool:bLoops;
if((iAnimDesired = lookup_sequence(id, szAnimation, fFrameRate, bLoops, fGroundSpeed)) == -1) iAnimDesired = 0;
static Float:fGameTime;
fGameTime = get_gametime();
set_pev(id, pev_frame, 0.0);
set_pev(id, pev_framerate, 1.0);
set_pev(id, pev_animtime, fGameTime);
set_pev(id, pev_sequence, iAnimDesired);
set_pdata_int(id, 40, bLoops, 4);
set_pdata_int(id, 39, 0, 4);
set_pdata_float(id, 36, fFrameRate, 4);
set_pdata_float(id, 37, fGroundSpeed, 4);
set_pdata_float(id, 38, fGameTime, 4);
set_pdata_int(id, 73, 28);
set_pdata_int(id, 74, 28);
set_pdata_float(id, 220, fGameTime);
}
Test2 Knife
PHP Code:
#define PLAYER_ANIM "test2"
public plugin_init()
{
register_event(FM_CmdStart, "fw_CmdStart")
}
public fw_CmdStart(id, uc_handle, seed)
{
if(!is_user_alive(id)) return FMRES_IGNORED
new button = get_uc(uc_handle, UC_Buttons)
if(button & IN_ATTACK)
{
new szAnim[64]
formatex(szAnim, charsmax(szAnim), pev(id, pev_flags) & FL_DUCKING ? "crouch_shoot_%s" : "ref_shoot_%s", PLAYER_ANIM)
UTIL_PlayerAnimation(id, szAnim)
}
}
stock UTIL_PlayerAnimation(id, szAnimation[])
{
static iAnimDesired, Float:fFrameRate, Float:fGroundSpeed, bool:bLoops;
if((iAnimDesired = lookup_sequence(id, szAnimation, fFrameRate, bLoops, fGroundSpeed)) == -1) iAnimDesired = 0;
static Float:fGameTime;
fGameTime = get_gametime();
set_pev(id, pev_frame, 0.0);
set_pev(id, pev_framerate, 1.0);
set_pev(id, pev_animtime, fGameTime);
set_pev(id, pev_sequence, iAnimDesired);
set_pdata_int(id, 40, bLoops, 4);
set_pdata_int(id, 39, 0, 4);
set_pdata_float(id, 36, fFrameRate, 4);
set_pdata_float(id, 37, fGroundSpeed, 4);
set_pdata_float(id, 38, fGameTime, 4);
set_pdata_int(id, 73, 28);
set_pdata_int(id, 74, 28);
set_pdata_float(id, 220, fGameTime);
}
__________________
|
|