Promoted and Demoted
#1

Hey guys. This is my /setlevel cmd. When I increase a person's level it shows Promoted, when I decrease there level it still shows them Promoted. While it should show promoted on increase and demoted on decrease. Please tell me what i need to add.
Pawn Code:
Код:
CMD:setlevel(playerid, params[])
{
    new level, aname[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][AdminLevel] <= 6 ) return SendClientMessage(playerid, COLOR_RED, "You must be atleast Lvl 7 Admin to use this command!");
    new targetid;
    if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /setlevel [PlayerID][Level]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player is not connected to the server");
    if(level < 0 || level > 10) return SendClientMessage(playerid, COLOR_RED, "Admin Level Range Is From 0 To 10");
	if(targetid != INVALID_PLAYER_ID)
	{
		new string1[90], tname[MAX_PLAYER_NAME], string2[90], file[300];
	    PlayerInfo[targetid][AdminLevel]=level;
	   	GetPlayerName(targetid, tname, sizeof(tname));
		format(file,sizeof(file),"nAdmin/Users/%s.ini",tname);
	    dini_IntSet(file,"AdminLevel",level);
	    GetPlayerName(playerid, aname, sizeof(aname));
	    format(string1, sizeof(string1), "Admin %s has set your Admin level to %i", aname, level);
	    SendClientMessage(targetid, COLOR_GREEN, string1);
	    GameTextForPlayer(targetid, "Promoted!", 2000, 5);
	    format(string2, sizeof(string1), "{00FF00}Admin %s has set %s's Admin level to %i", aname, tname, level);
	    SendClientMessageToAll(COLOR_YELLOW, string2);
	    SendCommandToAdmins(playerid,"/setlevel");
	    format(string1, sizeof(string1), "%s has set %s's Admin Level to %d", aname, tname, level);
		SaveIn("SetLevelLog",string1);
	}
	else return SendClientMessage(playerid, COLOR_RED, "ERROR: invalid playerid");
    return 1;
}
Reply
#2

You should check whether the parameter "level" is higher or lower than the admin level that the player already has.

Thus:
pawn Код:
if(PlayerInfo[targetid][AdminLevel] < level)
{
    //Promote
}
else
{
    //Demote
}
Reply
#3

can u please tell me the exact code since i m a newbie at scripting
Reply
#4

This should work. Didn't test it though.

pawn Код:
CMD:setlevel(playerid, params[])
{
    new level, aname[MAX_PLAYER_NAME], targetid, string1[90], tname[MAX_PLAYER_NAME], string2[90], file[300];
    if(PlayerInfo[playerid][AdminLevel] <= 6) return SendClientMessage(playerid, COLOR_RED, "You must be at least level 7 admin to use this command!");
    if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /setlevel [PlayerID][Level]");
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "That player is not connected to the server");
    if(level < 0 || level > 10) return SendClientMessage(playerid, COLOR_RED, "Admin Level Range Is From 0 To 10");
    if(PlayerInfo[playerid][AdminLevel] < level)
    {
        GetPlayerName(targetid, tname, sizeof(tname));
        format(file, sizeof(file), "nAdmin/Users/%s.ini", tname);
        dini_IntSet(file, "AdminLevel", level);
        GetPlayerName(playerid, aname, sizeof(aname));
        format(string1, sizeof(string1), "Admin %s has set your admin level to %i", aname, level);
        SendClientMessage(targetid, COLOR_GREEN, string1);
        GameTextForPlayer(targetid, "Promoted!", 2000, 5);
        format(string2, sizeof(string1), "{00FF00}Admin %s has set %s's Admin level to %i", aname, tname, level);
        SendClientMessageToAll(COLOR_YELLOW, string2);
        SendCommandToAdmins(playerid,"/setlevel");
        format(string1, sizeof(string1), "%s has set %s's Admin Level to %d", aname, tname, level);
        SaveIn("SetLevelLog",string1);
    }
    else
    {
        GetPlayerName(targetid, tname, sizeof(tname));
        format(file, sizeof(file), "nAdmin/Users/%s.ini", tname);
        dini_IntSet(file, "AdminLevel", level);
        GetPlayerName(playerid, aname, sizeof(aname));
        format(string1, sizeof(string1), "Admin %s has set your admin level to %i", aname, level);
        SendClientMessage(targetid, COLOR_GREEN, string1);
        GameTextForPlayer(targetid, "Demoted!", 2000, 5);
        format(string2, sizeof(string1), "{00FF00}Admin %s has set %s's Admin level to %i", aname, tname, level);
        SendClientMessageToAll(COLOR_YELLOW, string2);
        SendCommandToAdmins(playerid,"/setlevel");
        format(string1, sizeof(string1), "%s has set %s's Admin Level to %d", aname, tname, level);
        SaveIn("SetLevelLog",string1);
    }
    PlayerInfo[targetid][AdminLevel] = level;
    return 1;
}
Reply
#5

thanx dude worked like a charm...

+rep for u

-----Thread Closed-----
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)