Animation and freeze on death problem
#1

I have began writing a death system when you die (OnPlayerDeath) it will save your X,Y,Z and will spawn you at the same place using OnPlayerSpawn and will apply an animation and a freeze to you.
It works perfectly until it comes to the freeze and animation, it just won't work.
The player can move and no animation is applied, messages are sent, everything's just fine but no freeze and anim.
Anybody knows the solution? thanks!

EDIT: So.. I add a timer, now after a few seconds like 3-4 the animation stops and you can move, how come?

OnPlayerSpawn:

Код:
public OnPlayerSpawn(playerid)
{
    TogglePlayerSpectating(playerid, false);
	// Anti F4 Bug - Logging/Registering
	if(!PlayerInfo[playerid][pLoggedIn] && !IsPlayerNPC(playerid))
	{
		if(IsPlayerNPC(playerid)) return 1;
		SetPlayerJoinCamera(playerid);
	    SetSpawnInfo( playerid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	    new file[64];
		format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
	    // Player isn't banned
	    if(dini_Int(file, "AdminAccount") == 1)
		{
		    format(file, sizeof(file), "users/%s.ini",RPNU(playerid));
		    SetPlayerName(playerid, dini_Get(file, "OldName"));
		    format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
		    ShowDialog(playerid, 2);
		}
		if(!dini_Exists(file))
		{
		    ShowDialog(playerid, 1);
		    return 1;
		}
		else
		{
			ShowDialog(playerid, 2);
		}
		return 1;
	}
	PreloadAnimLib(playerid,"BOMBER");
	PreloadAnimLib(playerid,"RAPPING");
 	PreloadAnimLib(playerid,"SHOP");
	PreloadAnimLib(playerid,"BEACH");
	PreloadAnimLib(playerid,"SMOKING");
 	PreloadAnimLib(playerid,"FOOD");
 	PreloadAnimLib(playerid,"ON_LOOKERS");
 	PreloadAnimLib(playerid,"DEALER");
	PreloadAnimLib(playerid,"CRACK");
	PreloadAnimLib(playerid,"CARRY");
	PreloadAnimLib(playerid,"COP_AMBIENT");
	PreloadAnimLib(playerid,"PARK");
	PreloadAnimLib(playerid,"INT_HOUSE");
	PreloadAnimLib(playerid,"FOOD");
	PreloadAnimLib(playerid,"PED");
	PreloadAnimLib(playerid,"KNIFE");
	if(PlayerInfo[playerid][pMoneyReset] != 2)
	{
	    SetDodMoney(playerid, 2500);
		PlayerInfo[playerid][pBank] = 0;
		PlayerInfo[playerid][pMoneyReset] = 2;
		PlayerInfo[playerid][pExp] = 0;
		PlayerInfo[playerid][pMaterials] = 0;
		PlayerInfo[playerid][pBoombox] = 0;
		PlayerInfo[playerid][pMask] = 0;
		ResetDodWeapons(playerid);
	}
	foreach(Player, i)
    {
        if(PlayerStat[i][pMasked] == 1)
        {
            ShowPlayerNameTagForPlayer(i, playerid, false);
		}
	}
	if(PlayerInfo[playerid][pFac] != 0)
	{
		SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
	 	SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
	  	SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, 999);
	   	SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, 999);
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, 998);
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN, 300);
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 998);
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, 998);
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, 998);
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, 999);
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_SNIPERRIFLE, 1);
	}
	else if(PlayerInfo[playerid][pFac] == 0)
	{
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
	 	SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
	  	SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, 800);
	   	SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, 999);
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, 1);
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN, 1);
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1);
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, 999);
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, 998);
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, 998);
	    SetPlayerSkillLevel(playerid, WEAPONSKILL_SNIPERRIFLE, 1);
	}
	if(PlayerStat[playerid][pDying] == 1)
	{
	    new deathstring[128];
        SetPlayerPos(playerid,PlayerStat[playerid][DeathPosX], PlayerStat[playerid][DeathPosY], PlayerStat[playerid][DeathPosZ]);
        SetPlayerCameraPos(playerid,PlayerStat[playerid][DeathPosX], PlayerStat[playerid][DeathPosY], PlayerStat[playerid][DeathPosZ]+5);
        SetPlayerCameraLookAt(playerid,PlayerStat[playerid][DeathPosX], PlayerStat[playerid][DeathPosY], PlayerStat[playerid][DeathPosZ]);
        SetPlayerHealth(playerid, 20.0);
        SetPlayerArmour(playerid, 0.0);
        TogglePlayerControllable(playerid, 0);
        ApplyAnimation(playerid, "SWAT", "gnstwall_injurd", 4.1, 0, 1, 1, 1, 0, 1);
        ApplyAnimation(playerid, "SWAT", "gnstwall_injurd", 4.1, 0, 1, 1, 1, 0, 1);
        SendClientMessage(playerid, COLOR_LIGHTRED, "You have been critically injured.");
        SendClientMessage(playerid, COLOR_LIGHTRED, "No doctors available? you may use /acceptdeath.");
		format(deathstring, sizeof(deathstring), "%s has been critically injured and fell onto the ground on his back.", RPN(playerid));
		SendNearbyMessage(playerid, 10, deathstring, COLOR_DARKRED, COLOR_DARKRED, COLOR_DARKRED, COLOR_DARKRED, COLOR_DARKRED);
    }
    else if(PlayerStat[playerid][pDying] == 2)
    {
        PlayerInfo[playerid][pDying] = 0;
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pMoney] > 800)
	        {
	            if(PlayerInfo[playerid][pPrison] == 0)
	            {
	    			Hospital[playerid] = random(2);
					if(Hospital[playerid] == 0) // AllSaints
					{

					    SetPlayerPos(playerid, 1177.5485,-1323.5773,11.0761);
					    SetPlayerCameraPos(playerid,1223.2250,-1289.4913,31.9257);
					    SetPlayerCameraLookAt(playerid,1177.5485,-1323.5773,14.0761);
					    TogglePlayerControllable(playerid, 0);
					}
					else if(Hospital[playerid] == 1) // County General
					{
					    SetPlayerPos(playerid, 2034.0833,-1404.6536,14.2539);
					    SetPlayerCameraPos(playerid,1997.1254,-1457.8685,34.8850);
					    SetPlayerCameraLookAt(playerid,2034.0833,-1404.6536,17.2539);
					    TogglePlayerControllable(playerid, 0);
					}
					ResetDodWeapons(playerid);
					PlayerInfo[playerid][pFacDuty] = 0;
					SetPlayerInterior(playerid, 0);
				 	SetPlayerVirtualWorld(playerid, 0);
				    TogglePlayerControllable(playerid, 0);
					HospitalTime[playerid] = 60;
					PlayerInfo[playerid][pDead] = 0;
					if(PlayerInfo[playerid][pDonator] >= 2) HospitalTime[playerid] = 1;
					HospitalCountDown[playerid] = SetTimerEx("HospitalTimer", 1000, false, "d", playerid);
					if(DayNoDrops == 1)
					{
			  			for (new i = 0; i < 13; i++)
						{
						    GiveDodWeapon(playerid, DNDW[1][0], 7);
							GiveDodWeapon(playerid, DNDW[2][0], 7);
							GiveDodWeapon(playerid, DNDW[3][0], 7);
							GiveDodWeapon(playerid, DNDW[4][0], 7);
							GiveDodWeapon(playerid, DNDW[5][0], 7);
							GiveDodWeapon(playerid, DNDW[6][0], 7);
							GiveDodWeapon(playerid, DNDW[7][0], 7);
							GiveDodWeapon(playerid, DNDW[8][0], 7);
							GiveDodWeapon(playerid, DNDW[9][0], 7);
							GiveDodWeapon(playerid, DNDW[10][0], 7);
							GiveDodWeapon(playerid, DNDW[11][0], 7);
							GiveDodWeapon(playerid, DNDW[12][0], 7);
						}
					}
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to go to the hospital. A Debt has began!");
				if(PlayerInfo[playerid][pLoggedIn] == 1)
				{
					Hospital[playerid] = random(2);
					if(Hospital[playerid] == 0) // AllSaints
					{

					    SetPlayerPos(playerid, 1177.5485,-1323.5773,11.0761);
					    SetPlayerCameraPos(playerid,1223.2250,-1289.4913,31.9257);
					    SetPlayerCameraLookAt(playerid,1177.5485,-1323.5773,14.0761);
					    TogglePlayerControllable(playerid, 0);
					}
					else if(Hospital[playerid] == 1) // County General
					{
					    SetPlayerPos(playerid, 2034.0833,-1404.6536,14.2539);
					    SetPlayerCameraPos(playerid,1997.1254,-1457.8685,34.8850);
					    SetPlayerCameraLookAt(playerid,2034.0833,-1404.6536,17.2539);
					    TogglePlayerControllable(playerid, 0);
					}
					ResetDodWeapons(playerid);
					PlayerInfo[playerid][pFacDuty] = 0;
					SetPlayerInterior(playerid, 0);
				 	SetPlayerVirtualWorld(playerid, 0);
				    TogglePlayerControllable(playerid, 0);
					HospitalTime[playerid] = 30;
					PlayerInfo[playerid][pDead] = 0;
					if(PlayerInfo[playerid][pDonator] >= 2) HospitalTime[playerid] = 1;
					HospitalCountDown[playerid] = SetTimerEx("HospitalTimer", 1000, false, "d", playerid);
					if(DayNoDrops == 1)
					{
			  			for (new i = 0; i < 13; i++)
						{
						    GiveDodWeapon(playerid, DNDW[1][0], 7);
							GiveDodWeapon(playerid, DNDW[2][0], 7);
							GiveDodWeapon(playerid, DNDW[3][0], 7);
							GiveDodWeapon(playerid, DNDW[4][0], 7);
							GiveDodWeapon(playerid, DNDW[5][0], 7);
							GiveDodWeapon(playerid, DNDW[6][0], 7);
							GiveDodWeapon(playerid, DNDW[7][0], 7);
							GiveDodWeapon(playerid, DNDW[8][0], 7);
							GiveDodWeapon(playerid, DNDW[9][0], 7);
							GiveDodWeapon(playerid, DNDW[10][0], 7);
							GiveDodWeapon(playerid, DNDW[11][0], 7);
							GiveDodWeapon(playerid, DNDW[12][0], 7);
						}
					}
				}
			}
		}
	}
    StopAudioStreamForPlayer(playerid);
	// Actual Spawning
	if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
	{
	  new npcname[MAX_PLAYER_NAME];
	  GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
	  if(!strcmp(npcname, "GOD", true)) //Checking if the NPC's name is GOD
	  { //Putting the NPC into the vehicle we created for it.
	    return 1;
	  }
	  return 1;
	}
    if(PlayerInfo[playerid][pLoggedIn] && PlayerInfo[playerid][pSpawn])
    {
        FalseBan[playerid] = 0;
        SetTimerEx("FalseBanFix", 1000, false, "i", playerid);
		SpawnChar(playerid);
    }
    if(PlayerInfo[playerid][pDying] != 1 && PlayerInfo[playerid][pDying] != 2)
    {
		SetPlayerHealth(playerid, PlayerInfo[playerid][pSpawnHealth]);
	}
    if (!GetPVarInt(playerid, "color")) SetPVarInt(playerid, "color", 18643);
	return 1;
}
Under OnPlayerDeath
Код:
new Float: PosX, Float: PosY, Float: PosZ;
GetPlayerPos(playerid, PosX, PosY, PosZ);
PlayerStat[playerid][DeathPosX] = PosX;
PlayerStat[playerid][DeathPosY] = PosY;
PlayerStat[playerid][DeathPosZ] = PosZ;
SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVW]);
PlayerInfo[playerid][pDying] ++;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)