AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Sql update player choosing (https://forums.alliedmods.net/showthread.php?t=189800)

spirit 07-11-2012 03:53

Sql update player choosing
 
Hi all,

I trying to made a simple menu with all name for all player who has the same item on my db.

it's my request sql "SELECT `name` FROM `xprpg_data` WHERE `item` = %d"

But on my function 'submenuitem(id, menu, item)'. How i can take the name on the line choosing for remove this item ( UPDATE `xprpg_data` SET `item` = '0' WHERE `name` = %s )

(resume: create menu with all player who has item = on the player who open menu and choosing player for remove this item).

PHP Code:

public Remove_Item(id)
{
    new 
Data[1]
    
Data[0] = id
    
new szTemp[512]
    
format(szTemp,charsmax(szTemp), "SELECT `name` FROM `xprpg_data` WHERE `item` = %d"HasItem[id])
    
SQL_ThreadQuery(g_SqlTuple,"Sql_List",szTemp,Data,1)

    return 
PLUGIN_CONTINUE;
}

public 
Sql_List(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
        
log_amx("Load - Could not connect to SQL database.  [%d] %s"ErrcodeError);
    else if(
FailState == TQUERY_QUERY_FAILED)
        
log_amx("Load Query failed. [%d] %s"ErrcodeError);
  
    new 
id Data[0]
    
    new 
name[32]
    new 
menu menu_create("Choose player""submenuitem")
    
    while(
SQL_MoreResults(Query))
    {
        
SQL_ReadResult(Query0namecharsmax(name))
        
menu_additem(menu"\w%s"name
        
SQL_NextRow(Query)
    } 
    
menu_display(idmenu0)
    return 
PLUGIN_HANDLED
}  

public 
submenuitem(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED;
        
// ???
    
}
    




All times are GMT -4. The time now is 15:24.

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