SA-MP Forums Archive
Health+Armour saving as 1. - 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: Health+Armour saving as 1. (/showthread.php?tid=570723)



Health+Armour saving as 1. - BleverCastard - 12.04.2015

I have(in the database and ingame) set them to floats, though when a player leaves, it says it as 1 rather than 100. When I save the account:
pawn Код:
UPDATE `accounts` SET `Health` = %f, `Armour` = %f
pawn Код:
Float: Health,
    Float: Armour,
So they are floats.


Re: Health+Armour saving as 1. - d3ll - 12.04.2015

Can you show where it loads from the database?


Re : Health+Armour saving as 1. - Golimad - 12.04.2015

Check the Armor / Health Row length in the database


Re: Re : Health+Armour saving as 1. - BleverCastard - 12.04.2015

Quote:
Originally Posted by d3ll
Посмотреть сообщение
Can you show where it loads from the database?
Sure.
pawn Код:
PlayerInfo[playerid][Health] = cache_get_row_float(0, 3, MySQLConnection);
    PlayerInfo[playerid][Armour] = cache_get_row_float(0, 4, MySQLConnection);
Quote:
Originally Posted by Golimad
Посмотреть сообщение
Check the Armor / Health Row length in the database
They're set to 5.


Re: Health+Armour saving as 1. - Emmet_ - 12.04.2015

Make sure you are saving it like this:

pawn Код:
GetPlayerHealth(playerid, PlayerInfo[playerid][Health]);
GetPlayerArmour(playerid, PlayerInfo[playerid][Armour]);
GetPlayerHealth and GetPlayerArmour return 1 if the player is connected and the function has ran successfully. It doesn't return the health or armor directly, you have to pass it by reference.


Re: Health+Armour saving as 1. - BleverCastard - 12.04.2015

Yeah, thanks. Seems to have sorted it. Sadly, the anticheat keeps saying I'm hacking, I don't know if it's due to the fact that it's like 100.000000. What's the best way to round it down to just 100? or 56? Rather than having .000 after it?


Re: Health+Armour saving as 1. - d3ll - 12.04.2015

pawn Код:
mysql_format(MySQL, query, sizeof(query), "UPDATE `accounts` SET `Health' = '%0.0f', `Armour` = '%0.0f' WHERE `PlayerName` = '%s'");
Changes:

100.0000000 > 100


Re: Health+Armour saving as 1. - BleverCastard - 12.04.2015

Oh, you do learn something new every day. Thanks!

And I love you too<3

EDIT:

For some reason, it still detects it as hacking. Here's the code.
pawn Код:
if(PlayerInfo[playerid][Cash] != GetPlayerMoney(playerid))
        {
            format(GlobalString, sizeof(GlobalString), "%s "COL_WHITE"could potentially be Money hacking.(/check)", GetUsername(playerid));
            SendMessageToAdmins(COLOR_REALRED, GlobalString);
        }
        if(PlayerInfo[playerid][Health] != GetPlayerHealth(playerid, h))
        {
            format(GlobalString, sizeof(GlobalString), "%s "COL_WHITE"could potentially be Health hacking.(/check)", GetUsername(playerid));
            SendMessageToAdmins(COLOR_REALRED, GlobalString);
        }
        if(PlayerInfo[playerid][Armour] != GetPlayerArmour(playerid, a))
        {
            format(GlobalString, sizeof(GlobalString), "%s "COL_WHITE"could potentially be Armour hacking.(/check)", GetUsername(playerid));
            SendMessageToAdmins(COLOR_REALRED, GlobalString);
        }



Re: Health+Armour saving as 1. - Awdratai - 12.04.2015

Use floatround function, show your lines with saving health and armor and I'll help you to change it.


Re: Health+Armour saving as 1. - BleverCastard - 12.04.2015

pawn Код:
floatround(PlayerInfo[playerid][Health]),floatround(PlayerInfo[playerid][Armour])
I've done it. But I'm still having issues with the anticheat. Keeps detecting it as a hack.