Quick question about float
#1

Well, I made a command, which gets player pos, interior and virtual world. With the command /save (server sided), the pos is wrote on a file called "savedpositions.txt".

My command:
pawn Код:
if(strcmp("/get",cmdtext,true,10) == 0)
    {
       new Float:x,Float:y,Float:z;
       new string[128],nome[MAX_PLAYER_NAME];
       GetPlayerName(playerid,nome,sizeof(nome));
       format(file,sizeof(file),SERVER_USER_FILE,nome);
       GetPlayerPos(playerid, x,y,z);
       format(string,sizeof(string),"your position x: %f | y: %f | z: %f | Interior: %d | Virtual world: %d | Spawnou: %d",x,y,z,GetPlayerInterior(playerid),GetPlayerVirtualWorld(playerid),dini_Int(file,"Spawnou"));
       SendClientMessage(playerid, 0x33CCFFAA, string);
       PlayerPlaySound(playerid, 1139, 0.0,0.0,0.0);
       return 1;
       
    }
But I just could see that these positions are shown on float. On the file "savepositions", the positions are shown like this:

Код:
2036.3229,1283.8787,10.8203
But I can teleport to them with my command /lgoto simply using that:
Код:
/lgoto 2036.32,1283.87,10.82
instead
Код:
/lgoto 2036.3229,1283.8787,10.8203
So how do I save:
2036.32,1283.87,10.82
instead
2036.3229,1283.8787,10.8203

Sorry if I typed too much e_e. Thx.
Reply
#2

Why would you want to do that?

Anyways take a look at floatround()
Reply
#3

Well, you can see why.

It's pretty faster:
Код:
/lgoto 2036.32,1283.87,10.82
instead:
Код:
/lgoto 2036.3229,1283.8787,10.8203
Also for saving position easier.
Reply
#4

You can limit the number of decimals that are printed in format with:
%.2f (prints 2 decimals)
%.nf (prints n decimals)
Reply
#5

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
You can limit the number of decimals that are printed in format with:
%.2f (prints 2 decimals)
%.nf (prints n decimals)
Oh lolz. I just understood what he wanted when you posted that. Haha!
Reply
#6

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
You can limit the number of decimals that are printed in format with:
%.2f (prints 2 decimals)
%.nf (prints n decimals)
Thanks :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)