AFK system - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: AFK system (
/showthread.php?tid=613326)
AFK system -
,TomY' - 26.07.2016
How to do, that this AFK system shows not only seconds, but hours, minutes and seconds?
Code:
new AFKTime[MAX_PLAYERS];
new AFKTimer[MAX_PLAYERS];
new Text3D:label[MAX_PLAYERS];
forward AFKCheck();
public OnPlayerConnect(playerid)
{
AFKTimer[playerid] = SetTimer("AFKCheck",1000,1);
label[playerid] = Create3DTextLabel(" ", 0xFFFFFFFF, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
return 1;
}
public OnPlayerUpdate(playerid)
{
AFKTime[playerid] = 0;
Update3DTextLabelText(label[playerid], 0xFFFFFFFF, " ");
return 1;
}
public AFKCheck()
{
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]))
{
AFKTime[i]++;
}
if(AFKTime[i] > 20)
{
new string[100];
format(string, sizeof string, "This player is AFK {00FF00}(%d Seconds)", AFKTime[i]);
Update3DTextLabelText(label[i], 0xFFFFFFFF, string);
}
}
return 1;
}
Re: AFK system -
Usama651 - 26.07.2016
PHP Code:
CMD:afk(playerid, params[]) {
if(PlayerInfo[playerid][pAdmin] >= 2)
{
if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 6)
{
SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
return 1;
}
new
szMessage[36 + MAX_PLAYER_NAME];
SendClientMessage(playerid,COLOR_WHITE,"Listing all AFK players...");
foreach(Player, i) if(playerAFK[i] != 0 && playerAFKTime[i] > 60) {
format(szMessage,sizeof(szMessage),"* %s (ID %d), AFK for %d minutes.", GetPlayerNameEx(i), i, playerAFKTime[i] / 60);
if(PlayerInfo[i][pAdmin] >= 2) SendClientMessage(playerid,COLOR_RED,szMessage);
else SendClientMessage(playerid,COLOR_GREY,szMessage);
}
}
else SendClientMessage(playerid, COLOR_GRAD1, "You're not authorized to use this command.");
return 1;
}
[
tRY THIS...
Re: AFK system -
,TomY' - 26.07.2016
This is command.. :/