19.03.2019, 15:13
(
Последний раз редактировалось Banditul18; 19.03.2019 в 20:48.
)
Forgot to tell you something about your command actually:
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
I think something like this. If im wrong someone correct me
PHP код:
YCMD:makeadminslot(playerid, params[], help)
{
new id,level,slot,query[512],DB:base;
if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, SIVAUB, "No");
if(sscanf(params, "ii", id,slot)) return SendClientMessage(playerid, SIVAUB, "Use: /makeadminslot [id] [slot (1-20)]");
level = PlayerInfo[id][pAdmin];
base = db_open("base.db");
format(query, sizeof(query), "UPDATE admins SET Name = '%q' WHERE Slot = %d", GetName(id),slot);
db_free_result(db_query(base, query));
db_close(base);
}
Aint expert in SQLite but i assume you can do something like this for dialog
PHP код:
YCMD:adminlist(playerid, params[], help)
{
new query[129],DB:base, DBResult:db_result, rows, adminName[MAX_PLAYER_NAME+1], adminList[165];
base = db_open("base.db");
format(query, sizeof(query), "SELECT Name FROM admins");
db_result = db_query(base, query);
rows = db_num_rows(db_result);
if(!rows)
return SendClientMessage(playerid, -1, "There is no admins!");
for(new row = 0; i < rows; row++)
{
db_get_field(db_result, row, adminName, sizeof adminName);
strcat(adminList, adminName);
strcat(adminList, "\n");
}
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, "Admin List", adminList, "OK");
db_free_result(db_result);
db_close(base);
}