[FilterScript] Simple AFK System
#1

Hi,
This Is Simple FS Made By Me
That When You Type /AFK You Will Be Away From Keyboard And When You Type /Back You Will Return From AFK

Commands:
/AFK
/BACK

[EDITED]Here Is It:
pawn Code:
////////////////////////////Simple AFK System By Misho//////////////////////////
#include a_samp
#include ysi\y_commands
#define RED   0xFF0000FF
#define GREEN 0x008000FF
#define BLUE  0x0000FFFF
#define ORANGE    0xFF8000FF
new AFK[MAX_PLAYERS];
new Float:Health;


public OnFilterScriptInit()
{
    print("\n**************************************");
    print("********Simple AFK FS By Misho*********");
    print("**************************************\n");
    return 1;
}



public OnPlayerText(playerid, text[])
{
    if(AFK[playerid] ==1)
    {
        SendClientMessage(playerid,RED,"You're In AFK You Can't Talk");
        return 0;
}
    return 1;
}


                YCMD:afk(playerid,params[],help)
                {
                new string[128];
                new PNAME[MAX_PLAYER_NAME];
                if(AFK[playerid] ==1)
                {
                return SendClientMessage(playerid,RED,"You're Already In AFK");
                }
                if(IsPlayerInAnyVehicle(playerid) == 1)
                {
                AFK[playerid] = 1;
                SetVehicleHealth(GetPlayerVehicleID(playerid),9999999999);
                GetVehicleHealth(GetPlayerVehicleID(playerid),Health);
                SendClientMessage(playerid,RED,"You're Now In AFK");
                GetPlayerName(playerid, PNAME, MAX_PLAYERS);
                format(string, sizeof(string), "%s Is Now In AFK", PNAME);
                SendClientMessageToAll(BLUE,string);
                TogglePlayerControllable(playerid,0);
                return 1;
                }
                AFK[playerid] = 1;
                SetPlayerHealth(playerid,999999999);
                GetPlayerHealth(playerid,Health);
                SendClientMessage(playerid,RED,"You're Now In AFK");
                GetPlayerName(playerid, PNAME, MAX_PLAYERS);
                format(string, sizeof(string), "%s Is Now In AFK", PNAME);
                SendClientMessageToAll(BLUE,string);
                TogglePlayerControllable(playerid,0);
                return 1;
            }

                YCMD:back(playerid,params[],help)
                {
                new string[128];
                new PNAME[MAX_PLAYER_NAME];
                if(AFK[playerid] ==0)
                {
                return SendClientMessage(playerid,RED,"You're Not In AFK To Use This Command");
                }
                if(IsPlayerInAnyVehicle(playerid) == 1)
                {
                AFK[playerid] = 0;
                SetVehicleHealth(GetPlayerVehicleID(playerid),Health);
                TogglePlayerControllable(playerid,1);
                SendClientMessage(playerid,GREEN,"You're Back From AFK");
                GetPlayerName(playerid, PNAME, MAX_PLAYERS);
                format(string, sizeof(string), "%s Back From AFK", PNAME);
                SendClientMessageToAll(ORANGE,string);
                return 1;
                }
                AFK[playerid] = 0;
                SetPlayerHealth(playerid,Health);
                SendClientMessage(playerid,GREEN,"You're Back From AFK");
                GetPlayerName(playerid, PNAME, MAX_PLAYERS);
                format(string, sizeof(string), "%s Back From AFK", PNAME);
                SendClientMessageToAll(ORANGE,string);
                TogglePlayerControllable(playerid,1);
                return 1;
            }
Credits:
Misho:Script It
V_LOPE:Helped Me In Something

NEW:Bug Fixed

Sry For My Bad English
Reply
#2

Nice Good Job!
Reply
#3

thnx
Reply
#4

simple but nice.
Good Job.
Reply
#5

This can be used as a health restorer. A player health is 1.0 and when he /AFKs, his health is set to 999999999 or whatever and when he /BACKs his health is restored to 100.0. Great!
Reply
#6

suhrab is correct.

added this .
pawn Code:
//at top
new Float:OldHealth;
//.....:::: In /afk command ::::.....//
GetPlayerHealth(playerid,OldHealth);
//.......::: in /back command ::...//
SetPlayerHealth(playerid,OldHealth);
Reply
#7

You also have to see if the player is in vehicle and then set his vehicle health. If he isn't in a vehicle, how can you set the vehicle's health?
Reply
#8

Quote:
Originally Posted by suhrab_mujeeb
View Post
This can be used as a health restorer. A player health is 1.0 and when he /AFKs, his health is set to 999999999 or whatever and when he /BACKs his health is restored to 100.0. Great!
Sry I Wasn't know About Get Old Health
Quote:
Originally Posted by V_LOPE
View Post
simple but nice.
Good Job.
Thnx
Quote:
Originally Posted by V_LOPE
View Post
suhrab is correct.

added this .
pawn Code:
//at top
new Float:OldHealth;
//.....:::: In /afk command ::::.....//
GetPlayerHealth(playerid,OldHealth);
//.......::: in /back command ::...//
SetPlayerHealth(playerid,OldHealth);
Thnx For This I Add Your Name In the Credits
Reply
#9

Thanks for this AFK system.
Reply
#10

Quote:
Originally Posted by ryan39
View Post
Thanks for this AFK system.
You're Welcome!
Reply
#11

Cool work
Keep it up
Reply
#12

thnx dude
Reply
#13

Well, I guess no need for Set player health to 9999999999999 just Let him be afk in a particular place like

Set His Player Position to a Jail and Freeze him till he's back he can Go back to his own place and continue playing

Nice FS. GJ!
Reply
#14

Quote:
Originally Posted by Zarky
Посмотреть сообщение
Well, I guess no need for Set player health to 9999999999999 just Let him be afk in a particular place like

Set His Player Position to a Jail and Freeze him till he's back he can Go back to his own place and continue playing

Nice FS. GJ!
There Are already some one did that in his fs
...
thnx
Reply
#15

Nice idea but there are quite a few problems with this script in general:
pawn Код:
SetPlayerHealth(playerid,999999999);
SetVehicleHealth(vehicleid,9999999999);
GetPlayerHealth(playerid,OldHealth);
GetVehicleHealth(vehicleid,OldHealth);
What you are doing is setting the person health to 999999.. and then saving that health as 999999.. so that when the player gets back, you are setting the health back to 9999999.. again.

Also the OldHealth is a global variable, rather than a variable for every player so every time someone uses this command it will change the variable. Also you are using the SAME variable to store the health of the player AND the health of the vehicle.
Reply
#16

Quote:
Originally Posted by Agent Smith
Посмотреть сообщение
Nice idea but there are quite a few problems with this script in general:
pawn Код:
SetPlayerHealth(playerid,999999999);
SetVehicleHealth(vehicleid,9999999999);
GetPlayerHealth(playerid,OldHealth);
GetVehicleHealth(vehicleid,OldHealth);
What you are doing is setting the person health to 999999.. and then saving that health as 999999.. so that when the player gets back, you are setting the health back to 9999999.. again.

Also the OldHealth is a global variable, rather than a variable for every player so every time someone uses this command it will change the variable. Also you are using the SAME variable to store the health of the player AND the health of the vehicle.
When you Type /back it back your old health

pawn Код:
SetPlayerHealth(playerid,OldHealth);
        SetVehicleHealth(vehicleid,OldHealth);
before afk:http://imageshost.webs.com/apps/phot...toid=149462444

in afk:http://imageshost.webs.com/apps/phot...toid=149462445

back from afk:http://imageshost.webs.com/apps/phot...toid=149462446
Reply
#17

Thanks. I will use this.
Reply
#18

Quote:
Originally Posted by Henry_Martinez
Посмотреть сообщение
Thanks. I will use this.
Enjoy By Using It
Reply
#19

Sry For Double Post
The Bugs Fixed!
Reply
#20

C:\Users\Admin\Desktop\FMOK\FMOK\filterscripts\s.p wn(37) : error 017: undefined symbol "PInfo"
C:\Users\Admin\Desktop\FMOK\FMOK\filterscripts\s.p wn(37) : warning 215: expression has no effect
C:\Users\Admin\Desktop\FMOK\FMOK\filterscripts\s.p wn(37) : error 001: expected token: ";", but found "]"
C:\Users\Admin\Desktop\FMOK\FMOK\filterscripts\s.p wn(37) : error 029: invalid expression, assumed zero
C:\Users\Admin\Desktop\FMOK\FMOK\filterscripts\s.p wn(37) : fatal error 107: too many error messages on one line

help..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)