PDA

View Full Version : [HELP] Makeadmin


xMichaelx
09/12/2011, 01:21 AM
Hello there,

The following command that i made for some reason does not work:


CMD:makeadmin(playerid,params[])
{
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] >= 7)
{
new string[128],name[MAX_PLAYER_NAME],pID,Level;
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
if(sscanf(params,"ui",pID,Level)) return SendClientMessage(playerid,COLOR_GREY,"/makeadmin <player> <level>");
if(IsPlayerConnected(pID))
{
if(PlayerInfo[pID][pAdminLevel] != Level)
{
if(PlayerInfo[pID][pAdminLevel] < Level)
{
PlayerInfo[pID][pAdminLevel] = Level;
format(string,sizeof(string),"** ADMIN PROMOTE: %s Is Now An Administrator Level %d!",name,Level);
SendClientMessageToAll(COLOR_PINK,string);
GameTextForPlayer(pID,"~g~Promoted",3000,4);
}
else
{
GameTextForPlayer(pID,"~r~Demoted",3000,4);
format(string,sizeof(string),"** ADMIN DEMOTE: %s Has Been Demoted To Level %d!",name,Level);
SendClientMessageToAll(COLOR_PINK,string);
PlayerInfo[pID][pAdminLevel] = Level;
}
}
else return SendClientMessage(playerid, COLOR_RED, "This player is already that level.");
}
else return SendClientMessage(playerid, COLOR_RED, "Invalid Player Specified.");
}
else return 0;
return 1;
}

As it will return at IsPlayerConnected even if the player is connected.

I was testing this command on myself and entered my id = 0 then my name, however the command still didn't work.

Anyone have any idea?

Thanks

-Michael

[MWR]Blood
09/12/2011, 08:17 AM
CMD:makeadmin(playerid,params[])
{
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] >= 7)
{
new string[128],name[MAX_PLAYER_NAME],pID,Level;
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
if(sscanf(params,"ui",pID,Level)) return SendClientMessage(playerid,COLOR_GREY,"/makeadmin <player> <level>");
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid,COLOR_GREY,"ERROR: Player not connected!");
if(PlayerInfo[pID][pAdminLevel] != Level)
{
if(PlayerInfo[pID][pAdminLevel] < Level)
{
PlayerInfo[pID][pAdminLevel] = Level;
format(string,sizeof(string),"** ADMIN PROMOTE: %s Is Now An Administrator Level %d!",name,Level);
SendClientMessageToAll(COLOR_PINK,string);
GameTextForPlayer(pID,"~g~Promoted",3000,4);
}
else
{
GameTextForPlayer(pID,"~r~Demoted",3000,4);
format(string,sizeof(string),"** ADMIN DEMOTE: %s Has Been Demoted To Level %d!",name,Level);
SendClientMessageToAll(COLOR_PINK,string);
PlayerInfo[pID][pAdminLevel] = Level;
}
}
else return SendClientMessage(playerid, COLOR_RED, "This player is already that level.");
}
else return 0;
return 1;
}

xMichaelx
09/12/2011, 08:25 AM
Thanks, I believe that its a MySQL Error, due to the fact it all return 0 after IsPlayerConnected, It wasn't happening before I changed a function, however if i change that function back it won't save PlayerInfo, any ideas?

KingHual
09/12/2011, 08:35 AM
Its an issue of sscanf because it doesnt support 0.3d i think

xMichaelx
09/12/2011, 08:40 AM
As I said, it has nothing to do with an incorrect code, it is to do with MySQL, please read before you post.

Thanks.

KingHual
09/12/2011, 08:46 AM
Then.. Post your mysql code? Check if your mysql database accepts and writes the data from your server?

T0pAz
09/12/2011, 08:48 AM
Its an issue of sscanf because it doesnt support 0.3d i think

sscanf is working fine on 0.3d.