Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- I'm not a bad person so feel free to do whatever
- you want with my first release on sa-mp forums. edit it
- or copy&paste it to your gamemode.
- Harry :) Presents
- Advanced
- ______ ________
- | | | | /
- |----| |____ |/
- | | | |\
- | | | | \ System
- */
- #define FILTERSCRIPT
- #include <a_samp>
- #include <sscanf2>
- #include <foreach>
- #include <YSI\y_timers>
- #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- #define MAX_AFK_TIME 30 //in Minutes!
- #define LABEL_DRAW_DISTANCE 50.0
- new Text3D:AFKLabel[MAX_PLAYERS];
- new playerupdate[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\nAdvanced Away-From-Keyboard 1.0 Filterscript by 'Harry :)' loaded.\n");
- for(new playerid; playerid < MAX_PLAYERS; playerid++)
- {
- AFKLabel[playerid] = Create3DTextLabel(" ",0x000000,0.0,0.0,0.0,LABEL_DRAW_DISTANCE,0,1);
- }
- return 1;
- }
- stock CheckPausing(playerid)
- {
- if(GetTickCount() > ( GetPVarInt(playerid,"LastUpdate") + 3000 ) && GetPlayerState(playerid) != PLAYER_STATE_PASSENGER)
- {
- return 1;
- }
- return 0;
- }
- public OnPlayerConnect(playerid)
- {
- Attach3DTextLabelToPlayer(AFKLabel[playerid], playerid, 0.0, 0.0, 1.0);
- return 1;
- }
- task PerPlayerTimer[1000]()
- {
- foreach(Player,i)
- {
- AFKUpdate(i);
- }
- }
- AFKUpdate(playerid)
- {
- new string[128];
- if(GetTickCount() > (GetPVarInt(playerid,"LastUpdate") + 1000) && GetPlayerState(playerid) != PLAYER_STATE_PASSENGER)
- {
- playerupdate[playerid]++;
- if(playerupdate[playerid] > 60)
- {
- new mins,secs;
- mins = playerupdate[playerid] / 60;
- secs = playerupdate[playerid] - (mins * 60);
- if(mins == 1) format(string,sizeof(string),"Away From Keyboard \nfor\n%d minute and %d seconds",mins,secs);
- else format(string,sizeof(string),"Away From Keyboard \nfor\n%d minutes and %d seconds",mins,secs);
- }
- else format(string,sizeof(string),"Away From Keyboard \nfor\n%d seconds",playerupdate[playerid]);
- Update3DTextLabelText(AFKLabel[playerid], 0x00CDFFFF, string);
- }
- else if(playerupdate[playerid] >= MAX_AFK_TIME*60)
- {
- new Name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,Name,sizeof(Name));
- format(string,sizeof(string),"[AAS] %s has been kicked from the server. [Paused for %d Minutes]",Name,MAX_AFK_TIME);
- SendClientMessageToAll(0xFF00FFFF,string);
- Kick(playerid);
- }
- else
- {
- Update3DTextLabelText(AFKLabel[playerid],0x00000000," ");
- }
- }
- public OnPlayerUpdate(playerid)
- {
- SetPVarInt(playerid,"LastUpdate",GetTickCount());
- playerupdate[playerid] = 0;
- return 1;
- }
- public OnPlayerCommandText(playerid,cmdtext[])
- {
- dcmd(afklist,7,cmdtext);
- dcmd(afkcheck,8,cmdtext);
- return 1;
- }
- dcmd_afklist(playerid,params[])
- {
- #pragma unused params
- new string[128],variable[960],afk;
- foreach(Player,i)
- {
- if(CheckPausing(i) == 1)
- {
- new Name[MAX_PLAYER_NAME];
- GetPlayerName(i,Name,sizeof(Name));
- format(string,sizeof(string),"\n• %s",Name);
- strcat(variable,string);
- afk++;
- }
- }
- if(afk == 0) return SendClientMessage(playerid,0xFF00FFFF,"Nobody's AFK at the moment!");
- if(afk == 1)
- {
- format(string,sizeof(string),"%d Player is AFK",afk);
- }
- if(afk > 1)
- {
- format(string,sizeof(string),"%d Players are AFK",afk);
- }
- ShowPlayerDialog(playerid,1503,DIALOG_STYLE_MSGBOX,string,variable,"Got it!","");
- return 1;
- }
- dcmd_afkcheck(playerid,params[])
- {
- new id,Name[MAX_PLAYER_NAME],string[128];
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,0xFFFFFFFF,"Usage: /afkcheck ID");
- GetPlayerName(id,Name,sizeof(Name));
- if(CheckPausing(id) == 0)
- {
- format(string,sizeof(string),"%s {37D900}is not {FFBE00}A{37D900}way {FFBE00}F{37D900}rom his {FFBE00}K{37D900}eyboard",Name);
- SendClientMessage(playerid,0xFFBE00FF,string);
- }
- else if(CheckPausing(id) == 1)
- {
- format(string,sizeof(string),"%s {D70000}is {FFBE00}A{D70000}way {FFBE00}F{D70000}rom his {FFBE00}K{D70000}eyboard,Name");
- SendClientMessage(playerid,0xFFBE00FF,string);
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- foreach(Player,i)
- {
- Delete3DTextLabel(AFKLabel[i]);
- }
- print("/nAdvanced Away-From-Keyboard v1.0 by 'Harry :)' unloaded.");
- return 1;
- }
- //Hey, You just used my script,
- //but here's my website
- //so visit it maybe?
- //www.bfsamp.net
Advertisement
Add Comment
Please, Sign In to add comment