afk check doesnt work -
severance - 02.09.2018
OnPlayerConnect
PHP код:
SetTimerEx("AFKCheck", 5000, 1, "i", playerid);
PHP код:
forward AFKCheck(playerid);
public AFKCheck(playerid)
{
new Float:Pos[3];
for(new i = 0; i < MAX_PLAYERS; i++)
{
GetPlayerPos(i,Pos[0],Pos[1],Pos[2]);
if(IsPlayerInRangeOfPoint(i,2,Pos[0],Pos[1],Pos[2]))
{
AFK[i]++;
}
if(AFK[i] == 60)
{
AFK[i] = 0;
Lounge[i] = true;
SetPlayerPos(i, -794.806396,497.738037,1376.195312);
SetPlayerInterior(i, 1);
SetPlayerVirtualWorld(i,10);
IsPlayerInLobby[i] = 1;
SetPlayerHealth(i, 99999);
ResetPlayerWeapons(i);
new string[250];
format(string, sizeof(string), "_AFK_%s", PlayerName[i]);
SetPlayerName(i, string);
SetPlayerColor(i, COLOR_GREY);
}
}
return 1;
}
I joined a test sv with my friends, he goes afk, but instead changing his nickanem to _AFK_clown, i get it changed to myself instead, there's someting wrong with the "id's" cant figure out.
Re: afk check doesnt work -
solstice_ - 02.09.2018
Could you show the AFK code too?
Re: afk check doesnt work -
severance - 02.09.2018
It's just a variable that increases the count , and once it reaches 60, it will detect the player as being "afk".
PHP код:
new AFK[MAX_PLAYERS];
The system works, but when theres 2 players, it confuses the player id of who is going afk and who not. And so it puts all together.
Re: afk check doesnt work -
RogueDrifter - 02.09.2018
Well first that check is too messy it'll never work for several reasons which i don't have time to state atm,
Although here's something i made really quick:
CLICK HERE
It gives these to control with:
Код:
/*Functions:
__________*/
bool:IsPlayerPaused(playerid); //If the player pressed the Esc button
bool:IsPlayerAFK(playerid); //If the player isn't moving
/*Callbacks:
__________*/
public OnPlayerPause(playerid) //Once a player presses the Esc button
public OnPlayerResume(playerid) //Once a player returns from pausing
public OnPlayerAFK(playerid) //Once a player stops moving for about 55-65 seconds
public OnPlayerReturn(playerid) //Once a player starts moving again
It's an include so yeah just include it in your script using:
Код:
#include <rAfk_Checker>
Re: afk check doesnt work -
severance - 02.09.2018
Thanks for answer, will try this
Re: afk check doesnt work -
Shinja - 02.09.2018
1. You already set playerid param why would you loop again through all players?
2. You must get the player position for the first time at spawn
PHP код:
public OnPlayerSpawn(playerid)
{
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
return 1;
}
forward AFKCheck(playerid);
public AFKCheck(playerid)
{
new Float:Pos[3];
if(IsPlayerInRangeOfPoint(playerid,2,Pos[0],Pos[1],Pos[2]))
{
AFK[playerid]++;
}
else GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
if(AFK[playerid] == 60)
{
AFK[playerid] = 0;
Lounge[playerid] = true;
SetPlayerPos(playerid, -794.806396,497.738037,1376.195312);
SetPlayerInterior(playerid, 1);
SetPlayerVirtualWorld(playerid,10);
IsPlayerInLobby[playerid] = 1;
SetPlayerHealth(playerid, 99999);
ResetPlayerWeapons(playerid);
new string[250];
format(string, sizeof(string), "_AFK_%s", PlayerName[playerid]);
SetPlayerName(playerid, string);
SetPlayerColor(playerid, COLOR_GREY);
}
return 1;
}