Textdraw
#1

-----------
Reply
#2

There is a format trick that isnt mentioned often, as it seems to be quite unknown.
You can specifiy some options if you add something between the % and the d.

For example
%08d will fill it up with 0 until it is 8 chars long, so thats the thing you need.
Reply
#3

Code:
stock UpdateMoney(playerid)
{
    new money = GetPlayerCash(playerid);
    if(money < 10) {
        format(string, sizeof(string), "$0000000%d",money);
        TextDrawSetString(Textdraw3[playerid], string );
        return 1;
    }
    else if(money < 100) {
        format(string, sizeof(string), "$000000%d",money);
        TextDrawSetString(Textdraw3[playerid], string );
        return 1;
    }
    else if(money < 1000) {
        format(string, sizeof(string), "$00000%d",money);
        TextDrawSetString(Textdraw3[playerid], string );
        return 1;
    }
    else if(money < 10000) {
        format(string, sizeof(string), "$0000%d",money);
        TextDrawSetString(Textdraw3[playerid], string );
        return 1;
    }
    else if(money < 100000) {
        format(string, sizeof(string), "$000%d",money);
        TextDrawSetString(Textdraw3[playerid], string );
        return 1;
    }
    else if(money < 1000000) {
        format(string, sizeof(string), "$00%d",money);
        TextDrawSetString(Textdraw3[playerid], string );
        return 1;
    }
    else if(money < 10000000) {
        format(string, sizeof(string), "$0%d",money);
        TextDrawSetString(Textdraw3[playerid], string );
        return 1;
    }
    else if(money < 100000000) {
        format(string, sizeof(string), "$0%d",money);
        TextDrawSetString(Textdraw3[playerid], string );
        return 1;
    }
    else if(money < 1000000000) {
        format(string, sizeof(string), "$%d",money);
        TextDrawSetString(Textdraw3[playerid], string );
        return 1;
    }
    return 1;
}
Here.. i just copy pasted it out of my gamemode
Reply
#4

-----------
Reply
#5

No, thats foolish, use Mauzens method.

And why don't you use GivePlayerMoney, that would be much easier.
Reply
#6

-----------
Reply
#7

I've seen that so often, people just don't get it. (This is like buying a new car if the doorlock is broken)

Yes, if you use GetPlayerMoney for getting the player's money, cheating is possible.

That's why you should save player money into a server variable.
But why shouldn't GivePlayerMoney be used to display the money wich is saved in that variable?
People can use money hacks to change the displayed money, but this doesn't change the variable's value!
You just set the money, you don't read it out.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)