/mute CMD-Change
#1

Guys Could You tell me how to add [Reason] Function Please

Код HTML:
if(strcmp(cmd, "/mute", true) == 0)
	{
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /mute [playerid/PartOfName][Reason] ");
			return 1;
		}
		new playa;
		playa = ReturnUser(tmp);
		if(PlayerInfo[playerid][pAdmin] >= 2)
		{
			if(IsPlayerConnected(playa))
			{
				if(playa != INVALID_PLAYER_ID)
				{
					strmid(giveplayer, PlayerRPName(playa), 0, MAX_PLAYER_NAME);
					strmid(sendername, PlayerRPName(playerid), 0, MAX_PLAYER_NAME);
					if(PlayerInfo[playa][pMuted] == 0)
					{
						PlayerInfo[playa][pMuted] = 1;
						format(string, sizeof(string), "{FF0000}AdmWarning{FFFFFF}: %s was muted by %s.",giveplayer ,sendername);
						ABroadCast(COLOR_WHITE,string,1);
					}
					else
					{
						PlayerInfo[playa][pMuted] = 0;
						format(string, sizeof(string), "{FF0000}AdmWarning{FFFFFF}: %s was unmuted by %s.",giveplayer ,sendername);
						ABroadCast(COLOR_WHITE,string,1);
					}
				}
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
		}
	}
Thanks ++rep
Reply
#2

pawn Код:
new reason[100];
 if(sscanf(params, "us", id, reason)) return SendClientMessage(playerid, 0xFF0000FF, "SYNTAX ERROR: {00FF00}/MUTE {FFFF00}<PlayerID> < Reason>");

format(string, sizeof(string), "{FF0000}AdmWarning{FFFFFF}: %s was muted by %s.reason %s ",giveplayer ,sendername,reason);
Reply
#3

I suggest using sscaf, it's gone make your scripting easier

Quote:
Originally Posted by LarzI
Посмотреть сообщение
I recommend switching to ZCMD + SScanF2 for 100 times easier commands.

Here's how the code would look:

pawn Код:
CMD:mute(playerid, params[])
{
    new
        cmdid,
        reason[80],
        minutes,
        string[128];

    if(PlayerInfo[playerid][AdminLevel] < 1)
        return 0;
   
    if(sscanf(params, "uis[80]", cmdid, minutes, reason))
        return SendClientMessage(playerid,0xFFFF0000,"Usage: /mute [id/name] [time] [reason]");
    if(PlayerInfo[cmdid][AdminLevel] > PlayerInfo[playerid][AdminLevel])
        return SendClientMessage(playerid,COLOR_ORED,"You cant use this command against a higher level admin!");
    if(cmdid == playerid)
        return SendClientMessage(playerid,COLOR_ORED,"You cant mute yourself!");
    if(!IsPlayerConnected(cmdid) || cmdid == INVALID_PLAYER_ID)
        return SendClientMessage(playerid,COLOR_ORED,"Player not found!");

    new oname[MAX_PLAYER_NAME];
    GetPlayerName(cmdid, oname, sizeof(oname));

    if(time == 0) //permanent mute
    {
        format(string, sizeof(string), "~ %s has been muted. Reason: '%s' ", oname, minutes, reason);
        muted[cmdid] = 1;
    }
    else
    {
        format(string, sizeof(string), "~ %s has been muted for %i minutes. Reason: '%s' ", oname, minutes, reason);
        muted[cmdid] = 1;
        SetTimerEx("unmuteTimer", 60*1000*minutes, false, "i", cmdid);
    }
    SendClientMessageToAll(COLOR_YELLOW, string);
    print(string);
    return 1;
}
And here's the timer function:

pawn Код:
forward muteTimer(playerid);
public unmuteTimer(playerid)
{
    muted[playerid] = 0;
    return SendClientMessage(playerid,0x00FF0000,"You're no longer muted!");
}

Quote:
Originally Posted by 1fret
Посмотреть сообщение
pawn Код:
new reason[100];
 if(sscanf(params, "us", id, reason)) return SendClientMessage(playerid, 0xFF0000FF, "SYNTAX ERROR: {00FF00}/MUTE {FFFF00}<PlayerID> < Reason>");

format(string, sizeof(string), "{FF0000}AdmWarning{FFFFFF}: %s was muted by %s.reason %s ",giveplayer ,sendername,reason);
That's wrong, you're missing the string size in ("us", id, reason) it should be ("us[128]", id, reason);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)