SA-MP Forums Archive
What is the difference (About 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: What is the difference (About floats) (/showthread.php?tid=297431)



What is the difference (About floats) - DayaKisteme - 15.11.2011

Код:
new 
      Float:Pos1, 
      Float:Pos2, 
      Float:Pos3
;
and

Код:
new 
     Float:Pos[2]
;
I have three questions.

1) What is the difference ?

2) Can i use both at the same ?

3) Whichever is faster and better..etc


Re: What is the difference (About floats) - IceCube! - 15.11.2011

1) What is the difference ? Floats store decimals for exact amounts such as Health. Not sure what else they do. Although they are required to get EXACT locations and EXACT Health etc

2) Can i use both at the same ? Yes for example
pawn Код:
SetPlayerPos(playerid, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
3) Whichever is faster and better..etc . YOu mean?


Re: What is the difference (About floats) - DayaKisteme - 15.11.2011

I know them. Both are doing the same but must be a difference.


Re: What is the difference (About floats) - IceCube! - 15.11.2011

Yeah one of them takes the players X axis co-ords like a x axis on a globe a map or a graph

And One takes the Y axis Straight up and down - FOr samp Ahead and behnd

Z is Height and works the same way


Re: What is the difference (About floats) - DayaKisteme - 15.11.2011

Sorry my bad English

I think you don't understand me.

I say what is the difference...

new Float:Pos[2]; and new Float:Pos1, Float:Pos2, Float:Pos3;


Re: What is the difference (About floats) - Vince - 15.11.2011

One is an array and the others aren't. They behave exactly the same. Arrays are just more convenient for large groups of data.


Re: What is the difference (About floats) - Chrillzen - 15.11.2011

It's better to do Float:Pos[999999999999999] than doing 999999999999999 Float:Pos1, pos2, pos3 etc...


Re: What is the difference (About floats) - SuperViper - 16.11.2011

When using arrays such as

pawn Код:
new Float:Pos[3];
You are able to insert a variable into the [ ] as it is counted as a parameter of the variable, allowing you to loop through everything.

pawn Код:
new Float:Pos[3];

for(new i = 0; i < sizeof(Pos); i++) {
    printf("pos is currently set to %d", i);
}
You would use a size of 3 because it starts from zero. To have X, Y, Z and rotation, you would need a size of 4.