AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Grenade throwing animation (https://forums.alliedmods.net/showthread.php?t=22614)

SubFive 12-31-2005 01:09

Grenade throwing animation
 
Is there anyway to trigger a grenade throwing animation? For example, in a plugin I'm testing, I'd like it to act exactly as if I was throwing a grenade when I press whatever button is bound to "throw".

v3x 12-31-2005 01:19

This is what I did:
Code:
public client_PreThink( id ) {   // check some vars first and whatnot..   set_animation(id, 2); } public set_animation( id, seq ) {   entity_set_int(id, EV_INT_weaponanim, seq);   message_begin(MSG_ONE, SVC_WEAPONANIM, {0,0,0}, id);   write_byte(seq);   write_byte(entity_get_int(id, EV_INT_body));   message_end(); }
In this case the sequence # for the grenade throwing animation is 2.

SubFive 12-31-2005 01:20

Looks good, thanks! 8)

SubFive 12-31-2005 02:08

Tested it out, and it didnt go quite as planned. :wink: Maybe it was because of how I made the script to test it out. I gave myself enough money and the animation looked very weird with guns out, although that might be expected as its not a nade, and thats the animation I'm trying to do. So I gave my self a nade and then enough money to trigger it. Looked funky, I dont think that was how it was suppose to work. Any ideas?

Code:
#include <amxmodx> #include <cstrike> #include <engine> public client_PreThink(id) {     new money = cs_get_user_money(id);     if(money > 5000)     {         set_animation(id, 2);     } } public set_animation( id, seq ) {     entity_set_int(id, EV_INT_weaponanim, seq);     message_begin(MSG_ONE, SVC_WEAPONANIM, {0,0,0}, id);     write_byte(seq);     write_byte(entity_get_int(id, EV_INT_body));     message_end(); }

v3x 12-31-2005 02:20

Hmm.. Check if they have a nade out first and holding the attack button:
Code:
public client_PreThink(id) {     new money = cs_get_user_money(id);     new clip, ammo, weapid = get_user_weapon(id, clip, ammo);     new button = get_user_button(id);     if((weapid == 4 || weapid == 9 || weapid == 25) && button&IN_ATTACK && money > 5000)     {         set_animation(id, 2);     } }

SubFive 12-31-2005 02:40

The thing is, I want this animation to be able to happen (correctly :wink:) regardless of what the user is currently holding, wether it be a gun, nade, or shield, etc.

v3x 12-31-2005 02:44

Then you will have to set the model to the grenade one for all weaps :P

SubFive 12-31-2005 02:49

So basically that means its not doable? A little tired, sorry if I dont understand everything at first. What I think you just told me is that basically the animation wont work unless a grenade is at hand, so in that case, could I quickly switch the users weapon from whatever it is to any grenade the user has in his inventory, do the animation, and then switch back to the gun?

v3x 12-31-2005 03:06

Code:
if(user_has_weapon(id, CSW_HEGRENADE)) {   engclient_cmd(id, "weapon_hegrenade");   // set animation   set_task(1.5, "revert_back", id); // change 1.5 to the length of the animation }
Code:
public revert_back( id ) {   client_cmd(id, "lastinv"); // or w/e is bound to the 'q' key .. }
Not 100% sure it'll work but w/e, I'm tired :P

SubFive 12-31-2005 03:14

Quote:

Originally Posted by v3x
Code:
engclient_cmd(id, "weapon_hegrenade");

Wouldn't this actually make the person throw the grenade, instead of just doing the animation?


All times are GMT -4. The time now is 15:57.

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