|
Member
Join Date: Jul 2018
Location: Belgique - Belgium
|
05-28-2021
, 08:47
Re: A Author needs to help me. excuse me?
|
#3
|
Hey if it can help you, its putting player on AFK State
Quote:
Handle TimerAFK[MAXPLAYERS + 1] = { null, ... };
ConVar cvar_afk = null;
bool IsAFK[MAXPLAYERS + 1] = false;
public void OnPluginStart()
{
cvar_afk = CreateConVar("afk", "300", "Time to cooldown before to be AFK");
}
public Action OnClientCommand(int client)
{
ResetAFK(client);
return Plugin_Continue;
}
public void OnClientSettingsChanged(int client)
{
ResetAFK(client);
}
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
{
if(buttons != 0)
ResetAFK(client);
return Plugin_Continue;
}
int ResetAFK(int client)
{
if(IsClientValid(client))
{
int iYear, iMonth, iDay, iHour, iMinute, iSecond;
UnixToTime(GetTime(), iYear, iMonth, iDay, iHour, iMinute, iSecond, UT_TIMEZONE_CEST);
if(IsAFK[client])
PrintHintText(client, "Re-bonjour <font color='#eaff00'>%N</font>,\n nous sommes le <font color='#0091ff'>%02d/%02d/%d</font>, il est <font color='#0091ff'>%02d:%02d:%02d</font>", client, iDay, iMonth, iYear, iHour, iMinute, iSecond);
rp_SetClientBool(client, b_IsAfk, false);
if(TimerAFK[client] != null)
{
if(CloseHandle(TimerAFK[client]))
TimerAFK[client] = null;
}
TimerAFK[client] = CreateTimer(cvar_afk.FloatValue, SetAFK, client);
}
}
public Action SetAFK(Handle timer, any client)
{
if(IsClientValid(client))
{
if(cvar_afk.FloatValue != 0.0)
IsAFK[client] = true;
}
TimerAFK[client] = null;
}
|
__________________
|
|
|
|