Whats Wrong ?
#1

Hi guys I made a cmd /makeadmin with sscanf but when I type /makeadmin 0 5 its sets my admin level to 0 ?


pawn Код:
dcmd_makeadmin(playerid, params[])
{
         new string[256],giveid,value;
        new sendername[MAX_PLAYER_NAME];
        new giveplayer[MAX_PLAYER_NAME];
            if (PlayerInfo[playerid][pAdminLevel] >= 4)
  {
        if (sscanf(params, "ud", giveid, value)) SendClientMessage(playerid,COLOR_BLUE,"**USAGE:/MakeAdmin [Playerid/PlayerName] [Level]");
        else
        {
                if (value > 5) return SendClientMessage(playerid, COLOR_GREY,"* Only levels 0-5 Are allowed!");
             GetPlayerName(playerid, sendername, sizeof(sendername));
             GetPlayerName(giveid, giveplayer, sizeof(giveplayer));
             PlayerInfo[giveid][pAdminLevel] = value ;
             format(string,sizeof(string),"Admin %s has set your Admin Level to %d",sendername,value);
             SendClientMessage(giveid,COLOR_RED,string);
             format(string,sizeof(string),"You gave %s admin level %d",giveplayer,value);
             SendClientMessage(playerid,COLOR_RED,string); }
        }
    return 1;
}
Reply
#2

Код:
if (sscanf(params, "dd", giveid, value)) SendClientMessage(playerid,COLOR_BLUE,"**USAGE:/MakeAdmin [Playerid/PlayerName] [Level]");
Or try this:

Код:
CMD:setadmin(playerid, params[])
{
	new otherId;
	new adminLevel;

	if(PlayerInfo[playerid][pLogged] == 0)
	    return SendClientMessage(playerid, COLOR_RED, "[Error]: Please login before using this command.");
 	if(PlayerInfo[playerid][pAdmin] < 3)
	    return SendClientMessage(playerid, COLOR_RED, ADMIN_CMD_ERROR);

	GetPlayerName(otherId, otherName, sizeof(otherName));
	GetPlayerName(playerid, playerName, sizeof(playerName));

	if(sscanf(params, "dd", otherId, adminLevel))
	{
	    SendClientMessage(playerid, COLOR_STEELBLUE, "[USAGE]: /setadmin [playerid] [Admin Level]");
	    return true;
	}

	if (PlayerInfo[otherId][pAdmin] == PlayerInfo[playerid][pAdmin])
	{
	format(stri, sizeof(stri), "[AdminSys]: You cannot demote/promote %s.",PlayerInfo[playerid][pName]);
	SendClientMessage(otherId, COLOR_YELLOW,stri);
	SendClientMessage(playerid, COLOR_RED, "[Error]: You are not allowed to demote/promote this Admin.");
	return 1;
	}

 	if(PlayerInfo[otherId][pAdmin] == adminLevel)
	{
	    format(stri, sizeof(stri), "[Error]: Player is already level %d.", adminLevel);
	    SendClientMessage(playerid, COLOR_RED, stri);
		return true;
	}

	if(!IsPlayerConnected(otherId))
	    return SendClientMessage(playerid, COLOR_RED, "[Error]: Invalid Player ID.");

	if(adminLevel > 4)
		return SendClientMessage(playerid, COLOR_RED, "[Error]: Level can't be higher than 4.");

	if(adminLevel < 0)
		return SendClientMessage(playerid, COLOR_RED, "[Error]: Level can't be lower than 0.");

	if(adminLevel > PlayerInfo[otherId][pAdmin]) {
	format(stri, sizeof(stri), "[AdminSys]: You have been promoted to level %d administrator, by admin %s", adminLevel, playerName);
	SendClientMessage(otherId, COLOR_YELLOW, stri);
	format(stri, sizeof(stri), "[AdminSys]: You have promoted %s to level %d administrator.", otherName, adminLevel);
	SendClientMessage(playerid, COLOR_YELLOW, stri); }
	if(adminLevel < PlayerInfo[otherId][pAdmin]) {
	format(stri, sizeof(stri), "[AdminSys]: You have been demoted to level %d administrator, by admin %s", adminLevel, playerName);
	SendClientMessage(otherId, COLOR_YELLOW, stri);
	format(stri, sizeof(stri), "[AdminSys]: You have demoted %s to level %d administrator.", otherName, adminLevel);
	SendClientMessage(playerid, COLOR_YELLOW, stri); }

	PlayerInfo[otherId][pAdmin] = adminLevel;

	SavePlayer(otherId);

	return true;
}
Reply
#3

Quote:
Originally Posted by FreshDoubleX
Посмотреть сообщение
Код:
if (sscanf(params, "dd", giveid, value)) SendClientMessage(playerid,COLOR_BLUE,"**USAGE:/MakeAdmin [Playerid/PlayerName] [Level]");
Don't fix it when it isn't broke. The 'u' (User) parameter is a perfectly acceptable input for sscanf.
Reply
#4

pawn Код:
dcmd_makeadmin(playerid, params[])
{
    if ( PlayerInfo[playerid][pAdminLevel] >= 4 )
        return 0;
           
    if ( sscanf(params, "ud", params[ 0 ], params[ 1 ] ) )
        return SendClientMessage(playerid,COLOR_BLUE,"**USAGE:/MakeAdmin [Playerid/PlayerName] [Level]");
           
    if ( params[ 1 ] > 5 ) return SendClientMessage(playerid, COLOR_GREY,"* Only levels 0-5 Are allowed!");
       
    new string[256],
        sendername[MAX_PLAYER_NAME],
        giveplayer[MAX_PLAYER_NAME]
    ;
    GetPlayerName(playerid, sendername, sizeof( sendername ) );
    GetPlayerName(params[ 0 ], giveplayer, sizeof( giveplayer ) );
    PlayerInfo[giveid][pAdminLevel] = params[ 1 ] ;
    format(string,sizeof(string),"Admin %s has set your Admin Level to %d",sendername,params[ 1 ]);
    SendClientMessage(giveid,COLOR_RED,string);
    format(string,sizeof(string),"You gave %s admin level %d",giveplayer, params[ 1 ]);
    SendClientMessage(playerid,COLOR_RED,string); }
    return 1;
}
I hope it works.

oh, and use ZCMD not DCMD...
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
Don't fix it when it isn't broke. The 'u' (User) parameter is a perfectly acceptable input for sscanf.
Oke, So if I have D instead of U then D is only user id ?
Reply
#6

Yes. 'u', however, can also accept player names.
Reply
#7

Ok on this CMD: command I have an error...

pawn Код:
CMD:heal(playerid, params[])
{
    new
        id,value;
        if (PlayerInfo[playerid][pAdminLevel] >= 4)
  {
    if (sscanf(params, "ud", id,value)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid> <Amount>\"");
    else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
    else
    {
        SetPlayerHealth(id, value);
        SendClientMessage(id, 0x00FF00AA, "You have been healed");
        SendClientMessage(playerid, 0x00FF00AA, "Player healed");
       }
    }
    return 1;
}
ERRor:
pawn Код:
warning 203: symbol is never used: "heal"
Reply
#8

Where do you get this warning ? I mean witch line ?
Reply
#9

Last+1 line...
Reply
#10

Any idea or is CMD: need any include or define ?
Reply
#11

CMD: needs ZCMD I think.
Reply
#12

SOLVED:I add zcmd.inc Thankx guys....
Reply
#13

Same bug by zcmd Then I did /makeadmin 0 5 it sets my level to 0
Reply
#14

Quote:
Originally Posted by iRana
Посмотреть сообщение
Same bug by zcmd Then I did /makeadmin 0 5 it sets my level to 0
*BUMP* How to fix it ??
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)