/setadmin problem.
#1

pawn Код:
CMD:setadmin(playerid, params[])
{
    new pID, value;
    if(PlayerInfo[playerid][pAdmin] < 1338 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, NOTADMIN);
    else if (sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, 0xFF0000AA, "Kasutus: /setadmin [playerid/partofname] [level 1-1338]"); //how to use it.
    else if (value < 0 || value > 1338) return SendClientMessage(playerid, 0xFF0000AA, "Vale level! Levelid: 0-1338"); //wrong level
    else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY,"Vale ID."); //wrong id
    else
    {
        new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        GetPlayerName(pID, tName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "Sa muutsid %s'i admini leveli %i peale.", tName, value); //you changed %s's alevel to %i.
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "Su adminlevel on nььd %i.", value); //your adminlevel is...
        SendClientMessage(pID, COLOR_WHITE, string);
        PlayerInfo[pID][pAdmin] = value;
    }
    return 1;
}
Here is the code. Problem is that in the game it says Wrong ID. Can somebody help me?
Reply
#2

pawn Код:
CMD:setadmin(playerid, params[])
{
    new pID, value;
    if(PlayerInfo[playerid][pAdmin] < 1338 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, NOTADMIN);
    if(sscanf(params, "ud", pID, value)) return SendClientMessage(playerid, 0xFF0000AA, "Kasutus: /setadmin [playerid/partofname] [level 1-1338]"); //how to use it.
    if(value < 0 || value > 1338) return SendClientMessage(playerid, 0xFF0000AA, "Vale level! Levelid: 0-1338"); //wrong level
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_GREY,"Vale ID."); //wrong id
    else
    {
        new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        GetPlayerName(pID, tName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "Sa muutsid %s'i admini leveli %d peale.", tName, value); //you changed %s's alevel to %i.
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "Su adminlevel on nььd %d.", value); //your adminlevel is...
        SendClientMessage(pID, COLOR_WHITE, string);
        PlayerInfo[pID][pAdmin] = value;
    }
    return 1;
}
Reply
#3

Still it doesnt work.
Reply
#4

pawn Код:
CMD:setadmin(playerid, params[])
{
    new pID, value;
    if(PlayerInfo[playerid][pAdmin] < 1338 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, NOTADMIN);
    else if (sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, 0xFF0000AA, "Kasutus: /setadmin [playerid/partofname] [level 1-1338]"); //how to use it.
    else if (value < 0 || value > 1338) return SendClientMessage(playerid, 0xFF0000AA, "Vale level! Levelid: 0-1338"); //wrong level
    else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY,"Vale ID."); //wrong id
    new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    GetPlayerName(pID, tName, MAX_PLAYER_NAME);
    format(string, sizeof(string), "Sa muutsid %s'i admini leveli %i peale.", tName, value); //you changed %s's alevel to %i.
    SendClientMessage(playerid, COLOR_WHITE, string);
    format(string, sizeof(string), "Su adminlevel on nььd %i.", value); //your adminlevel is...
    SendClientMessage(pID, COLOR_WHITE, string);
    PlayerInfo[pID][pAdmin] = value;
    return 1;
}
Reply
#5

Try this im shure it will work fine..thats the best..replace that /setadmin with this new one



Код:
if(strcmp(cmd, "/setadmin", true) == 0 
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /[s]et[a]dmin[l]evel [playerid/PartOfName] [level(1-1338)]");
				return 1;
			}
			new para1;
			new level;
			new playerlevel;
			para1 = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			level = strval(tmp);
			playerlevel = PlayerInfo[para1][pAdmin];
			if(PlayerInfo[playerid][pAdmin] >= 1337 || IsPlayerAdmin(playerid))
			{
			    if(IsPlayerConnected(para1))
			    {
			        if(para1 != INVALID_PLAYER_ID)
			        {
 						if(level == playerlevel)
						{
							SendClientMessage(playerid, COLOR_GREY, "** Player is already that level");
							return 1;
						}
						if(level >= 7 && level <= 1336) return SendClientMessage(playerid, COLOR_GREY,"* Only levels 0-6 and 1337-1338 Are allowed!");
						if(level < 0 || level > 1338) return SendClientMessage(playerid, COLOR_GREY,"* Only levels 0-6 and 1337-1338 Are allowed!");
						if(level > 4 && PlayerInfo[playerid][pAdmin] == 1337) return SendClientMessage(playerid, COLOR_GREY, "You can only promote admins to lvl 4 or below");
						if(playerlevel >= 5 && PlayerInfo[playerid][pAdmin] == 1337) return SendClientMessage(playerid, COLOR_GREY, "You can not demote Main Administrators or Above.");
						GetPlayerName(para1, giveplayer, sizeof(giveplayer));
						new Float:X, Float:Y, Float:Z;
						GetPlayerPos(para1, X,Y,Z);
						format(string, sizeof(string),"[ADMIN]: %s has set %s (%d)'s Level to: [%d]", sendername, giveplayer, para1, level);
						ABroadCast(COLOR_LIGHTRED, string, 5);
						format(string, sizeof(string), "** %s Gave You Admin Level: %d",sendername, level);
						SendClientMessage(para1, TEAM_GROVE_COLOR, string);
						if(level > PlayerInfo[para1][pAdmin])
						{
							format(string, sizeof(string), "Congratulations to %s. He is now Level: %d Admin !!!!",giveplayer, level);
							SendClientMessageToAll(COLOR_LIGHTBLUE, string);
                            PlayerPlaySound(para1, 1056, X, Y, Z);
                            GameTextForPlayer(para1, "~y~Promoted!",7500,3);
                            format(string, sizeof(string), "** You have promoted %s (%d) to level %d.", giveplayer, para1, level);
							SendClientMessage(playerid, COLOR_LIGHTRED, string);
							PlayerInfo[para1][pAdmin] = level;
							PlayerInfo[para1][pHelper] = 3;
							if(playerlevel == 0 && level >= 1)
							{
							    admins ++;
							}
						}
						else
						{
                            PlayerPlaySound(para1, 1055, X, Y, Z);
                            GameTextForPlayer(para1, "~r~Demoted!",7500,3);
                            format(string, sizeof(string), "** You have demoted %s (%d) to admin level %d.", giveplayer, para1, level);
							SendClientMessage(playerid, COLOR_LIGHTRED, string);
							PlayerInfo[para1][pAdmin] = level;
       						if(level == 0)
							{
								PlayerInfo[para1][pHelper] = 1;
								admins --;
							}
						}
						new y, m, d;
						new h,mi,s;
						getdate(y,m,d);
						gettime(h,mi,s);
						format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Gave to %s Admin Level: [%d].",d,m,y,h,mi,s,sendername,giveplayer,level);
						AdminLog(string);
						ChatLog(string);
						LoginLog(string);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
				return 1;
			}
		}
		return 1;
	}
Reply
#6

Код:
CMD:setadmin(playerid, params[])
{
    new pID, value adminname[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pAdmin] < 1338 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, NOTADMIN);
    else if (sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, 0xFF0000AA, "Kasutus: /setadmin [playerid/partofname] [level 1-1338]"); //how to use it.
    else if (value < 0 || value > 1338) return SendClientMessage(playerid, 0xFF0000AA, "Vale level! Levelid: 0-1338"); //wrong level
    else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY,"Vale ID."); //wrong id
    else
    {
        new string[128];
        GetPlayerName(pID, pName, sizeof(pName));
        GetPlayerName(playerid, adminname, sizeof(adminname));
        format(string, sizeof(string), "Sa muutsid %s'i admini leveli %i peale.", pName, value); //you changed %s's alevel to %i.
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "Su adminlevel on nььd %i.", value); //your adminlevel is...
        SendClientMessage(pID, COLOR_WHITE, string);
        PlayerInfo[pID][pAdmin] = value;
    }
    return 1;
}
try this one
Reply
#7

you may try:

pawn Код:
CMD:setadmin(playerid, params[])
{
    new pID, value;
    if(PlayerInfo[playerid][pAdmin] < 1338 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, NOTADMIN);
    else if (sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, 0xFF0000AA, "Kasutus: /setadmin [playerid/partofname] [level 1-1338]"); //how to use it.
    else if (value < 0 || value > 1338) return SendClientMessage(playerid, 0xFF0000AA, "Vale level! Levelid: 0-1338"); //wrong level
    else
    {
        if(IsPlayerConnected(playerid)) {
            new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
            GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
            GetPlayerName(pID, tName, MAX_PLAYER_NAME);
            format(string, sizeof(string), "Sa muutsid %s'i admini leveli %i peale.", tName, value); //you changed %s's alevel to %i.
            SendClientMessage(playerid, COLOR_WHITE, string);
            format(string, sizeof(string), "Su adminlevel on nььd %i.", value); //your adminlevel is...
            SendClientMessage(pID, COLOR_WHITE, string);
            PlayerInfo[pID][pAdmin] = value;
        }
        else {
            return SendClientMessage(playerid, COLOR_GREY,"Vale ID."); //wrong id
        }
    }
    return 1;
}
Reply
#8

Still, none of these didn't work.
Reply
#9

The /setadmin allow to set admin level to ONLINE players only?If yes,just delete:

pawn Код:
else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY,"Vale ID."); //wrong id
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)