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 = %s WHERE Slot = %d", GetName(id),slot); db_query(base, query); }
What you mean with "i cant get it to work"?
Also you should escape strings, use %e instead of %s. |
format(query, sizeof(query), "UPDATE admins SET Name = '%q' WHERE Slot = %d", GetName(id),slot);
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);
}
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);
}