How can I bypass the 32 bit integer limit? (2,147,483,647)
#7

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
The HUD only has 8 digits, so an extremely surreal unrealistic economy wasn't a really bright idea.

About getting the total amount of cash held by the users on the server. You can do that with a simple SQL statement that does all the work for you. You just have to display the number it gives you.

About players being able to have so unrealistic amounts of money, you can create an array. Look at them as pockets, wallets or whatever.

Wallet 1: 500 bucks
Wallet 2: 200 bucks
Total cash by adding all the wallets up: 700 bucks

You just gotta think out of the box sometimes. Good luck and have fun!
But let's say I'd calculate the total sum of the array, I would use a loop. And the variable that returns the total amount is still a 32 bit integer. So I could I do that?

I mean, I already kinda know how to add the money, but I don't know how to calculate it.

Код:
new money[MAX_PLAYERS][20];

stock AddMoney(playerid, money)
{
	for(new i; i < 20; i++)
	{
	    if(money[playerid][i] < 2147483647)
	    {	
	    	if(money[playerid][i] + money <= 2147483647)
	    	{
	    		money[playerid][i] += money;
	    		break;
	    	}       
	    }
	}
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)