Mute - Command
#1

Hello all, it's been long since I've scripted so i'm having some problems getting this command fixed

pawn Код:
new Muted[MAX_PLAYERS];


CMD:mute(playerid, params[])
{
    if(pInfo[playerid][Admin] >= 1)
    {
        new id,msg1[128],msg2[128];
        if(!sscanf(params, "uS[40]", id))
        {
            if(playerid == id)
            {
              if(IsPlayerConnected(id))
              {
                if(isnull(msg1,msg2))
                {
                    new string[200];
                    new string2[200];
                    format(string,sizeof(string)," You have been Muted by Admin ( %s ) Reason: No reason specified.",pInfo[playerid][playername]);
                    format(string2,sizeof(string2),"You have muted Player ( %s ) Reason: No reason specified.",pInfo[id][playername]);
                    SendClientMessage(id,COLOR_ADMIN,string);
                    SendClientMessage(playerid,COLOR_ADMIN,string2);
                    Muted[id] = 1;
                } else {
                    new string[200];
                    new string2[200]
                    format(string,sizeof(string),"AdminCMD: You have been Muted by Admin ( %s ) Reason: %s.",pInfo[playerid][playername],msg1);
                    format(string2,sizeof(string2),"AdminCMD: You have Muted Player ( %s ) Reason: %s.",pInfo[id][playername],msg2);
                    SendClientMessage(id,COLOR_ADMIN,string);
                    SendClientMessage(playerid,COLOR_ADMIN,string2);
                    Muted[id] = 1;
                }
              } else SendError(playerid, "This player is not Connected!");
            } else SendError(playerid, "You can't mute yourself!");
        } else SendError(playerid," Syntax: /Mute <playerid> [reason]");
    } else SendError(playerid," You don't have enough priviliges");
    return 1;
}
errors
Код:
admin.pwn(57) : error 001: expected token: ";", but found "-identifier-"
admin.pwn(77) : error 033: array must be indexed (variable "Muted")
Reply
#2

pawn Код:
CMD:mute(playerid, params[])
{
    if(pInfo[playerid][Admin] >= 1)
    {
        new id,msg1[128],msg2[128];
        new string[200],string2[200];
        if(!sscanf(params, "uS[40]", id))
        {
            if(playerid == id)
            {
              if(IsPlayerConnected(id))
              {
                if(isnull(msg1,msg2))
                {
                   
                    format(string,sizeof(string)," You have been Muted by Admin ( %s ) Reason: No reason specified.",pInfo[playerid][playername]);
                    format(string2,sizeof(string2),"You have muted Player ( %s ) Reason: No reason specified.",pInfo[id][playername]);
                    SendClientMessage(id,COLOR_ADMIN,string);
                    SendClientMessage(playerid,COLOR_ADMIN,string2);
                    Muted[id] = 1;
                } else {
                    format(string,sizeof(string),"AdminCMD: You have been Muted by Admin ( %s ) Reason: %s.",pInfo[playerid][playername],msg1);
                    format(string2,sizeof(string2),"AdminCMD: You have Muted Player ( %s ) Reason: %s.",pInfo[id][playername],msg2);
                    SendClientMessage(id,COLOR_ADMIN,string);
                    SendClientMessage(playerid,COLOR_ADMIN,string2);
                    Muted[id] = 1;
                }
              } else SendError(playerid, "This player is not Connected!");
            } else SendError(playerid, "You can't mute yourself!");
        } else SendError(playerid," Syntax: /Mute <playerid> [reason]");
    } else SendError(playerid," You don't have enough priviliges");
    return 1;
}
Reply
#3

pawn Код:
new string[200];
new string2[200]
You miss a semicolor at the end of the second one.

You can use only a string with size of 128, it's really pointless what you did there (2 arrays with size of 200).

Which is the line 77?
Reply
#4

grr ballu beat me to it, so instead of double posting, removed.
Reply
#5

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
pawn Код:
CMD:mute(playerid, params[])
{
    if(pInfo[playerid][Admin] >= 1)
    {
        new id,msg1[128],msg2[128];
        new string[200],string2[200];
        if(!sscanf(params, "uS[40]", id))
        {
            if(playerid == id)
            {
              if(IsPlayerConnected(id))
              {
                if(isnull(msg1,msg2))
                {
                   
                    format(string,sizeof(string)," You have been Muted by Admin ( %s ) Reason: No reason specified.",pInfo[playerid][playername]);
                    format(string2,sizeof(string2),"You have muted Player ( %s ) Reason: No reason specified.",pInfo[id][playername]);
                    SendClientMessage(id,COLOR_ADMIN,string);
                    SendClientMessage(playerid,COLOR_ADMIN,string2);
                    Muted[id] = 1;
                } else {
                    format(string,sizeof(string),"AdminCMD: You have been Muted by Admin ( %s ) Reason: %s.",pInfo[playerid][playername],msg1);
                    format(string2,sizeof(string2),"AdminCMD: You have Muted Player ( %s ) Reason: %s.",pInfo[id][playername],msg2);
                    SendClientMessage(id,COLOR_ADMIN,string);
                    SendClientMessage(playerid,COLOR_ADMIN,string2);
                    Muted[id] = 1;
                }
              } else SendError(playerid, "This player is not Connected!");
            } else SendError(playerid, "You can't mute yourself!");
        } else SendError(playerid," Syntax: /Mute <playerid> [reason]");
    } else SendError(playerid," You don't have enough priviliges");
    return 1;
}
Thanks, But i'm still getting the error
pawn Код:
if(pInfo[id][Muted] == 1)
Код:
admin.pwn(74) : error 033: array must be indexed (variable "Muted")
Reply
#6

Change this:

pawn Код:
if(pInfo[id][Muted] == 1)
To:
pawn Код:
if(Muted[id] == 1)
and its cool Sublime :P Thanks for attempting to help.

EDIT: Lol hahaha guys. No offense. Anyways Konstantinos, Repped+4 you therefore grats on your 500th Rep
Reply
#7

Quote:
Originally Posted by Rudy_
Посмотреть сообщение
Thanks, But i'm still getting the error
pawn Код:
if(pInfo[id][Muted] == 1)
Код:
admin.pwn(74) : error 033: array must be indexed (variable "Muted")
You declared as:
pawn Код:
new Muted[MAX_PLAYERS];
at first so you had to use:
pawn Код:
if(Muted[id])
// OR
if(Muted[id] == 1)
EDIT: Ballu Miaa beat me twice lol
Reply
#8

Oh thank you everyone, I will make sure not to make this mistake again.
Thank you all of 3 (Rep'd)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)