• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Exit but character still online

LuisPro

World War <3
Joined
May 10, 2009
Messages
425
Solutions
1
Reaction score
53
Distibution: OTHire

Hello.
I show my problem in video.
My question is: How to make Exit working like Logout (if player is out of battle, no pz lock etc)

(If Bubble was on pz lock it will be ok, but if he is without any battle status he should also logout instant)

Any idea?
Thanks.
 
Code:
function onThink(interval)
 for _, pid in ipairs(getPlayersOnlineList()) do
  if getPlayerIp(pid) == 0 and getCreatureCondition(pid, CONDITION_INFIGHT) == false then
  doRemoveCreature(pid)
  end
 end
 return true
end
@Printer ?
 
Code:
void Player::onThink(uint32_t interval)
{
   Creature::onThink(interval);
   int64_t timeNow = OTSYS_TIME();
   if(timeNow - lastPing >= 5000)
   {
     lastPing = timeNow;
     if(client)
       client->sendPing();
     else if(!getTile()->hasFlag(TILESTATE_NOLOGOUT) && !isConnecting && !pzLocked && !hasCondition(CONDITION_INFIGHT))
       g_game.removeCreature(this, true);
   }

Could work I think
 
Last edited:
Based on this CREATURE_EVENT_LOGOUT (logout).
I would try to make a creature event:
Code:
<event name="disconnectPlayer" type="logout" script="disconnectplayer.lua"/>
With an onlogout script environment:

LUA:
function onLogout(cid)
    -- find a way to wait for player to loose battle icon and execute a logout.
end

To hook the event for the player, I probably need to register it in login.lua.
LUA:
registerCreatureEvent(cid, "disconnectPlayer")
Even if your going for an interval loop (there is probably a better way), the loop would run only during the battle icon duration (after player disconnected) on that specific player, and not all the time on all players using onThink.
 
Last edited:
Back
Top