OnPlayerDeath
#1

i've tried multipe times to fix this problem it's pissed me off!!!
sometimes it works good and sometimes no, when you shot someone or he's died by the server or a fire or anything they spawn in blueberry with 0HP and killed multipe times :@

i don't know what's wrong i had backup working good, and still it doesn't work.

Here's OnPlayerDeath

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(IsPlayerConnected(killerid))
	{
		format(QFA[playerid],24,"%s",PlayerName(killerid));
	}
	PlayerInfo[playerid][pHealth] = 0.0;
	PlayerDrunk[playerid] = 0;
	gPlayerSpawned[playerid] = 0;
	PlayerDrunkTime[playerid] = 0;
	UsingDrugs[playerid] = 0;
	DeletePVar(playerid, "UsingSprunk");

	if(CarryBody[playerid] > 0)
	   StopCarry(playerid);

	if(PlayerInfo[playerid][pDeath] == 1)
       PlayerInfo[playerid][pDeath] = 2;

	if(PlayerInfo[playerid][pDeath] == 0)
       PlayerDeath(playerid,reason,PlayerName(killerid));

	foreach(Player, i)
	{
		if(EMSAccepted[i] < 999)
		{
			if(EMSAccepted[i] == playerid)
			{
				EMSAccepted[i] = 999;
				GameTextForPlayer(i, "~w~Patient~n~~r~is died", 5000, 1);
				EMSCallTime[i] = 0;
				DisablePlayerCheckpoint(i);
			}
		}
	}
	if(GetPVarInt(playerid, "Injured") == 1)
	{
		foreach(new i: Player)
		{
			if(EMSAccepted[i] == playerid)
			{
				EMSAccepted[i] = INVALID_PLAYER_ID;
				GameTextForPlayer(i, "~w~EMS Caller~n~~r~Has Died", 5000, 1);
				EMSCallTime[i] = 0;
				DisablePlayerCheckpoint(i);
			}
		}
		ProcessDeath(playerid);
	    KillEMSQueue(playerid);
	    ResetPlayerWeaponsEx(playerid);
	    return 1;
	}
	if(PlayerDraggedBy[playerid] != INVALID_PLAYER_ID)
	{
		IsCopDragging[PlayerDraggedBy[playerid]] = INVALID_PLAYER_ID;
	}
	IsCopDragging[playerid] = INVALID_PLAYER_ID;
	PlayerDraggedBy[playerid] = INVALID_PLAYER_ID;
	PlayerDragged[playerid] = 0;
	for(new x;x<MAX_PLAYERTOYS;x++) RemovePlayerAttachedObject(playerid, x);

	new caller = Mobile[playerid];
	if(caller != INVALID_PLAYER_ID)
	{
		if(caller < INVALID_PLAYER_ID)
		{
			SendInfoMessage(caller, 0, "25", "The line has been lost..");
			SendInfoMessage(playerid, 0, "25", "The line has been lost.");
			CellTime[caller] = 0;
			CellTime[playerid] = 0;
			Mobile[caller] = INVALID_PLAYER_ID;
		}
		Mobile[playerid] = INVALID_PLAYER_ID;
		CellTime[playerid] = 0;
	}

	if(gPlayerUsingLoopingAnim[playerid] == 1)
	{
		gPlayerUsingLoopingAnim[playerid] = 0;
		JugadorSentado[playerid] = 0;
		TextDrawHideForPlayer(playerid, AnimacionText);
	}
	if(DrugTimer[playerid]) KillTimer(DrugTimer[playerid]);
	return 1;
}
And here's the function of
Код:
Function  KillEMSQueue(playerid)
{
DeletePVar(playerid, "Injured");
SetPVarInt(playerid, "FirstSpawn", 1);
DeletePVar(playerid, "EMSAttempt");
DeletePVar(playerid, "MedicCall");
return 1;
}
Код:
Function SendEMSQueue(playerid,type)
{
	switch(type)
	{
		case 1:
		{
			Streamer_UpdateEx(playerid, GetPVarFloat(playerid,"MedicX"), GetPVarFloat(playerid,"MedicY"), GetPVarFloat(playerid,"MedicZ"));
			SetPlayerPos(playerid, GetPVarFloat(playerid,"MedicX"), GetPVarFloat(playerid,"MedicY"), GetPVarFloat(playerid,"MedicZ"));
			SetPlayerVirtualWorld(playerid, GetPVarInt(playerid,"MedicVW"));
			SetPlayerInterior(playerid, GetPVarInt(playerid,"MedicInt"));
			SetPVarInt(playerid, "EMSAttempt", -1);
			ClearAnimations(playerid);
			ApplyAnimation(playerid, "CRACK", "crckidle1",4.0,0,1,1,1,-1);
			if(GetPlayerInterior(playerid) > 0)
			{
				CargarObjetos(playerid);
			}
			GameTextForPlayer(playerid, "~w~Type ~r~/service~n~~w~or ~y~/accept death", 10000, 3);
			SetHP(playerid, 100);
			SetPlayerArmour(playerid,0);
			SetPVarInt(playerid,"MedicCall",1);
		}
		case 2:
		{
			SetPVarInt(playerid,"EMSAttempt", 2);
			ApplyAnimation(playerid, "SWAT", "gnstwall_injurd", 4.0, 0, 1, 1, 1, 0, 1);
			SetHP(playerid, 100);
			SetPlayerArmour(playerid,0);
		}
	}
	return 1;
}
And here SetPlayerSpawn
Код:
SetPlayerSpawn(playerid)
{
	if(IsPlayerConnectedEx(playerid))
	{
		SetPlayerSkin(playerid, PlayerInfo[playerid][jRopa]);
		new Float: x, Float: y, Float: z;
		GetPlayerPos(playerid, x, y, z);
		if(x == 0.0 && y == 0.0 && z == 0.0)
		{
			if(PlayerInfo[playerid][jOrigen] == 2)
			{
				SetPlayerPos(playerid, 1449.5273,-2286.9753,13.5469);
				SetPlayerFacingAngle(playerid, 94.1927);
			}
			else if(PlayerInfo[playerid][jOrigen] == 1)
			{
				SetPlayerPos(playerid, -1968.9153,137.7357,27.6875);
				SetPlayerFacingAngle(playerid, 88.9782);
			}
			SetPlayerInterior(playerid,0);
			SetCameraBehindPlayer(playerid);
		}
		if(PlayerInfo[playerid][jRegistrado] == 0)
		{
			gOoc[playerid] = 1; gNews[playerid] = 1; gFam[playerid] = 1;
			TogglePlayerControllable(playerid, 0);
			Registrar(playerid);
			return 1;
		}
		new rand;
		switch(PlayerInfo[playerid][jJaileado])
		{
			case 1:
			{
				PhoneOnline[playerid] = 1;
				rand = random(sizeof(OOCJail));
				CargarObjetos(playerid);
				SetPlayerPos(playerid, OOCJail[rand][0], OOCJail[rand][1], OOCJail[rand][2]);
				SetPlayerVirtualWorld(playerid, 0);
				SetPlayerInterior(playerid, 0);
				Skin(playerid, 50);
				SendInfoMessage(playerid, 2, "0", "You are in a prison, we need to finish out your sentence.");
				return 1;
			}
			case 3:
			{
				SetPosEx(playerid, 263.4922,77.0915,1001.0391,322.1463,6,0);
				SendInfoMessage(playerid, 2, "0", "You had an accident in prison, you're in the last cell.");
				return 1;
			}
			case 4:
			{
				PhoneOnline[playerid] = 1;
				PlayerInfo[playerid][jInterior] = 0;
				rand = random(sizeof(OOCJail));
				CargarObjetos(playerid);
				SetPlayerPos(playerid, OOCJail[rand][0], OOCJail[rand][1], OOCJail[rand][2]);
				SetPlayerVirtualWorld(playerid, 0);
				SetPlayerInterior(playerid, 0);
				Skin(playerid, 50);
				SendInfoMessage(playerid, 2, "0", "An administrator has prisoned you when you were Disconnected, {FF1B31}Due carry on the forum or lack of RolePlay.");
				SendInfoMessage(playerid, 3, "0", "If you think it was a mistake seeking an administrator immediately.");
				return 1;
			}
			case 0: { }
		}
		if(GetPVarInt(playerid, "FirstSpawn") == 2)
		{
			SendEMSQueue(playerid,1);
			return 1;
		}
		if(GetPVarInt(playerid, "FirstSpawn") == 1 && GetPVarInt(playerid, "Hospital") != 0)
		{
			DeletePVar(playerid, "Hospital");

			if(PlayerInfo[playerid][jTipoSpawn] == 1)
			{
				SendInfoMessage(playerid, 2, "0", "All your illegal possessions were taken by hospital security.");
				SendClientMessage(playerid, COLOR_VIP, "VIP: You've respawned in home by 'GOLD VIP' Feature enabled.");
				for(new i = 0; i < sizeof(InfoCasa); i++)
				{
					if(PlayerInfo[playerid][jCasaKey] == i)
					{
						Streamer_UpdateEx(playerid, InfoCasa[i][cInteriorX],InfoCasa[i][cInteriorY],InfoCasa[i][cInteriorZ]);
						SetPlayerInterior(playerid,InfoCasa[i][cCInteriorWorld]);
						CargarObjetos(playerid);
						SetPlayerPos(playerid,InfoCasa[i][cInteriorX],InfoCasa[i][cInteriorY],InfoCasa[i][cInteriorZ]);
						GameTextForPlayer(playerid, "~w~Welcome to home", 5000, 1);
						PlayerInfo[playerid][jInterior] = InfoCasa[i][cCInteriorWorld];
						PlayerInfo[playerid][jVirtualWorld] = i+6000;
						SetPlayerVirtualWorld(playerid, i+6000);
					}
				}
				ResetPlayerWeaponsEx(playerid);
				return 1;
			}
			if(PlayerInfo[playerid][pWantedLevel] > 0)
			{
				PlayerInfo[playerid][jJaileado] = 3; PlayerInfo[playerid][jJailTiempo] = 15*60; GivePlayerCash(playerid, -1000);
				SendClientMessage(playerid, COLOR_ROJO2, "You figure as a suspect in the center of the LSPD.");
				SendClientMessage(playerid, COLOR_ROJO2, "We find you and we put you in the hands of law enforcement.");
				SendClientMessage(playerid, COLOR_ROJO2, "As we find to hurt you, you are only condemned a few days. (15 minutes)");
				SetPlayerInterior(playerid, 6);
				PlayerInfo[playerid][jInterior] = 6;
				SetPosEx(playerid, 263.4922,77.0915,1001.0391,322.1463,6,0);
				if(PlayerInfo[playerid][pHungry] > 100) return 1;
				if(PlayerInfo[playerid][pHungry] < 101) { if(PlayerInfo[playerid][pHungry] > 100) return 1;}
				HungryCheck(playerid, PlayerInfo[playerid][pHungry]);
				StopAudioStreamForPlayer(playerid);
				ResetPlayerWeaponsEx(playerid);
				return 1;
			}
			else
			{
				if(PlayerInfo[playerid][jOrigen] == 1)
				{
					SetPlayerCameraPos(playerid, 2003.2898, -1476.5282, 52.5343);
					SetPlayerCameraLookAt(playerid, 2003.6920, -1475.6085, 51.8193);
					SetPosEx(playerid, 2032.0820,-1416.0764,16.9922,133.1913,0,0);
				}
				else if(PlayerInfo[playerid][jOrigen] == 2)
				{
					SetPlayerCameraPos(playerid, -2560.6887, 578.8904, 75.6639);
					SetPlayerCameraLookAt(playerid, -2561.5264, 579.4449, 75.1738);
					SetPosEx(playerid, -2656.0825,633.5092,14.4531,178.7625,0,0);
				}
				SendInfoMessage(playerid, 2, "0", "All your illegal possessions were taken by hospital security.");
				SetTimerEx("HospitalFun", 5000, false, "i", playerid); StopAudioStreamForPlayer(playerid);
				ResetPlayerWeaponsEx(playerid);
				return 1;
			}
		}
		if(GetPVarInt(playerid, "FirstSpawn") == 1 && GetPVarInt(playerid, "Hospital") == 0)
		{
			SetPlayerPos(playerid,PlayerInfo[playerid][jPosicion_X],PlayerInfo[playerid][jPosicion_Y],PlayerInfo[playerid][jPosicion_Z]);
			SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][jVirtualWorld]);
			SetPlayerFacingAngle(playerid, PlayerInfo[playerid][jPosicion_R]);
			SetPlayerInterior(playerid,PlayerInfo[playerid][jInterior]);
			SetHP(playerid, PlayerInfo[playerid][pHealth]);
			SetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
			SetCameraBehindPlayer(playerid);
			if(PlayerInfo[playerid][jInterior] > 0 || PlayerInfo[playerid][jVirtualWorld] > 0)
			{
				SendInfoMessage(playerid, 2, "0", "You disconnected in an interior, wait a moment loading objects.");
				CargarObjetos(playerid);
			}
			return 1;
		}
	}
	return 1;
}
Reply
#2

Forget everything i've said, now when you kill someone sometimes it works good and sometimes he get desynced
Reply
#3

bump
Reply


Forum Jump:


Users browsing this thread: