23.03.2013, 06:43 
	(
 Последний раз редактировалось iFear; 23.03.2013 в 07:42.
)
	
	F - AFK System
INFO
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 - 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
    bool: g_AFK[MAX_PLAYERS],
    Float: g_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(playerid, text[])
{
    if (g_AFK[playerid]) // The player is AFK and tried to chat!
        return  SendClientMessage(playerid, RED, "You are AFK! You cannot talk."),
                0; // Sends a message and return 0, therefore the text will not be send.
                
    return true;
}
YCMD:afk(playerid, params[], help)
{
    if (g_AFK[playerid]) // The player is already AFK.
        return SendClientMessage(playerid, RED, "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(iVeh, g_fHealth[playerid]); // Get's the current vehicle health
        SetVehicleHealth(iVeh, INFINITY); // Set the vehicle's health to INFINITY
    }
    
    else // The player is on foot.
    {
        GetPlayerHealth(playerid, g_fHealth[playerid]); // Get's the player's current health
        SetPlayerHealth(playerid, INFINITY); // Set the player's health to INFINITY
    }
    
    g_AFK[playerid] = true; // The player is now AFK.
    TogglePlayerControllable(playerid, false); // Freeze the player so they can't move.
    
    new name[MAX_PLAYER_NAME], str[128];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME); // Get's the player name
    format(str, sizeof 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(GREEN, str);
    
    return true;
}
YCMD:back(playerid, params[], help)
{
    if (!g_AFK[playerid]) // The player is not AFK
        return SendClientMessage(playerid, RED, "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(iVeh, g_fHealth[playerid]); // Set the vehicle's health to the vehicle's old health
    }
    else // The player is on foot.
    {
        SetPlayerHealth(playerid, g_fHealth[playerid]); // Set the player's health to the player's old health
    }
    
    g_AFK[playerid] = false; // The player is now not AFK.
    TogglePlayerControllable(playerid, true); // The player can now move again.
    
    new name[MAX_PLAYER_NAME], str[128];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME); // Get's the player name
    format(str, sizeof str, "%s is back from AFK!", name); // Format the string
    // Send client messages.
    SendClientMessage(playerid, -1, "Welcome back!");
    SendClientMessageToAll(GREEN, str);
    
    return true;
} 
Credits
| iFear | Scripter | |
| ****** | For YSI | 
__________________________________________________ ___________
I Hope you all Like it. Thanks for your time.
~ iFear




 
	 
	


