playertakedamage
#1

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
Reply
#2

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

Not set them to death, just give them less HP
Reply
#4

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

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.
Reply


Forum Jump:


Users browsing this thread: