Help with acronyms scripting
#1

anyone can help me how can i add another cmd for this, "/admsg" i want it just to be "#" in shortcut but not totally will remove /admsg .. pls help me

Код:
dcmd_admsg(playerid,params[])
{
	new string[128];
	if(!strlen(params))
	{
	    SendClientMessage(playerid,COLOR_ERROR,"USAGE: /admsg (Message)");
	    return 1;
	}
	if(IsSpawned[playerid] == 0)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
	    return 1;
	}
	format(string,sizeof(string),"4[ADMIN CHAT] %s(%d): %s",PlayerName(playerid),playerid,params);
	IRC_GroupSay(gGroupAdminID,IRC_ADMINCHANNEL,string);
	for(new i=0; i<MAX_PLAYERS; i++)
	{
	    if(AdminLevel[i] >= 1)
	    {
	        format(string,sizeof(string),"[ADMIN CHAT] %s(%d): %s",PlayerName(playerid),playerid,params);
	        SendClientMessage(i,COLOR_ADMIN,string);
		}
	}
	return 1;
}
Reply
#2

any help plz?
Reply
#3

Go Under OnPlayerText and add;
pawn Код:
public OnPlayerText(playerid, text[])
{
if (text[0] == '#')
{
        format(string,sizeof(string),"4[ADMIN CHAT] %s(%d): %s",PlayerName(playerid),playerid,params);
    IRC_GroupSay(gGroupAdminID,IRC_ADMINCHANNEL,string);
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(AdminLevel[i] >= 1)
        {
            format(string,sizeof(string),"[ADMIN CHAT] %s(%d): %s",PlayerName(playerid),playerid,params);
            SendClientMessage(i,COLOR_ADMIN,string);
        }
    }
    return 1;
Reply
#4

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128];
    if(text[0] == '#' && AdminLevel[i] >= 1)
    {
        if(IsSpawned[playerid] == 0)
        {
            SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
            return 0;
        }
        format(string,sizeof(string),"4[ADMIN CHAT] %s(%d): %s",PlayerName(playerid),playerid,params);
        IRC_GroupSay(gGroupAdminID,IRC_ADMINCHANNEL,string);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(AdminLevel[i] >= 1)
            {
                format(string,sizeof(string),"[ADMIN CHAT] %s(%d): %s",PlayerName(playerid),playerid,params);
                SendClientMessage(i,COLOR_ADMIN,string);
                return 0;
            }
        }
    }
    return 0;
}
Reply
#5

The new command:
pawn Код:
dcmd_admsg(playerid,params[])
{
    if(!strlen(params)) return SendClientMessage(playerid,COLOR_ERROR,"USAGE: /admsg (Message)");
    if(!IsSpawned[playerid]) return SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
    new string[128];
    format(string, sizeof(string), "4[ADMIN CHAT] %s(%d): %s", PlayerName(playerid), playerid, params);
    IRC_GroupSay(gGroupAdminID, IRC_ADMINCHANNEL, string);
    format(string, sizeof(string), "[ADMIN CHAT] %s(%d): %s", PlayerName(playerid), playerid, params);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(!AdminLevel[i]) continue;
        SendClientMessage(i,COLOR_ADMIN,string);
    }
    return 1;
}
OnPlayerText:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '#')
    {
        if(AdminLevel[playerid])
        {
            if(IsSpawned[playerid])
            {
                new string[128];
                format(string, sizeof(string), "4[ADMIN CHAT] %s(%d): %s", PlayerName(playerid), playerid, text[1]);
                IRC_GroupSay(gGroupAdminID, IRC_ADMINCHANNEL, string);
                format(string, sizeof(string), "[ADMIN CHAT] %s(%d): %s", PlayerName(playerid), playerid, text[1]);
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(!IsPlayerConnected(i)) continue;
                    if(!AdminLevel[i]) continue;
                    SendClientMessage(i, COLOR_ADMIN, string);
                }
                return 0;
            }
        }
    }
    //Rest of code...
I know there may be a way to return a command, I know that for ZCMD it would be cmd_admsg, but for dcmd it would be this?:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '#')
    {
        if(AdminLevel[playerid])
        {
            dcmd_admsg(playerid, text[1]);
            return 0;
        }
    }
    //Rest of code...
}
Not sure what it is in dcmd though.

EDIT: @SyntaxQ and BenJackster, you should at least return 0 to stop admin chat from showing to all players. We can't predict his code.
Reply
#6

Oops I was too late..
Reply
#7

not this? coz i got errors, i want like this

Код:
CMD:reply(playerid, params[])
    {
        	new text[256], string[256];
            if(sscanf(params, "s[256]", text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /reply (message) - Enter your message");
            new pID = pInfo[playerid][Last];
            if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
            if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself.");
            format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", PlayerName(pID), pID);
            if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
            format(string, sizeof(string), "PM to %s: %s", PlayerName(pID), text);
        	SendClientMessage(playerid, COLOR_YELLOW, string);
        	format(string, sizeof(string), "PM from %s: %s", PlayerName(playerid), text);
        	SendClientMessage(pID, COLOR_YELLOW, string);
        	pInfo[pID][Last] = playerid;
            for (new i = 0; i < MAX_PLAYERS; i++)
            if (IsPlayerAdmin(i))
            {
                    format(string, sizeof(string), "PM: %s(%d) to %s(%d): %s", PlayerName(playerid), playerid, PlayerName(pID), pID, text);
                    {
                            if (IsPlayerAdmin(i))
                            SendClientMessage(i, COLOR_GREY, string);
                    }
            }
        	return 1;
    }
    CMD:r(playerid, params[]) return cmd_reply(playerid, params);
i just want like this, so its easy to just edit it.. plz?
Код:
CMD:r(playerid, params[]) return cmd_reply(playerid, params);
Reply
#8

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '#')
    {
        if(AdminLevel[playerid])
        {
            dcmd_admsg(playerid, text[1]);
            return 0;
        }
    }
    //Rest of code...
}
I posted it...

And are you using zcmd or dcmd? Don't use both..
Reply
#9

Quote:
Originally Posted by ******
Посмотреть сообщение
Don't call commands like that directly - they are human interfaces to your code, not internal interfaces to other parts of your code. Instead, abstract the bulk of the admin chat functionality to a standard function, and call that function from both commands and OnPlayerText.
If you don't understand the language of "smart", he means this:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '#')
    {
        if(AdminLevel[playerid])
        {
            if(IsSpawned[playerid])
            {
                new string[128];
                format(string, sizeof(string), "4[ADMIN CHAT] %s(%d): %s", PlayerName(playerid), playerid, text[1]);
                IRC_GroupSay(gGroupAdminID, IRC_ADMINCHANNEL, string);
                format(string, sizeof(string), "[ADMIN CHAT] %s(%d): %s", PlayerName(playerid), playerid, text[1]);
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(!IsPlayerConnected(i)) continue;
                    if(!AdminLevel[i]) continue;
                    SendClientMessage(i, COLOR_ADMIN, string);
                }
                return 0;
            }
        }
    }
    //Rest of code...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)