SA-MP Forums Archive
playertakedamage - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: playertakedamage (/showthread.php?tid=550394)



playertakedamage - Shazwan - 12.12.2014

I don't why it doesn't? anyone can check it?

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
    {
        Fitness(playerid);
	}
    if(issuerid != INVALID_PLAYER_ID && weaponid == 0 && bodypart == 3)
    {
        Bullet(playerid);
	}
    return 1;
}
Код:
forward Bullet(playerid);
public Bullet(playerid)
{
    if(PlayerInfo[playerid][pBullet] >= 1)
	{
	    SetPlayerHealth(playerid, 0.0);
        PlayerInfo[playerid][pBullet] -= 1;
	}
    return 1;
}

forward Fitness(playerid);
public Fitness(playerid)
{
    if(PlayerInfo[playerid][pFitness] >= 5000)
	{
        new Float:HP;
		GetPlayerHealth(playerid,HP);
        SetPlayerHealth(playerid,HP-50);
	}
    else if(PlayerInfo[playerid][pFitness] >= 2500)
	{
        new Float:HP;
		GetPlayerHealth(playerid,HP);
        SetPlayerHealth(playerid,HP-35);
	}
    else if(PlayerInfo[playerid][pFitness] >= 1500)
	{
        new Float:HP;
		GetPlayerHealth(playerid,HP);
        SetPlayerHealth(playerid,HP-30);
	}
    else if(PlayerInfo[playerid][pFitness] >= 1000)
	{
        new Float:HP;
		GetPlayerHealth(playerid,HP);
        SetPlayerHealth(playerid,HP-25);
	}
    else if(PlayerInfo[playerid][pFitness] >= 700)
	{
        new Float:HP;
		GetPlayerHealth(playerid,HP);
        SetPlayerHealth(playerid,HP-20);
	}
    else if(PlayerInfo[playerid][pFitness] >= 500)
	{
        new Float:HP;
		GetPlayerHealth(playerid,HP);
        SetPlayerHealth(playerid,HP-15);
	}
    else if(PlayerInfo[playerid][pFitness] >= 300)
	{
        new Float:HP;
		GetPlayerHealth(playerid,HP);
        SetPlayerHealth(playerid,HP-10);
	}
    else if(PlayerInfo[playerid][pFitness] >= 100)
	{
        new Float:HP;
		GetPlayerHealth(playerid,HP);
        SetPlayerHealth(playerid,HP-5);
	}
    return 1;
}
please help


Re: playertakedamage - Pottus - 12.12.2014

You can't set health lower in OnPlayerTakeDamage() than the damage received it will still kill the player.


Re: playertakedamage - Shazwan - 12.12.2014

Not set them to death, just give them less HP


Re: playertakedamage - Shazwan - 12.12.2014

any one can try give me example? i have been stress out doing this thing since morning


Re: playertakedamage - SkyCloud - 12.12.2014

It will still take the normal damage you used to get even if you did that. So if you're planning to make headshot script or anything, i suggest you should make serverside health. and maybe serverside healthbar like i did in my gamemode. This way, the damage can be more accurate. It's really easy though.