Negative Values in MySQL?
#1

Hey.

I have an little problem.
I tried to save negative values (cash) in MySQL, but if i save a value like -500 ($) and i make a relog i get -1 ($)
Can you help me?

I created the mysql-value like this:

- Cash, INT, 11 Lenght, 0 Decimals, NOT NULL

Thanks.
Reply
#2

Oops delete.
Reply
#3

Yes you can store a negative value in mysql, a field of type INTEGER can store any value ranging from –2147483648 to 2147483647. There is most likely something wrong with your code.

http://help.scibit.com/mascon/mascon...eld_Types.html
Reply
#4

@Sinner
Yeah, but how can i do it?
If i save an negative value it automatically set's it to -1.
Reply
#5

Show code. (Save & Load system's)
Reply
#6

pawn Code:
stock LoadPlayer(playerid, inputtext[])
{
    new hash[129];
    WP_Hash(hash, sizeof(hash), inputtext);
    if(IsPlayerConnected(playerid))
    {
        if(!strcmp(hash, mysql_ReturnPasswort(GetName(playerid)), true))
        {
            Spieler[playerid][pCash] = mysql_GetInt("accounts", "Cash", "Name", GetName(playerid));
//etc.
pawn Code:
stock SavePlayer(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        new query[1024];
        format(query, sizeof(query), "UPDATE `accounts` SET Level=%d, Admin=%d, Cash=%d, Tutorial=%d, AccountLocked=%d, SpawnHealth=%f, Geschlecht=%d, Skin=%d, Perso=%d, CarLic=%d, Fraktion=%d, Rank=%d WHERE Name='%s'",
        Spieler[playerid][pLevel],
        Spieler[playerid][pAdmin],
        GetPlayerMoney(playerid),
        Spieler[playerid][pTutorial],
        Spieler[playerid][pAccountLocked],
        Spieler[playerid][pSpawnHealth],
        Spieler[playerid][pGeschlecht],
        Spieler[playerid][pSkin],
        Spieler[playerid][pPerso],
        Spieler[playerid][pCarLic],
        Spieler[playerid][pFraktion],
        Spieler[playerid][pRank],
        GetName(playerid));
        mysql_query(query);
:/
Reply
#7

#close pls.

I've found the problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)