CMD:setlevel(playerid, params[])
{
if(PlayerInfo[playerid][Padmin] >5)
{
new id, lvl, string[128], string2[128], string3[128];
new INI:file = INI_Open(Path(playerid));
if(sscanf(params,"ui",id,lvl)) return SendClientMessage(playerid, -1, "USAGE: /setlevel <id> <lvl>");
format(string, sizeof(string), "You have set %s admin level to %d", PlayerName(id), lvl);
format(string2, sizeof(string2), "Your level has been set to %d by %s", lvl, PlayerName(playerid));
format(string3, sizeof(string3), "%s is now admin level %d", PlayerName(id), lvl);
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, string2);
SendClientMessageToAll(-1, string3);
INI_WriteInt(file,"Padmin",lvl);
INI_Close(file);
return 1;
}
else if(PlayerInfo[playerid][Padmin] <5)
{
SendClientMessage(playerid, -1, "Your not a admin");
return 1;
}
return 1;
}
hello, i guessed on how to make this command but it doesnt work
|
CMD:setlevel(playerid, params[])
{
if(PlayerInfo[playerid][Padmin] > 5)
{
new id, lvl, string[128], string2[128], string3[128];
new INI:file = INI_Open(Path(playerid));
if(sscanf(params,"ui",id,lvl)) return SendClientMessage(playerid, -1, "USAGE: /setlevel <id> <lvl>");
format(string, sizeof(string), "You have set %s admin level to %d", PlayerName(id), lvl);
format(string2, sizeof(string2), "Your level has been set to %d by %s", lvl, PlayerName(playerid));
format(string3, sizeof(string3), "%s is now admin level %d", PlayerName(id), lvl);
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, string2);
SendClientMessageToAll(-1, string3);
INI_WriteInt(file,"Padmin",lvl);
INI_Close(file);
return 1;
}
else if(PlayerInfo[playerid][Padmin] > 5)
{
SendClientMessage(playerid, -1, "Your not a admin");
return 1;
}
return 1;
}
CMD:setlevel(playerid, params[])
{
if(PlayerInfo[playerid][Padmin] < 5) return SendClientMessage(playerid, -1, "Your not a admin");
new id, lvl, string[128];
if(sscanf(params,"ui",id,lvl)) return SendClientMessage(playerid, -1, "USAGE: /setlevel <id> <lvl>");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid playerid");
if(lvl < 1 || lvl > PlayerInfo[playerid][Padmin] && PlayerInfo[playerid][Padmin] < 5) return SendClientMessage(playerid, -1, "Invalid level");
format(string, sizeof(string), "You have set %s admin level to %d", PlayerName(id), lvl);
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "Your level has been set to %d by %s", lvl, PlayerName(playerid));
SendClientMessage(id, -1, string);
format(string, sizeof(string), "%s is now admin level %d", PlayerName(id), lvl);
SendClientMessageToAll(-1, string);
PlayerInfo[id][Padmin] = lvl;
return 1;
}
I'm assuming player's stats get saved on quit, so I just set their admin VARIABLE to "lvl" and also added a few checks for if player is connected, and a few proper lvl checks, you may change this to your preferences if you wish.
|
CMD:setlevel(playerid, params[])
{
if(PlayerInfo[playerid][Padmin] < 5) return SendClientMessage(playerid, -1, "Your not a admin");
new id, lvl, string[128];
if(sscanf(params,"ds", id , lvl)) return SendClientMessage(playerid, -1, "USAGE: /setlevel <id> <lvl>");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid playerid");
if(lvl < 1 || lvl > PlayerInfo[playerid][Padmin] && PlayerInfo[playerid][Padmin] < 5) return SendClientMessage(playerid, -1, "Invalid level");
format(string, sizeof(string), "You have set %s admin level to %d", PlayerName(id), lvl);
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "Your level has been set to %d by %s", lvl, PlayerName(playerid));
SendClientMessage(id, -1, string);
format(string, sizeof(string), "%s is now admin level %d", PlayerName(id), lvl);
SendClientMessageToAll(-1, string);
PlayerInfo[id][Padmin] = lvl;
return 1;
}
CMD:setlevel(playerid, params[])
{
new INI:file = INI_Open(Path(playerid));
if(!IsPlayerAdmin(playerid)) return 0;
if(PlayerInfo[playerid][Padmin] < 5) return SendClientMessage(playerid, -1, "Your not a admin");
new id, lvl, string[128], string2[128], string3[128];
if(sscanf(params,"us", id , lvl)) return SendClientMessage(playerid, -1, "USAGE: /setlevel <id> <lvl>");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid playerid");
format(string, sizeof(string), "You have set %s admin level to %d", PlayerName(id), lvl);
SendClientMessage(playerid, -1, string);
format(string2, sizeof(string), "Your level has been set to %d by %s", lvl, PlayerName(playerid));
SendClientMessage(id, -1, string2);
format(string3, sizeof(string), "%s is now admin level %d", PlayerName(id), lvl);
SendClientMessageToAll(-1, string3);
PlayerInfo[id][Padmin] = lvl;
INI_WriteInt(file,"Padmin",lvl);
INI_Close(file);
return 1;
}
COMMAND:setlevel(playerid,params[])
{
new id,level;
if(IsPlayerAdmin(playerid))
{
if(sscanf(params,"ud",id,level)) return SendClientMessage(playerid,COLOR_RED,"[USAGE]: /setlevel [playerid/name] [level]");
else
{
if(level > 5) return SendClientMessage(playerid, COLOR_RED,"Only 1-5 levels allowed!");
else
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"RCON Administrator promoted %s to administrator!",pName);
SendClientMessageToAll(COLOR_GREEN,string);
new INI:File = INI_Open(Path(id));
INI_WriteInt(File,"Adminlevel",level);
INI_Close(File);
}
}
}
else
{
return 1;
}
return 1;
}