Help with floats - 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 with floats (
/showthread.php?tid=635106)
Help with floats -
andrejc999 - 01.06.2017
Hi everybody.
So I made a VIP shop with dialogs and people can buy stuff with their Euros which they have on their account.
The problem is when I buy a VIP package it doesn't take amount of Euros from my account. It gives me like 10 million Euros more idk why...
Here is the code:
Код:
if(dialogid == DIALOG_VIPPAKET4)
{
if(response)
{
if(pInfo[playerid][pVip] == 4) return SCM(playerid, COLOR_RED, "Vec imate VIP 4!");
if(pInfo[playerid][pEuro] < 10) return SCM(playerid, COLOR_RED, "Nemate dovoljno Eura(Ђ)!
(10.00Ђ)");
pInfo[playerid][pEuro] -= 10; //This is the problem...
SCM(playerid, COLOR_GREEN, "CESTITAMO! Uspesno ste kupili VIP Paket Level 4!");
SCM(playerid, COLOR_GREEN, "Za pomoc oko VIP-a koristite: /viphelp!");
pInfo[playerid][pVip] = 4;
GivePlayerMoneyEx(playerid, 350000);
}
}
The float pInfo[playerid][pEuro] is beeing weird for some reason.
Can someone help me?
Thx in advanced
Re: Help with floats -
Whatname - 01.06.2017
Show the enum
Re: Help with floats -
Kane - 01.06.2017
Код:
GivePlayerMoneyEx(playerid, 350000);
This...?
Re: Help with floats -
andrejc999 - 01.06.2017
Код:
enum PlInfo
{
Float:pEuro,
};
new pInfo[MAX_PLAYERS][PlInfo];
There you go, I removed everything except the Euros float... You know, for unique reasons
EDIT: nah the problem is not with money, the float pEuro is not working well...
Re: Help with floats -
Kane - 01.06.2017
Money shouldn't be a float.
Re: Help with floats -
Whatname - 01.06.2017
The code seem to be fine hmm
Re: Help with floats -
andrejc999 - 01.06.2017
It's a float because you know there are CENTS in Euros? So something could be 1.50€?
Re: Help with floats -
andrejc999 - 01.06.2017
Guys I fixed it. Thx for helping out.
The problem was I should have put pInfo[playerid][pEuro] -= 10.00000 because welcome to the world of floats.
Re: Help with floats -
Whatname - 01.06.2017
-REMOVED-
Re: Help with floats -
andrejc999 - 01.06.2017
Yeah that works too, ty!