setplayerhealth
#1

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

Try using 50.0 i.o. 50 at your first SetPlayerHealth
Reply
#3

Put it in onplayerspawn
Reply
#4

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

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

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

help please
Reply
#8

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??
Reply
#9

help, it isnt impossible...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)