Help with AFK - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with AFK (
/showthread.php?tid=149666)
Help with AFK -
coole210 - 23.05.2010
I'm making and auto-afk checker
I used Redgies and modified it..
Код:
forward CheckAFK();
public CheckAFK()
{
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(PPos[i][1] == 0)
{
GetPlayerPos(i,PPos[i][0],PPos[i][1],PPos[i][2]);
return 1;
}
new Float:x,Float:y,Float:z;
GetPlayerPos(i,x,y,z);
if(x == PPos[i][0] && y == PPos[i][1] && z == PPos[i][2])
{
AFKMins[i]++;
if(AFKMins[i] >= AFKTime)
{
if(AFK[i] == 0)
{
AFK[i] = 1;
TogglePlayerControllable(i,0);
SetPlayerColor(i,COLOR_GREY);
oldworld[i] = GetPlayerVirtualWorld(i);
SetPlayerVirtualWorld(i,10);
new string[256];
format(string,sizeof(string),"[ ! ] %s is now in AFK mode!",GetName(i));
SendClientMessageToAll(COLOR_GREY,string);
}
}
}
}
return 1;
}
i enter or leave some place and it doesn't work
Any ideas?
NOTE: /back sets AFKMins to 0 and AFK to 0..
Re: Help with AFK -
Bayler - 23.05.2010
Virtual World would have nothing to do with being AFK... the check for it is redundant...
Simply checking the XY POS of a player ever 1 sec and comparing it to the next time it loops..
tick +1 if coords match or setvar back to 0 if not match...
from there, you can set whatever var to be your AFK time, 120 secs of no POS change = AFK or whatever..
Re: Help with AFK -
coole210 - 23.05.2010
Virtual world would make them invisible that's why that's there..
I am already doing the var thing..
checks his XYZ POS in 30 secs, if his pos is the same at the next 30 secs, he becomes AFK
Re: Help with AFK -
coole210 - 23.05.2010
bump
Re: Help with AFK -
coole210 - 24.05.2010
Bump #2
Re: Help with AFK -
coole210 - 26.05.2010
Bump #3 ..
Re: Help with AFK -
Jefff - 27.05.2010
Код:
forward CheckAFK();
public CheckAFK()
{
new string[50];
new Float:x,Float:y,Float:z;
for(new i,g=GetMaxPlayers(); i < g; i++) if(IsPlayerConnected(i) && !IsPlayerNPC(i))
{
GetPlayerPos(i,x,y,z);
if(x == PPos[i][0] && y == PPos[i][1] && z == PPos[i][2])
{
AFKMins[i]++;
if(AFKMins[i] >= AFKTime)
{
if(AFK[i] == 0)
{
AFK[i] = 1;
TogglePlayerControllable(i,0);
SetPlayerColor(i,COLOR_GREY);
oldworld[i] = GetPlayerVirtualWorld(i);
SetPlayerVirtualWorld(i,10);
format(string,sizeof(string),"[ ! ] %s is now in AFK mode!",GetName(i));
SendClientMessageToAll(COLOR_GREY,string);
}
}
}else{
PPos[i][0] = x;
PPos[i][1] = y;
PPos[i][2] = z;
}
}
return 1;
}
Re: Help with AFK -
coole210 - 27.05.2010
Thanks it works