Mute player if he uses this more than X times
#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


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)