Errors in creating advanced AFK kicker
#1

Okay so, I tried to make an AFK kicker using this include: https://sampforum.blast.hk/showthread.php?tid=281590 and I was gonna make it so when you are AFK for 20 minutes, a dialog comes up and you have 30 seconds to click ok or get kicked. The dialog was bugging for some reason so I removed it, pawno is still generating errors for everything, like "KillTimer" Could it be the include?

pawn Код:
public OnPlayerUpdate(playerid)
    {
    if(IsPlayerAFKing{playerid})
        {
        SetTimer("afkick", 1200000, false);
    else
        killTimer(afkick);
        }
    }

/*public afk()
if(IsPlayerAFKing{playerid})
{
    {
    ShowPlayerDialog(playerid, AFKmessage, DIALOG_STYLE_MSGBOX, "AFK Kicker", "Are you still here?\nYou have 30 seconds to\nclick the button below or you will be kicked.", "I'm still here!", "");
    SetTimer("afkick", 30000, false);
    }
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
    {
        if(dialogid == AFKmessage)
        {
            if(response)
            {
                KillTimer(afkick);
               }
            else
            {
                KillTimer(afkick);
     }*/

     
public afkick()
{
if(IsPlayerAFKing{playerid})
{
    {
    new string[128];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(i, name, sizeof(name));
    format(string, sizeof(string), "[AFK]%s was kicked for AFKing.",name);
    SendClientMessage(playerid, 0xFF0000AA, "You have been kicked for AFKing too long.");
    Kick(playerid);
    SendClientMessageToAll(0xFF0000AA,string);
    }
}
}
public OnFilterScriptExit()
    {
    return 1;
    }
Reply
#2

Yeah well you need to assign the SetTimer to a variable, like
pawn Код:
// somewhere on top of your script
new ktimer;

//In onplayerupdate

ktimer = SetTimerEx("afkkick",30000,false,"i",playerid); //settimerex because settimer would always be set only for ID 0
else KillTimer(ktimer)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)