help with mysql
#1

hi i have this code:
Quote:

CMD:adminai(playerid,params[])
{
new
Index,
query[ 300 ],
str [ 1200 ];

mysql_query( "SELECT `vardas`,`admin`,`online` FROM `zaidejai` WHERE `admin` > '0'" );
mysql_store_result();
if ( mysql_num_rows( ))
{
while( mysql_fetch_row( query ))
{
new
name[ MAX_PLAYER_NAME ],
adminid,
OnlineEx;

sscanf( query, "p<|>s[24]ii", name, adminid, OnlineEx );


if ( !OnlineEx )
{
format( str, 1200, "{FFFFFF}%s%s - %s - {FF0000}OFFLINE\n{FFFFFF}", str, name, ReplaceAdminName( adminid ) );
Index++;
}
else
{
format( str, 1200, "{FFFFFF}%s%s - %s - {00FF00}ONLINE\n{FFFFFF}", str, name, ReplaceAdminName( adminid ) );
Index++;
}
}
}
mysql_free_result();
if ( !Index )
{
ShowPlayerDialog( playerid, 2501, DIALOG_STYLE_MSGBOX, "{FF0000}Adminai", "{FF0000}Atsiprasome siuo metu nera isrinktas nei vienas direktorius!", "Gerai", "" );
}
else
{
ShowPlayerDialog( playerid, 2502, DIALOG_STYLE_MSGBOX, "{00FF00}Adminai", str, "Gerai", "" );
}
return 1;
}

but even admin is online it says offline and doesnt show ReplaceAdminName
Reply
#2

Wait a second.... Are you telling me that this script should show a list of online admins? If so, you don't even need mysql.
Reply
#3

Do you set `online` value when admin connects to server? You should check if variables have correct values:
pawn Код:
print(query);
printf("%s %d %d", name, adminid, OnlineEx);
Reply
#4

Quote:
Originally Posted by Mystique
Посмотреть сообщение
Wait a second.... Are you telling me that this script should show a list of online admins? If so, you don't even need mysql.
i want that it show online and offline
Reply
#5

Quote:

print(query);
printf("%s Admin id: %d Online: %d", name, adminid, OnlineEx);

shows zeros
Reply
#6

Can you compare printed results with results in mysql database? Take a look what mysql_log contains, maybe you will see some errors. Also I would recommend to use latest version of this plugin.
Reply
#7

in sql debug it show me this:
Quote:

[10:44:34] CMySQLHandler::FetchRow() - Return: Ance_Zas|3|1

it's from this code:
Quote:

sscanf( query, "p<|>s[24]ii", name, adminid, OnlineEx );

why it show me |?
Reply
#8

Its OK. Try this and tell me, what your server log shows.
pawn Код:
CMD:adminai(playerid,params[])
{
    new
        Index,
        query[ 300 ],
        str  [ 1200 ];

    mysql_query( "SELECT `vardas`,`admin`,`online` FROM `zaidejai` WHERE `admin` > '0'" );
    mysql_store_result();
    if ( mysql_num_rows( ))
    {
        while( mysql_fetch_row( query ))
        {
            new
                name[ MAX_PLAYER_NAME ],
                adminid,
                OnlineEx;
   
            sscanf( query, "p<|>s[24]ii", name, adminid, OnlineEx );
            //  Print result
            print(query);
            printf("%s, %d, %d", name, adminid, OnlineEx);

            if ( !OnlineEx )
            {
                format( str, 1200, "{FFFFFF}%s%s - %s - {FF0000}OFFLINE\n{FFFFFF}", str, name, ReplaceAdminName( adminid ) );
                Index++;
            }
            else
            {
                format( str, 1200, "{FFFFFF}%s%s - %s - {00FF00}ONLINE\n{FFFFFF}", str, name, ReplaceAdminName( adminid ) );
                Index++;
            }
        }
    }
    mysql_free_result();
    if ( !Index )
    {
        ShowPlayerDialog( playerid, 2501, DIALOG_STYLE_MSGBOX, "{FF0000}Adminai", "{FF0000}Atsiprasome siuo metu nera isrinktas nei vienas direktorius!", "Gerai", "" );
    }
    else
    {
        ShowPlayerDialog( playerid, 2502, DIALOG_STYLE_MSGBOX, "{00FF00}Adminai", str, "Gerai", "" );
    }
    return 1;
}
Reply
#9

it gives me:
Quote:

[11:57:06] Ance_Zas|3|1
[11:57:06] Ance_Zas|3|1, 0, 0

Reply
#10

any sscanf warnings? You are using sscanf plugin or just pawn function?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)