Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define MAX_AFK_TIMER 60000*2
- new upd[MAX_PLAYERS]=0;
- new afking[MAX_PLAYERS]=0;
- new sended[MAX_PLAYERS]=0;
- new debafk[MAX_PLAYERS]=0;
- new originame[MAX_PLAYERS][24];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("Extreme AFK checker By ST4]N[L3Y");
- print("--------------------------------------\n");
- SetTimer("update",3900,1);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerText(playerid,text[])
- {
- if(afking[playerid]==1&&upd[playerid]!=0 && sended[playerid]==1)
- {
- SetPlayerName(playerid,originame[playerid]);
- sended[playerid]=0;
- afking[playerid]=0;
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- debafk[playerid]=0;
- format(originame[playerid],24,"%s",PlayerName(playerid));
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- SetPlayerName(playerid,originame[playerid]);
- debafk[playerid]=0;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- debafk[playerid]=1;
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(afking[playerid]==1&&upd[playerid]!=0 && sended[playerid]==1)
- {
- SetPlayerName(playerid,originame[playerid]);
- sended[playerid]=0;
- afking[playerid]=0;
- }
- return 1;
- }
- forward OnPlayerUpdate(playerid);
- public OnPlayerUpdate(playerid)
- {
- upd[playerid]++;
- return 1; // <----------- thx to peppe <3
- }
- new timmaxafk[MAX_PLAYERS];
- forward update();
- public update()
- {
- for (new i=0;i<MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i))
- {
- if(upd[i]==0 && sended[i]==0 && debafk[i]==1)
- {
- if(strlen(PlayerName(i))<=MAX_PLAYER_NAME-6)
- {
- new name[MAX_PLAYER_NAME];
- format(name,MAX_PLAYER_NAME,"[AFK]%s",PlayerName(i));
- SetPlayerName(i,name);
- KillTimer(timmaxafk[i]);
- timmaxafk[i]=SetTimerEx("maxafk",MAX_AFK_TIMER,0,"i",i);
- sended[i]=1;
- afking[i]=1;
- }else{
- new string[190];
- format(string,190,"%s is now away from key board",PlayerName(i));
- SendClientMessageToAll(0x00ff00aa,string);
- KillTimer(timmaxafk[i]);
- timmaxafk[i]=SetTimerEx("maxafk",MAX_AFK_TIMER,0,"i",i);
- sended[i]=1;
- afking[i]=1;
- }
- }else if(afking[i]==1&&upd[i]!=0 && sended[i]==1)
- {
- SetPlayerName(i,originame[i]);
- sended[i]=0;
- afking[i]=0;
- }
- upd[i]=0;
- }
- }
- }
- forward maxafk(i);
- public maxafk(i)
- {
- Kick(i);
- }
- stock PlayerName(playerid)
- {
- new name[25];
- GetPlayerName(playerid, name, 25);
- return name;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement