Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define FILTERSCRIPT
- #define AFKTime 30 //This number indicates the number of minutes a player can be AFK
- #define ShowTime 0 //This Enables/Disables the AFK Time in the kick message.(0=Disable,1=Enable)
- #define Public 0 //This Enables/Disables a notification message being sent to all players.(0=Disable,1=Enable)
- /* Welcome to my FS, I have no way of ensuring that this FS is kept to my name, so I won't
- bother trying, if you want to give credit, that would be wonderful, as time went into
- making this filterscript.
- Thanks, Redgie (RedgiesRP.co.uk).
- OTHER NOTES: This AutoKicker only runs the timer every minute, this means that you should allow
- up to 1 extra minute for the autokicker to work
- HOW TO USE: Simply edit the "AFKTime" At the top of the script, to show the value of minutes
- you want to be the maximum "AFK Time" in your server, and whether you want this value to be
- shown on the kick message by editing the ShowTime value(0=Disable,1=Enable).
- */
- /*--------------------------NOTHING BELOW THIS POINT NEEDS TO BE CHANGED--------------------------*/
- public OnFilterScriptInit()
- {
- SetTimer("AFKKicker", 60000, 1);
- return 1;
- }
- forward AFKKicker();
- new Float:PPos[MAX_PLAYERS][3];
- new AFKMins[MAX_PLAYERS];
- new show = ShowTime;
- new pub = Public;
- public OnPlayerConnect(playerid)
- {
- PPos[playerid][0] = 0;
- PPos[playerid][1] = 0;
- PPos[playerid][2] = 0;
- AFKMins[playerid] = 0;
- }
- public AFKKicker()
- {
- for(new i = 0; i <= MAX_PLAYERS; i++)
- {
- if(PPos[i][1] == 0)
- {
- GetPlayerPos(i,PPos[i][0],PPos[i][1],PPos[i][2]);
- return 1;
- }
- new Float:x,Float:y,Float:z;
- GetPlayerPos(i,x,y,z);
- if(x == PPos[i][0] && y == PPos[i][1] && z == PPos[i][2])
- {
- AFKMins[i]++;
- if(AFKMins[i] >= AFKTime)
- {
- if(show == 1)
- {
- new string[128];
- format(string, sizeof(string), "You were Away From Keyboard(AFK) for too long(%d minutes)",AFKTime);
- SendClientMessage(i,0xAA3333AA,string);
- }
- else
- {
- SendClientMessage(i, 0xAA3333AA,"You were Away From Keyboard(AFK) for too long");
- }
- Kick(i);
- if(pub == 1)
- {
- new string[128];
- new name[MAX_PLAYER_NAME];
- GetPlayerName(i, name, sizeof(name));
- format(string, sizeof(string), "%s was kicked for being AFK too long",name);
- SendClientMessageToAll(0xAA3333AA,string);
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment