Show The Gravity - 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: Show The Gravity (
/showthread.php?tid=101904)
Show The Gravity -
Marc_307 - 12.10.2009
Hey guys,
I've got a problem. I'm using a random gravity, changing after a certain time (I'm using a timer therefor).
The gravity change, then a message should be sended. e.g. "New Gravity: 0.002" -> "New Gravity: X.XXX"
My code always shows 0.00000000.
Here's my code:
pawn Код:
new RandomGravity=random(sizeof(GravityValues));
SetGravity(GravityValues[RandomGravity][0]);
new stringG[255];
format(stringG,sizeof(stringG),"Neue Gravitation: %f",RandomGravity);
SendClientMessageToAll(WHITE,stringG);
I hope you can help me.
Re: Show The Gravity -
Pawno_Master - 12.10.2009
Should this
format(stringG,sizeof(stringG),"Neue Gravitation: %f",RandomGravity);
not be this?
format(stringG,sizeof(stringG),"Neue Gravitation: %s",RandomGravity);
Re: Show The Gravity -
Correlli - 12.10.2009
Quote:
Originally Posted by ekeleke
Should this
format(stringG,sizeof(stringG),"Neue Gravitation: %f",RandomGravity);
not be this?
format(stringG,sizeof(stringG),"Neue Gravitation: %s",RandomGravity);
|
No,
%f is for float numbers (example: 5.0), while
%s is for strings (example: "hello").
Show your GravityValues code and don't use 255 cells, you don't need it. SA:MP's MAX_IO is 128.
Re: Show The Gravity -
Marc_307 - 12.10.2009
pawn Код:
new Float:GravityValues[][1]=
{
{0.0080},
{0.0070},
//etc.
{0.0295},
{0.0300}
};
Re: Show The Gravity -
MenaceX^ - 12.10.2009
%f.
Re: Show The Gravity -
Marc_307 - 12.10.2009
Quote:
Originally Posted by MenaceX^
%f.
|
This looks now like this: 0.000000.
Re: Show The Gravity -
Marc_307 - 12.10.2009
Quote:
Originally Posted by Seif_
pawn Код:
new Float:GravityValues[]= { 0.0080, 0.0070, //etc. 0.0295, 0.0300 };
//timer new RandomGravity = random(sizeof(GravityValues)); SetGravity(GravityValues[RandomGravity]); new stringG[128]; format(stringG,sizeof(stringG),"Neue Gravitation: %f",GravityValues[RandomGravity]); SendClientMessageToAll(WHITE,stringG);
|
Thank you, it works.