AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   PHP / SQL list table (https://forums.alliedmods.net/showthread.php?t=168150)

reinert 09-24-2011 17:53

PHP / SQL list table
 
Hey, could someone share a code of a table with list from SQL.

Like I've table player rankings in my SQL and I want to show them as top 30 descending by skill.

modernwarfare 09-24-2011 20:08

Re: PHP / SQL list table
 
Quote:

Originally Posted by reinert (Post 1562542)
Hey, could someone share a code of a table with list from SQL.

Like I've table player rankings in my SQL and I want to show them as top 30 descending by skill.


Code:

public Show_Rank(id)
{
    for(new i; i < g_iMaxPlayers; i++)
    {
        if(is_user_connected(i) && get_cvar_num("SaveXP") == 1  && !is_user_bot(id)) {
          SaveData(i)
        }
    }
       
    new Data[1]
    Data[0] = id
   
    new szTemp[512]
    format(szTemp,charsmax(szTemp),"SELECT COUNT(*) FROM `xpmod` WHERE `xp` >= %d", PlayerXP[id])
    SQL_ThreadQuery(g_SqlTuple,"Sql_Rank",szTemp,Data,1)
       
    return PLUGIN_CONTINUE
}
public Sql_Rank(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(FailState == TQUERY_CONNECT_FAILED)
            log_amx("Load - Could not connect to SQL database.  [%d] %s", Errcode, Error)
    else if(FailState == TQUERY_QUERY_FAILED)
            log_amx("Load Query failed. [%d] %s", Errcode, Error)
 
    new count = 0
    count = SQL_ReadResult(Query,0)
    if(count == 0)
    count = 1
   
    new id
    id = Data[0]

    client_print(id, print_chat, "[XP Mod] %L", id, "RANK", count, PlayerLevel[id] , PlayerXP[id])
   
    return PLUGIN_HANDLED
}
public ShowTop15(id)
{
    //i must save stat for will haven't error into top15.
    //
    new Data[1]
    Data[0] = id
   
    // no need for a variable since it's not being formatted
    /*new Temp[512]
    format(Temp,charsmax(Temp),"SELECT steamid, xp FROM xpmod ORDER BY xp DESC LIMIT 15;")
    SQL_ThreadQuery(g_SqlTuple,"Sql_Top15",Temp,Data,1)*/
    SQL_ThreadQuery(g_SqlTuple,"Sql_Top15","SELECT steamid, xp FROM xpmod ORDER BY xp DESC LIMIT 15;",Data,1)
    return PLUGIN_CONTINUE;
}
public Sql_Top15(FailState,Handle:hQuery,Error[],Errcode,Data[],DataSize)
{
    // get player who is looking at top
    new id = Data[ 0 ];
   
    // check for errors
    if( FailState == TQUERY_CONNECT_FAILED
    ||  FailState == TQUERY_QUERY_FAILED )
    {
        log_amx( "Error on top15 query (%i): %s", Errcode, Error );
        console_print( id, "Error on top15 query (%i): %s", Errcode, Error );
        return;
    }
   
    new szSteamID[ 35 ], PlayerXP;
    new iPos = 1;
   
    while( SQL_MoreResults( hQuery ) )
    {
        SQL_ReadResult( hQuery, 0, szSteamID, charsmax( szSteamID ) );
        PlayerXP = SQL_ReadResult( hQuery, 1 );

        client_print(id,print_chat, "[XP Mod] %L", id, "RANK2", iPos, szSteamID, PlayerXP);
       
        iPos++;
        SQL_NextRow( hQuery );
    }
}

this is what i use for my ranking system

reinert 09-25-2011 02:50

Re: PHP / SQL list table
 
I need PHP not AMXX :)

jimaway 09-25-2011 16:04

Re: PHP / SQL list table
 
this is amxx scripting help section...

reinert 09-25-2011 16:42

Re: PHP / SQL list table
 
Someone moved my thread >.< anyways delete thread, already made list :)


All times are GMT -4. The time now is 19:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.