Weird thing when I want to add exp to player...
#1

Hello, I made code about adding exp points to players every 30seconds...
So after they play 1seconds they will get 0.346 experience points, when I tried it, player got A WAY TOO MUCH EXP like 1318926827 I was surprised...

Here is the code...

Код:
public Experience()
{
  for(new i=0; i<MAX_PLAYERS; i++)
  {
     if(IsPlayerConnected(i))
     {
        Seconds[i]++;
        if(Seconds[i] >= 30)
        {
           Seconds[i]=0;
           PlayerInfo[i][Exppoints]+=0.346;
					 GameTextForPlayer(i, "Exp~n~~w~+0.346", 3000, 1);
        }
     }
  }
}
Please help me so I get 0.346 exp every 30 secs
Reply
#2

probably adding a non full number and you probably have it as a decimal and not a float which is what you need if you want to have x.xx
Reply
#3

Can you help me fixing it please?
Reply
#4

try a
Код:
new Float:PlayerInfo[i][Exppoints];
Reply
#5

Maybe it's because on /stats command I use
Код:
(Exp: %d, (PlayerInfo[playerid][Exppoints])
Maybe that causes it?
Reply
#6

yep. use %f (floating point), to solve the tons of zeros after the dot, use %.2f
Reply
#7

So something like this?

Код:
(Exp: %f.%2f, (PlayerInfo[playerid][Exppoints])
Thanks for the reply...
Reply
#8

Quote:
Originally Posted by HeGe
So something like this?

Код:
(Exp: %f.%2f, (PlayerInfo[playerid][Exppoints])
Thanks for the reply...
OK I tried it in game, now it's little bit better, shows like Exp: 0.346999. 0.000000000 (How to remove that 999 at the end, and how to remove that 0.00000000 after it...)

EDIT: After 2nd experience add, it still shows some BIG NUMBERS LIKE 1031245123.00000 or something, PLEASE HELP ME
Reply
#9

may i see your snipped u r using? it will help me fixing your problem. u already defined that value as
Код:
new Float:PlayerInfo[i][Exppoints];
? if not, do it. if you display an integer and add a float value, it always grows at large amounts..
maybe that will fix your problem, if i give you some examples:
lets assume you got this value of 120.0 and adding your 0.346
%f == 120.346000
%.3f == 120.346
%.4f == 120.3460
%.8f == 120.34600000
%8.f == 00000120.346
%8.8f == 00000120.34600000
and, finally, maybe u need this:
%3.3f == 120.346
hope it helps a bit
Reply
#10

Код:
new Float:PlayerInfo[i][Exppoints];
Where I need to add this??

When I try, it shows me this errors

Код:
warning 219: local variable "PlayerInfo" shadows a variable at a preceding level
error 008: must be a constant expression; assumed zero
error 036: empty statement
Please help me..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)