SA-MP Forums Archive
Quick question about float - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Quick question about float (/showthread.php?tid=203955)



Quick question about float - blackwave - 28.12.2010

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.


Re: Quick question about float - _rAped - 28.12.2010

Why would you want to do that?

Anyways take a look at floatround()


Re: Quick question about float - blackwave - 28.12.2010

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.


Re: Quick question about float - Mauzen - 28.12.2010

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


Re: Quick question about float - _rAped - 28.12.2010

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!


Re: Quick question about float - blackwave - 28.12.2010

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