/setrankname command.
#1

I have made myself a setrankname command for factions but it doesn't work. Can someone look at it for me?

Код:
command(setrankname, playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 4)
	{
		new target, rankname, string[128];
		if(sscanf(params,"ui", target, rankname)) return SendClientMessage(playerid, GREY, "SYNTAX:{FFFFFF} /setrankname [ID] [rankname]");
		{
		    PlayerInfo[target][pRankName] = rankname;
			{
				format(string, sizeof(string), "WARN: You changed: %s's rankname to: %s", RPName(target), PlayerInfo[playerid][pRankName]);
        		SendClientMessage(playerid, ADMINBLUE, string);
        		format(string, sizeof(string), "WARN: %s has changed your rankname to: %s", RPName(playerid), PlayerInfo[playerid][pRankName]);
        		SendClientMessage(target, ADMINBLUE, string);
			}
		}
	}
	return 1;
}
Thanks.
Reply
#2

I assume that 'rankname' is suppose to be a string, however you have it set up to be checked as a integer under sscanf.

pawn Код:
command(setrankname, playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 4)
    {
        new target, rankname[24], string[128]; //change [24] to however long you want the rank name to be at maximum
        if(sscanf(params,"us[24]", target, rankname)) return SendClientMessage(playerid, GREY, "SYNTAX:{FFFFFF} /setrankname [ID] [rankname]");
        {
            PlayerInfo[target][pRankName] = rankname;
            {
                format(string, sizeof(string), "WARN: You changed: %s's rankname to: %s", RPName(target), PlayerInfo[playerid][pRankName]);
                SendClientMessage(playerid, ADMINBLUE, string);
                format(string, sizeof(string), "WARN: %s has changed your rankname to: %s", RPName(playerid), PlayerInfo[playerid][pRankName]);
                SendClientMessage(target, ADMINBLUE, string);
            }
        }
    }
    return 1;
}
If you get an error related to
Код:
PlayerInfo[target][pRankName] = rankname;
, try using this.

pawn Код:
format(string, sizeof(string), "%s", rankname);
PlayerInfo[target][pRankName] = string;
That should fix it if an error shows up.
Reply
#3

Quote:
Originally Posted by DTV
Посмотреть сообщение
I assume that 'rankname' is suppose to be a string, however you have it set up to be checked as a integer under sscanf.

pawn Код:
command(setrankname, playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 4)
    {
        new target, rankname[24], string[128]; //change [24] to however long you want the rank name to be at maximum
        if(sscanf(params,"us[24]", target, rankname)) return SendClientMessage(playerid, GREY, "SYNTAX:{FFFFFF} /setrankname [ID] [rankname]");
        {
            PlayerInfo[target][pRankName] = rankname;
            {
                format(string, sizeof(string), "WARN: You changed: %s's rankname to: %s", RPName(target), PlayerInfo[playerid][pRankName]);
                SendClientMessage(playerid, ADMINBLUE, string);
                format(string, sizeof(string), "WARN: %s has changed your rankname to: %s", RPName(playerid), PlayerInfo[playerid][pRankName]);
                SendClientMessage(target, ADMINBLUE, string);
            }
        }
    }
    return 1;
}
If you get an error related to
Код:
PlayerInfo[target][pRankName] = rankname;
, try using this.

pawn Код:
format(string, sizeof(string), "%s", rankname);
PlayerInfo[target][pRankName] = string;
That should fix it if an error shows up.
I changed the "PlayerInfo[target][pRankName] = rankname;" to the pawn you said along with the rankname being [24] characters, I still got this error "error 047: array sizes do not match, or destination array is too small" on the line that has the code: "PlayerInfo[target][pRankName] = rankname;"

Thanks for the help.
Reply
#4

Quote:
Originally Posted by OMonger
Посмотреть сообщение
I changed the "PlayerInfo[target][pRankName] = rankname;" to the pawn you said along with the rankname being [24] characters, I still got this error "error 047: array sizes do not match, or destination array is too small" on the line that has the code: "PlayerInfo[target][pRankName] = rankname;"

Thanks for the help.
pawn Код:
format( PlayerInfo[target][pRankName], 24, "%s", rankname );
Reply
#5

Quote:
Originally Posted by LetsOWN[PL]
Посмотреть сообщение
pawn Код:
format( PlayerInfo[target][pRankName], 24, "%s", rankname );
Same error.
Reply
#6

Fixed. thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)