Lag when shooting in a player.
#1

Hello sa-mp.com forum, i have a very big problem with my sa:mp server, when you shot a player their health will decrease after some time.
I have my damage system in gamemode, all players have same team. All my stuff is located at onplayergivedamage.

Here is the code.
Код:
forward SetPlayerHealthEx(playerid, Float:health);
public SetPlayerHealthEx(playerid, Float:health)
{
	SetPlayerHealth(playerid, health);
	s_HL[playerid] = health;
	return 1;
}

forward GetPlayerHealthEx(playerid, &Float:health);
public GetPlayerHealthEx(playerid, &Float:health)
{
	health = s_HL[playerid];
	return 1;
}

forward SetPlayerArmourEx(playerid, Float:armour);
public SetPlayerArmourEx(playerid, Float:armour)
{
	SetPlayerArmour(playerid, armour);
	s_AM[playerid] = armour;
	return 1;
}

forward GetPlayerArmourEx(playerid, &Float:armour);
public GetPlayerArmourEx(playerid, &Float:armour)
{
	armour = s_AM[playerid];
	return 1;
}


public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
	if(damagedid != INVALID_PLAYER_ID)
	{

	    if(weaponid == 34) amount = 300;
	    
	    if(PlayerInfo[playerid][pPaintBallG] > 0)
		{
		    PlayerPlaySound(playerid,17802,0.0,0.0,0.0);
		}
	    
        if(IsAMember(playerid) && IsAMember(damagedid))
        {
         	if((InWar[PlayerInfo[playerid][pMember]] == InWar[PlayerInfo[damagedid][pMember]]) && InWar[PlayerInfo[playerid][pMember]] > 0)
         	{
         	    PlayerPlaySound(playerid,17802,0.0,0.0,0.0);
			}
		}
		if(PlayerInfo[damagedid][pPaintBallG] > 0)
		{
		    if(paintrs[PlayerInfo[damagedid][pPaintBallG]] > 0)
		    {
		    	SetPlayerHealthEx(damagedid, 100.0);
			}
		}
		if(PlayerCuffed[damagedid] == 1)
		{
			SetPlayerHealthEx(damagedid,100);
		}
	
		if(tazer[playerid] == 1 && IsACop(playerid) && weaponid == 23)
		{
			if(IsACop(damagedid)) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFFF}You can't taze Cops/FBI/National Guard.");
			if(PlayerCuffed[damagedid] == 1) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFFF}ERROR: This player is already tazed.");
			if(PlayerInfo[damagedid][pSleeping] == 1) return SendClientMessage(playerid, COLOR_WHITE, "ERROR: You can't taze this player because he/she is on sleep.");
			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), "* You were Tazed by %s for 8 seconds.", 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;
				return 0;
			}
		}
	
	    /*Hit Calculates*/
	    
	    if(PlayerIsDead[damagedid] == false)
	    {
			new Float:armour; GetPlayerArmourEx(damagedid,armour);
			if(armour < 1)
			{
				new Float:health;
				GetPlayerHealthEx(damagedid, health);
				SetPlayerHealthEx(damagedid, health-amount);
				if(IsPlayerPaused2(damagedid) && (health-amount) < 1) OnPlayerDeath(damagedid, playerid, weaponid);
				lasthit[damagedid] = playerid;
				return 1;
			}
			if(armour > 0)
			{
			    if(armour < amount)
			    {
			        new Float:health; GetPlayerHealthEx(damagedid, health);
			        new Float:value = amount-armour;
					SetPlayerArmourEx(damagedid,0);
					SetPlayerHealthEx(damagedid,health-value);
					if(IsPlayerPaused2(damagedid) && (health-value) < 1) OnPlayerDeath(damagedid, playerid, weaponid);
					lasthit[damagedid] = playerid;
					return 1;
				}
				if(armour > amount)
			    {
					SetPlayerArmourEx(damagedid,armour-amount);
					lasthit[damagedid] = playerid;
					return 1;
				}
				return 1;
			}
		}
		return 1;
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)