My chat commands don't work..
#1

When I type in /b, or /d or any other channel on the server it just tells me the command and how to use it, for example if I type "/b Hey!" it would appear as "/B [OOC CHAT]" in the chat box.

Here's the script..

pawn Код:
CMD:b(playerid, text[])
{
    if(PlayerMuteInfo[playerid][AllMuted])
    {
        SendClientMessage(playerid, TEAM_CYAN_COLOR, "   You can't speak, you have been silenced from all chats!");
        return 1;
    }
    new result[81];
    if(!sscanf(text, "s[81]", result))
    {
        new string3[128];
        if(AdminDuty[playerid])
        {
            if(PlayerInfo[playerid][pAdmin] == 1)
            {
                format(string3, sizeof(string3), "<Mod>%s%s says: (( %s ))", Accent[playerid], PlayerNameEx(playerid), result);
            }
            else
            {
                format(string3, sizeof(string3), "<%d Admin>%s%s says: (( %s ))", PlayerInfo[playerid][pAdmin], Accent[playerid], PlayerNameEx(playerid), result);
            }
        }
        else
        {
            format(string3, sizeof(string3), "%s%s says: (( %s ))", Accent[playerid], PlayerNameEx(playerid), result);
        }
        ProxDetector(20.0, playerid, string3,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        printf("%s", string3);
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /B [OOC chat]");
    }
    return 1;
}
Reply
#2



Disregard this. Was completely off.
Thanks irinel1996. ^^
Reply
#3

Quote:
Originally Posted by shitbird
Посмотреть сообщение
pawn Код:
if(!sscanf(text, "s[81]", result))
=

pawn Код:
if(sscanf(text, "s[81]", result))
Edit: Also, you don't have to use SSCANF when you're only dealing with one parameter, which you are, in this case.
I think is correct what is he doing, because this returns the message just using /b:
pawn Код:
if(sscanf(text,"s[81]",result)) return SendClientMessage(playerid,-1,"Usage: /b [Text]");
You'll get the message if you write just /b.
__________________
Where's the problem? I can't really see it.
I will test the command.
Reply
#4

The problem is if you type /b and anything after it, it will just return

pawn Код:
else
    {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /B [OOC chat]");
    }
    return 1;
}
So for instance if I typed "/b Hi!!", it would just return "USAGE: /B [OOC CHAT]" It does it for all chats, /r, /d, /w, /n...

Could it be due to this line..
pawn Код:
if(PlayerMuteInfo[playerid][AllMuted])
Shouldn't it be this..
pawn Код:
if(PlayerMutedInfo[playerid] [pMuted] == 1)
Reply
#5

Try this. Untested. Let me know if it returns any errors.
pawn Код:
CMD:b(playerid, params[])
{
    new
        str[128];
       
    if (!strlen(params[0])) {
        SendClientMessage(playerid, -1, "Error: parameter is missing.");
    }
   
    else
    {
        if(AdminDuty[playerid])
        {
            switch(PlayerInfo[playerid][pAdmin])
            {
                case 0: format(str, sizeof(string), "%s %s says: (( %s ))", Accent[playerid], PlayerNameEx(playerid), params[0]);
                case 1: format(str, sizeof(string), "<Mod> %s %s says: (( %s ))", Accent[playerid], PlayerNameEx(playerid), params[0]);
                case 2: format(str, sizeof(string), "<Admin> %s %s says: (( %s ))", Accent[playerid], PlayerNameEx(playerid), params[0]);
            }
        }
        ProxDetector(20.0, playerid, str, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        printf("%s", str);
    }
    return 1;
}
You don't need to use sscanf when dealing with one parameter only.
Are you running the latest updated version of sscanf also?
Reply
#6

If you're using the sscanf include (NOT the plugin, the stock sscanf(...) code), then change:
pawn Код:
if(!sscanf(text, "s[81]", result))
to
pawn Код:
if(!sscanf(text, "s", result))
Reply
#7

Ah, the problem was sscanf not being up-to date.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)