Admin Announce Command
#1

Код:
	CMD:adminann(playerid, params[])
    {
		if(PlayerInfo[playerid][pAdminLevel] >= 2)
		{
			if(!params[8])
			{
				new str[128];
		        SendClientMessageToAll(COLOR_LIGHTBLUE, "|~~~~~~~~~~ Admin Announcement ~~~~~~~~~~|");
		        format(str, sizeof(str), "%s %s", str, params[0]);
		        SendClientMessageToAll(COLOR_GREEN, str);
		        SendClientMessageToAll(COLOR_LIGHTBLUE, "|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|");
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "USAGE: /adminann [text]");
			    return 1;
			}
		}
  		else
		{
			SendClientMessage(playerid, COLOR_GREY, "You are not an admin");
			return 1;
		}
		return 1;
    }
When I type /adminann ingame it comes up with Unknown Command :/
Reply
#2

pawn Код:
Par dйfaut Admin Announce Command
Code:

CMD:adminann(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminLevel] >= 2)
    {
        if(!params[8])
        {
        new str[128];
        SendClientMessageToAll(COLOR_LIGHTBLUE, "|~~~~~~~~~~ Admin Announcement~~~~~~~~~~|");
        format(str, sizeof(str), "%s %s", str, params[0]);
        SendClientMessageToAll(COLOR_GREEN, str);
                SendClientMessageToAll(COLOR_LIGHTBLUE,"|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|");
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /adminann [text]");
            return 1;
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "You are not an admin");
        return 1;
    }
    return 0;
    }
Reply
#3

Still Unknown Command?
Reply
#4

Код:
CMD:ann(playerid, params[])
{
    new msg[30];
    if(sscanf(params, "s[30]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /ann [msg]]");
    if(strlen(msg) < 1 || strlen(msg) > 30) return SendClientMessage(playerid, RED, "Your message can only contain 1-30 characters.");
    if(PlayerInfo[playerid][pAdminLevel] < 2) return SendClientMessage(playerid, RED, "Only admin level 2+ can use this command.");
	{
        format(fstr, sizeof(fstr), "~w~%s", msg);
        GameTextForAll(fstr, 5000, 5);
        new astring[64];
    	format(astring, sizeof(astring),"%s [%d] typed: /ann", GetName(playerid), playerid);
    	SendAdminMessage(GREY, astring);
    }
	return true;
}
Reply
#5

Try using sscanf...

SSCANF Version:
pawn Код:
CMD:adminann(playerid, params[])
{
    new message[100];
    if(PlayerInfo[playerid][pAdminLevel] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not an admin");
    if(sscanf(params,"s",message)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /adminann [text]");
    if(strlen(message) > 100) return SendClientMessage(playerid, COLOR_GREY, "Your message must not exceed 100 characters");
    new str[128];
    SendClientMessageToAll(COLOR_LIGHTBLUE, "|~~~~~~~~~~ Admin Announcement ~~~~~~~~~~|");
    format(str, sizeof(str), "%s", message);
    SendClientMessageToAll(COLOR_GREEN, str);
    SendClientMessageToAll(COLOR_LIGHTBLUE, "|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|");
    return 1;
}
NON-SSCANF Version:
pawn Код:
CMD:adminann(playerid,params[])
{
    if(PlayerInfo[playerid][pAdminLevel] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not an admin");
    if(!strlen(params)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /adminann [text]");
    if(strlen(params) > 100) return SendClientMessage(playerid, COLOR_GREY, "Your message must not exceed 100 characters");
    new str[128];
    SendClientMessageToAll(COLOR_LIGHTBLUE, "|~~~~~~~~~~ Admin Announcement ~~~~~~~~~~|");
    format(str, sizeof(str), "%s", params);
    SendClientMessageToAll(COLOR_GREEN, str);
    SendClientMessageToAll(COLOR_LIGHTBLUE, "|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|");
    return 1;
}
Reply
#6

It Works! And Thanks;

Can you by an chance help me with my /newb command aswell? As it shows the same error?

((Im a newbie scripter just started out 2 days ago so I may ask a lot of questions ))

pawn Код:
CMD:newb(playerid, params[])
    {
        if(params[4])
        {
            new str[128];
            GetPlayerName(playerid, str, sizeof(str));
            format(str, sizeof(str), "[NEWBIE]%s {FFFFFF}%s", str, params[0]);
            SendClientMessageToAll(COLOR_BLUE, str);
            new string[128];
            new Lname[MAX_PLAYER_NAME];
            new year, month, day;
            new Hour, Minute;
            GetPlayerName(playerid,Lname,sizeof(Lname));
            getdate(year, month, day);
            gettime(Hour, Minute);
            format(string,sizeof(string),"[%d/%d/%d :: %02d:%02d] - %s has used the command (%s) \r\n", day, month, year, Hour, Minute, Lname, params);
            cmdlog = fopen("files/logs/chat.txt", io_append);
            fwrite(cmdlog,string);
            fclose(cmdlog);
        }
        else
        {
            SendClientMessage(playerid,COLOR_GREY, "USAGE: /newb [question]");
            return 1;
        }
        return 1;
    }
Any Ideas?
Reply
#7

Код:
CMD:n(playerid, params[])
{
	if(IsNewbieMutted{playerid} == true) return  SendClientMessage(playerid, WHITE, "Elvis: You are mutted from newbie chat, you cant use it!");
    if(PlayerInfo[playerid][aLevel] == 1)
	{
        new msg[64];
        if(sscanf(params, "s[64]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /(n)ew [msg]");
        if(strlen(msg) < 1 || strlen(msg) > 64) return SendClientMessage(playerid, RED, "Your message can only contain 1-64 characters.");
        format(fstr, sizeof(fstr), "Trial Admin %s [%d]: %s", GetName(playerid), playerid, msg);
        SendClientMessageToAll(LIGHTBLUE, fstr);
    }
    else if(PlayerInfo[playerid][aLevel] == 2)
	{
        new msg[64];
        if(sscanf(params, "s[64]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /(n)ew [msg]");
        if(strlen(msg) < 1 || strlen(msg) > 64) return SendClientMessage(playerid, RED, "Your message can only contain 1-64 characters.");
        format(fstr, sizeof(fstr), "Server Admin %s [%d]: %s", GetName(playerid), playerid, msg);
        SendClientMessageToAll(LIGHTBLUE, fstr);
    }
    else if(PlayerInfo[playerid][aLevel] == 3)
	{
        new msg[64];
        if(sscanf(params, "s[64]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /(n)ew [msg]");
        if(strlen(msg) < 1 || strlen(msg) > 64) return SendClientMessage(playerid, RED, "Your message can only contain 1-64 characters.");
        format(fstr, sizeof(fstr), "Head Admin %s [%d]: %s", GetName(playerid), playerid, msg);
        SendClientMessageToAll(LIGHTBLUE, fstr);
    }
    else if(PlayerInfo[playerid][aLevel] == 4)
	{
        new msg[64];
        if(sscanf(params, "s[64]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /(n)ew [msg]");
        if(strlen(msg) < 1 || strlen(msg) > 64) return SendClientMessage(playerid, RED, "Your message can only contain 1-64 characters.");
        format(fstr, sizeof(fstr), "Owner %s [%d]: %s", GetName(playerid), playerid, msg);
        SendClientMessageToAll(LIGHTBLUE, fstr);
    }
    else if(PlayerInfo[playerid][hHelper] >= 1)
	{
        new msg[64];
        if(sscanf(params, "s[64]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /(n)ew [msg]");
        if(strlen(msg) < 1 || strlen(msg) > 64) return SendClientMessage(playerid, RED, "Your message can only contain 1-64 characters.");
        format(fstr, sizeof(fstr), "Head Helper %s [%d]: %s", GetName(playerid), playerid, msg);
        SendClientMessageToAll(LIGHTBLUE, fstr);
    }
	else if(PlayerInfo[playerid][Helper] >= 1)
	{
        new msg[64];
        if(sscanf(params, "s[64]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /(n)ew [msg]");
        if(strlen(msg) < 1 || strlen(msg) > 64) return SendClientMessage(playerid, RED, "Your message can only contain 1-64 characters.");
        format(fstr, sizeof(fstr), "Helper %s [%d]: %s", GetName(playerid), playerid, msg);
        SendClientMessageToAll(LIGHTBLUE, fstr);
    }
    else
    {
        new msg[64];
        if(sscanf(params, "s[64]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /(n)ew [msg]");
        if(strlen(msg) < 1 || strlen(msg) > 64) return SendClientMessage(playerid, RED, "Your message can only contain 1-64 characters.");
        format(fstr, sizeof(fstr), "Newbie %s [%d]: %s", GetName(playerid), playerid, msg);
        SendClientMessageToAll(LIGHTBLUE, fstr);
    }
    return true;
}

CMD:new(playerid, params[])
{
	if(IsNewbieMutted{playerid} == true) return  SendClientMessage(playerid, WHITE, "Elvis: You are mutted from newbie chat, you cant use it!");
    if(PlayerInfo[playerid][aLevel] == 1)
	{
        new msg[64];
        if(sscanf(params, "s[64]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /(n)ew [msg]");
        if(strlen(msg) < 1 || strlen(msg) > 64) return SendClientMessage(playerid, RED, "Your message can only contain 1-64 characters.");
        format(fstr, sizeof(fstr), "Trial Admin %s [%d]: %s", GetName(playerid), playerid, msg);
        SendClientMessageToAll(LIGHTBLUE, fstr);
    }
    else if(PlayerInfo[playerid][aLevel] == 2)
	{
        new msg[64];
        if(sscanf(params, "s[64]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /(n)ew [msg]");
        if(strlen(msg) < 1 || strlen(msg) > 64) return SendClientMessage(playerid, RED, "Your message can only contain 1-64 characters.");
        format(fstr, sizeof(fstr), "Server Admin %s [%d]: %s", GetName(playerid), playerid, msg);
        SendClientMessageToAll(LIGHTBLUE, fstr);
    }
    else if(PlayerInfo[playerid][aLevel] == 3)
	{
        new msg[64];
        if(sscanf(params, "s[64]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /(n)ew [msg]");
        if(strlen(msg) < 1 || strlen(msg) > 64) return SendClientMessage(playerid, RED, "Your message can only contain 1-64 characters.");
        format(fstr, sizeof(fstr), "Head Admin %s [%d]: %s", GetName(playerid), playerid, msg);
        SendClientMessageToAll(LIGHTBLUE, fstr);
    }
    else if(PlayerInfo[playerid][aLevel] == 4)
	{
        new msg[64];
        if(sscanf(params, "s[64]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /(n)ew [msg]");
        if(strlen(msg) < 1 || strlen(msg) > 64) return SendClientMessage(playerid, RED, "Your message can only contain 1-64 characters.");
        format(fstr, sizeof(fstr), "Owner %s [%d]: %s", GetName(playerid), playerid, msg);
        SendClientMessageToAll(LIGHTBLUE, fstr);
    }
    else if(PlayerInfo[playerid][hHelper] >= 1)
	{
        new msg[64];
        if(sscanf(params, "s[64]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /(n)ew [msg]");
        if(strlen(msg) < 1 || strlen(msg) > 64) return SendClientMessage(playerid, RED, "Your message can only contain 1-64 characters.");
        format(fstr, sizeof(fstr), "Head Helper %s [%d]: %s", GetName(playerid), playerid, msg);
        SendClientMessageToAll(LIGHTBLUE, fstr);
    }
	else if(PlayerInfo[playerid][Helper] >= 1)
	{
        new msg[64];
        if(sscanf(params, "s[64]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /(n)ew [msg]");
        if(strlen(msg) < 1 || strlen(msg) > 64) return SendClientMessage(playerid, RED, "Your message can only contain 1-64 characters.");
        format(fstr, sizeof(fstr), "Helper %s [%d]: %s", GetName(playerid), playerid, msg);
        SendClientMessageToAll(LIGHTBLUE, fstr);
    }
    else
    {
        new msg[64];
        if(sscanf(params, "s[64]", msg)) return SendClientMessage(playerid, RED, "[USAGE]: /(n)ew [msg]");
        if(strlen(msg) < 1 || strlen(msg) > 64) return SendClientMessage(playerid, RED, "Your message can only contain 1-64 characters.");
        format(fstr, sizeof(fstr), "Newbie %s [%d]: %s", GetName(playerid), playerid, msg);
        SendClientMessageToAll(LIGHTBLUE, fstr);
    }
    return true;
}
Reply
#8

pawn Код:
CMD:newb(playerid, params[])
{
    if(!strlen(params)) return SendClientMessage(playerid,COLOR_GREY, "USAGE: /newb [question]");
    new Lname[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid,Lname,sizeof(Lname));
    format(string, sizeof(string), "[NEWBIE]%s {FFFFFF}%s", Lname, params);
    SendClientMessageToAll(COLOR_BLUE, string);
    new year, month, day, Hour, Minute, Second;
    getdate(year, month, day);
    gettime(Hour, Minute, Second);
    format(string,sizeof(string),"[%d/%d/%d :: %02d:%02d:%02d] - %s has used the command /newb (%s) \r\n", day, month, year, Hour, Minute, Second, Lname, params);
    cmdlog = fopen("files/logs/chat.txt", io_append);
    fwrite(cmdlog,string);
    fclose(cmdlog);
    return 1;
}
The guy above me needs a [NEWBIE] tag...
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)