10.12.2017, 12:56
I wanted to ask, if there is a possible way to get player killed if hes in AFK mode ( ESC menu ).
#define FILTERSCRIPT
#include <a_samp>
new bool:PlayerPaused;
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerPaused = false;
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED(KEY_ESC))
{
PlayerPaused = true;
if(PlayerPaused)
{
SetPlayerHealth(playerid, 0);
}
}
return 1;
}
//Top of the script
enum pInfo{
Float:pAFKPos[6],
pAFKTime,
pAFK
};
new PlayerInfo[playerid][pInfo];
//OnPlayerConnect
SetTimerEx("AFKCheck", 1000, true, "i", playerid);
//Somewhere in the script, outside of a callback/function
forward AFKCheck(playerid);
public AFKCheck(playerid)
{
new
Float:x,
Float:y,
Float:z,
Float:cx,
Float:cy,
Float:cz;
GetPlayerPos(playerid, x, y, z);
GetPlayerCameraPos(playerid, cx, cy, cz);
if(PlayerInfo[playerid][pAFKPos][0] == x && PlayerInfo[playerid][pAFKPos][1] == y && PlayerInfo[playerid][pAFKPos][2] == z && PlayerInfo[playerid][pAFKPos][3] == cx && PlayerInfo[playerid][pAFKPos][4] == cy && PlayerInfo[playerid][pAFKPos][5] == cz)
{
PlayerInfo[playerid][pAFKTime]++;
if(PlayerInfo[playerid][pAFK] && PlayerInfo[playerid][pAFKTime] >= 60)
{
SendClientMessage(playerid, COLOR_WHITE, "**{FF0000}Server:{FFFFFF} You have been killed since you have been {00AA00}Away from keyboard{ffffff} in one minute.");
SetPlayerHealth(playerid, 0.0);
PlayerInfo[playerid][pAFK];
}
}
PlayerInfo[playerid][pAFKPos][0] = x;
PlayerInfo[playerid][pAFKPos][1] = y;
PlayerInfo[playerid][pAFKPos][2] = z;
PlayerInfo[playerid][pAFKPos][3] = cx;
PlayerInfo[playerid][pAFKPos][4] = cy;
PlayerInfo[playerid][pAFKPos][5] = cz;
}
Try this
PHP код:
|