[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
#2

Instead of
pawn Код:
new Float:Health;
You will need
pawn Код:
new Float: Health[MAX_PLAYERS];
So, you'll use it like
pawn Код:
GetPlayerHealth(playerid, Health[playerid]);
(Because you will store all player health in the same variable, it'll mix up)

And
pawn Код:
SetPlayerHealth(playerid,999999999);
GetPlayerHealth(playerid,Health);
You set the player's health and then get it. That way, Health will return 99999999999. Not the old player health.
I think it should be like :
pawn Код:
GetPlayerHealth(playerid, Health[playerid]); // Assuming that it's new Float: Health[MAX_PLAYERS];
SetPlayerHealth(playerid, 999999999);
Same goes with Vehicle Health thingy.
Reply
#3

Fixed! Thanks for COmment
Reply
#4

Any more comments?
Reply
#5

very easy AFK System
Reply
#6

Thanks Firemanstone.
Reply
#7

Why in the world is there only AFK systems being released on SA-MP forums?
Reply
#8

Quote:
Originally Posted by Lordz™
Посмотреть сообщение
Why in the world is there only AFK systems being released on SA-MP forums?
Choot Choot everyone get on the rep train
Reply
#9

Quote:

C:\Users\x\Desktop\Just_Roleplay\afk sistem\AFK_System.pwn(6) : fatal error 100: cannot read from file: "YSI\y_commands"

I have this error!
Reply
#10

Traillion of sa-mp afk system ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)