SA-MP Forums Archive
Help! - 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)
+--- Thread: Help! (/showthread.php?tid=482999)



Help! - TheViking - 23.12.2013

Hello!

This command, works just fine:

Quote:


if(strcmp("/SetHealth", cmd, true) == 0)
{
new tmp1[256];
new tmp2[256];

tmp1 = strtok(cmdtext, idx);
tmp2 = strtok(cmdtext, idx);

new id = strval(tmp1);
new health = strval(tmp2);

new string[250];

SetPlayerHealth(id, health);

GetPlayerName(id, iName, sizeof(iName));

format(string, sizeof(string), "You've set %s (%d)'s Health to: %d.", iName, id, health);
SendClientMessage(playerid, 0x33AA33AA, string);

}
return 1;
}
Well, here's the thing:

You can set somebody's health to: 10, 25, 54, 61, 67, 73, 81, etc...
But what about: 10.5, 25.6, 54.4, 61.7, 73.2, 81.3, etc... ?

I need an option which is able to set Player's health/armour/etc... To a decimal number, for an example 23.3.

Is it even posible, and if You could post an example here, thank You!

- TheViking


Re: Help! - xVIP3Rx - 23.12.2013

Use Floatstr instead of strval in the health variable.. and make it a float..


Re: Help! - TheViking - 23.12.2013

Hmmm...

I'm still new to this, and it's a bit complicated for me.
Could You please post an example, I would be really appreciative, please. :/


Re: Help! - J4mmyHD - 23.12.2013

pawn Код:
if(strcmp("/SetHealth", cmd, true) == 0)
{
    new tmp1[256];
    new Float:tmp2[256];

    tmp1 = strtok(cmdtext, idx);
    tmp2 = strtok(cmdtext, idx);

    new id = strval(tmp1);
    new health = FloatStr(tmp2);

    new string[250];

    SetPlayerHealth(id, health);

    GetPlayerName(id, iName, sizeof(iName));

    format(string, sizeof(string), "You've set %s (%d)'s Health to: %d.", iName, id, health);
    SendClientMessage(playerid, 0x33AA33AA, string);
    return 1;
}
Try this..


Re: Help! - TheViking - 23.12.2013

Nope, doesn't work.


Re: Help! - J4mmyHD - 23.12.2013

Don't use strcmp it's awful, use ZCMD is a faster command processor.