SA-MP Forums Archive
MySQL always returning 1 in SELECT - 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: MySQL always returning 1 in SELECT (/showthread.php?tid=474737)



MySQL always returning 1 in SELECT - iryston - 09.11.2013

I'm doing it to check if the player is vip.

pawn Код:
new Stra[94], Nome[21];
        GetPlayerName(playerid,Nome,21);
        format(Stra, 94, "SELECT `Nome`, `Quantidade`, `TempoExpire` FROM `viplist` WHERE `Nome`='%s'", Nome);
        mysql_function_query(Connect, Stra, true, "CheckVip", "i",playerid);
        CheckVip(playerid);
pawn Код:
forward CheckVip(playerid);
public CheckVip(playerid)
{
    new row, field, temp[25], quantidade, TempExpire;
    cache_get_data(row,field, Connect);
    if(row==1)
    {//Are Always running here. but in mysql table But in mysql table, there is nothing. is empty
        cache_get_row(0, 1, temp), quantidade = strval(temp);
        cache_get_row(0, 2, temp), TempExpire = strval(temp);
        new calculo = (2592000 * quantidade) + TempExpire;
        if(calculo < gettime())
        {
            new Nome[21];
            GetPlayerName(playerid,Nome,21);
            SendClientMessage(playerid, -1,"");
            SendClientMessage(playerid, -1,"Sua conta vip venceu, renove-a para continuar com seus benefнcios!");
            new Str[51];
            format(Str,51,"DELETE FROM `viplist` WHERE `Nome`='%s'",Nome);
            mysql_function_query(Connect, Str, false, "", "");
            return 1;
        }
        else
        {
            if (PlayerInfo[playerid][pVIP] == 1)
            {
                SendClientMessage(playerid, COR_VIP,"{C6E2FF}{FFFFFF}[{00FF00}B{f3f300}V{909090}S{FFFFFF}]{CCCCFF} : Vocк e jogador [VIP-PRATA]");
            }
            else if (PlayerInfo[playerid][pVIP] == 2)
            {
                SendClientMessage(playerid, COR_VIP,"{FFF68F}{FFFFFF}[{00FF00}B{f3f300}V{909090}S{FFFFFF}]{CCCCFF} : Vocк e jogador [VIP-OURO]");
            }
            else if (PlayerInfo[playerid][pVIP] == 3)
            {
                SendClientMessage(playerid, COR_VIP,"{97FFFF}{FFFFFF}[{00FF00}B{f3f300}V{909090}S{FFFFFF}]{CCCCFF} : Vocк e jogador [VIP-Sуcio]");
            }
            else if (PlayerInfo[playerid][pVIP] == 4)
            {
                SendClientMessage(playerid, COR_VIP,"{97FFFF}{FFFFFF}[{00FF00}B{f3f300}V{909090}S{FFFFFF}]{CCCCFF} : Vocк e jogador [Sуcio-Diamante]");
            }
        }
    }
    else
    {
    }
    return 1;
}
The tables is empty, but he always returns 1.

If someone can help me, thank you very much!


Re: MySQL always returning 1 in SELECT - iryston - 09.11.2013

pls help me =/


Re: MySQL always returning 1 in SELECT - smeti - 09.11.2013

Delete this line:

Quote:

new Stra[94 + 1], Nome[21]; // +1 null character ('\0')
GetPlayerName(playerid,Nome,21);
format(Stra, 94 + 1, "SELECT `Nome`, `Quantidade`, `TempoExpire` FROM `viplist` WHERE `Nome`='%s'", Nome);
mysql_function_query(Connect, Stra, true, "CheckVip", "i",playerid);
// CheckVip(playerid); // remove




Re: MySQL always returning 1 in SELECT - iryston - 09.11.2013

++REP!!

I just realized that rsrs, Thank you Very thanks.
One thing, could you explain more about..
pawn Код:
mysql_function_query(Connect, Stra, true, "CheckVip", "i",playerid);
Код:
"i",playerid
When and how should it be used?

Thanks!!


Re: MySQL always returning 1 in SELECT - smeti - 11.11.2013

To be used when you need extra arguments to callback.

Example.:
pawn Код:
mysql_function_query(Connect, Stra, true, "CheckVip", "iis", playerid, 123, Stra);


public CheckVip(playerid, integer, string[])
{
    printf("%d - %d - %s", playerid, integer, string);
}