How to change the function ?
#1

Hi, can someone here help me ?? This script have an system to auto kick player who flooding on mainchat. I dont like that system, so can someone here help me to change the system from autokick to auto muted for 60 minutes. Below the script i give to you who want to help me Thanks a lot.

Code:
new count = GetTickCount2();
	if (count-cflood[playerid][1] < 1000) {
		cflood[playerid][0] ++;
		if (cflood[playerid][0] == 5) {
			if (cdata[playerid][2] == 0 || text[0] == '!') {
				printf("[chat] [%s]: %s", playername, text);
			}
			else {
				GetPlayerName(cdata[playerid][0], string, MAX_PLAYER_NAME);
				printf("[phonecall] [%s - %s]: %s", playername, string, text);
			}
			cflood[playerid][0] = 0;
			SendClientMessage2(playerid, COLOR_WHITE, "~ You have been auto kicked for flooding.");
			pkicktimer[playerid] = SetTimerEx("KickBanTimer", 50, 0, "dd", playerid, 1);
			format(string, 128, "~ %s has been auto kicked from the server (Flooding).", playername);
			SendClientMessageToAll2(COLOR_WHITE, string);
			printf("[kicked] %s has been auto kicked from the server (Flooding).", playername);
			return 0;
		}
	}
	else
	{
		cflood[playerid][0] = 1;
	}
	cflood[playerid][1] = count;
Reply
#2

Can you give me the name of variable for mute time? (Like PlayerInfo[playerid][MuteTime]) And the variable for
player muted? (Like PlayerInfo[playerid][Muted])
Reply
#3

here is the code of CMD:mute

Code:
CMD:mute(playerid, params[])
{
	new giveplayerid, giveplayer[25], playername[25], strings[256], string[256], moneys1, tmp3[256];
	if (adlvl[playerid] < 1) return 0;
	if (sscanf(params, "ud", giveplayerid, moneys1)) return SendClientMessage2(playerid, COLOR_WHITE, "Usage: /mute [playerid] [time] [reason]");
	if (!IsPlayerConnected2(giveplayerid)) return SendClientMessage2(playerid, COLOR_RED, "Error: Inactive player id!");
	if (moneys1 < 1 || moneys1 > 60) return SendClientMessage2(playerid, COLOR_WHITE, "Error: Select a time between 1-60 minutes.");
	if (giveplayerid == playerid) return SendClientMessage2(playerid, COLOR_RED, "Error: You can't mute yourself!");
	GetPlayerName(giveplayerid, giveplayer, MAX_PLAYER_NAME);
	if (adlvl[giveplayerid] > adlvl[playerid] && adlvl[playerid] != 6) return SendPlayerFormattedText(playerid, COLOR_RED, "Error: You cannot mute %s.", giveplayer, "");
	if (mtimer[giveplayerid] != 0) return SendPlayerFormattedText(playerid, COLOR_RED, "Error: %s is already muted.", giveplayer, "");
	if (moneys1 < 1 || moneys1 > 60) return SendClientMessage2(playerid, COLOR_WHITE, "Error: Select a time between 1-60 minutes.");
	GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
	mtimer[giveplayerid] = 1;
	mutedtime[giveplayerid]=moneys1*60;
	if (sscanf(params, "uds[128]", giveplayerid, moneys1, tmp3))
	{
		format(strings, sizeof(strings), "~ You have been muted by an admin for %d minute(s).", moneys1);
		SendClientMessage2(giveplayerid, COLOR_RED, strings);

		format(strings, sizeof(strings), "~ %s has been muted by an admin for %d minute(s).", giveplayer, moneys1);
		SendClientMessageToAll(COLOR_RED, strings);
	}
	else
	{
		format(strings, sizeof(strings), "~ You have been muted by an admin for %d minute(s) for '%s'.", moneys1,tmp3);
		SendClientMessage2(giveplayerid, COLOR_RED, strings);

		format(strings, sizeof(strings), "~ %s has been muted by an admin for %d minute(s) for '%s'.", giveplayer, moneys1,tmp3);
		SendClientMessageToAll(COLOR_RED, strings);
	}
	SendPlayerFormattedText(playerid, COLOR_RED, "You have muted %s.", giveplayer, "");
	if (adminuc[playerid] == 0)
	{
		if (!strlen(tmp3)) format(string, 128, "Admin Log: %s has muted player %s (Id%d) for %d minute(s).", playername, giveplayer, giveplayerid, moneys1);
		else format(string, 128, "Admin Log: %s has muted player %s (Id%d) for %d minute(s) for %s.", playername, giveplayer, giveplayerid, moneys1, tmp3);
		SendMessageToAdmins(COLOR_ADMIN, string);
	}
	printf("[muted] %s has muted player %s (Id%d) for %d minutes.", playername, giveplayer, giveplayerid, moneys1);
	new str[256];
	format(str, sizeof(str), "%s has muted player %s (Id%d) for %d minutes.\r\n", playername, giveplayer, giveplayerid, moneys1);
	new File: file = fopen("Alog.cfg", io_append);
	fwrite(file, str);
	fclose(file);
	return 1;
}
Reply
#4

Code:
GetTickCount2();
	if (count-cflood[playerid][1] < 1000) {
		cflood[playerid][0] ++;
		if (cflood[playerid][0] == 5) {
			if (cdata[playerid][2] == 0 || text[0] == '!') {
				printf("[chat] [%s]: %s", playername, text);
			}
			else {
				GetPlayerName(cdata[playerid][0], string, MAX_PLAYER_NAME);
				printf("[phonecall] [%s - %s]: %s", playername, string, text);
			}
			cflood[playerid][0] = 0;
			SendClientMessage2(playerid, COLOR_WHITE, "~ You have been auto muted for flooding.");
			pkicktimer[playerid] = SetTimerEx("KickBanTimer", 50, 0, "dd", playerid, 1);
			format(string, 128, "~ %s has been auto kicked from the server (Flooding).", playername);
			SendClientMessageToAll2(COLOR_WHITE, string);
			printf("[kicked] %s has been auto muted from the server (Flooding).", playername);
                        Muted[playerid] = 1;
                        MutedTimer[playerid] = SetTimerEx("PLAYERUNMUTE",60*1000,false,"i",playerid);
			printf("[kicked] %s has been auto muted from the server (Flooding).", playername);
			return 0;
		}
	}
	else
	{
		cflood[playerid][0] = 1;
	}
	cflood[playerid][1] = count;
Code:
public OnPlayerText(playerid, text[])
{
   	if(Muted[playerid] == 1)
	{
	SendClientMessage(playerid, -1 , "[SERVER]You are muted due to flood,");
	return 0;
}
}
and add this at end
Code:
forward UNMUTE(playerid);
public UNMUTE(playerid)
{
    Muted[playerid] = 0;
    SendClientMessage(playerid,-1,"[SERVER]You are now unmuted");
    KillTimer(MutedTimer[playerid]);
}
and this in your code's news
Code:
new Muted[MAX_PLAYERS];
new MutedTimer[MAX_PLAYERS];
and 60 minutes are you mad, or maybe ur mistaken with seconds
the above timer maked player muted for a minute aka 60 sec if you want increase change 60*1000 to 600*1000, its 60 minutes aka a hour
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)