pInfo[playerid][tempoafk] = false;
#include a_samp
#include zcmd
enum pafk {
Timer,
Tempo,
bool:AFK
}
new SistemaAFK[MAX_PLAYERS][pafk];
public OnFilterScriptInit()
{
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
SistemaAFK[playerid][Tempo] = 0;
SistemaAFK[playerid][AFK] = false;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SistemaAFK[playerid][Tempo] = 0;
SistemaAFK[playerid][AFK] = false;
return 1;
}
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(success){
if(SistemaAFK[playerid][AFK] == true)return SendClientMessage(playerid, -1, "Senhor esta ausente.");}
return true;
}
command(afk, playerid, params[])
{
if(SistemaAFK[playerid][AFK] == false)
{
TogglePlayerControllable(playerid, false);
SendClientMessage(playerid, -1, "Use: /afk, para sair do modo ausente");
SistemaAFK[playerid][AFK] = true;
SistemaAFK[playerid][Timer] = SetTimerEx("CheckAFK", 1000, true, "i", playerid);
}
else
{
TogglePlayerControllable(playerid, true);
SendClientMessage(playerid, -1, "Use: /afk, para entrar no modo ausente");
SistemaAFK[playerid][AFK] = false;
KillTimer(SistemaAFK[playerid][Timer]);
}
return true;
}
command(lista, playerid, params[])
{
new pimbando[128];
for (new ds;ds <MAX_PLAYERS; ds++)
{
if(SistemaAFK[ds][AFK] == true)
{
format(pimbando, sizeof(pimbando), "%s O jogador %s estб ausente por: [%s]\n", pimbando, DonPegaNome(ds), Convert(SistemaAFK[ds][Tempo]));
}
}
if (strlen(pimbando) > 0)
ShowPlayerDialog(playerid, 99, DIALOG_STYLE_MSGBOX, "Jogadores ausentes:", pimbando, "FECHAR", #);
else
SendClientMessage(playerid, 0xFF0000FF, "{FF0000}Nгo hб jogadores ausentes.");
return true;
}
forward CheckAFK(playerid);
public CheckAFK(playerid)return SistemaAFK[playerid][Tempo]++;
stock DonPegaNome(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
stock Convert(number)
{
new hours = 0, mins = 0, secs = 0, string[100];
hours = floatround(number / 3600);
mins = floatround((number / 60) - (hours * 60));
secs = floatround(number - ((hours * 3600) + (mins * 60)));
new days = 0;
if(hours >= 24)
{
days = floatround((hours/24), floatround_floor);
hours = hours % 24;
}
if(days > 0)
{
format(string, 100, "%ddias, %dh %dm e %ds", days, hours, mins, secs);
}
else if(hours > 0)
{
format(string, 100, "%dh %dm e %ds", hours, mins, secs);
}
else
{
format(string, 100, "%dm e %ds", mins, secs);
}
return string;
}
// sгo dois arquivos. caso alguйm nгo tenha entendido.
/*
# db db d88888b .d8b. d8888b. d88888b d8888b. d888888b d8b db .o88b.
# 88 88 88' d8' `8b 88 `8D 88' 88 `8D `88' 888o 88 d8P Y8
# 88ooo88 88ooooo 88ooo88 88 88 88ooooo 88oobY' 88 88V8o 88 8P
# 88~~~88 88~~~~~ 88~~~88 88 88 88~~~~~ 88`8b 88 88 V8o88 8b
# 88 88 88. 88 88 88 .8D 88. 88 `88. db .88. 88 V888 Y8b d8
# YP YP Y88888P YP YP Y8888D' Y88888P 88 YD VP Y888888P VP V8P `Y88P'
*/
#if defined _inc_header
#undef _inc_header
#endif
#include <YSI\y_groups>
#include <YSI\y_commands>
#include <YSI\y_hooks>
new
Group:Group_AFK,
Player_Name[MAX_PLAYERS][MAX_PLAYER_NAME],
Player_TimeAfk[MAX_PLAYERS];
/*
# d88888b d8b db d8888b. .d88b. d88888b d88888b d888888b db d88888b
# 88' 888o 88 88 `8D .8P Y8. 88' 88' `88' 88 88'
# 88ooooo 88V8o 88 88 88 88 88 88ooo 88ooo 88 88 88ooooo
# 88~~~~~ 88 V8o88 88 88 88 88 88~~~ 88~~~ 88 88 88~~~~~
# 88. 88 V888 88 .8D `8b d8' 88 88 .88. 88booo. 88.
# Y88888P VP V8P Y8888D' `Y88P' YP YP Y888888P Y88888P Y88888P
*/
// [...]
// [...]
// [...]
/*
# d888888b .88b d88. d8888b. db d888888b d8b db .o88b.
# `88' 88'YbdP`88 88 `8D 88 `88' 888o 88 d8P Y8
# 88 88 88 88 88oodD' 88 88 88V8o 88 8P
# 88 88 88 88 88~~~ 88 88 88 V8o88 8b
# .88. 88 88 88 88 88booo. db .88. 88 V888 Y8b d8
# Y888888P YP YP YP 88 Y88888P VP Y888888P VP V8P `Y88P'
*/
#if defined _inc_impl
#undef _inc_impl
#endif
hook OnGameModeInit()
{
Group_AFK = Group_Create("AFK");
return true;
}
hook OnPlayerConnect(playerid)
{
GetPlayerName(playerid, Player_Name[playerid], MAX_PLAYER_NAME);
return true;
}
YCMD:ausentes(playerid, params[], help)
{
new
tmp_str[128];
SendClientMessage(playerid, -1, "Exibindo jogadores ausentes:");
foreach(new i : GroupMember(Group_AFK))
{
format(tmp_str, sizeof tmp_str, " %s - %i", Player_Name[playerid], gettime() - Player_TimeAfk[playerid]);
SendClientMessage(playerid, -1, tmp_str);
}
return true;
}
YCMD:afk(playerid, params[], help)
{
if(Group_GetPlayer(Group_AFK, playerid))
{
Group_SetPlayer(Group_AFK, playerid, false);
SendClientMessage(playerid, -1, "Vocк nгo esta mais afk.");
}
else
{
Group_SetPlayer(Group_AFK, playerid, true);
SendClientMessage(playerid, -1, "Agora vocк esta ausente.");
Player_TimeAfk[playerid] = gettime();
}
return true;
}
/*
# d88888b d8b db d8888b. .d88b. d88888b d88888b d888888b db d88888b
# 88' 888o 88 88 `8D .8P Y8. 88' 88' `88' 88 88'
# 88ooooo 88V8o 88 88 88 88 88 88ooo 88ooo 88 88 88ooooo
# 88~~~~~ 88 V8o88 88 88 88 88 88~~~ 88~~~ 88 88 88~~~~~
# 88. 88 V888 88 .8D `8b d8' 88 88 .88. 88booo. 88.
# Y88888P VP V8P Y8888D' `Y88P' YP YP Y888888P Y88888P Y88888P
*/
SetTimer global desnecessario , vocк criou uma stock para getar o nome dos jogadores e mesmo assim em alguns pontos com loop vocк criou outra variavel para getar o nome .
PHP код:
|
pInfo[playerid][tempoak] = false;
Acho que vocк nem compilou, acho que isto vai dar um aviso ao compilar. Mas e tentando que se aprende
|
Nгo testei talvez tenha algum erro , estou sem os programas no pc para testar mas pode ser uma base para vocк poder melhorar.
|
Poderia ter utilizado um SetPlayChatBubble para notificar aos que nгo visualizarem o chatbox e se aproximarem do player. Nada tгo surpreendente, vejo constantemente esse "sistema", porйm parabйns pela forзa de vontade.
|
Sinceramente o seu sistema nгo й nada diferente dos demais sу muda que esta utilizando ZCMD , na minha opniгo qualquer pessoa poderia pegar um FS antigo e otimizar, se vocк queria trazer algo novo(Nгo conseguiu), deveria ter feito sem os cmd de deixar AFK fazendo assim um timer que verifica se o player esta parado a muitos minutos e deixando ele AFK.
|
Nгo й muito um FilterScript mas pode ser ъtil para vбrios novatos que
estгo comeзando. |
Vocк leu o que eu escrevi? se nгo, leia.
Minha intenзгo nгo foi criar algo novo e sim optimizar algo que estб desatualizado no search. Principalmente porquк meu pъblico alvo foi para os que estгo comeзando a mexer com pawno. |