# Help with animating sprite (.spr) in Pawn language

**URL:** <https://forum.esforces.com/t/help-with-animating-sprite-spr-in-pawn-language/67424>\
**Category:** ESF Related\
**Tags:** sprite, report-issues\
**Created:** [March 24, 2008, 5:30pm UTC](https://forum.esforces.com/t/help-with-animating-sprite-spr-in-pawn-language/67424 "2008-03-24T17:30:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![SSJ4boneVegeta](https://forum.esforces.com/user_avatar/forum.esforces.com/ssj4bonevegeta/32/401_2.png) [@SSJ4boneVegeta](https://forum.esforces.com/u/SSJ4boneVegeta)\
**Post date:** [March 24, 2008, 5:30pm UTC](https://forum.esforces.com/t/help-with-animating-sprite-spr-in-pawn-language/67424/1 "2008-03-24T17:30:48Z")

</div>

Hi everyone,

This past weekend, I’ve been trying to code my first plugin in pawn. I have not been able to animate my sprite explode02.spr (from half-life sdk) no matter what I do and I’d like some help from those that know how.

here’s a code snippet:

```auto
        //Called whenever the PS hud appears

        //Good for entering water by beam block or swoop

        new origin[3], Float:Orig[3];

	get_user_origin(id, origin, 0);

	Orig[0] = float(origin[0]);

	Orig[1] = float(origin[1]);

	Orig[2] = float(origin[2]);

        //Draw sprite here

        new ent = create_entity("env_sprite");

        entity_set_string(ent, EV_SZ_model, "sprites/explode02.spr"); //additional info on the entity can be used to match entities

        //From Harsens' EFFECTS.CPP & edited to AMX Functions

        set_pev(ent, pev_spawnflags, SF_SPRITE_STARTON); //env_sprite

        set_pev(ent, pev_solid, SOLID_NOT);

	set_pev(ent, pev_movetype, MOVETYPE_NONE);

	set_pev(ent, pev_effects, 0); //Produces glaring sprite on EF_LIGHT

	set_pev(ent, pev_frame, 0);

        engfunc(EngFunc_SetModel, ent, "sprites/explode02.spr");

        entity_set_origin(ent, Orig);

        //entity_set_float(ent,EV_FL_animtime,1.0);

      	//set_pev(ent,pev_animtime,10.0);

        //entity_set_float(ent,EV_FL_framerate,10.0);

       	set_pev(ent,pev_framerate,10.0);

        //Animate

        new maxframes = engfunc(EngFunc_ModelFrames,engfunc(EngFunc_ModelIndex,"sprites/explode02.spr"));

        new lasttime = global_get(glb_time);

        for(new Float:frame = 0.0; pev(ent,pev_frame) < maxframes; frame += pev(ent,pev_framerate) * (global_get(glb_time)- lasttime))

        {

                set_pev(ent, pev_frame, frame);

        }

        //EF_AnimationAutomove(ent, 1.0);

        //set_rendering(ent);

        //call_think(ent);

        //remove_entity(ent);
```

Thanks

---

<div class="post-metadata">

**Author:** ![Raven](https://forum.esforces.com/user_avatar/forum.esforces.com/raven/32/869_2.png) [@Raven](https://forum.esforces.com/u/Raven)\
**Post date:** [March 24, 2008, 8:56pm UTC](https://forum.esforces.com/t/help-with-animating-sprite-spr-in-pawn-language/67424/2 "2008-03-24T20:56:38Z")

</div>

dispatch spawn…

---

<div class="post-metadata">

**Author:** ![SSJ4boneVegeta](https://forum.esforces.com/user_avatar/forum.esforces.com/ssj4bonevegeta/32/401_2.png) [@SSJ4boneVegeta](https://forum.esforces.com/u/SSJ4boneVegeta)\
**Post date:** [March 24, 2008, 8:59pm UTC](https://forum.esforces.com/t/help-with-animating-sprite-spr-in-pawn-language/67424/3 "2008-03-24T20:59:12Z")

</div>

I’ve seen dispatchkeyvalue and dispatchspawn but I don’t really know what they do or how to use them.

The sprite is rendered/drawn to screen but stuck on first frame and fairly small. So will dispathspawn animate the sprite? And if so, where/when should I call the function?

Thanks

---

<div class="post-metadata">

**Author:** ![Raven](https://forum.esforces.com/user_avatar/forum.esforces.com/raven/32/869_2.png) [@Raven](https://forum.esforces.com/u/Raven)\
**Post date:** [March 24, 2008, 9:08pm UTC](https://forum.esforces.com/t/help-with-animating-sprite-spr-in-pawn-language/67424/4 "2008-03-24T21:08:02Z")

</div>

try this:

[CODE]//Called whenever the PS hud appears  
//Good for entering water by beam block or swoop

//Draw sprite here  
new Entity = create\_entity( “env\_sprite” );

entity\_set\_string ( Entity, EV\_SZ\_classname, “SpriteEntity” );  
entity\_set\_model ( Entity, “sprites/explode02.spr” );  
entity\_set\_float ( Entity, EV\_FL\_scale, 1.0 );

//if u like:  
/\*  
entity\_set\_int( Entity, EV\_INT\_renderfx, kRenderFxNone );  
entity\_set\_int( Entity, EV\_INT\_rendermode, kRenderTransAdd );  
entity\_set\_float( Entity, EV\_FL\_renderamt, 255.0 );  
\*/

// Spawn Sprite at Clients Origin Coords  
new Float:CoreOrigin[3];  
entity\_get\_vector( Client, EV\_VEC\_origin, CoreOrigin );  
entity\_set\_origin( Entity, CoreOrigin );

//Framerate if u like…  
entity\_set\_float( Entity, EV\_FL\_framerate, 10.0 );

DispatchSpawn( Entity );

//EF\_AnimationAutomove(ent, 1.0);

//set\_rendering(ent);

//call\_think(ent);

//remove\_entity(ent);[/CODE]

---

<div class="post-metadata">

**Author:** ![SSJ4boneVegeta](https://forum.esforces.com/user_avatar/forum.esforces.com/ssj4bonevegeta/32/401_2.png) [@SSJ4boneVegeta](https://forum.esforces.com/u/SSJ4boneVegeta)\
**Post date:** [March 25, 2008, 2:14pm UTC](https://forum.esforces.com/t/help-with-animating-sprite-spr-in-pawn-language/67424/5 "2008-03-25T14:14:55Z")

</div>

Thx, I’ll give it a try tonight for flexibility.

I did get the animation to work using set\_task with a delay of 0.1 and changing pev\_frame. The weird thing is I’ve tried changing it before in a for loop with no success. (fps must of been too high for me to notice a change in frame or there might not be an intermediate frame like 1.1 and instead it has to be a whole number/interger).

Thanks

---

<div class="post-metadata">

**Author:** ![EncorE\_SX](https://forum.esforces.com/letter_avatar_proxy/v4/letter/e/c5a1d2/32.png) [@EncorE\_SX](https://forum.esforces.com/u/EncorE_SX)\
**Post date:** [July 21, 2008, 8:15am UTC](https://forum.esforces.com/t/help-with-animating-sprite-spr-in-pawn-language/67424/6 "2008-07-21T08:15:00Z")

</div>

lol trying to reproduce flameeffect arent you

---

<div class="post-metadata">

**Author:** ![ESForcer](https://forum.esforces.com/letter_avatar_proxy/v4/letter/e/b5ac83/32.png) [@ESForcer](https://forum.esforces.com/u/ESForcer)\
**Post date:** [July 27, 2008, 6:51am UTC](https://forum.esforces.com/t/help-with-animating-sprite-spr-in-pawn-language/67424/7 "2008-07-27T06:51:35Z")

</div>

I do not see anything wrong in your approach…let me check the source carefully and get back to you.

---

<div class="post-metadata">

**Author:** ![Radditzssj](https://forum.esforces.com/letter_avatar_proxy/v4/letter/r/48db29/32.png) [@Radditzssj](https://forum.esforces.com/u/Radditzssj)\
**Post date:** [September 19, 2008, 4:58pm UTC](https://forum.esforces.com/t/help-with-animating-sprite-spr-in-pawn-language/67424/8 "2008-09-19T16:58:20Z")

</div>

what program I need to make sprites?
