Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 100 // Cámbia a la cantidad de slot's que usas en tu Servidor.
- #include <dini>
- #define DIRECCION "CarpetaUsuarios/%s.ini" // Cambia a la dirección en donde guardas los datos de tus usuarios.
- stock Timer:operator = (var) return Timer:var;
- stock bool:TimerHasHappened(Timer:timer)
- {
- return (ObtainTimer(_:timer) <= 0) ? (true) : (false);
- }
- static Timer[MAX_PLAYERS];
- static Timer:TimerFlood[MAX_PLAYERS];
- static AntiFlood[MAX_PLAYERS];
- static TimerSaved[MAX_PLAYERS];
- public OnPlayerText(playerid, text[])
- {
- AntiFlood[playerid] ++;
- Timer[playerid] = SetTimerEx("FloodPublic", 5000, false, "d", playerid);
- if(AntiFlood[playerid] == 3)
- {
- AntiFlood[playerid] = 4;
- KillTimer(Timer[playerid]);
- StartTimer(TimerFlood[playerid], (5*60)); // (5*60) = 5 minutos, cámbialo a tu gusto.
- return SendClientMessage(playerid, -1, "* No hagas Flood."), false;
- }
- if(TimerHasHappened(TimerFlood[playerid]) == false)
- {
- new string[144];
- format(string, sizeof(string), "[AntiFlood] Has sido Muteado por hacer Flood por %i Segundos.", ObtainTimer(TimerFlood[playerid]));
- return SendClientMessage(playerid, -1, string), false;
- }
- return 1;
- }
- forward FloodPublic(playerid);
- public FloodPublic(playerid)
- {
- AntiFlood[playerid] = 0;
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new string[100];
- format(string, sizeof(string), DIRECCION, GetName(playerid));
- if(!fexist(string)) return dini_Create(string);
- else
- {
- TimerSaved[playerid] = dini_Int(string, "SecondsMuted");
- if(TimerSaved[playerid] != 0)
- {
- AntiFlood[playerid] = 4;
- StartTimer(TimerFlood[playerid], TimerSaved[playerid]);
- }
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new string[100];
- format(string, sizeof(string), DIRECCION, GetName(playerid));
- dini_IntSet(string, "SecondsMuted", ObtainTimer(TimerFlood[playerid]));
- return 1;
- }
- stock GetName(playerid)
- {
- new Nick[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Nick, sizeof(Nick));
- return Nick;
- }
- /* .: By DesingMyCry :. */
- stock StartTimer(&Timer:timer, const TimerTime)
- {
- timer = ((gettime())+(TimerTime));
- return 1;
- }
- stock ObtainTimer(Timer:timer)
- {
- new CurrentTime = gettime();
- return (_:timer-CurrentTime <= 0) ? (0) : (_:timer-CurrentTime);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement