• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Kick players from trainers after 30 min idle time

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,535
Solutions
27
Reaction score
872
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
[Movemevent] Using this script allows me to kick players on trainer who spend more that 30 minutes without moving.

12a177afcd.png


But i have this error when player logout and still having the efect of storage id

1297802009.png


Someone knows how to fix?
 
Solution
wait.. is there multiple monsters trying to step on the tile?
Try this.. for whatever it's worth.

Code:
local config = {
   timer = 0.1, -- time in minutes (0.1 = 6 seconds, for easy testing)
   teleport = {x = 11111, y = 11111, z = 11} -- teleport position
}

kick_player = {}

local function kickPlayer(cid)
   if not isPlayer(cid) then
       return true
   end
   doTeleportThing(cid, config.teleport)
   addEvent(doRemoveCreature, 0, cid)
   return true
end

local function stopKick(cid)
   if stopEvent(kick_player[cid]) then
       if not isPlayer(cid) then
           return true
       end
       doPlayerSendTextMessage(cid, 23, "You will no longer be forcibly logged out.")
   end
   return true
end

function onStepIn(cid, item...
Sorry to say that, but my Point is...
Players shouldnt be able to logout while trainning or even Die.
if that is the case something is very wrong, now if you tell me you want to do that to kick playing using bot i can undestand (still it is a war you cant win) else you should just use the afk time in config.lua.

Lua:
local function kickPlayer(cid)
    if isPlayer(cid) then
        doTeleportThing(cid, config.teleport)
        addEvent(doRemoveCreature, 0, cid)
    end
end

function onStepIn( cid, item, pos, fromPos)
    if isPlayer(cid) then
        t_kickPlayer[cid] = addEvent( kickPlayer, config.timer * 60 *1000, cid )
        doPlayerSendTextMessage(cid, 22, "BLABLA from onStepIn autokick.")
    end
end

function onStepOut( cid, item, pos, fromPos)
    if isPlayer(cid) then
        stopEvent(t_kickPlayer[cid])
        doPlayerSendTextMessage(cid, 22, "BLABLA from onStepOut autokick.")
    end
end[/cde]
[/SPOILER]
 
Last edited by a moderator:
yes i got them like this :p

6bce68cd21.png


i will set speed="0" to trainers but at the moment never see them moving, thanks @Xikini ^^
You should stagger your doors as well, otherwise you'll get a player who will have 2 friends, or mc 2 noob characters to open the doors on either side, and then shoot sd's, or projectiles from 1 door through to the other person training.
Or set the entire area for non-pvp or something.
In either case, glad it's working for you.
 
You should stagger your doors as well, otherwise you'll get a player who will have 2 friends, or mc 2 noob characters to open the doors on either side, and then shoot sd's, or projectiles from 1 door through to the other person training.
Or set the entire area for non-pvp or something.
In either case, glad it's working for you.

sure i set the area as no-pvp and dont allow more that 2 mc's per player on my server ^^

sailorv5 said:
you should just use the afk time in config.lua.

hmm this script started by this issue https://otland.net/threads/otx-2-5-...ed-or-receive-idle-warnings-while-afk.248376/. anyways the script increases activity of afk players, forcing them to see his character after a period of time, but my real concern was to kick characters that log out with exit and doesnt get disconnected; and also rise the difficult of training a little bit.
 
Last edited:
hmm this script started by this issue https://otland.net/threads/otx-2-5-...ed-or-receive-idle-warnings-while-afk.248376/. anyways the script increases activity of afk players, forcing them to see his character after a period of time, but my real concern was to kick characters that log out with exit and doesnt get disconnected; and also rise the difficult of training a little bit.
i know the issue has already been solved...

if you have access to the source, you can try to fix it or at least undestand it a little better. ( i am not a pro, but this may help OR not XD )
C++:
configmanager.cpp  (  you dont need to open it or modify  )  there is something this this ( found by searching for exit )
m_confBool[STOP_ATTACK_AT_EXIT] = getGlobalBool("stopAttackingAtExit", false);
//  maybe setting it to true in the config.lua colve solve the idle problems
else you could look deeper
open player.cpp search for STOP_ATTACK_AT_EXIT you will find.
C++:
    if(timeNow - lastPing >= 5000)
   {
       lastPing = timeNow;
       if(hasClient())
           client->sendPing();
       else if(g_config.getBool(ConfigManager::STOP_ATTACK_AT_EXIT))
           setAttackedCreature(NULL);
   }
this mean after 5sec that the player has closed the client or lost the connection it will stop attacking ( only if you had set config.lua stopAttackingAtExit to true )

Code:
// now if you want it to not stop attacking but to logout you can change
setAttackedCreature(NULL);
//TO
g_game.removeCreature(this, true);

dont do anything i said, if you dont undestand. ( any way you already solved this issue )
 
i know the issue has already been solved...
this mean after 5sec that the player has closed the client or lost the connection it will stop attacking ( only if you had set config.lua stopAttackingAtExit to true )

sure i get but thats not what i'm saying. player who logs out with exit will stop attacking, that's compiled and i have no trouble with it. the thing is that the player on trainer that logs out with exit and stop attacking doesnt get disconnected by idle time because the idle time function is corrupted (i dont know the reason). example of this dysfunction is when i stay afk out of depot without getting attacked (or any place including pz, no-pvp, etc.) idle time doesnt kick me out.

by the way, is there any sources related to idle time? @sailorv5
 
// now if you want it to not stop attacking but to logout you can change
setAttackedCreature(NULL);
//TO
g_game.removeCreature(this, true);
luascript.cpp

not sure about the output, but if it is a number you can create and register a creature event and if it is a time like > (more than) u can kick the player.
PHP:
    //getPlayerIdleTime(cid)
   lua_register(m_luaState, "getPlayerIdleTime", LuaInterface::luaGetPlayerIdleTime);

   //doPlayerSetIdleTime(cid, amount)
   lua_register(m_luaState, "doPlayerSetIdleTime", LuaInterface::luaDoPlayerSetIdleTime);

it is not complete, here it is a small part of my idle.lua creatureScriptEvent.
PHP:
    local idleTime = getPlayerIdleTime(cid) + interval
    doPlayerSetIdleTime(cid, idleTime)
    if(config.idleKick > 0 and idleTime > config.idleKick) then
        doRemoveCreature(cid)
    end
 
Last edited:
Back
Top