Need help a Simple chat not working.
#1

pawn Код:
CMD:n(playerid, params[])
{
    if(PlayerInfo[playerid][pNMuted] == 0)
    {
        new
            Message[128];
        if(sscanf(params, "z", Message))
        {
         SendClientMessage(playerid, ERROR, "SYNTAX: /n [message]");
        }
        else
        {
      if(PlayerInfo[playerid][pAdmin] >= 1)
            {
                new
                    MsgStr[128];
                format(MsgStr, sizeof(MsgStr), "Admin %s: %s", GetName(playerid), Message);
                SendNewbieMessage(MsgStr);
            }
            else if(PlayerInfo[playerid][pHelper] == 1)
            {
                new
                    MsgStr[128];
                format(MsgStr, sizeof(MsgStr), "Helper %s: %s", GetName(playerid), Message);
                SendNewbieMessage(MsgStr);
            }
            else if(PlayerInfo[playerid][pHelper] == 2)
            {
                new
                    MsgStr[128];
                format(MsgStr, sizeof(MsgStr), "Mod Helper %s: %s", GetName(playerid), Message);
                SendNewbieMessage(MsgStr);
            }
            else if(PlayerInfo[playerid][pHelper] < 1 && PlayerInfo[playerid][pAdmin] < 1)
            {
                new
                    MsgStr[128];
                format(MsgStr, sizeof(MsgStr), "Newbie %s: %s", GetName(playerid), Message);
                SendNewbieMessage(MsgStr);

                PlayerInfo[playerid][pNMuted] = 1;
                SetTimerEx("NSpamTimer", 4000, false, "d", playerid);
            }
        }
    }
    else
    {
       
        SendClientMessage(playerid, ERROR, "You are muted from the newbie chat.");
    }
    return 1;
}
The problem is the chat is not working properly when there is admin online then only it worx but with a Problem.

When i type /n it dosent show Usage: /n [message]
it shows the message to all that Admin/Helper/Helper Mod %s:

PLZ HELP ME
Reply
#2

Beacuse use
pawn Код:
if(sscanf(params, "s[128]", Message))
not "z"

Note:

Z(string)[length] Invalid optional string
z(string)[length] Deprecated optional string

S(string)[length] Optional string
s[length] String

You need a lenth by using s or z for exemple s[128] as i put above
Reply
#3

But i can use it if only a Admin is online.
Reply
#4

I dont have the full code to verify everything. Acctualy that command for me is 100% working.
Reply
#5

I will give you the Full Code
Reply
#6

I didnt found any notice but you can also try this:

pawn Код:
CMD:n(playerid, params[])
{
        if(PlayerInfo[playerid][pNMuted] == 0)
        {
            new
                        Message[128];
            if(sscanf(params, "s[128]", Message))
            {
         SendClientMessage(playerid, ERROR, "Usage: /n [Message]");
            }
            else
            {
                    if(PlayerInfo[playerid][pHelper] < 1 && PlayerInfo[playerid][pAdmin] < 1)
                    {
                                new
                                        MsgStr[128];
                                format(MsgStr, sizeof(MsgStr), "Newbie %s: %s", GetName(playerid), Message);
                                SendClientMessageToAll(COLOR_GREEN, MsgStr);
 
                                PlayerInfo[playerid][pNMuted] = 1;
                                SetTimerEx("NSpamTimer", 4000, false, "d", playerid);
                        }

                    else if(PlayerInfo[playerid][pAdmin] >= 1)
                    {
                                new
                                        MsgStr[128];
                                format(MsgStr, sizeof(MsgStr), "* Admin %s: %s", GetName(playerid), Message);
                                SendClientMessageToAll(COLOR_GREEN, MsgStr);
                        }
                    else if(PlayerInfo[playerid][pHelper] == 1)
                    {
                                new
                                        MsgStr[128];
                                format(MsgStr, sizeof(MsgStr), "* Helper %s: %s", GetName(playerid), Message);
                                SendClientMessageToAll(COLOR_GREEN, MsgStr);
                        }
                    else if(PlayerInfo[playerid][pHelper] == 2)
                    {
                                new
                                        MsgStr[128];
                                format(MsgStr, sizeof(MsgStr), "* Helper Mod %s: %s", GetName(playerid), Message);
                                SendClientMessageToAll(COLOR_GREEN, MsgStr);
                        }
                }
        }
        else
        {
               
            SendClientMessage(playerid, ERROR, "You are muted from the newbie chat.");
        }
        return 1;
}
P.S Optimize the code beacuse i couldnt here.
Reply
#7

Nop it not worked still when i am not admin then i cant use it.
Reply
#8

Try to use this then:

pawn Код:
CMD:n(playerid, params[])
{
    if(PlayerInfo[playerid][pNMuted] == 0) SendClientMessage(playerid, ERROR, "You are muted from the newbie chat.");
    new
        Message[128];
    if(sscanf(params, "s[128]", Message))
    {
        SendClientMessage(playerid, ERROR, "Usage: /n [Message]");
    }
    else
    {
        if(PlayerInfo[playerid][pHelper] < 1 && PlayerInfo[playerid][pAdmin] < 1)
        {
            new
                MsgStr[128];
            format(MsgStr, sizeof(MsgStr), "Newbie %s: %s", GetName(playerid), Message);
            SendClientMessageToAll(COLOR_GREEN, MsgStr);
            PlayerInfo[playerid][pNMuted] = 1;
            SetTimerEx("NSpamTimer", 4000, false, "d", playerid);
        }
        else
        {
            if(PlayerInfo[playerid][pAdmin] >= 1)
            {
                new
                    MsgStr[128];
                format(MsgStr, sizeof(MsgStr), "* Admin %s: %s", GetName(playerid), Message);
                SendClientMessageToAll(COLOR_GREEN, MsgStr);
            }
            else if(PlayerInfo[playerid][pHelper] == 1)
            {
                new
                    MsgStr[128];
                format(MsgStr, sizeof(MsgStr), "* Helper %s: %s", GetName(playerid), Message);
                SendClientMessageToAll(COLOR_GREEN, MsgStr);
            }
            else if(PlayerInfo[playerid][pHelper] == 2)
            {
                new
                    MsgStr[128];
                format(MsgStr, sizeof(MsgStr), "* Helper Mod %s: %s", GetName(playerid), Message);
                SendClientMessageToAll(COLOR_GREEN, MsgStr);
            }
        }
    }
    return 1;
}
Reply
#9

It just says that YOu are Muted from newbie chat.
Reply
#10

It says that you are muted from newbie chat.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)