Raised This Month: $ Target: $400
 0% 

Animated Sprite Entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 03-17-2009 , 12:27   Animated Sprite Entity
Reply With Quote #1

I'm trying to create an animated sprite entity which can freely move around the map.

I've come up with something, but there is a problem: the sprite's animation doesn't play.

Setting pev_framerate seems to have no effect. Any ideas?

Code:
#include <amxmodx> #include <fakemeta> new const g_firesprite[] = "sprites/flame.spr" public plugin_precache() {     precache_model( g_firesprite ) } public plugin_init() {     register_plugin( "Animated Sprite Entity", "0.0", "Test" )     register_clcmd( "say test", "clcmd_say_test" ) } public clcmd_say_test( id ) {     // Retrieve player's origin     new origin[3]     pev( id, pev_origin, origin )         // Create entity at player's position     new ent = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "info_target" ) )     set_pev( ent, pev_origin, origin)         // Set sprite on entity     engfunc( EngFunc_SetModel, ent, g_firesprite )     // Set proper rendering     set_pev( ent, pev_rendermode, kRenderTransAdd)     set_pev( ent, pev_renderamt, 200.0)         // Set the animation's framerate     set_pev( ent, pev_framerate, 1.0) // doesn't work! }
__________________
MeRcyLeZZ is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 03-17-2009 , 13:04   Re: Animated Sprite Entity
Reply With Quote #2

I'm pretty sure this will do it: (it's the method I use in my In-Game Ads plugin)

Code:
public clcmd_say_test( id ) {     // Retrieve player's origin     new origin[3]     pev( id, pev_origin, origin )         // Create entity at player's position     new ent = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "env_sprite" ) )     engfunc( EngFunc_SetOrigin, ent, origin )         // Set sprite on entity     engfunc( EngFunc_SetModel, ent, g_firesprite )     // Set proper rendering     set_pev( ent, pev_rendermode, kRenderTransAdd )     set_pev( ent, pev_renderamt, 200.0 )         // Set the animation's framerate     set_pev( ent, pev_framerate, 1.0 ) // doesn't work!     set_pev( ent, pev_spawnflags, SF_SPRITE_STARTON )     dllfunc( DLLFunc_Spawn, ent ) }
__________________
stupok is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-17-2009 , 13:52   Re: Animated Sprite Entity
Reply With Quote #3

This works fine for me:
Code:
	set_pev( newEnt, pev_animtime, 1.0);
	set_pev( newEnt, pev_framerate, 1.0);
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-17-2009 , 14:00   Re: Animated Sprite Entity
Reply With Quote #4

I remember that DLLFunc_Spawn is needed otherwise animation will not start. You can see it if you take a look in the HLSDK.
Arkshine is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-17-2009 , 14:08   Re: Animated Sprite Entity
Reply With Quote #5

I don't have DLLFunc_Spawn anywhere, but maybe its because I'm using an animated model instead of a sprite.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-17-2009 , 14:13   Re: Animated Sprite Entity
Reply With Quote #6

Animated model ? Ah yeah probably because of that. For sure, if not spawn sprite can't be animated.
Arkshine is offline
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 03-17-2009 , 14:15   Re: Animated Sprite Entity
Reply With Quote #7

Thanks for your replies, I'll be testing those when I get home...
__________________
MeRcyLeZZ is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 03-17-2009 , 18:20   Re: Animated Sprite Entity
Reply With Quote #8

Sorry for interrupting, I guess it's a typo or something, but to just clear things up - the origin[] var should be a float to retrieve pev_origin's value.

PHP Code:
new Float:origin[3];
pev(idpev_originorigin); 
Sorry for OT.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 03-18-2009 , 10:47   Re: Animated Sprite Entity
Reply With Quote #9

Quote:
Originally Posted by Dores View Post
Sorry for interrupting, I guess it's a typo or something, but to just clear things up - the origin[] var should be a float to retrieve pev_origin's value.

PHP Code:
new Float:origin[3];
pev(idpev_originorigin); 
Sorry for OT.
It doesn't need to be float. You can retrieve it as int if you want.
SnoW is offline
Send a message via MSN to SnoW
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 03-18-2009 , 21:02   Re: Animated Sprite Entity
Reply With Quote #10

Yep, spawning it did the trick all right. +k
__________________
MeRcyLeZZ 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 08:59.


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