Float fail? - 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: Float fail? (
/showthread.php?tid=161849)
Float fail? -
whitedragon - 21.07.2010
How make Float right?
pawn Код:
enum Pydinf
{
Float:Pros
}
new AdminDuty[MAX_PLAYERS];
forward Prot;
new PlayerInfo[MAX_PLAYERS][Pydinf];
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/testcmd", cmdtext, true, 10) == 0)
{
new text[128];
format(text,sizeof text,"Stuff have: %s",PlayerInfo[playerid][Pros]);
SendClientMessage(playerid,0x8C1717,text);
return 1;
}
return 0;
}
public Prot()
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(AdminDuty[i] == 0)
PlayerInfo[i][Pros] -= 1;
else
{
PlayerInfo[i][Pros] += 1;
}
}
}
when i do /testcmd then i get nnnnnnnnnnnnnn

I think how to make its to player dynamic.....
Re: Float fail? -
MadeMan - 21.07.2010
pawn Код:
format(text,sizeof text,"Stuff have: %s",PlayerInfo[playerid][Pros]);
Change %s to %f
pawn Код:
format(text,sizeof text,"Stuff have: %f",PlayerInfo[playerid][Pros]);
Re: Float fail? -
bartje01 - 21.07.2010
You can do it like this:
@ top
new Pros[MAX_PLAYERS];
Re: Float fail? -
bartje01 - 21.07.2010
Btw. if it has to be a number.
Example: you have 5 drugs.
Don't use %f or %s.
%s is only text.
Than you need %d
That puts INT. like money and stuff.
Re: Float fail? -
whitedragon - 21.07.2010
But how to show every player different that?
Re: Float fail? -
Joe_ - 21.07.2010
• %d, %i Inserts a whole integer
• %s Inserts a string
• %f Inserts a float point (rational number)
• %x Inserts a hexadecimal
• %c Inserts a single character
• %b (quote wiki) Inserts a number at this position in binary radix
• %% Inserts a percent symbol '%'.
Now I have not a clue what your code is meant to do, but I am assuming you need a integer.
Unless you want a number like this, for example '5.3' which is called a rational number, you use the placeholder '%f' for rational numbers.
I will give you a small example, we're here to help, not code for you.
pawn Код:
// Where your declarations are, usually under your includes
enum
E_PLAYER_DATA
{
Items
}
new
pData[MAX_PLAYERS][E_PLAYER_DATA];
// Under your command
format(text, sizeof(text), "You have %d items", pData[playerid][Items]);
SendClientMessage(playerid, 0x8C1717, text);
// When you want to decrease the amount
pData[playerid][Items]--; // Decreases by one
// When you want to increase the amount
pData[playerid][Items]++; // Increases by one