I am trying to spawn an entity and play its animation to the end right when it spawns. What happens is that upon spawning, the animations starts playing up to certain frames, resets to the first frame then continues after a few moments. This could be best shown with a video example:
https://youtu.be/XiXJi3-640o. You can clearly see how it is bugged out.
PHP Code:
public CmdCorpse(iPlayer) {
new iOrigin[3], Float:fOrigin[3];
get_user_origin(iPlayer, iOrigin, 2);
IVecFVec(iOrigin, fOrigin);
new entCorpse = create_entity("info_target");
if (!entCorpse) {
log_amx("Could not create custom corpse entity.");
return FMRES_IGNORED;
}
entity_set_string(entCorpse, EV_SZ_classname, "custom_corpse");
entity_set_model(entCorpse, "models/player/terror/terror.mdl");
entity_set_int(entCorpse, EV_INT_solid, SOLID_TRIGGER);
entity_set_int(entCorpse, EV_INT_movetype, MOVETYPE_TOSS);
fOrigin[2] += 50.0;
entity_set_origin(entCorpse, fOrigin);
new Float:maxs[3] = {16.0, 16.0, 36.0};
new Float:mins[3] = {-16.0, -16.0, -36.0};
entity_set_size(entCorpse, mins, maxs);
entity_set_int(entCorpse, EV_INT_sequence, 107);
entity_set_float(entCorpse, EV_FL_frame, 1.0);
entity_set_float(entCorpse, EV_FL_animtime, get_gametime());
entity_set_float(entCorpse, EV_FL_framerate, 1.0);
return FMRES_IGNORED;
}
This code is how I managed to spawn an entity and set its animation. Suggestions for better methods (that work, obviously) are open!
I don't know what animtime does actually, but setting it to 100.0 like seen in many threads related to animations delays the animation for a few seconds. Clueless.