27.04.2015, 16:43
For players, NPCs and now actors it's a well known bug "Animations desync".
We have a body death system (lying animation, using NPCs), we solved this by sending the RPC ApplyAnimation to each stream-in player, for example this is using the RAK plugin (also works in 0.3.7):
NOTE: Remember to use ApplyAnimationEx() and ClearAnimationsEx() instead of ClearAnimations()
That you need is the new RPC for ApplyActorAnimation to make it work with Actors – or SA-MP team adds OnActorStreamIn, ApplyActorAnimationForPlayer and ApplyAnimationForPlayer to avoid plugins and network manipulation (and others workarounds).
Regards.
We have a body death system (lying animation, using NPCs), we solved this by sending the RPC ApplyAnimation to each stream-in player, for example this is using the RAK plugin (also works in 0.3.7):
Code:
#define RPC_ApplyAnimation 86 enum AnimsSyncEnum { s_is_anim, s_animlib[50], s_animname[50], Float:s_fDelta, s_loop, s_lockx, s_locky, s_freeze, s_time, s_forcesync }; new AnimsSync[MAX_PLAYERS][AnimsSyncEnum]; forward ApplyAnimationEx(playerid, animlib[], animname[], Float:fDelta, loop, lockx, locky, freeze, time, forcesync); public ApplyAnimationEx(playerid, animlib[], animname[], Float:fDelta, loop, lockx, locky, freeze, time, forcesync) { AnimsSync[playerid][s_is_anim] = true; format(AnimsSync[playerid][s_animlib], 50, "%s", animlib); format(AnimsSync[playerid][s_animname], 50, "%s", animname); AnimsSync[playerid][s_fDelta] = fDelta; AnimsSync[playerid][s_loop] = loop; AnimsSync[playerid][s_lockx] = lockx; AnimsSync[playerid][s_locky] = locky; AnimsSync[playerid][s_freeze] = freeze; AnimsSync[playerid][s_time] = time; AnimsSync[playerid][s_forcesync] = forcesync; //ApplyAnimation(playerid, animlib, "null", fDelta, loop, lockx, locky, freeze, time, forcesync); // Pre-load? ApplyAnimation(playerid, animlib, animname, fDelta, loop, lockx, locky, freeze, time, forcesync); } forward ClearAnimationsEx(playerid, forcesync); public ClearAnimationsEx(playerid, forcesync) { AnimsSync[playerid][s_is_anim] = false; ClearAnimations( playerid, forcesync ); } forward ApplyAnimationSync(playerid, toplayerid); public ApplyAnimationSync(playerid, toplayerid) { if ( AnimsSync[playerid][s_is_anim] && ! IsPlayerInAnyVehicle(playerid) ) { new BitStream:bsAnim = InitBitStream(); WriteToBitStream(bsAnim, BS_SHORT, playerid); WriteToBitStream(bsAnim, BS_CHAR, strlen(AnimsSync[playerid][s_animlib])); // anim lib len WriteToBitStream(bsAnim, BS_STRING, AnimsSync[playerid][s_animlib] ); // anim lib WriteToBitStream(bsAnim, BS_CHAR, strlen( AnimsSync[playerid][s_animname] )); // anim name len WriteToBitStream(bsAnim, BS_STRING, AnimsSync[playerid][s_animname] ); // anim name WriteToBitStream(bsAnim, BS_FLOAT, AnimsSync[playerid][s_fDelta] ); // fDelta WriteToBitStream(bsAnim, BS_BOOL, AnimsSync[playerid][s_loop] ); // loop WriteToBitStream(bsAnim, BS_BOOL, AnimsSync[playerid][s_lockx] ); // lockx WriteToBitStream(bsAnim, BS_BOOL, AnimsSync[playerid][s_locky] ); // locky WriteToBitStream(bsAnim, BS_BOOL, AnimsSync[playerid][s_freeze] ); // freeze WriteToBitStream(bsAnim, BS_UINT, AnimsSync[playerid][s_time] ); // time //WriteToBitStream(bsAnim, BS_CHAR, AnimsSync[playerid][s_forcesync] ); // forcesync // doesn't exists SendRPC(toplayerid, RPC_ApplyAnimation, bsAnim); // Pre-load? SendRPC(toplayerid, RPC_ApplyAnimation, bsAnim); } } // Sync public OnPlayerStreamIn(playerid, forplayerid) { ApplyAnimationSync( playerid, forplayerid ); ApplyAnimationSync( forplayerid, playerid ); return 1; }
That you need is the new RPC for ApplyActorAnimation to make it work with Actors – or SA-MP team adds OnActorStreamIn, ApplyActorAnimationForPlayer and ApplyAnimationForPlayer to avoid plugins and network manipulation (and others workarounds).
Regards.