Jump to content
  • 0

pomoc Problém s floatstr


MatoC9

Dotaz

Mám menší problém s funkciou floatstr

 

Kód:

new File:file_money = fopen(txtfile_money, io_read), money[20], Float:fmoney;
fread(file_money,money);
fclose(file_money);
fmoney=floatstr(money);

 

v súbore z ktorého berie tú premennú je hodnota "10000"

no keď si dám vypísať fmoney tak mi vypíše že fmoney=11561564791 (+-)

v compileri nevypíše chybu len potom keď spustím hru tak vypíše toto

 

//keď si dám vypísať premennú money tak mi vypíše "10000" ale tá premenná je string a nie float takže ju potom nemôžem použiť

Link to comment
Share on other sites

8 odpovědí na tuto otázku

Recommended Posts

  • 0

dával som %d :d

ale tak keď som dal %f vypísalo 10000.00000

 

//pri použití funkcie:

GivePlayerMoney(playerid, fmoney);

mi dalo zase tých 11561564791, a chybu:

C:\Users\Mato\Desktop\SAMP Server\gamemodes\mode.pwn(361) : warning 213: tag mismatch
Link to comment
Share on other sites

  • 0

Pri floatround mi to vypísalo chybu

fmoney=floatround(money);

C:\Users\Mato\Desktop\SAMP Server\gamemodes\mode.pwn(357) : error 035: argument type mismatch (argument 1)

 

asi preto že money je string a nie číslo

Link to comment
Share on other sites

  • 0

Dám ti př:

new str[128] = "11.010010";
new Float:xd = floatstr(str);
new x = floatround(xd);
printf("%d",x);

 

a printne ti to číslo 11.

 

Zkus to tak udělat na to co potřebuješ ty

Link to comment
Share on other sites

  • 0
new File:file_money = fopen(txtfile_money, io_read), money[20], kes;

fread(file_money,money);

fclose(file_money);

kes=strval(money);

GivePlayerMoney(playerid, kes);

 

strval - prevedie string na integer :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...