SA-MP Forums Archive
setplayerhealth - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: setplayerhealth (/showthread.php?tid=138439)



setplayerhealth - Headshot1108 - 01.04.2010

i have a problem..
i like that a player get health, depends which rank he is.

this won't working:

pawn Code:
forward SpawnKillOver(playerid);
public SpawnKillOver(playerid)
{
    SpawnKillProtected[playerid] = 0;
    if(Rank[playerid] == 0)
    {
    SetPlayerHealth(playerid,50);
    }
    if(Rank[playerid] == 1)
    {
    SetPlayerHealth(playerid,52.5);
    }
    if(Rank[playerid] == 2)
    {
    SetPlayerHealth(playerid,55);
    }
    if(Rank[playerid] == 3)
    {
    SetPlayerHealth(playerid,55);
    SetPlayerArmour(playerid,5);
    }
    if(Rank[playerid] == 4)
    {
    SetPlayerHealth(playerid,60);
    SetPlayerArmour(playerid,5);
    }
    if(Rank[playerid] == 5)
    {
    SetPlayerHealth(playerid,65);
    SetPlayerArmour(playerid,10);
    }
    if(Rank[playerid] == 6)
    {
    SetPlayerHealth(playerid,70);
    SetPlayerArmour(playerid,10);
    }
    new Float:Health;
    new Float:Armour;
    if(ClassSet[playerid] == 1)
    {
    GetPlayerHealth(playerid,Health);
    SetPlayerHealth(playerid,Health + 10);
    GetPlayerArmour(playerid,Armour);
    SetPlayerArmour(playerid,Armour + 10);
    }
    SendClientMessage(playerid,_COLOR_GREEN,"You are not Spawnkill Protected anymore.");
    if(ClassSet[playerid] == 2)
    {
    GetPlayerHealth(playerid,Health);
    SetPlayerHealth(playerid,Health + 20);
    }
    if(ClassSet[playerid] == 3)
    {
    GetPlayerArmour(playerid,Armour);
    SetPlayerArmour(playerid,Armour + 20);
    }
    if(ClassSet[playerid] == 4)
    {
    GetPlayerHealth(playerid,Health);
    SetPlayerHealth(playerid,Health + 5);
    GetPlayerArmour(playerid,Armour);
    SetPlayerArmour(playerid,Armour + 15);
    }
    return 1;
}
it comes a strange amount of health, and not the health what i wrote.
example, if i are rank 0 and i have the first class, i must get 60 health and 10 armour, but i comes 137 health and 10 armour lol


Re: setplayerhealth - Ragidon - 01.04.2010

Try using 50.0 i.o. 50 at your first SetPlayerHealth


Re: setplayerhealth - 02manchestera - 01.04.2010

Put it in onplayerspawn


Re: setplayerhealth - Headshot1108 - 01.04.2010

Quote:
Originally Posted by Ragidon
Try using 50.0 i.o. 50 at your first SetPlayerHealth
now it comes Health: 72 and Armour: 10. A other time came 117 Health and Armour: 10..
i think armour is working, but health is like random lol.

and in onplayerspawn is impossible to do, its a timer because of Spawnkill Protecting.


Re: setplayerhealth - 02manchestera - 01.04.2010

did you try what the over scripter said doing 50.0 and 60.0 and so on.


Re: setplayerhealth - Headshot1108 - 01.04.2010

Quote:
Originally Posted by MR Loose Brackets
did you try what the over scripter said doing 50.0 and 60.0 and so on.
yes..


Re: setplayerhealth - Headshot1108 - 01.04.2010

help please


Re: setplayerhealth - Headshot1108 - 02.04.2010

why it works if i put a timer??
this code works:

pawn Code:
forward SpawnKillOver(playerid);
public SpawnKillOver(playerid)
{
    if(Rank[playerid] == 0)
    {
    SetPlayerHealth(playerid,50.0);
    }
    if(Rank[playerid] == 1)
    {
    SetPlayerHealth(playerid,52.5);
    }
    if(Rank[playerid] == 2)
    {
    SetPlayerHealth(playerid,55.0);
    }
    if(Rank[playerid] == 3)
    {
    SetPlayerHealth(playerid,55.0);
    SetPlayerArmour(playerid,5.0);
    }
    if(Rank[playerid] == 4)
    {
    SetPlayerHealth(playerid,60.0);
    SetPlayerArmour(playerid,5.0);
    }
    if(Rank[playerid] == 5)
    {
    SetPlayerHealth(playerid,65.0);
    SetPlayerArmour(playerid,10.0);
    }
    if(Rank[playerid] == 6)
    {
    SetPlayerHealth(playerid,70.0);
    SetPlayerArmour(playerid,10.0);
    }
    SendLangMessage(playerid,_COLOR_GREEN,"You are not Spawnkill Protected anymore.");
    SpawnKillProtect[playerid] = 0;
    SetTimerEx("ClassHealth",500,false,"d",playerid);
    return 1;
}

forward ClassHealth(playerid);
public ClassHealth(playerid)
{
    new Float:Health;
    new Float:Armour;
    if(ClassSet[playerid] == 1)
    {
    GetPlayerHealth(playerid,Health);
    SetPlayerHealth(playerid,Health + 10.0);
    GetPlayerArmour(playerid,Armour);
    SetPlayerArmour(playerid,Armour + 10.0);
    }
    if(ClassSet[playerid] == 2)
    {
    GetPlayerHealth(playerid,Health);
    SetPlayerHealth(playerid,Health + 20.0);
    }
    if(ClassSet[playerid] == 3)
    {
    GetPlayerArmour(playerid,Armour);
    SetPlayerArmour(playerid,Armour + 20.0);
    }
    if(ClassSet[playerid] == 4)
    {
    GetPlayerHealth(playerid,Health);
    SetPlayerHealth(playerid,Health + 5.0);
    GetPlayerArmour(playerid,Armour);
    SetPlayerArmour(playerid,Armour + 15.0);
    }
}
but i like to do all in one public, why it won't work??


Re: setplayerhealth - Headshot1108 - 02.04.2010

help, it isnt impossible...