[FilterScript] F-AFK System
#1

F - AFK System

I
NFO

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.


C
ommands

/afk - To Away from Keyboard.
/back - Back from AFK.


Download

PHP код:
/*
    F-AFK System by iFear
*/
#include <a_samp>
#include <YSI\y_commands>
#define RED       0xFF0000FF
#define GREEN     0x33FF33AA
#define BLUE      0x0000FFFF
#define ORANGE  0xFF8000FF
#if !defined INFINITY
    #define INFINITY (Float:0x7F800000)
#endif
// Creates new variables
new
    
boolg_AFK[MAX_PLAYERS],
    
Floatg_fHealth[MAX_PLAYERS];
    
// Main script
public OnFilterScriptInit()
{
    print(
"\n**************************************");
    print(
"********F-AFK System by iFear*********");
    print(
"**************************************\n");
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
g_AFK[playerid] = false// Set g_AFK to false.
    
return true;
}
public 
OnPlayerText(playeridtext[])
{
    if (
g_AFK[playerid]) // The player is AFK and tried to chat!
        
return  SendClientMessage(playeridRED"You are AFK! You cannot talk."),
                
0// Sends a message and return 0, therefore the text will not be send.
                
    
return true;
}
YCMD:afk(playeridparams[], help)
{
    if (
g_AFK[playerid]) // The player is already AFK.
        
return SendClientMessage(playeridRED"You are AFK. Use /back if you're back.");
        
    if (
IsPlayerInAnyVehicle(playerid)) // The player is in a vehicle
    
{
        new 
iVeh GetPlayerVehicleID(playerid); // Get's the player's vehicle ID
        
GetVehicleHealth(iVehg_fHealth[playerid]); // Get's the current vehicle health
        
SetVehicleHealth(iVehINFINITY); // Set the vehicle's health to INFINITY
    
}
    
    else 
// The player is on foot.
    
{
        
GetPlayerHealth(playeridg_fHealth[playerid]); // Get's the player's current health
        
SetPlayerHealth(playeridINFINITY); // Set the player's health to INFINITY
    
}
    
    
g_AFK[playerid] = true// The player is now AFK.
    
TogglePlayerControllable(playeridfalse); // Freeze the player so they can't move.
    
    
new name[MAX_PLAYER_NAME], str[128];
    
GetPlayerName(playeridnameMAX_PLAYER_NAME); // Get's the player name
    
format(strsizeof str"%s is now AFK!"name); // Format the string
    
    // Send client messages.
    
SendClientMessage(playerid, -1"You are now AFK. Use /back if you are back!");
    
SendClientMessageToAll(GREENstr);
    
    return 
true;
}
YCMD:back(playeridparams[], help)
{
    if (!
g_AFK[playerid]) // The player is not AFK
        
return SendClientMessage(playeridRED"You are not AFK!");
        
    if (
IsPlayerInAnyVehicle(playerid)) // The player is in a vehicle
    
{
        new 
iVeh GetPlayerVehicleID(playerid); // Get's the player's vehicle ID
        
SetVehicleHealth(iVehg_fHealth[playerid]); // Set the vehicle's health to the vehicle's old health
    
}
    else 
// The player is on foot.
    
{
        
SetPlayerHealth(playeridg_fHealth[playerid]); // Set the player's health to the player's old health
    
}
    
    
g_AFK[playerid] = false// The player is now not AFK.
    
TogglePlayerControllable(playeridtrue); // The player can now move again.
    
    
new name[MAX_PLAYER_NAME], str[128];
    
GetPlayerName(playeridnameMAX_PLAYER_NAME); // Get's the player name
    
format(strsizeof str"%s is back from AFK!"name); // Format the string
    // Send client messages.
    
SendClientMessage(playerid, -1"Welcome back!");
    
SendClientMessageToAll(GREENstr);
    
    return 
true;



Credits

iFearScripter
******For YSI


__________________________________________________ ___________

I Hope you all Like it. Thanks for your time.

~ iFear
Reply


Messages In This Thread
F-AFK System - by iFear - 23.03.2013, 06:43
Re: F-AFK System - by greentarch - 23.03.2013, 07:08
Re: F-AFK System - by iFear - 23.03.2013, 07:42
Re: F-AFK System - by iFear - 24.03.2013, 03:55
Re: F-AFK System - by FiReMaNStone - 24.03.2013, 04:11
Re: F-AFK System - by iFear - 24.03.2013, 04:54
Re: F-AFK System - by Lordzy - 10.04.2013, 18:00
AW: Re: F-AFK System - by [AK]Nazgul - 10.04.2013, 19:10
Re: F-AFK System - by breckmen - 10.04.2013, 19:29
Re: F-AFK System - by M3mPHi$_S3 - 11.04.2013, 01:56

Forum Jump:


Users browsing this thread: 2 Guest(s)