dcmd_mute(playerid, params[])
{
new pID, time, reason[128];
if(adminlevel==0) return SendClientMessage(playerid, COLOR_WHITE, "Server: Unrecognized command, type /commands to see the commands available for you.");
if(adminlevel<2) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This command is unavailable for your admin rank.");
if(sscanf(params, "uds", pID, time, reason)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "Correct usage: /mute [name/id] [seconds] [reason]");
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This player is not connected.");
if(playerid==pID) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: You cannot mute yourself.");
new pIDadminlevel;
INI_ParseFile(UserPath(pID), "LoadUser_%s", .bExtra = true, .extra = pID);
pIDadminlevel= PlayerInfo[pID][pAdmin];
if(pIDadminlevel>0)
{
if(adminlevel==10)
{
muted[pID] = 1;
new amalmuteclient[128], amalmuteserver[128];
format(amalmuteclient, sizeof(amalmuteclient), "You have been muted by the Senior Admin AmalM for %d seconds (Reason: %s).", time, reason);
SendClientMessage(pID, COLOR_BRIGHTRED, amalmuteclient);
new pName[128];
GetPlayerName(pID, pName, sizeof(pName));
format(amalmuteserver, sizeof(amalmuteserver), "Admin-mute: %s(%d) has been muted by the Senior Admin AmalM for %d seconds (Reason: %s).", pName, pID, time, reason);
SendClientMessageToAll(COLOR_BRIGHTRED, amalmuteserver);
SetTimerEx("amalmute", time*1000, false, "is", pID, pName);
}
else
{
muted[pID] = 1;
new muteclient[128], muteserver[128];
format(muteclient, sizeof(muteclient), "You have been muted by an admin for %d seconds (Reason: %s).", time, reason);
SendClientMessage(pID, COLOR_BRIGHTRED, muteclient);
new pName[128];
GetPlayerName(pID, pName, sizeof(pName));
format(muteserver, sizeof(muteserver), "Admin-mute: %s(%d) has been muted for %d seconds (Reason: %s).", pName, pID, time, reason);
SendClientMessageToAll(COLOR_BRIGHTRED, muteserver);
SetTimerEx("mute", time*1000, false, "i", pID, pName);
}
}
return 1;
}
forward amalmute(pID, pName);
public amalmute(pID, pName)
{
muted[pID] = 0;
SendClientMessage(pID, COLOR_BRIGHTRED, "You have been auto-unmuted.");
new unmuted[128];
format(unmuted, sizeof(unmuted), "Auto-unmute: %s(%d) has been auto-unmuted.");
SendClientMessageToAll(COLOR_BRIGHTRED, unmuted);
return 1;
}
forward mute(pID, pName);
public mute(pID, pName)
{
muted[pID] = 0;
SendClientMessage(pID, COLOR_BRIGHTRED, "You have been auto-unmuted.");
new unmuted[128];
format(unmuted, sizeof(unmuted), "Auto-unmute: %s(%d) has been auto-unmuted.");
SendClientMessageToAll(COLOR_BRIGHTRED, unmuted);
return 1;
}
E:\My Server\gamemodes\SARCR.pwn(831) : error 028: invalid subscript (not an array or too many subscripts): "muted" E:\My Server\gamemodes\SARCR.pwn(831) : warning 215: expression has no effect E:\My Server\gamemodes\SARCR.pwn(831) : error 001: expected token: ";", but found "]" E:\My Server\gamemodes\SARCR.pwn(831) : error 029: invalid expression, assumed zero |
if(sscanf(params, "uds[128]", pID, time, reason))
First of all, sscanf has to go like this:
Код:
if(sscanf(params, "uds[128]", pID, time, reason)) |
new muted=0;
new muted[MAX_PLAYERS]; // under onPlayerConnect muted[playerid] = 0;
// /me if (strcmp(cmdtext, "/me ", true, 4) == 0) { if(!cmdtext[4])return SendClientMessage(playerid, COLOR_ORANGE, "Correct Usage: /me [action]"); if(muted > 0) return SendClientMessage(playerid, COLOR_ORANGE, "You cannot use this command when you are muted."); new actionme[128]; format (actionme, sizeof(actionme), "*%s %s", playername, cmdtext[4]); SendLocalMessage(playerid, COLOR_PINK, 7, actionme); return 1; } // /do if (strcmp(cmdtext,"/do ", true, 4) == 0) { if(!cmdtext[4])return SendClientMessage(playerid, COLOR_ORANGE, "Correct Usage: /do [message]"); if(muted > 0) return SendClientMessage(playerid, COLOR_ORANGE, "You cannot use this command when you are muted."); new actiondo[128]; format (actiondo, sizeof(actiondo), "*%s((%s))", cmdtext[4], playername); SendLocalMessage(playerid,COLOR_PINK,7, actiondo); return 1; } // /do if (strcmp(cmdtext, "/w ", true, 3) == 0) { if(!cmdtext[3])return SendClientMessage(playerid, COLOR_ORANGE, "Correct Usage: /w [message]"); if(muted > 0) return SendClientMessage(playerid, COLOR_ORANGE, "You cannot use this command when you are muted."); new wmessage[128]; format (wmessage, sizeof(wmessage), "(Local) %s(%d): %s", playername, playerid, cmdtext[3]); SendLocalMessage(playerid, COLOR_YELLOW, 7, wmessage); return 1; } |
E:\My Server\gamemodes\SARCR.pwn(922) : error 033: array must be indexed (variable "muted") E:\My Server\gamemodes\SARCR.pwn(933) : error 033: array must be indexed (variable "muted") E:\My Server\gamemodes\SARCR.pwn(944) : error 033: array must be indexed (variable "muted") |
forward mute(pID, pName); public mute(pID, pName) { muted[pID] = 0; SendClientMessage(pID, COLOR_BRIGHTRED, "You have been auto-unmuted."); new unmuted[128]; format(unmuted, sizeof(unmuted), "Auto-unmute: %s(%d) has been auto-unmuted."); SendClientMessageToAll(COLOR_BRIGHTRED, unmuted); return 1; } |
Thanks man, its all fixed, now I gets no errors.
Also here I need to put mute[playerid] or mute[pID]? rep++; |
// /mute[dcmd]
dcmd_mute(playerid, params[])
{
new pID, time, reason[128];
if(adminlevel==0) return SendClientMessage(playerid, COLOR_WHITE, "Server: Unrecognized command, type /commands to see the commands available for you.");
if(adminlevel<2) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This command is unavailable for your admin rank.");
if(sscanf(params, "uds", pID, time, reason)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "Correct usage: /mute [name/id] [seconds] [reason]");
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: This player is not connected.");
if(playerid==pID) return SendClientMessage(playerid, COLOR_ADMINBLUE, "ERROR: You cannot mute yourself.");
new pIDadminlevel;
INI_ParseFile(UserPath(pID), "LoadUser_%s", .bExtra = true, .extra = pID);
pIDadminlevel= PlayerInfo[pID][pAdmin];
if(pIDadminlevel>0)
{
if(adminlevel==10)
{
muted[pID] = 1;
new amalmuteclient[128], amalmuteserver[128];
format(amalmuteclient, sizeof(amalmuteclient), "You have been muted by the Senior Admin AmalM for %d seconds (Reason: %s).", time, reason);
SendClientMessage(pID, COLOR_BRIGHTRED, amalmuteclient);
new pName[128];
GetPlayerName(pID, pName, sizeof(pName));
format(amalmuteserver, sizeof(amalmuteserver), "Admin-mute: %s(%d) has been muted by the Senior Admin AmalM for %d seconds (Reason: %s).", pName, pID, time, reason);
SendClientMessageToAll(COLOR_BRIGHTRED, amalmuteserver);
SetTimerEx("amalmute", time*1000, false, "is", pID, pName);
}
else
{
muted[pID] = 1;
new muteclient[128], muteserver[128];
format(muteclient, sizeof(muteclient), "You have been muted by an admin for %d seconds (Reason: %s).", time, reason);
SendClientMessage(pID, COLOR_BRIGHTRED, muteclient);
new pName[128];
GetPlayerName(pID, pName, sizeof(pName));
format(muteserver, sizeof(muteserver), "Admin-mute: %s(%d) has been muted for %d seconds (Reason: %s).", pName, pID, time, reason);
SendClientMessageToAll(COLOR_BRIGHTRED, muteserver);
SetTimerEx("mute", time*1000, false, "i", pID, pName);
}
}
return 1;
}
forward amalmute(pID, pName);
public amalmute(pID, pName)
{
muted[pID] = 0;
SendClientMessage(pID, COLOR_BRIGHTRED, "You have been auto-unmuted.");
new unmuted[128];
format(unmuted, sizeof(unmuted), "Auto-unmute: %s(%d) has been auto-unmuted.");
SendClientMessageToAll(COLOR_BRIGHTRED, unmuted);
return 1;
}
forward mute(pID, pName);
public mute(pID, pName)
{
muted[pID] = 0;
SendClientMessage(pID, COLOR_BRIGHTRED, "You have been auto-unmuted.");
new unmuted[128];
format(unmuted, sizeof(unmuted), "Auto-unmute: %s(%d) has been auto-unmuted.");
SendClientMessageToAll(COLOR_BRIGHTRED, unmuted);
return 1;
}