[FilterScript] Auto 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: Filterscripts (
https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Auto AFK System (
/showthread.php?tid=615585)
Auto AFK System -
Tass007 - 24.08.2016
REMOVED
Re: Auto AFK System -
Younes44 - 24.08.2016
Not bad..
Re: Auto AFK System -
Moersy - 24.08.2016
That's soo simple but soo good!
Re: Auto AFK System -
oMa37 - 24.08.2016
https://sampforum.blast.hk/showthread.php?tid=479616
You just did few edits, Which is nothing.
Re: Auto AFK System -
K0P - 24.08.2016
GG string size 128
it should be 41 or 42.
Код:
CMD:afk(playerid,params[])// /afk command
{
new string[128];// Store the intial action
if(IsAFK[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "Error: You are already AFK.");
else // And why using else while the "return" already breaks the code?
{
format(string,sizeof(string),"*%s has gone AFK",GetName(playerid));//Formats the /do cmd output
IsAFK[playerid] = 1;
SendClientMessageToAll(COLOR_WHITE,string);//Display the output to all clients
}
return 1;
}
Код:
CMD:back(playerid,params[])// /back command
{
new string[128];// Store the intial action
if(IsAFK[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "Error: You aren't AFK.");
format(string,sizeof(string),"*%s is back",GetName(playerid));//Formats the /do cmd output
IsAFK[playerid] = 0;
SendClientMessageToAll(COLOR_WHITE,string);//Display the output to all clients
return 1;
}
EDIT:
Код:
forward AFKCheck();
public AFKCheck() // And another huge mistake, you are not checking if the players are online are not,imagine what if there are 10 players playing on a 1000 slots server
{
new Float:Pos[3] /* Arrays are slower than variables,it should be "new Float:x, Float:y, Float:z"*/, string[128]; // creating an array variable of 3 values whose datatype is Float.
for(new i = 0; i < MAX_PLAYERS; i++) // Looping through the players.
{
if(IsAFK[i] == 1) return 1; //Checks to see if the player is already AFK
GetPlayerPos(i,Pos[0],Pos[1],Pos[2]); // Gets the player position and saves into their variables.
if(IsPlayerInRangeOfPoint(i,2,Pos[0],Pos[1],Pos[2])) // If player is around the position (if player is at the same place)
{
AFK[i]++; // Increment the AFK variable (for every second if player is at same location, increase the AFK variable by 1)
}
if(AFK[i] == SetAFKTime) // Checking to see how long the player has been in the same place, if the varible (AFK) matches (SetAFKTime) it sets the player AFK.
{
format(string,sizeof(string),"*%s has gone AFK",GetName(i));//Formats the /do cmd output
SendClientMessageToAll(COLOR_WHITE,string);
IsAFK[i] = 1;
}
}
return 1;
}
Re: Auto AFK System -
SeanDenZYR - 25.08.2016
make an ANTI-SPAM thingy cause the can keep spamming /afk and /back to spam the server chat