Bank money!
#1

Hello,

I'm using a simple bank system in my server, it uses mysql system to save/load bank money, I have deposited $2000000000 in my bank account and it works but when i disconnect the bank money saves into minus with a different amount $-xxxxxxxxxx

I'm using SA-MP's player variable (SetPVarInt/GetPVarInt) for the bank system.

What could be the problem?

Thank you.
Reply
#2

Yes, I'm sure that is the value. This is how saved bank money looks like after disconnecting(Screenshot from MySQL table):


Is there any way to fix/bypass maximum integer value?
Reply
#3

So that is the maximum value?
Reply
#4

Try using player-enumerators. PVars aren't really that good in my opinion
So let's give you en example:

Код:
enum pInfo
{
     pBank
}
new PlayerInfo[MAX_PLAYERS][pInfo];

// (Saving and Loading the SQL) -if your using the same variables!  You need to put them in stocks, which I'm sure you have.

// Saving
new szQuery[256];

format(szQuery, sizeof(szQuery), "UPDATE Accounts SET Bank='%i' WHERE Username='%s'", PlayerInfo[playerid][pBank], DB_Escape(PlayerInfo[playerid][pUsername]));
db_free_result(db_query(Database, szQuery));
////////////////////

// Loading
new szValue[64];
db_get_field_assoc(dbresult, "Bank", szValue, sizeof(szValue));
PlayerInfo[playerid][pBank] = strval(szValue);
////////////////////
EDIT:
If you still wish to continue using PVars, I suggest making another one called "Bank2", and then break the integer up, so half 50/50 get's deposited into each account, and on withdraw, 50/50 will be withdrawn.
Reply
#5

Your amount is invalid.
There is no way players can have money more than 999m ($999,999,999)
You're exceeding the maximum value, so it's automatically set to a negative value.
Reply
#6

Someone delete this, please.
Bullshit internet..
Reply
#7

Try not to double-post. ^ - There might be a very good reason in to which he/she is trying to get bigger than the maximum value. It is possible, when you use coding with it.

You can do it, simply, buy dividing the two values into a multiplication feature. You can simply add them into each bank account.

OR what you can do is, enable an infinity sign, which is pretty cool. Where it doesn't withdraw money out of your bank account, it just simply let's you keep adding money using a similar function to /givemoney.

On your bank cmd, if your using zcmd

Quote:

COMMAND:withdraw(playerid, params[])
{
new amount;
if(sscanf(params, "i", amount)) return SendClientMessage(playerid, -1, "USAGE: /withdraw [amount]");
if(GetPVarStr(playerid, "Bank") == "∞")
{
GivePlayerMoney(playerid, amount);
return 1;
}
else
// Blah blah, rest of your code. (NOT SURE if this works, but it's similiar to that.)
}

Reply
#8

Alright, thanks everyone!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)