Kill if AFK(ESC Menu)
#1

I wanted to ask, if there is a possible way to get player killed if hes in AFK mode ( ESC menu ).
Reply
#2

Serverside health.
Reply
#3

Quote:
Originally Posted by Dignity
Посмотреть сообщение
Serverside health.
The thing is that i dont know how to script that.
Reply
#4

Quote:
Originally Posted by Dignity
Посмотреть сообщение
Serverside health.
what? He asked how to script a system that kills the player when he goes afk.
Reply
#5

PHP код:
#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; 
} 
Reply
#6

Quote:
Originally Posted by rfr
Посмотреть сообщение
PHP код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (
PRESSED(ESC))
    {
        
SetPlayerHealth(playerid, 0);
    }
    return 
1;
} 
If they use ESC to close a dialog?
Reply
#7

Try this

PHP код:
//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;
} 
Reply
#8

Quote:
Originally Posted by Lucases
Посмотреть сообщение
If they use ESC to close a dialog?
Yeah, I don't want to spend 10 mins on answering.
Reply
#9

Quote:
Originally Posted by NealPeteros
Посмотреть сообщение
Try this

PHP код:
//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;
} 
I guess it kills automatically the player after 1 minute. But if i want that somebody kills the afk player, then...
Reply
#10

Quote:
Originally Posted by Funce
Посмотреть сообщение
But if i want that somebody kills the afk player, then...
Huh?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)