MySQL always returning 1 in SELECT
#1

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!
Reply
#2

pls help me =/
Reply
#3

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

Reply
#4

++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!!
Reply
#5

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);
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)