AFK Problem
#1

Everytime i do afk it keeps Kicking me out of the server

here is code
Код:
CMD:afk(playerid,params[])
{
  new name[MAX_PLAYER_NAME];
  new str[128];
  TextDrawShowForPlayer(playerid, Textdraw3);
  TextDrawShowForPlayer(playerid, Textdraw5);
  GetPlayerName(playerid,name,sizeof(name));
  GetPlayerPos(playerid,xpos,ypos,zpos);
  ainterior = GetPlayerInterior(playerid);
  GetPlayerHealth(playerid,hp[playerid]);
  GetPlayerArmour(playerid,armour[playerid]);
  SetPlayerHealth(playerid,100000);
  SetPlayerArmour(playerid,0);
  SetPlayerInterior(playerid,3);
  SetPlayerPos(playerid,-2668.868408,1410.360107,906.460937);
  TogglePlayerControllable(playerid,0);
  GameTextForPlayer(playerid,"~r~ AFK ] MODE",3000,3);
  tAFK[playerid] = Create3DTextLabel("AFK-MODE", 0xFF0000FF, 0.0, 0.0, 2.0, 40, 0, 0);
  Attach3DTextLabelToPlayer(tAFK[playerid],playerid, 0.0, 0.0, 0.4);
  PlayerPlaySound(playerid, 1056, 0, 0, 0);
  ApplyAnimation(playerid,"DANCING","dance_loop", 4.1,1,1,1,1,1);
  format(str, sizeof(str), "%s is now Away From Keyboard {FF0000}(AFK)", name);
  SendClientMessageToAll(green,str);
  AFK[playerid]=1;
  SetTimerEx("Kicktimer", TIMEFORMAT(AFK_HOUR, AFK_MINUTES, AFK_SECONDS),false,"d",playerid);
  AFKcount++;
  if(AFK[playerid] == 1)
  {
        return SendClientMessage(playerid, red, "You are already in AFK. Use /back");
  }
  format(str, sizeof(str), "[Player-Act]: %s has used /afk",GetPName(playerid));
  SendAdminMessage(green2,str);
  return 1;
}
Reply
#2

Mind showing this 'TIMEFORMAT(AFK_HOUR, AFK_MINUTES, AFK_SECONDS)'?
Reply
#3

Do a print after each line to see where it's going wrong. Check if player is connected though.
pawn Код:
if(IsPlayerConnected(playerid)) { print("1"); }
Reply
#4

Quote:
Originally Posted by biker122
Посмотреть сообщение
Mind showing this 'TIMEFORMAT(AFK_HOUR, AFK_MINUTES, AFK_SECONDS)'?
Код:
#define TIMEFORMAT(%0,%1,%2) (((%0)*3600+(%1)*60+(%2))*1000)
#define AFK_MINUTES 60
#define AFK_SECONDS 60
#define AFK_HOUR 0
Reply
#5

idk why you use AFK_HOUR when its 0
try this;
pawn Код:
#define TIMEFORMAT(%1,%2) (((%1)*60+(%2))*1000)
#define AFK_MINUTES 60
#define AFK_SECONDS 60
in the cmd, remove AFK_HOUR
Reply
#6

According to my Log
Код:
TeamPRO (IP:49) has been kicked from the server(Reason:Exceeded 1 HOUR in AFK)
Reply
#7

try
pawn Код:
SetTimerEx("Kicktimer",3600000,false,"d",playerid);
Reply
#8

Quote:
Originally Posted by Eth
Посмотреть сообщение
try
pawn Код:
SetTimerEx("Kicktimer",3600000,false,"d",playerid);
Nothing happens
Reply
#9

Quote:
Originally Posted by Eth
Посмотреть сообщение
try
pawn Код:
SetTimerEx("Kicktimer",3600000,false,"d",playerid);
This code can help you.
Just pause for an hour and test it?
or use some basic timers to increase the player's paused time and kick them if an hour is passed.

EDIT: Didn't see the above post..
Reply
#10

Quote:
Originally Posted by biker122
Посмотреть сообщение
This code can help you.
Just pause for an hour and test it?
or use some basic timers to increase the player's paused time and kick them if an hour is passed.

EDIT: Didn't see the above post..
yes and an killtimer when player is back coz if timer on and player is back timer didn't ended and he goes afk again will timer restart ? if yes then fine if no then u need the killtimer and all other looks fine
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)