[AFK System] need help -
JeroenX - 08.04.2012
Hello, ive made an simple afk system.
But i have one question:
I want to auto-afk someone if he is not moving for 30 minutes, how to do this?
I hope you guys can help me!
- Jeroen
Re: [AFK System] need help -
Plastic - 08.04.2012
i think you should ask this in scripting discussion section
Re: [AFK System] need help -
.FuneraL. - 08.04.2012
pawn Код:
forward TimeAFK(playerid);
public TimeAFK(playerid)
{
TogglePlayerControllable(playerid, 0);
return 1;
}
if(strcmp("/afk", cmdtext, true) == 0)
{
SetTimerEx("TimeAFK", 1800000, false, "d", playerid);
TogglePlayerControllable(playerid, 1)
new Name[MAX_PLAYER_NAME];
new string[256]
GetPlayerName(playerid, Name, MAX_PLAYER_NAME];
format(string, sizeof(string), "%s Entered into auto-away mode", Name);
SendClientMessageToAll(0xFFFFFFFF, string);
return 1;
}
Try This.
Re: [AFK System] need help -
JeroenX - 08.04.2012
Hello,
I wished to auto afk someone when he's not moving for 10 minutes,
When hes not moving in 10 minutes, he will be kicked.
- Jeroen
Re: [AFK System] need help -
[EuG]ZeRoGoD - 08.04.2012
dont use strcmp its outdated! and try this and all you do is define a timer for afk members
Код:
new AFK[MAX_PLAYERS];
CMD:afk(playerid, params[])
{
new string[200];
if(AFK[playerid] == 0)
{
SetPlayerHealth(playerid, 999999);
format(string, sizeof(string), " **{00CCFF}[ AFK ] {2641FE} %s {FFFFFF}is now AFK Don't attack him!", PlayerName(playerid));
SendClientMessageToAll(COLOR_MODRA, string);
TogglePlayerControllable(playerid, false);
SendClientMessage(playerid, COLOR_WHITE,"You are now AFK");
AFK[playerid] = 1;
}
return 1;
}
CMD:back(playerid, params[])
{
new string[200];
if(AFK[playerid] == 1)
{
SetPlayerHealth(playerid, 60);
format(string, sizeof(string), " **{00CCFF}[ AFK ] {2641FE} %s {FFFFFF}is now Back!", PlayerName(playerid));
SendClientMessageToAll(COLOR_MODRA, string);
TogglePlayerControllable(playerid, true);
SendClientMessage(playerid, COLOR_WHITE,"Welcome Back! ");
AFK[playerid] = 0;
}
return 1;
}
if failing that then try putting this in with a afk system
Код:
new name[MAX_PLAYER_NAME], string[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "[AFK]%s", name);
SetPlayerName(playerid, string);
Re: [AFK System] need help -
[EuG]ZeRoGoD - 08.04.2012
or try this!
Код:
new AFK[MAX_PLAYERS];
// ...
public OnGameModeInit()
{
// Run a timer here
SetTimer("CheckAFK", 1000, true);
}
// ...
public OnPlayerUpdate(playerid)
{
// If the player just came back from being afk, the AFK variable is most likely more than 3/5 (vary this based on your gamemode and experience)
if(AFK[playerid] > 3)
{
// This player just came back from being AFK
}
AFK[playerid] = 0;
}
// ...
forward CheckAFK();
public CheckAFK()
{
// Suggestions for loop: either use foreach or at least define MAX_PLAYERS to your server's server.cfg amount!
for(new i = 0; i != MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
AFK[i] ++;
if(AFK[i] == 3)
{
// The player most likely just went AFK!
}
}
}
Код:
format(string, sizeof(string), "%s(%i) has been away from keyboard for %d seconds.", PlayerName, playerid, AFK[playerid]);
SendClientMessageToAll(-1, string);