Mute player if he uses this more than X times
#1

So players can spam the chat with the engine on/off key bind.

how can i mute a player if he spam pressing 2?

this is the code.

PHP код:
    if ((newkeys==KEY_SUBMISSION))
    {
        if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playeridCOLOR_WHITE"{FFFFCC}Error: You are not driving any car.");
        new 
string2[128];
        new 
vehid GetPlayerVehicleID(playerid);
        if(
IsABike(vehid)) return SendClientMessage(playeridCOLOR_WHITE"{FFFFCC}Error: You can't turn on engine on a bike!");
        if(
Gas[vehid] == 0) return SendClientMessage(playeridCOLOR_WHITE"{FFFFCC}Error: This vehicle doesn't have fuel.");
        new 
e,l,a,d,b,bo,o;
        
GetVehicleParamsEx(vehid,e,l,a,d,b,bo,o);
        new 
name[25];
        
GetPlayerName(playeridnamesizeof(name));
        if(
== 0)
        {
        
SetVehicleParamsEx(vehid,1,l,a,d,b,bo,o);
        
format(string2sizeof(string2), "* %s turns on the engine of %s."name,vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
        
ProxDetector(30.0playeridstring2COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        }
        else
        {
        
SetVehicleParamsEx(vehid,0,l,a,d,b,bo,o);
        
format(string2sizeof(string2), "* %s turns off the engine of%s."name,vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
        
ProxDetector(30.0playeridstring2COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        }
    } 
Reply
#2

you have to create timer, I'll give u example.

new floodcntrl[MAX_PLAYERS]; // at the top

Код:
forward ResetFloodCntrl(playerid);
public ResetFloodCntrl(playerid)
{
    floodcntrl[playerid] = 0;
    return 1;
}
Код:
    if ((newkeys==KEY_SUBMISSION)) 
    { 
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: You are not driving any car."); // actually u dont need this message, when player is on a foot key is not '2'
        new string2[128]; 
        new vehid = GetPlayerVehicleID(playerid); 
        if(IsABike(vehid)) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: You can't turn on engine on a bike!"); 
        if(Gas[vehid] == 0) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: This vehicle doesn't have fuel.");
        if(floodcntrl[playerid] != 1) floodcntrl[playerid] = 1; 
        else return SendClientMessage(playerid,-1,"u're too fast bro"); // anti flood message
        SetTimerEx("ResetFloodCntrl",1000,0,"i",playerid); // 1 sec for reset
        new e,l,a,d,b,bo,o; 
        GetVehicleParamsEx(vehid,e,l,a,d,b,bo,o); 
        new name[25]; 
        GetPlayerName(playerid, name, sizeof(name)); 
        if(e == 0) 
        { 
        SetVehicleParamsEx(vehid,1,l,a,d,b,bo,o); 
        format(string2, sizeof(string2), "* %s turns on the engine of %s.", name,vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]); 
        ProxDetector(30.0, playerid, string2, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); 
        } 
        else 
        { 
        SetVehicleParamsEx(vehid,0,l,a,d,b,bo,o); 
        format(string2, sizeof(string2), "* %s turns off the engine of%s.", name,vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]); 
        ProxDetector(30.0, playerid, string2, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); 
        } 
    }
Reply
#3

Quote:
Originally Posted by Mugalito
Посмотреть сообщение
you have to create timer, I'll give u example.

new floodcntrl[MAX_PLAYERS]; // at the top

Код:
forward ResetFloodCntrl(playerid);
public ResetFloodCntrl(playerid)
{
    floodcntrl[playerid] = 0;
    return 1;
}
Код:
    if ((newkeys==KEY_SUBMISSION)) 
    { 
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: You are not driving any car."); // actually u dont need this message, when player is on a foot key is not '2'
        new string2[128]; 
        new vehid = GetPlayerVehicleID(playerid); 
        if(IsABike(vehid)) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: You can't turn on engine on a bike!"); 
        if(Gas[vehid] == 0) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: This vehicle doesn't have fuel.");
        if(floodcntrl[playerid] != 1) floodcntrl[playerid] = 1; 
        else return SendClientMessage(playerid,-1,"u're too fast bro"); // anti flood message
        SetTimerEx("ResetFloodCntrl",1000,0,"i",playerid); // 1 sec for reset
        new e,l,a,d,b,bo,o; 
        GetVehicleParamsEx(vehid,e,l,a,d,b,bo,o); 
        new name[25]; 
        GetPlayerName(playerid, name, sizeof(name)); 
        if(e == 0) 
        { 
        SetVehicleParamsEx(vehid,1,l,a,d,b,bo,o); 
        format(string2, sizeof(string2), "* %s turns on the engine of %s.", name,vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]); 
        ProxDetector(30.0, playerid, string2, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); 
        } 
        else 
        { 
        SetVehicleParamsEx(vehid,0,l,a,d,b,bo,o); 
        format(string2, sizeof(string2), "* %s turns off the engine of%s.", name,vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]); 
        ProxDetector(30.0, playerid, string2, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); 
        } 
    }
That is old fashioned way... useless timers.

Use like this

Код:
new AntiSpamKey[MAX_PLAYERS];//Somewhere top

if((newkeys==KEY_SUBMISSION))
{
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: You are not driving any car."); // actually u dont need this message, when player is on a foot key is not '2'
    new string2[128];
    new vehid = GetPlayerVehicleID(playerid);
    if(IsABike(vehid)) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: You can't turn on engine on a bike!");
    if(Gas[vehid] == 0) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: This vehicle doesn't have fuel.");
    if(gettime() < AntiSpamKey[playerid]) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Wait 1 second");//We defined + 1;
    new e,l,a,d,b,bo,o;
    GetVehicleParamsEx(vehid,e,l,a,d,b,bo,o);
    new name[25];
    GetPlayerName(playerid, name, sizeof(name));
    AntiSpamKey[playerid] = gettime() + 1;//For how much seconds you want
    if(e == 0)
    {
	    SetVehicleParamsEx(vehid,1,l,a,d,b,bo,o);
	    format(string2, sizeof(string2), "* %s turns on the engine of %s.", name,vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
	    ProxDetector(30.0, playerid, string2, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    }
    else
    {
	    SetVehicleParamsEx(vehid,0,l,a,d,b,bo,o);
	    format(string2, sizeof(string2), "* %s turns off the engine of%s.", name,vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
	    ProxDetector(30.0, playerid, string2, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    }
}
Reply
#4

it works but its not what i want.

i dont want him to use the cmd every 1 second,i want him to get muted if he uses it more than 5 times in less than a few seconds..
Reply
#5

Quote:
Originally Posted by PepsiCola23
Посмотреть сообщение
it works but its not what i want.

i dont want him to use the cmd every 1 second,i want him to get muted if he uses it more than 5 times in less than a few seconds..
This is better way, for mute you need extra timer and extra check, it's just dumb.
Reply
#6

you dont understand lol

its like mute on chat for spamming
i want players to be able to write fast but if they excees a limit they get muted.
not to wait 1 second before any chat line
Reply
#7

if u want players to be able to 'write', why u gave us this key_submission script?
u must give us OnPlayerText<--
Reply
#8

What he meant is, that just like on some RP servers, if they spam something again and again, a warning message is shown to them that they are muted for 10 secs. after 10 secs they can talk again. He want similar system just with the key this time. if they press 2 many times within X amount seconds, instead of turning on and off, a warning message should be displayed on them about cool down time.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)