Unknow command
#1

i maked this two commands, and IG its saying, Unknow commands

pawn Код:
command(setadminlevel, playerid, params[])
{
    new targetid, type, string[128], string1[128];
    if(sInfo[playerid][Adminlevel] >= 6 && IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You can't use this command");
    if(sscanf(params, "ui", targetid, type)) SendClientMessage(playerid, COLOR_GREY, "USAGE: /setadminlevel [PlayerID] [level 0-6]");
    if(type < 0 || type > 6) return SendClientMessage(playerid, COLOR_GREY, "SERVER: Cannot go under 0 or above 6.");
    {
        format(string, sizeof(string), "Your Admin Level has been set to level %d", type);
        SendClientMessage(targetid, ADMINBLUE, string);
        format(string1, sizeof(string1), "You've set the Admin Level from %s to level %d", RPName(targetid), type);
        SendClientMessage(playerid, ADMINBLUE, string1);
        sInfo[targetid][Adminlevel] = type;
    }
    return 1;
}

command(changeadminpass, playerid, params[])
{
    new iu, string[128], code;
    if(sInfo[playerid][Adminlevel] >= 6 && IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You can't use this command");
    {
        sInfo[iu][AdminCode] = code;
        format(string, sizeof(string), "You have changed the Admin Code from %s to %d", RPName(iu), code);
        SendClientMessage(playerid, ADMINBLUE, string);
        format(string, sizeof(string), "%s has changed your Admin Code to %d", RPName(playerid), code);
        SendClientMessage(playerid, ADMINBLUE, string);
    }
    return 1;
}
Reply
#2

your code is correct, try using zcmd

Код:
#include <zcmd>

CMD:setadminlevel(playerid, params[])
{
	new targetid, type, string[128], string1[128];
	if(sInfo[playerid][Adminlevel] >= 6 && IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You can't use this command");
	if(sscanf(params, "ui", targetid, type)) SendClientMessage(playerid, COLOR_GREY, "USAGE: /setadminlevel [PlayerID] [level 0-6]");
	if(type < 0 || type > 6) return SendClientMessage(playerid, COLOR_GREY, "SERVER: Cannot go under 0 or above 6.");
	{
		format(string, sizeof(string), "Your Admin Level has been set to level %d", type);
  		SendClientMessage(targetid, ADMINBLUE, string);
  		
		format(string1, sizeof(string1), "You've set the Admin Level from %s to level %d", RPName(targetid), type);
        SendClientMessage(playerid, ADMINBLUE, string1);
        
		sInfo[targetid][Adminlevel] = type;
	}
	return 1;
}

CMD:changeadminpass(playerid, params[])
{
	new iu, string[128], code;
	if(sInfo[playerid][Adminlevel] >= 6 && IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You can't use this command");
	{
		sInfo[iu][AdminCode] = code;
		
		format(string, sizeof(string), "You have changed the Admin Code from %s to %d", RPName(iu), code);
		SendClientMessage(playerid, ADMINBLUE, string);
		
		format(string, sizeof(string), "%s has changed your Admin Code to %d", RPName(playerid), code);
		SendClientMessage(playerid, ADMINBLUE, string);
	}
	return 1;
}
Reply
#3

Well the changeadminpass command doesn't even look finished, variable iu will always be 0.

As for setadminlevel, you should varify that targetid is valid before using it as an index. If sscanf can't find the player, it will return INVALID_PLAYER_ID for targetid and when you try to access sInfo[targetid] it will most likely cause an array out of bounds error which might be the reason for your problem.

It is likely that there is some runtime error, if you would use "crashdetect" plugin it may give us more info.
Reply
#4

pawn Код:
command(changeadminpass, playerid, params[])
{
    new iu, string[128], code;
    if(sInfo[playerid][Adminlevel] >= 6 && IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You can't use this command");
    if(sscanf(params, "ud", iu, code)) SendClientMessage(playerid, WHITE, "SYNTAX: /changeadmincode [playerid] [code]");
    {
        sInfo[iu][AdminCode] = code;

        format(string, sizeof(string), "You have changed the Admin Code from %s to %d", RPName(iu), code);
        SendClientMessage(playerid, ADMINBLUE, string);

        format(string, sizeof(string), "%s has changed your Admin Code to %d", RPName(playerid), code);
        SendClientMessage(iu, ADMINBLUE, string);
    }
    return 1;
}
pawn Код:
command(setadminlevel, playerid, params[])
{
    new iu, type, string[128];
    if(sInfo[playerid][Adminlevel] >= 6 && IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You can't use this command");
    if(sscanf(params, "ui", iu, type)) SendClientMessage(playerid, COLOR_GREY, "USAGE: /setadminlevel [PlayerID] [level 0-6]");
    if(type < 0 || type > 6) return SendClientMessage(playerid, COLOR_GREY, "SERVER: Cannot go under 0 or above 6.");
    {
        format(string, sizeof(string), "Your Admin Level has been set to level %d", type);
        SendClientMessage(iu, ADMINBLUE, string);

        format(string, sizeof(string), "You've set the Admin Level from %s to level %d", RPName(iu), type);
        SendClientMessage(playerid, ADMINBLUE, string);

        sInfo[iu][Adminlevel] = type;
    }
    return 1;
}
Edited, and changed, but still the same errors
Reply
#5

Which gamemode are you using?
Reply
#6

Quote:
Originally Posted by Mouiz
Посмотреть сообщение
Which gamemode are you using?
One that doesn't exist yet, i'm creating one from scratch
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)