Float fail?
#1

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

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]);
Reply
#3

You can do it like this:
@ top
new Pros[MAX_PLAYERS];
Reply
#4

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

But how to show every player different that?
Reply
#6

• %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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)