PDA

View Full Version : [Help] MYSQL /setadmin problem


andrew2695
22/06/2012, 07:36 PM
I'm trying to make a /setadmin command using MySQL database but I keep getting That player is not online. And its not going well.
Here the code. Anyone know whats wrong?
CMD:setadmin(playerid, params[])
{
new iD, gMessage[250], pName[24], NewAdmin[24], gQuery[250], Level;
if(sscanf(params, "ui", iD, Level)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /setadmin [playerid] [level]");
else if(!IsPlayerConnected(iD)) return SendClientMessage(playerid, 0xFF0000FF, "That player is not online.");
else
{
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(iD, NewAdmin, sizeof(NewAdmin));
format(gQuery, sizeof(gQuery), "UPDATE Accounts SET Admin = '%i' WHERE Username = '%s'", Level, NewAdmin);
mysql_query(gQuery);

format(gMessage, sizeof(gMessage), "* You have set %s has a level %i admin.", NewAdmin, Level);
SendClientMessage(playerid, 0xFFFFFFFF, gMessage);

format(gMessage, sizeof(gMessage), "* You have been set as a level %i admin.", Level);
SendClientMessage(iD, 0xFFFFFFFF, gMessage);
}
return 1;
}

Ricop522
22/06/2012, 08:05 PM
Could you show us the mysql_log ? :D
(mysql_debug(1))

CMD:setadmin(playerid, params[])
{
new iD, gMessage[250], pName[24], NewAdmin[24], gQuery[250], Level;
if(sscanf(params, "ui", iD, Level)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /setadmin [playerid] [level]");
if(!IsPlayerConnected(iD)) return SendClientMessage(playerid, 0xFF0000FF, "That player is not online.");
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(iD, NewAdmin, sizeof(NewAdmin));

format(gQuery, sizeof(gQuery), "UPDATE Accounts SET Admin = %i WHERE Username = '%s'", Level, NewAdmin);
mysql_query(gQuery);

format(gMessage, sizeof(gMessage), "* You have set %s has a level %i admin.", NewAdmin, Level);
SendClientMessage(playerid, 0xFFFFFFFF, gMessage);

format(gMessage, sizeof(gMessage), "* You have been set as a level %i admin.", Level);
SendClientMessage(iD, 0xFFFFFFFF, gMessage);

return 1;
}



Its the same code, I dont modify nothing /\

andrew2695
22/06/2012, 08:09 PM
Here the debug http://pastebin.com/WJG2C09d