#include <a_samp>
#include <ZCMD>
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_RED 0xAA3333AA
#define COLOR_BLACK 0x0E0101FF
new Text3D:AFKLABEL[MAX_PLAYERS];
new AFK[MAX_PLAYERS];
new Float:OldPHealth;
new Float:NewPHealth;
new Float:OldPArmour;
new Float:NewPArmour;
#pragma unused NewCHealth
#pragma unused NewPHealth
#pragma unused NewPArmour
new Float:OldCHealth;
new Float:NewCHealth;
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print("AFK System by Mya");
print("--------------------------------------\n");
return 1;
}
public OnPlayerConnect(playerid)
{
AFK[playerid] = 0;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(AFK[playerid] == 1)
{
new name[MAX_PLAYER_NAME];
new WasAFK[70];
GetPlayerName(playerid, name, sizeof(name));
format(WasAFK, sizeof(WasAFK), "%s{FFFFFF} Has logged out while in /AFK Mode", name);
SendClientMessageToAll(COLOR_RED, WasAFK);
AFK[playerid] = 0;
}
}
CMD:afk(playerid, params[])
{
if(AFK[playerid] == 0)
{
new vehicleid;
GetPlayerHealth(playerid,OldPHealth);
GetPlayerArmour(playerid, OldPArmour);
GetVehicleHealth(vehicleid,OldCHealth);
SetPlayerHealth(playerid, 999999);
SetPlayerArmour(playerid, 999999);
SetVehicleHealth(vehicleid,999999);
SendClientMessage(playerid, COLOR_RED, "You are now Away from the Keyboard, type /afk again to resume playing.");
SetPlayerColor(playerid, COLOR_BLACK);
AFK[playerid] = 1;
AFKLABEL[playerid] = Create3DTextLabel("Away From Keyboard",COLOR_YELLOW,30.0,40.0,50.0,40.0,0);
Attach3DTextLabelToPlayer(AFKLABEL[playerid], playerid, 0.0, 0.0, 0.7);
TogglePlayerControllable(playerid,0);
new AfkMessage[70];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(AfkMessage, sizeof(AfkMessage), "**%s {FFFFFF}Now Is AFK(away from keyboard)", name);
SendClientMessageToAll(COLOR_YELLOW, AfkMessage);
}
else
{
new vehicleid;
SendClientMessage(playerid, COLOR_RED, "Welcome back, you are no longer flagged as Away From Keyboard!");
TogglePlayerControllable(playerid,1);
SetPlayerHealth(playerid,OldPHealth);
SetPlayerArmour(playerid,OldPArmour);
SetVehicleHealth(vehicleid,OldCHealth);
SetPlayerColor(playerid, 0xFFFFFFAA);
AFK[playerid] = 0;
new AfkMessage[70];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(AfkMessage, sizeof(AfkMessage), "**%s {FFFFFF}Now back from AFK(away from keyboard)", name);
SendClientMessageToAll(COLOR_YELLOW, AfkMessage);
Delete3DTextLabel(Text3D:AFKLABEL[playerid]);
}
return 1;
}
SetVehicleHealth(vehicleid,9999999999); GetVehicleHealth(vehicleid,OldHealth);
Код:
SetVehicleHealth(vehicleid,9999999999); GetVehicleHealth(vehicleid,OldHealth); and every players can refill their health easily. You must create variable to save player health & armour too. |
Look,
You need to remove the PlayerHealth and Vehicle health codes because i can use /afk while i am in the battle zone i can hide and use command to recover my health also same with the vehicles. Regards |