SA-MP Forums Archive
Whats Wrong ? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Whats Wrong ? (/showthread.php?tid=192652)



Whats Wrong ? - iRana - 23.11.2010

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;
}



Re: Whats Wrong ? - FreshDoubleX - 23.11.2010

Код:
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;
}



Re: Whats Wrong ? - Vince - 23.11.2010

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.


Re: Whats Wrong ? - Zh3r0 - 23.11.2010

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...


Re: Whats Wrong ? - FreshDoubleX - 23.11.2010

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 ?


Re: Whats Wrong ? - Vince - 23.11.2010

Yes. 'u', however, can also accept player names.


Re: Whats Wrong ? - iRana - 24.11.2010

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"



Re: Whats Wrong ? - FreshDoubleX - 24.11.2010

Where do you get this warning ? I mean witch line ?


Re: Whats Wrong ? - iRana - 25.11.2010

Last+1 line...


Re: Whats Wrong ? - iRana - 25.11.2010

Any idea or is CMD: need any include or define ?


Re: Whats Wrong ? - Basicz - 25.11.2010

CMD: needs ZCMD I think.


Re: Whats Wrong ? - iRana - 25.11.2010

SOLVED:I add zcmd.inc Thankx guys....


Re: Whats Wrong ? - iRana - 25.11.2010

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


Re: Whats Wrong ? - iRana - 25.11.2010

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 ??