/asay?
#1

I have made a command and I don't know how to set it sp it just says Admin: Text.

pawn Код:
if (strcmp("/asay1", cmdtext, true, 10) == 0)
    {
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Error: You are not an admin");
        {
            new str[128];
            GetPlayerName(playerid, str, sizeof(str));
            format(str, sizeof(str), "Admin: %s %s", cmdtext);
            SendClientMessageToAll(COLOR_YELLOW, cmdtext);
        }
        return 1;
    }
Reply
#2

pawn Код:
if (strcmp("/asay1", cmdtext, true, 10) == 0)
    {
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Error: You are not an admin");
        {
            new name[128];
            new string[128];
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "Admin: %s %s", cmdtext,name);
            SendClientMessageToAll(COLOR_YELLOW, string);
        }
        return 1;
    }
try ..

or use dcmds
define
pawn Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
dcmd(asay1,5,cmdtext);

the command
pawn Код:
dcmd_asay1(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Error: You are not an admin");
    {
        if(!strlen(params)) return SendClientMessage(playerid, RED, "USAGE: /asay1 [text]");
        new string[128];
        new name[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(string,sizeof(string),"[ADMIN] %s: %s",name,params);
        SendClientMessageToAll(yourcolorE,string);
    }
    return 1;
}
idk if is correct
Reply
#3

pawn Код:
if(strcmp(cmd, "/asay", true) == 0 || strcmp(cmd, "/adminsay", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You havent logged in yet !");
                return 1;
            }
            if (PlayerInfo[playerid][pAdmin] < 1)
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   The OOC channel has been disabled by an Admin !");
                return 1;
            }
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USE: /asay [aooc chat]");
                return 1;
            }
            format(string, sizeof(string), "[AOOC] Admin says: %s ", result);
            OOCOff(0x62B382AA,string);
            printf("%s", string);
        }
        return 1;
    }
maybe that..
Reply
#4

Just gave me errors?
Код:
C:\Users\BooNii3\Los Santos Role Play Forums - Server\Los Santos Role Play - Server\gamemodes\Test.pwn(245) : error 017: undefined symbol "cmd"
C:\Users\BooNii3\Los Santos Role Play Forums - Server\Los Santos Role Play - Server\gamemodes\Test.pwn(249) : error 017: undefined symbol "gPlayerLogged"
C:\Users\BooNii3\Los Santos Role Play Forums - Server\Los Santos Role Play - Server\gamemodes\Test.pwn(249) : warning 215: expression has no effect
C:\Users\BooNii3\Los Santos Role Play Forums - Server\Los Santos Role Play - Server\gamemodes\Test.pwn(249) : error 001: expected token: ";", but found "]"
C:\Users\BooNii3\Los Santos Role Play Forums - Server\Los Santos Role Play - Server\gamemodes\Test.pwn(249) : error 029: invalid expression, assumed zero
C:\Users\BooNii3\Los Santos Role Play Forums - Server\Los Santos Role Play - Server\gamemodes\Test.pwn(249) : fatal error 107: too many error messages on one line
Also I just want a command that says Admin: Text but when he/she says it, it will not disable OOC...
Reply
#5

You should consider usin ZCMD/sscanf...its much easier and faster.
pawn Код:
CMD:asay(playerid, params[])
{
    new
        str[128],
        name[24]
    ;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You are not a admin!");
    {
        if(sscanf(params, "s[128]", str)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /asay <message>");
        GetPlayerName(playerid, name, 24);
        format(str, sizeof(str), "Admin Say %s: %s" name, str);
        SendClientMessageToAll(0xFF0000FF, str);
    }
    return 1;
}
Reply
#6

I will use that but I got these errors,
Код:
C:\Users\BooNii3\Los Santos Role Play Forums - Server\Los Santos Role Play - Server\gamemodes\Test.pwn(245) : error 029: invalid expression, assumed zero
C:\Users\BooNii3\Los Santos Role Play Forums - Server\Los Santos Role Play - Server\gamemodes\Test.pwn(245) : error 017: undefined symbol "cmd_asay"
C:\Users\BooNii3\Los Santos Role Play Forums - Server\Los Santos Role Play - Server\gamemodes\Test.pwn(245) : error 029: invalid expression, assumed zero
C:\Users\BooNii3\Los Santos Role Play Forums - Server\Los Santos Role Play - Server\gamemodes\Test.pwn(245) : fatal error 107: too many error messages on one line
I have tried using zcmd and sscanf before and got this error?
Reply
#7

pawn Код:
if (strcmp("/asay1", cmdtext, true, 10) == 0)
    {
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Error: You are not an admin");
        {
            new str[128];
            GetPlayerName(playerid, str, sizeof(str));
            strdel(cmdtext,0,6);
            format(str, sizeof(str), "Admin: %s %s", cmdtext);
            SendClientMessageToAll(COLOR_YELLOW, cmdtext);
        }
        return 1;
    }
I think this should work same (if not even faster, than the other ones).
Reply
#8

pawn Код:
CMD:asay(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Error: You are not an admin");

    new str[128];
    if(sscanf(params, "s", text)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /asay <text>");
    format(str, sizeof(str), "Admin: %s", str);
    SendClientMessageToAll(COLOR_YELLOW, str);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)