Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define AUTO_AFK_CHECK_INTERVAL 5 //in minutes
- #define AUTO_AFK_TOLERANCE 5 //in minutes
- #define C_LIGHT_BLUE 0x00FFFFFF
- #define C_LIGHT_BLUE_E "{00FFFF}"
- enum
- {
- DIALOG_AFK
- }
- enum HPandAP
- {
- Float:health,
- Float:armour
- }
- new bool:AutoAFK_Detected[MAX_PLAYERS],
- Float:Position[MAX_PLAYERS][3],
- AutoAFK_Timer[MAX_PLAYERS],
- StartGodModeTimer[MAX_PLAYERS],
- bool:IsPlayerAFK[MAX_PLAYERS] = false,
- Float:PlayerHPandAP[MAX_PLAYERS][HPandAP];
- #define FILTERSCRIPT
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("+--------------------+");
- print("| AutoAFK by Manyula |");
- print("+--------------------+");
- SetTimer("AutoAFK_Check", AUTO_AFK_CHECK_INTERVAL*1000, true);
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("AutoAFK has been unloaded.");
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- GetPlayerPos(playerid, Position[playerid][0], Position[playerid][1], Position[playerid][2]);
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if(AutoAFK_Detected[playerid])
- {
- AutoAFK_Detected[playerid] = false;
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_AFK)
- {
- if(response)
- {
- new PlayerWhoGoesBack[MAX_PLAYER_NAME],
- string[64];
- KillTimer(StartGodModeTimer[playerid]);
- ReturnPlayerHPandAP(playerid);
- GetPlayerName(playerid, PlayerWhoGoesBack, sizeof(PlayerWhoGoesBack));
- format(string, sizeof(string), "»PLAYERINFO« {%06x}%s "#C_LIGHT_BLUE_E"is playing again.", GetPlayerColor(playerid) >>> 8, PlayerWhoGoesBack);
- SendClientMessageToAll(C_LIGHT_BLUE, string);
- ClearAnimations(playerid);
- IsPlayerAFK[playerid] = false;
- return 1;
- }
- else ShowPlayerDialog(playerid, DIALOG_AFK, DIALOG_STYLE_MSGBOX, "Away From Keyboard", "You are now in the "#C_LIGHT_BLUE_E"AFK mode"#C_DIALOG_E".\nPress "#C_LIGHT_BLUE_E"Back"#C_DIALOG_E" to play again.", "Back", "");
- }
- return 1;
- }
- forward AutoAFK_Processed(playerid);
- public AutoAFK_Processed(playerid)
- {
- new PlayerWhoGoesAFK[MAX_PLAYER_NAME],
- string[64+32];
- ShowPlayerDialog(playerid, DIALOG_AFK, DIALOG_STYLE_MSGBOX, "Away From Keyboard", "You are now in the "#C_LIGHT_BLUE_E"AFK mode"#C_DIALOG_E".\nPress "#C_LIGHT_BLUE_E"Back"#C_DIALOG_E" to play again.", "Back", "");
- SavePlayerHPandAP(playerid);
- StartGodModeTimer[playerid] = SetTimerEx("StartGodMode", 250, true, "i", playerid);
- GetPlayerName(playerid, PlayerWhoGoesAFK, sizeof(PlayerWhoGoesAFK));
- format(string, sizeof(string), "»PLAYERINFO« {%06x}%s "#C_LIGHT_BLUE_E"is now AFK.", GetPlayerColor(playerid) >>> 8, PlayerWhoGoesAFK);
- SendClientMessageToAll(C_LIGHT_BLUE, string);
- ApplyAnimation(playerid, "SUNBATHE", "ParkSit_M_in", 4.1, 0, 1, 1, 1, 1);
- IsPlayerAFK[playerid] = true;
- return 1;
- }
- forward AutoAFK_Check();
- public AutoAFK_Check()
- {
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(!IsPlayerAFK[i])
- {
- if(IsPlayerInRangeOfPoint(i, 0, Position[i][0], Position[i][1], Position[i][2]))
- {
- if(AutoAFK_Detected[i])
- {
- return 1;
- }
- else if(!AutoAFK_Detected[i])
- {
- AutoAFK_Detected[i] = true;
- AutoAFK_Timer[i] = SetTimerEx("AutoAFK_Processed", AUTO_AFK_TOLERANCE*60000, false, "i", i);
- return 1;
- }
- }
- else if(!IsPlayerInRangeOfPoint(i, 0, Position[i][0], Position[i][1], Position[i][2]))
- {
- if(AutoAFK_Detected[i])
- {
- KillTimer(AutoAFK_Timer[i]);
- AutoAFK_Detected[i] = false;
- GetPlayerPos(i, Position[i][0], Position[i][1], Position[i][2]);
- return 1;
- }
- else if(!AutoAFK_Detected[i])
- {
- AutoAFK_Detected[i] = false;
- GetPlayerPos(i, Position[i][0], Position[i][1], Position[i][2]);
- return 1;
- }
- }
- }
- else if(IsPlayerAFK[i])
- {
- return 1;
- }
- }
- }
- return 1;
- }
- forward StartGodMode(playerid);
- public StartGodMode(playerid) return SetPlayerHealth(playerid, 99999);
- stock SavePlayerHPandAP(playerid)
- {
- GetPlayerHealth(playerid, PlayerHPandAP[playerid][health]);
- GetPlayerArmour(playerid, PlayerHPandAP[playerid][armour]);
- return 1;
- }
- stock ReturnPlayerHPandAP(playerid)
- {
- SetPlayerHealth(playerid, PlayerHPandAP[playerid][health]);
- SetPlayerArmour(playerid, PlayerHPandAP[playerid][armour]);
- return 1;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement