AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Animated Sprite Entity (https://forums.alliedmods.net/showthread.php?t=87859)

MeRcyLeZZ 03-17-2009 12:27

Animated Sprite Entity
 
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! }

stupok 03-17-2009 13:04

Re: Animated Sprite Entity
 
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 ) }

Emp` 03-17-2009 13:52

Re: Animated Sprite Entity
 
This works fine for me:
Code:

        set_pev( newEnt, pev_animtime, 1.0);
        set_pev( newEnt, pev_framerate, 1.0);


Arkshine 03-17-2009 14:00

Re: Animated Sprite Entity
 
I remember that DLLFunc_Spawn is needed otherwise animation will not start. You can see it if you take a look in the HLSDK.

Emp` 03-17-2009 14:08

Re: Animated Sprite Entity
 
I don't have DLLFunc_Spawn anywhere, but maybe its because I'm using an animated model instead of a sprite.

Arkshine 03-17-2009 14:13

Re: Animated Sprite Entity
 
Animated model ? Ah yeah probably because of that. For sure, if not spawn sprite can't be animated.

MeRcyLeZZ 03-17-2009 14:15

Re: Animated Sprite Entity
 
Thanks for your replies, I'll be testing those when I get home...

Dores 03-17-2009 18:20

Re: Animated Sprite Entity
 
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. :mrgreen:

SnoW 03-18-2009 10:47

Re: Animated Sprite Entity
 
Quote:

Originally Posted by Dores (Post 783114)
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. :mrgreen:

It doesn't need to be float. You can retrieve it as int if you want.

MeRcyLeZZ 03-18-2009 21:02

Re: Animated Sprite Entity
 
Yep, spawning it did the trick all right. +k


All times are GMT -4. The time now is 08:59.

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