OnPlayerGiveDamage BUG
#1

If i kill a player with deagle he die and OnPlayerDeath is called (the message "you killed X" appear) but if i kill with m4 or mp5 message or something functions from OnPlayerDeath doesn't appear (sometimes yes, sometimes not). I think is from OnPlayerGiveDamage because this function call "OnPlayerDeath". Idk what's wrong, please helpp, i'll give +3 rep.

Код:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
{
	if(damagedid != INVALID_PLAYER_ID)
    {
	 	if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) return 1;
		if(GetPlayerSurfingVehicleID(playerid) != INVALID_VEHICLE_ID) return 1;
		if(amount < 0)
		{
			new string[128],sendername[25];
		    GetPlayerName(playerid,sendername,sizeof(sendername));
			format(string,sizeof(string),"[AdmInfo]: %s(%d) it is possible to use global kill, hp amount %.2f.(GIVE)",sendername,playerid,amount);
			ABroadCast(0xf03337FF,string,1);
			Kick(playerid);
			return 1;
		}
		if(playerdeath[damagedid] == 0)
		{
				if(weaponid == 34)
			    {
			        SetPlayerHealthEx(damagedid, 0.0);
			        SetPlayerArmourEx(damagedid, 0.0);
			        OnPlayerDeath(damagedid,playerid,weaponid);
					playerdeath[damagedid] = 1;
					return 1;
			    }
			 	new Float: HP, Float: AP ;
				GetPlayerHealthEx(damagedid,HP);
				GetPlayerArmourEx(damagedid,AP);
				if ( AP >= amount )
				{
					SetPlayerArmourEx ( damagedid, AP - amount );
				}
				else if ( AP <= 0 )
				{
					new const Float: remainHP = HP - amount;
					SetPlayerHealthEx ( damagedid, remainHP );
					if ( remainHP <= 0 )
					{
						OnPlayerDeath( damagedid, playerid, weaponid );
						playerdeath[damagedid] = 1;
						return 1;
					}
				}
				else
				{
					new const Float: remainHP = HP + ( AP - amount );
					SetPlayerArmourEx ( damagedid, 0.0 );
					SetPlayerHealthEx ( damagedid, remainHP );
					if ( remainHP <= 0 )
					{
						OnPlayerDeath( damagedid, playerid, weaponid );
						playerdeath[damagedid] = 1;
						return 1;
					}
				}
				if(PlayerCuffed[damagedid] == 1)
				{
					SetPlayerHealthEx(damagedid,100);
				}
				if(PlayerInfo[damagedid][pSleeping] == 1)
				{
					SetPlayerHealthEx(damagedid, 100);
				}
				new Float:xx1,Float:yy1,Float:zz1;
	            GetPlayerPos(playerid,xx1,yy1,zz1);
	            new factiuneid;
	            factiuneid = PlayerInfo[playerid][pMember];
	  		    if(IsPlayerInArea(playerid, 1440.428, -1741.078, 1622.964, -1595.012)) // lspd
		        {
	     		    if(IsACop(playerid) && PlayerInfo[damagedid][pWantedLevel] > 0)
				    {
					    return 1;
				    }
				    if(InWar[factiuneid] == 1)
				    {
				        return 1;
			        }
				    if(GoChase[playerid] != 999)
				    {
					    return 1;
				    }
				    else
				    {
				       TogglePlayerControllable(playerid, 0);
				       SCM(playerid, COLOR_LIGHTRED, "Ai primit freeze 3 secunde pentru ca ai atacat un jucator in Safe-Zone!");
				       SetTimerEx("freezetimer",3000, false, "i", playerid);
				    }
			    }
			    if(IsPlayerInArea(playerid, 371.8314, -2104.27, 455.4938, -1910.831)) // Fish
		        {
					  if(IsACop(playerid) && PlayerInfo[damagedid][pWantedLevel] > 0)
					  {
						return 1;
					  }
					  if(GoChase[playerid] != 999)
					  {
						return 1;
					  }
					  else
					  {
					    TogglePlayerControllable(playerid, 0);
					    SCM(playerid, COLOR_LIGHTRED, "Ai primit freeze 3 secunde pentru ca ai atacat un jucator in Safe-Zone!");
					    SetTimerEx("freezetimer",3000, false, "i", playerid);
					  }
			    }
			    if(IsPlayerInArea(playerid, -280.269, -420.4035, 81.74512, -163.4902)) // Camionagiu
		        {
			          if(IsACop(playerid) && PlayerInfo[damagedid][pWantedLevel] > 0)
					  {
						return 1;
					  }
					  if(GoChase[playerid] != 999)
					  {
					 	return 1;
					  }
				      else
					  {
					    TogglePlayerControllable(playerid, 0);
					    SCM(playerid, COLOR_LIGHTRED, "Ai primit freeze 3 secunde pentru ca ai atacat un jucator in Safe-Zone!");
					    SetTimerEx("freezetimer",3000, false, "i", playerid);
					  }
			    }
			    if(IsPlayerInArea(playerid, 622.8186, -1405.52, 828.1717, -1330.513)) // cnn
		        {
			          if(IsACop(playerid) && PlayerInfo[damagedid][pWantedLevel] > 0)
					  {
						return 1;
					  }
					  if(InWar[factiuneid] == 1)
					  {
					    return 1;
					  }
					  if(GoChase[playerid] != 999)
					  {
						return 1;
					  }
					  else
					  {
					    TogglePlayerControllable(playerid, 0);
					    SCM(playerid, COLOR_LIGHTRED, "Ai primit freeze 3 secunde pentru ca ai atacat un jucator in Safe-Zone!");
					    SetTimerEx("freezetimer",3000, false, "i", playerid);
					  }
			    }
			    if(IsPlayerInArea(playerid, 1695.218, -1966.099, 1824.515, -1606.855)) // spawn & DMV
		        {
			          if(IsACop(playerid) && PlayerInfo[damagedid][pWantedLevel] > 0)
					  {
						return 1;
					  }
					  if(InWar[factiuneid] == 1)
					  {
					    return 1;
					  }
					  if(GoChase[playerid] != 999)
					  {
						return 1;
					  }
					  else
					  {
					    TogglePlayerControllable(playerid, 0);
					    SCM(playerid, COLOR_LIGHTRED, "Ai primit freeze 3 secunde pentru ca ai atacat un jucator in Safe-Zone!");
					    SetTimerEx("freezetimer",3000, false, "i", playerid);
					  }
			    }
			    if(IsPlayerInArea(playerid, 1706.627, -1227.872, 1854.937, -1133.126)) // gsls
		        {
			          if(IsACop(playerid) && PlayerInfo[damagedid][pWantedLevel] > 0)
					  {
						return 1;
					  }
					  if(PlayerInfo[playerid][pWantedLevel] > 0)
					  {
					    return 1;
					  }
					  if(InWar[factiuneid] == 1)
					  {
					    return 1;
					  }
					  if(GoChase[playerid] != 999)
					  {
						return 1;
					  }
					  else
					  {
					    TogglePlayerControllable(playerid, 0);
					    SCM(playerid, COLOR_LIGHTRED, "Ai primit freeze 3 secunde pentru ca ai atacat un jucator in Safe-Zone!");
					    SetTimerEx("freezetimer",3000, false, "i", playerid);
					  }
			    }
			    if(IsPlayerInArea(playerid, 1390.991, -1058.119, 1569.725, -951.5297)) // banca
		        {
			          if(IsACop(playerid) && PlayerInfo[damagedid][pWantedLevel] > 0)
					  {
						return 1;
					  }
					  if(PlayerInfo[playerid][pWantedLevel] > 0)
					  {
					    return 1;
					  }
					  if(InWar[factiuneid] == 1)
					  {
					    return 1;
					  }
					  if(GoChase[playerid] != 999)
					  {
						return 1;
					  }
					  else
					  {
					    TogglePlayerControllable(playerid, 0);
					    SCM(playerid, COLOR_LIGHTRED, "Ai primit freeze 3 secunde pentru ca ai atacat un jucator in Safe-Zone!");
					    SetTimerEx("freezetimer",3000, false, "i", playerid);
				      }
			    }
			    if(IsPlayerInArea(playerid, -583.8938, -1553.157, -163.4902, -1249.533)) // banca
		        {
			          if(IsACop(playerid) && PlayerInfo[damagedid][pWantedLevel] > 0)
					  {
						return 1;
					  }
					  if(PlayerInfo[playerid][pWantedLevel] > 0)
					  {
					    return 1;
					  }
					  if(InWar[factiuneid] == 1)
					  {
					    return 1;
					  }
					  if(GoChase[playerid] != 999)
					  {
						return 1;
					  }
					  else
					  {
					    TogglePlayerControllable(playerid, 0);
					    SCM(playerid, COLOR_LIGHTRED, "Ai primit freeze 3 secunde pentru ca ai atacat un jucator in Safe-Zone!");
					    SetTimerEx("freezetimer",3000, false, "i", playerid);
				      }
			    }
			    if(tazer[playerid] == 1 && IsACop(playerid) && weaponid == 24)
			    {
					if(IsACop(damagedid)) return SendClientMessage(playerid, 0xFFB870FF, "Nu puteti utiliza tazer-ul pe politisti.");
					if(PlayerCuffed[damagedid] == 1) return SendClientMessage(playerid, 0xFFB870FF, "Acest jucator este deja electrocutat.");
					if(PlayerInfo[damagedid][pSleeping] == 1) return SendClientMessage(playerid, 0xFFB870FF, "Jucator electrocutat");
					if(GetDistanceBetweenPlayers(playerid,damagedid) < 15)
					{
						new string[126],sendername[25],giveplayer[25];
						GetPlayerName(playerid,sendername,sizeof(sendername));
						GetPlayerName(damagedid,giveplayer,sizeof(giveplayer));
						format(string, sizeof(string), "* Ai fost electrocutat de %s pentru 8 secunde.", sendername);
						SendClientMessage(damagedid, COLOR_LIGHTBLUE, string);
						format(string, sizeof(string), "* You tazed %s for 8 seconds.", giveplayer);
						SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
						format(string, sizeof(string), "* %s shoots with his tazer at %s, and tazed him.", sendername ,giveplayer);
						ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
						GameTextForPlayer(damagedid, "~r~~h~Tazed", 2500, 3);
						TogglePlayerControllable(damagedid, 0);
						PlayerCuffed[damagedid] = 1;
						PlayerCuffedTime[damagedid] = 8;
						SetPlayerHealthEx(damagedid,100);
					}
			    }
			}
	    }
		return 1;
}
Reply


Messages In This Thread
OnPlayerGiveDamage BUG - by Addons - 10.04.2016, 09:21

Forum Jump:


Users browsing this thread: 1 Guest(s)