SA-MP Forums Archive
Negative Values in MySQL? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Negative Values in MySQL? (/showthread.php?tid=402089)



Negative Values in MySQL? - 'Pawno. - 25.12.2012

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.


Re: Negative Values in MySQL? - Djole1337 - 25.12.2012

Oops delete.


Re: Negative Values in MySQL? - Sinner - 25.12.2012

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


AW: Negative Values in MySQL? - 'Pawno. - 25.12.2012

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


Re: Negative Values in MySQL? - Typhome - 25.12.2012

Show code. (Save & Load system's)


AW: Negative Values in MySQL? - 'Pawno. - 25.12.2012

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);
:/


AW: Negative Values in MySQL? - 'Pawno. - 25.12.2012

#close pls.

I've found the problem.