Show The Gravity
#1

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.
Reply
#2

Should this

format(stringG,sizeof(stringG),"Neue Gravitation: %f",RandomGravity);

not be this?

format(stringG,sizeof(stringG),"Neue Gravitation: %s",RandomGravity);
Reply
#3

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.
Reply
#4

pawn Код:
new Float:GravityValues[][1]=
{
{0.0080},
{0.0070},
//etc.
{0.0295},
{0.0300}
};
Reply
#5

%f.
Reply
#6

Quote:
Originally Posted by MenaceX^
%f.
This looks now like this: 0.000000.
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)