[FilterScript] F-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] F-AFK System (
/showthread.php?tid=424638)
F-AFK System -
iFear - 23.03.2013
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
Re: F-AFK System -
greentarch - 23.03.2013
Instead of
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.
Re: F-AFK System -
iFear - 23.03.2013
Fixed! Thanks for COmment
Re: F-AFK System -
iFear - 24.03.2013
Any more comments?
Re: F-AFK System -
FiReMaNStone - 24.03.2013
very easy AFK System
Re: F-AFK System -
iFear - 24.03.2013
Thanks Firemanstone.
Re: F-AFK System -
Lordzy - 10.04.2013
Why in the world is there only AFK systems being released on SA-MP forums?
AW: Re: F-AFK System -
[AK]Nazgul - 10.04.2013
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
Re: F-AFK System -
breckmen - 10.04.2013
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!
Re: F-AFK System -
M3mPHi$_S3 - 11.04.2013
Traillion of sa-mp afk system ...