Problem with SQL query
#5

Forgot to tell you something about your command actually:
PHP код:
YCMD:makeadminslot(playeridparams[], help
{
    new 
id,level,slot,query[512],DB:base;
    if(
PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playeridSIVAUB"No");
    if(
sscanf(params"ii"id,slot)) return SendClientMessage(playeridSIVAUB"Use: /makeadminslot [id] [slot (1-20)]");
    
level PlayerInfo[id][pAdmin];
    
base db_open("base.db");
    
format(querysizeof(query), "UPDATE admins SET Name = '%q' WHERE Slot = %d"GetName(id),slot);
    
db_free_result(db_query(basequery));
    
db_close(base);

ALWAYS free the db_query, doesnt matter what type of query is. Memory leak is bad. Also i see you open a connection with database yet never close it this might lead to to many connections to database and lock the database

Aint expert in SQLite but i assume you can do something like this for dialog
PHP код:
YCMD:adminlist(playeridparams[], help
{
    new 
query[129],DB:baseDBResult:db_resultrowsadminName[MAX_PLAYER_NAME+1], adminList[165];
    
    
base db_open("base.db");
    
format(querysizeof(query), "SELECT Name FROM admins");
    
db_result db_query(basequery);
    
rows db_num_rows(db_result);
    if(!
rows)
        return 
SendClientMessage(playerid, -1"There is no admins!");
    
    for(new 
row 0rowsrow++)
    {
        
db_get_field(db_resultrowadminNamesizeof adminName);
        
strcat(adminListadminName);
        
strcat(adminList"\n");
    }
    
    
ShowPlayerDialog(playeriddialogidDIALOG_STYLE_LIST"Admin List"adminList"OK");
    
db_free_result(db_result);
    
db_close(base);

I think something like this. If im wrong someone correct me
Reply


Messages In This Thread
Problem with SQL query - by Dolke - 18.03.2019, 17:44
Re: Problem with SQL query - by SymonClash - 18.03.2019, 20:49
Re: Problem with SQL query - by Banditul18 - 18.03.2019, 20:53
Re: Problem with SQL query - by Dolke - 19.03.2019, 05:59
Re: Problem with SQL query - by Banditul18 - 19.03.2019, 15:13
Re: Problem with SQL query - by Dolke - 19.03.2019, 20:21
Re: Problem with SQL query - by Dolke - 21.03.2019, 23:57

Forum Jump:


Users browsing this thread: 2 Guest(s)