SA-MP Forums Archive
[FilterScript] Simple AFK System - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Simple AFK System (/showthread.php?tid=316878)

Pages: 1 2


Simple AFK System - misho1 - 09.02.2012

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


Re: Simple AFK System - Gravity4501 - 09.02.2012

Nice Good Job!


Re: Simple AFK System - misho1 - 09.02.2012

thnx


Re: Simple AFK System - V_LOPE - 09.02.2012

simple but nice.
Good Job.


Re: Simple AFK System - suhrab_mujeeb - 09.02.2012

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!


Re: Simple AFK System - V_LOPE - 09.02.2012

suhrab is correct.

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



Re: Simple AFK System - suhrab_mujeeb - 09.02.2012

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?


Re: Simple AFK System - misho1 - 09.02.2012

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


Re: Simple AFK System - ryan39 - 09.02.2012

Thanks for this AFK system.


Re: Simple AFK System - misho1 - 10.02.2012

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


Re: Simple AFK System - lakshikagayal - 10.02.2012

Cool work
Keep it up


Re: Simple AFK System - misho1 - 10.02.2012

thnx dude


Re: Simple AFK System - Zarky - 12.02.2012

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!


Re: Simple AFK System - misho1 - 13.02.2012

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


Re: Simple AFK System - Agent Smith - 16.02.2012

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.


Re: Simple AFK System - misho1 - 16.02.2012

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


Re: Simple AFK System - Henry_Martinez - 17.02.2012

Thanks. I will use this.


Re: Simple AFK System - misho1 - 17.02.2012

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


Re: Simple AFK System - misho1 - 11.06.2012

Sry For Double Post
The Bugs Fixed!


Re: Simple AFK System - MoonCalF - 07.08.2012

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..