[FilterScript] Simple AFK System :D [FIRST FILTERSCRIPT]
#1

AFK System
Hi all,

now i make AFK system just 30 Mins, its pretty simple, but you can AFK in vehicles

COMMAND:
/afk for AFK mode and type /afk again For back from AFK mode

DOWNLOAD:
Solidfiles AMX File : Solidfiles
Solidfiles PWN File : Solidfiles

For Pawno Code :
PHP код:
#include <a_samp>
#include <ZCMD>
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_RED 0xAA3333AA
#define COLOR_BLACK 0x0E0101FF
new Text3D:AFKLABEL[MAX_PLAYERS];
new 
AFK[MAX_PLAYERS];
new 
Float:OldPHealth;
new 
Float:NewPHealth;
new 
Float:OldPArmour;
new 
Float:NewPArmour;
#pragma unused NewCHealth
#pragma unused NewPHealth
#pragma unused NewPArmour
new Float:OldCHealth;
new 
Float:NewCHealth;
public 
OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
"AFK System by Mya");
    print(
"--------------------------------------\n");
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
AFK[playerid] = 0;
     return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    if(
AFK[playerid] == 1)
    {
        new 
name[MAX_PLAYER_NAME];
        new 
WasAFK[70];
        
GetPlayerName(playeridnamesizeof(name));
        
format(WasAFKsizeof(WasAFK), "%s{FFFFFF} Has logged out while in /AFK Mode"name);
        
SendClientMessageToAll(COLOR_REDWasAFK);
        
AFK[playerid] = 0;
    }
}
CMD:afk(playeridparams[])
{
    if(
AFK[playerid] == 0)
    {
         new 
vehicleid;
        
GetPlayerHealth(playerid,OldPHealth);
        
GetPlayerArmour(playeridOldPArmour);
        
GetVehicleHealth(vehicleid,OldCHealth);
           
SetPlayerHealth(playerid999999);
        
SetPlayerArmour(playerid999999);
        
SetVehicleHealth(vehicleid,999999);
        
SendClientMessage(playeridCOLOR_RED"You are now Away from the Keyboard, type /afk again to resume playing.");
        
SetPlayerColor(playeridCOLOR_BLACK);
        
AFK[playerid] = 1;
        
AFKLABEL[playerid] = Create3DTextLabel("Away From Keyboard",COLOR_YELLOW,30.0,40.0,50.0,40.0,0);
        
Attach3DTextLabelToPlayer(AFKLABEL[playerid], playerid0.00.00.7);
        
TogglePlayerControllable(playerid,0);
        new 
AfkMessage[70];
        new 
name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridnamesizeof(name));
        
format(AfkMessagesizeof(AfkMessage), "**%s {FFFFFF}Now Is AFK(away from keyboard)"name);
        
SendClientMessageToAll(COLOR_YELLOWAfkMessage);
    }
    else
    {
         new 
vehicleid;
         
SendClientMessage(playeridCOLOR_RED"Welcome back, you are no longer flagged as Away From Keyboard!");
         
TogglePlayerControllable(playerid,1);
         
SetPlayerHealth(playerid,OldPHealth);
         
SetPlayerArmour(playerid,OldPArmour);
         
SetVehicleHealth(vehicleid,OldCHealth);
         
SetPlayerColor(playerid0xFFFFFFAA);
         
AFK[playerid] = 0;
         new 
AfkMessage[70];
         new 
name[MAX_PLAYER_NAME];
         
GetPlayerName(playeridnamesizeof(name));
         
format(AfkMessagesizeof(AfkMessage), "**%s {FFFFFF}Now back from AFK(away from keyboard)"name);
         
SendClientMessageToAll(COLOR_YELLOWAfkMessage);
         
Delete3DTextLabel(Text3D:AFKLABEL[playerid]);
     }
     return 
1;

Reply
#2

Look,
You need to remove the PlayerHealth and Vehicle health codes because i can use /afk while i am in the battle zone i can hide and use command to recover my health also same with the vehicles.
Regards
Reply
#3

Код:
SetVehicleHealth(vehicleid,9999999999); 
GetVehicleHealth(vehicleid,OldHealth);
You saved vehicle health after you set it to 9999999999?
and every players can refill their health easily.
You must create variable to save player health & armour too.
Reply
#4

Quote:
Originally Posted by bondowocopz
Посмотреть сообщение
Код:
SetVehicleHealth(vehicleid,9999999999); 
GetVehicleHealth(vehicleid,OldHealth);
You saved vehicle health after you set it to 9999999999?
and every players can refill their health easily.
You must create variable to save player health & armour too.
Im newbie scripter, i need learn more about scripting thanks for that

Quote:
Originally Posted by MohanedZzZ
Посмотреть сообщение
Look,
You need to remove the PlayerHealth and Vehicle health codes because i can use /afk while i am in the battle zone i can hide and use command to recover my health also same with the vehicles.
Regards
Ok, im newbie
Reply
#5

Nice Good
Reply
#6

Quote:
Originally Posted by LazyBoyyyy
Посмотреть сообщение
Nice Good
Thanks. its my first Filterscript
Reply
#7

not bad for first Filterscript
Reply
#8

Great to see how newbies learn and create new things, Also I like when newbie scripter doesn't copy.

Great job brother.
Reply
#9

This is not a bad script. I see you have some good scripting habits and you don't use strings much longer than you need. However this script can be abused a lot. So a better way to do it is, Save the player's position, run a 5 seconds timer or so to give a chance for anyone that was chasing him to kill him, and then check his position again. If it's not the same then maybe he's too busy to AFK now and if it is the same, Simply leave his health unchanged but set his virtual world to his ID + 1 for example so everyone will be in his own VW. And when they are back you can just unfreeze them and set their VW to 0. If there is a chance that the player is AFKing in a VW other than 0 then simply save the player's VW BEFORE you change it.
Reply
#10

Good Job!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)