Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Releases Filterscripts [Filterscript] Simple AFK system

 
  • 1 Vote(s) - 1 Average
Filterscript Simple AFK system
Flofey
Offline

Burgershot Member
Posts: 2
Threads: 1
Joined: Oct 2020
Reputation: 0
Location: Lebanon
#1
2021-10-08, 06:56 PM
AFK Filterscript

Simple AFK filterscript system includes 2 commands, and yes right it would be nice if it was made only with one command
but it's made for beginner so they can understand the code.

What with this script?
This script is made of two commands
  • /afk - gets you away from keyboard by freezing the player, so he cannot move or get damaged while he's away also there'll be 3D text label above the player's head labeling (AFK).
  • /back - gets the player back with his movements and everything as normal.

Recommended files
ZCMD - Github
Downloads

AFK.pwn - Download


credits to Zeex for the amazing ZCMD.
Waiting for your responds fellas.
Galardo420
Offline

Burgershot Member
Posts: 2
Threads: 0
Joined: Jul 2020
Reputation: 0
#2
2021-10-09, 09:22 PM
I'm about to cry.
offr0ad
Offline

Burgershot Member
Posts: 19
Threads: 2
Joined: Apr 2019
Reputation: 0
#3
2021-10-14, 10:57 PM
Code:
// Use SetPVarInt and GetPVarInt it gives possibility for user to use AFK information also inside gamemode itself.
// Currently your filterscript funcinality is useless, because it's basic command, what can be written by everyone, who knows something about variables and strings.
// But its great idea to implement something new and useful for others

#include <a_samp>

static PlayerAFKCounter[MAX_PLAYERS],
    bool:PlayerIsAFK[MAX_PLAYERS];

public OnFilterScriptInit(){
    SetTimer("CheckPlayerAFKStatus", 1000, true);
    return 1;
}

public OnPlayerConnect(playerid){
    PlayerIsAFK[playerid] = false;
    SetPVarInt(playerid, "isPlayerAFK", 0);
    return 1;
}

public OnPlayerUpdate(playerid){
    PlayerAFKCounter[playerid] = 0;
    // Called, when player returns from AFK
    if(PlayerIsAFK[playerid]){
        PlayerIsAFK[playerid] = false;
        SetPVarInt(playerid, "isPlayerAFK", 0);
    }
    return 1;
}

forward CheckPlayerAFKStatus();
public CheckPlayerAFKStatus(){
    for(new i; i < MAX_PLAYERS; i++){
        if(!IsPlayerConnected(i))continue;

        // Explanation
        // This timer is called in every second and when player isn't AFK, then OnPlayerUpdate will reset this counter
        // But if player is AFK OnPlayerUpdate doesn't reset counter and player is setted into AFK status.
        PlayerAFKCounter[i] += 1;
        if(PlayerAFKCounter[i] >= 5){
            // Called, when player enters AFK status
            if(!PlayerIsAFK[playerid]){
                PlayerIsAFK[playerid] = true;
                SetPVarInt(playerid, "isPlayerAFK", 1);
            }
        }
    }
    return 1;
}
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode