Showing dynamic ShowPlayerDialog MySQL
#1

Hello. I'm trying to make a command /factions which will show user all the factions in my database.
However, It doesn't seem to work for me.
PHP код:
CMD:factions(playerid,params[])
{
    
mysql_tquery(mysql"SELECT * FROM `Factions` LIMIT "#MAX_FACTIONS"", "LoadFactionsIG", "");
    
return 1;
}
forward LoadFactionsIG();
public 
LoadFactionsIG()
{
    new 
userstring[250];
    
    new 
count cache_get_row_count();
    for (new 
icounti++)
    {
        
format(userstringsizeof(userstring), "%s  \n",cache_get_field_content(i"Name"Factions[i][Name]));
        
ShowPlayerDialog(i10DIALOG_STYLE_MSGBOX"Factions"userstring"OK","");
    }
    
    
printf("> %d factions have been loaded from the database."count); // Prints out the information of how many factions created
    
return 1;

Do I have to use callback for such thing isn't there a simpler way to achieve what I want.
Reply
#2

Код:
CMD:factions(playerid,params[]) return mysql_tquery(mysql, "SELECT `Name` FROM `Factions'", "LoadFactionsIG", "i",playerid);
forward LoadFactionsIG(playerid);
public LoadFactionsIG(playerid)
{
    if(playerid == INVALID_PLAYER_ID) return 1;
    new rows,fields,str[160];
    cache_get_data(rows,fields,mysql);
    if(!rows) return 1;
    new fracName[32];
    for (new i; i < rows; i++)
    {
        cache_get_field_content(i, "Name",fracName,mysql);
        format(str, sizeof(str), "%s%s  \n",str,fracName);
    }
    ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "Factions", str, "OK","");
    return 1;
}
Reply
#3

Works now!
Reply


Forum Jump:


Users browsing this thread: