Raised This Month: $7 Target: $400
 1% 

Solved Send third person animation to player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 04-14-2020 , 00:04   Send third person animation to player
Reply With Quote #1

Hello

I'm trying to re-create a weapon attack from scratch, but I have a problem where I have to set the "player" third person animation.

Any idea what's going on?

Code:
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_medkit", "heal_pre", 0);

Code:
public heal_pre(weaponID) {     new id = get_pdata_ehandle(weaponID, 404, 16);     new target;     get_user_aiming(id, target);     if(ExecuteHam(Ham_SC_IsMonster, target))         return HAM_IGNORED;     new tempid = -1;     new Float:v_Player[3];     pev(id, pev_origin, v_Player)     while((tempid = find_ent_in_sphere(tempid, v_Player, 100.0)))     {         if(tempid == 0         || tempid > MaxClients         || pev(tempid, pev_max_health) <= pev(tempid, pev_health)         || pev(tempid, pev_deadflag) & DEAD_DYING         || pev(tempid, pev_deadflag) & DEAD_DEAD         || tempid == id)             continue;         new key[3];         num_to_str(weaponID,key,charsmax(key));         if(!TrieKeyExists(g_tcBusyHealthkits, key))         {             ExecuteHam(Ham_Weapon_SendWeaponAnim, weaponID, 3, 0, 0);             set_pev(id, pev_frame, 1.0);             set_pev(id, pev_animtime, 100.0);             set_pev(id, pev_framerate, 1.0);             if(pev(id, pev_flags) & FL_DUCKING)                 set_pev(id, pev_sequence, 46);             else                 set_pev(id, pev_sequence, 43);             TrieSetCell(g_tcBusyHealthkits, key, 0, true);             healgroup(id, weaponID);             set_task(1.0, "remove_from_busy_hk", TASK_NUM+weaponID);             break;         }     }         return HAM_SUPERCEDE; }

Thanks in advance.
__________________

Last edited by gabuch2; 05-18-2020 at 23:12.
gabuch2 is offline
Gian_Yagami
Member
Join Date: Apr 2014
Old 04-21-2020 , 23:56   Re: Send third person animation to player
Reply With Quote #2

try switch
PHP Code:
new id get_pdata_ehandle(weaponID40416); 
to
PHP Code:
new id pev(entpev_owner
Gian_Yagami is offline
thEsp
BANNED
Join Date: Aug 2017
Old 04-22-2020 , 04:23   Re: Send third person animation to player
Reply With Quote #3

Quote:
Originally Posted by Gian_Yagami View Post
try switch
PHP Code:
new id get_pdata_ehandle(weaponID40416); 
to
PHP Code:
new id pev(entpev_owner
For some reasons sometimes pev_owner in hamsandwich forwards outputs a null or invalid value, so I think that's why Gabbe didn't do that.
thEsp is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 04-22-2020 , 09:42   Re: Send third person animation to player
Reply With Quote #4

Quote:
Originally Posted by Gian_Yagami View Post
try switch
PHP Code:
new id get_pdata_ehandle(weaponID40416); 
to
PHP Code:
new id pev(entpev_owner
My piece of code is correct, it extracts the player ID from a weapon_ entity.
__________________
gabuch2 is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 04-30-2020 , 17:02   Re: Send third person animation to player
Reply With Quote #5

Reached 3rd page, I still need help with this.
__________________
gabuch2 is offline
Smilex_Gamer
Senior Member
Join Date: Apr 2017
Location: Portugal
Old 04-30-2020 , 19:03   Re: Send third person animation to player
Reply With Quote #6

Quote:
Originally Posted by knekter View Post
Ok I have been experimenting with this lately, I have created a mod that adds in the Displacer Gun from Opposing forces. I was able to play the animations for the weapons when they are firing/reloading/idleing/ect. I also noticed that setting it once won't work. I needed to constantly set it either in server frame or prethink. I used prethink. Here is my code and what I have so far, not many intentions to finish it:

Code:
#include <amxmodx> #include <engine> #include <fakemeta> #define SEQ_IDLE    0 #define SEQ_CHARGE  2 #define SEQ_FIRE    4 // All the CS Standard knife sounds new const g_szKnifeSnd[9][] = {     "weapons/knife_deploy1.wav",     "weapons/knife_hit1.wav",     "weapons/knife_hit2.wav",     "weapons/knife_hit3.wav",     "weapons/knife_hit4.wav",     "weapons/knife_hitwall1.wav",     "weapons/knife_slash1.wav",     "weapons/knife_slash2.wav",     "weapons/knife_stab.wav" } new g_iSequence[33]  // Current sequence your weapon is in new g_sprGlow, g_sprSmoke   // Sprites public plugin_init() {     register_plugin("Displacer Cannon", "0.1", "Knekter")     register_event("CurWeapon", "WeaponChange", "be")     register_forward(FM_SetModel, "SetModel")     register_forward(FM_EmitSound, "EmitSound") } public plugin_precache() {     precache_model("models/v_displacer.mdl")     precache_model("models/p_displacer.mdl")     precache_model("models/w_displacer.mdl")     precache_sound("weapons/displacer_spin.wav")     precache_sound("weapons/displacer_fire.wav")     g_sprGlow = precache_model("sprites/glow04.spr")     g_sprSmoke = precache_model("sprites/smoke.spr") } public WeaponChange(id) {     new iWeap = read_data(2)     if(iWeap == 29)     {         entity_set_string(id, EV_SZ_viewmodel, "models/v_displacer.mdl")         entity_set_string(id, EV_SZ_weaponmodel, "models/p_displacer.mdl")     } } public EmitSound(entity, channel, const sound[]) {     for(new iSnd = 0; iSnd < 8; iSnd++)     {         if(containi(sound, g_szKnifeSnd[iSnd]) != -1)             return FMRES_SUPERCEDE     }     return FMRES_IGNORED } public client_PreThink(id) {     new iClip, iAmmo     new iWeap = get_user_weapon(id, iClip, iAmmo)     if(iWeap == 29)     {         if(g_iSequence[id] == SEQ_CHARGE)             entity_set_int(id, EV_INT_weaponanim, SEQ_CHARGE)         else if(g_iSequence[id] == SEQ_FIRE)             entity_set_int(id, EV_INT_weaponanim, SEQ_FIRE)         else if(g_iSequence[id] == SEQ_IDLE)             entity_set_int(id, EV_INT_weaponanim, SEQ_IDLE)         if((get_user_button(id) & IN_ATTACK) && !(get_user_oldbutton(id) & IN_ATTACK) && !task_exists(id + 57455))         {             new param[1]             param[0] = id             client_cmd(id, "spk ^"%s^"", "weapons/displacer_spin.wav")             set_task(1.0, "FireDisplacer", id + 57455, param, 1)             g_iSequence[id] = SEQ_CHARGE         }     }     return PLUGIN_CONTINUE } public FireDisplacer(param[1]) {     new id = param[0]     g_iSequence[id] = SEQ_FIRE     client_cmd(id, "spk ^"%s^"", "weapons/displacer_fire.wav")     new entity = create_entity("info_target")     if(entity > 0)     {         new Float:Origin[3], Float:Velocity[3], Float:Angle[3]         entity_set_string(entity, EV_SZ_classname, "energy_ball")         entity_get_vector(id, EV_VEC_origin, Origin)         Origin[2] += 12.0         entity_set_origin(entity, Origin)         entity_set_size(entity, Float:{-1.0, -1.0, -1.0}, Float:{1.0, 1.0, 1.0})         entity_set_int(entity, EV_INT_solid, 2)         entity_set_int(entity, EV_INT_movetype, 5)         entity_set_edict(entity, EV_ENT_owner, id)         velocity_by_aim(id, 500, Velocity)         vector_to_angle(Velocity, Angle)         entity_set_vector(entity, EV_VEC_angles, Angle)         entity_set_vector(entity, EV_VEC_velocity, Velocity)         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)         write_byte(22)         write_short(entity)         write_short(g_sprSmoke)         write_byte(10)         write_byte(5)         write_byte(255)         write_byte(156)         write_byte(0)         write_byte(255)         message_end()         new param2[2]         param[0] = id         param2[1] = entity         set_task(0.1, "EnergyEffect", id + 49734, param2, 1, "b")     }     set_task(0.9, "IdleDisplacer", id)     return PLUGIN_CONTINUE } public EnergyEffect(param2[1]) {     new entity = param2[0]     if(is_valid_ent(entity))     {         new Float:fOrigin[3], Origin[3]         entity_get_vector(entity, EV_VEC_origin, fOrigin)         FVecIVec(fOrigin, Origin)         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)         write_byte(17)         write_coord(Origin[0])         write_coord(Origin[1])         write_coord(Origin[2])         write_short(g_sprGlow)         write_byte(10)         write_byte(150)         message_end()     }     return PLUGIN_CONTINUE } public IdleDisplacer(id) {     g_iSequence[id] = SEQ_IDLE } public pfn_touch(ptr, ptd) {     if(ptr > 0 && ptd >= 0)     {         new pToucher[33]         entity_get_string(ptr, EV_SZ_classname, pToucher, 32)         if(equal(pToucher, "energy_ball"))         {             new Float:fOrigin[3], Origin[3]             entity_get_vector(ptr, EV_VEC_origin, fOrigin)             FVecIVec(fOrigin, Origin)             /*message_begin(MSG_BROADCAST, SVC_TEMPENTITY)             write_byte(27)             write_coord(Origin[0])             write_coord(Origin[1])             write_coord(Origin[2])             write_byte(200)             write_byte(255)             write_byte(255)             write_byte(255)             write_byte(200)             write_byte(5)             write_byte(10)             message_end()             message_begin(MSG_BROADCAST, SVC_TEMPENTITY)             write_byte(14)             write_coord(Origin[0])             write_coord(Origin[1])             write_coord(Origin[2])             write_byte(100)             write_byte(100)             write_byte(10)             message_end()*/             new param[4]             param[0] = Origin[0]             param[1] = Origin[1]             param[2] = Origin[2]             param[3] = entity_get_edict(ptr, EV_ENT_owner)             remove_task(entity_get_edict(ptr, EV_ENT_owner) + 49734)             set_task(0.8, "DetonateBall", ptr + 75665, param, 4)             remove_entity(ptr)         }     }     return PLUGIN_CONTINUE } public DetonateBall(param[4]) {     return PLUGIN_CONTINUE }

I guess some day I will finish this up/ change the energy ball effect.
Maybe this can help you
Smilex_Gamer is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 05-03-2020 , 11:18   Re: Send third person animation to player
Reply With Quote #7

Mister Iggy!
I am assuming the mdl is precached on the script.
Even if it is; a line of this sort is required to see it in 3rd person.
Code:
new Float:frame = entity_get_float(weapon_ent[id],EV_FL_fuser1) + 2.0
Older non-ham method.
Might be of assistance.

Best of luck.

PS: Miss your little army helmet avatar!!
__________________
DJEarthQuake is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 05-18-2020 , 22:43   Re: Send third person animation to player
Reply With Quote #8

Managed to do it with Orpheu.

It seems the sequence on players gets overwritten by SetAnimation.

HTML Code:
{
    "name" : "SC_SetAnimation",
    "library" : "mod",
    "arguments" :
    [
        {
            "type" : "CBaseEntity *"
        },
        {
            "type" : "int"
        },
        {
            "type" : "int"
        }
    ],
    "identifiers" :
    [
        {
            "os"    : "linux",
            "mod"   : "svencoop",
            "value" : [0x55, 0x57, 0x56, 0x53, 0x83, 0xEC, 0x5C, 0xE8, 0x9A, 0x73, 0xCA, 0xFF, 0x81, 0xC3, 0x3A, 0x8B, 0x3A, 0x00]
        }
    ]
}
Code:
OrpheuCall(OrpheuGetFunction("SC_SetAnimation"), id, 5, 0);
__________________
gabuch2 is offline
Reply


Thread Tools
Display Modes

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 07:55.


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