Placeholder problem
#1

pawn Код:
COMMAND:sethp(playerid, params[])
{
    new user, amount;
    if(sscanf(params, "ui", user, amount)) return SendClientMessage(playerid, 0x924161FF, "USAGE: /sethp <player id/name> <amount>");
    new string[180], name[MAX_PLAYER_NAME], Float:health;
    SetPlayerHealth(user, amount);
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "Your health has been set to %f from %s", health, name);
    SendClientMessage(user, 0x924161FF, string);
    return 1;
}

I can't get player's health at line:
pawn Код:
format(string, sizeof(string), "Your health has been set to %f from %s", health, name);
Can someone explain me how I can get this working, pls?
Reply
#2

pawn Код:
GetPlayerHealth(playerid, health);
under GetPlayerName. You've forget to get the player's health as a result the var value is 0.0.
Reply
#3

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
pawn Код:
GetPlayerHealth(playerid, health);
under GetPlayerName. You've forget to get the player's health as a result the var value is 0.0.
Well, when I set HP to player it puts incorrect numbers of health, I meant result does not match with HP. it shows 95.045454567444 when I use /sethp 0 1.
Reply
#4

It's because health are float's on gta sa and your setting the value as an integer. Use the Float: tag on amount and change the sscanf specifier to f.
Reply
#5

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
It's because health are float's on gta sa and your setting the value as an integer. Use the Float: tag on amount and change the sscanf specifier to f.
Everything works fine, thank you very much for this I hope I learned it :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)