Health set
#1

Hi samp i have a question with SetPlayerHealth
I need the player to lose 50hp with each sniper shot and yes i did use OnPlayerTakeDamage before the following code
//================================================== ========
if(issuerid != INVALID_PLAYER_ID && weaponid == 34)
{
new Float:health;
SetPlayerHealth(playerid,GetPlayerHealth(playerid, health-50));//wouldn't compile and even if it did it ouldn't work proparly
}

return 1;
}
//================================================== =====================
Thanks for reading!
Reply
#2

Syntax for GetPlayerHealth:
Код:
GetPlayerHealth(playerid, Float:&Health);
You need to save the parameter 'Health' to another variable like so.
pawn Код:
if(issuerid != INVALID_PLAYER_ID && weaponid == 34)
{
    new Float:health;
    GetPlayerHealth(playerid, health); //We're saving it to our new Float:health variable.
    SetPlayerHealth(playerid, (health - 50));
    return 1;
}
Reply
#3

Wouldn't work
Reply
#4

Try it now...
pawn Код:
if(issuerid != INVALID_PLAYER_ID)
{
    if(weaponid == 34)
    {    
        new Float:health;    
        GetPlayerHealth(playerid, health); //We're saving it to our new Float:health variable.    
        SetPlayerHealth(playerid, ((health + amount) - 50));
    }
    return 1;
}
Reply
#5

pawn Код:
if(issuerid != INVALID_PLAYER_ID)
{
    if(weaponid == 34)
    {    
        new Float:health;    
        GetPlayerHealth(playerid, health); //We're saving it to our new Float:health variable.    
        SetPlayerHealth(playerid, (health)-50);
    }
    return 1;
}
or replace
SetPlayerHealth(playerid, (health)-50);
with
SetPlayerHealth(playerid, -50);
Reply
#6

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
Try it now...
pawn Код:
if(issuerid != INVALID_PLAYER_ID)
{
    if(weaponid == 34)
    {    
        new Float:health;    
        GetPlayerHealth(playerid, health); //We're saving it to our new Float:health variable.    
        SetPlayerHealth(playerid, ((health + amount) - 50));
    }
    return 1;
}
Works!
Thanks again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)