• 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...
hmm didnt know that i thought u were talking about mysql tables, where i should search? or some thread to learn about global tables and catching up with this
a global table is just a regular table, but you can call it and use it anywhere
its the same thing as having a function and a local function
or a variable
 
@Xeraphus @Xikini error again after some hours

6943ef2e9f.png


any ideas? this error is make lags and i cant make the system be able
are you sure you have the function arguments correct?
(cid, item, position, toPosition)
cid shouldn't be invalid randomly for onStepIn
show us what you have in the script again
 
I'll have to agree.
Show us your current script.
It's almost like somethings been changed, or not copied correctly.
 
that makes no sense
onStepIn executes when a creature steps on that certain tile
which means cid will 10000000% be passed through the function
cid will never be nil
i have no idea why you would be getting that error lol
 
i wonder why functions are not working, something is weird on my distribution (using The OTX Server Version: (2.51 - SE - 1549) - Codename: (Necron)), i'll post anything u think can be an error or corrupted file
 
it looks like it's spamming you within milliseconds in your console
maybe somehow events from before got stacked or something in older versions of that script with different global table name
have you tried restarting the server?
 
yes i replaced that action id with this script

ralke said:
function onStepIn(cid, item, pos)
doCreatureSay(cid, "Have fun!", TALKTYPE_MONSTER)
doSendMagicEffect(pos, CONST_ME_NONE)
return true
end

then restarted, put the @Xikini script again, and then console started to send me picture error again.
im also wondering why console sends me luaDoPlayerSendTextMessage before Player not Found if kicked characted is not supposed to receive a message when got log out@Xeraphus
 
wtf that makes no sense
try
Lua:
print(cid)
under function onStepIn
see if it prints any numbers to the console
 
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, position, fromPosition)
   if not isPlayer(cid) then
       return false
   end
   kick_player[cid] = addEvent(kickPlayer, config.timer * 60 * 1000, cid)
   doPlayerSendTextMessage(cid, 22, "[Trainer]: If you remain on this tile longer then " .. config.timer .. " minutes, the system will automatically log you out.")
   return true
end

function onStepOut(cid, item, position, fromPosition)
   if not isPlayer(cid) then
       return false
   end
   addEvent(stopKick, 0, cid)
   return true
end
 
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, position, fromPosition)
   if not isPlayer(cid) then
       return false
   end
   kick_player[cid] = addEvent(kickPlayer, config.timer * 60 * 1000, cid)
   doPlayerSendTextMessage(cid, 22, "[Trainer]: If you remain on this tile longer then " .. config.timer .. " minutes, the system will automatically log you out.")
   return true
end

function onStepOut(cid, item, position, fromPosition)
   if not isPlayer(cid) then
       return false
   end
   addEvent(stopKick, 0, cid)
   return true
end
instead of return false it should teleport the creature back to fromPosition
return values in onStepIn/onStepIn don't matter (they still don't in later versions, but should matter)
also why are you using addEvent with 0ms delay when you can just call it straight up?
 
instead of return false it should teleport the creature back to fromPosition
return values in onStepIn/onStepIn don't matter (they still don't in later versions, but should matter)
also why are you using addEvent with 0ms delay when you can just call it straight up?
It was a small bug I found, when having two tiles side by side with the same actionid
If you stepped from one to the other, it caused an issue, or a crash. I can't remember. :p
Or maybe I'm just an idiot. That's usually the case.
 
instead of return false it should teleport the creature back to fromPosition
return values in onStepIn/onStepIn don't matter (they still don't in later versions, but should matter)
also why are you using addEvent with 0ms delay when you can just call it straight up?
Wait I remember. When you logout, it causes the onStepOut event, and cid no longer exists and it crashes the server.
I knew it was there for a reason. xD
@Xikini ok i made reload, now works

6b3aed744e.png


i'll post any changes on console



dont think that u booth are solving this ^^
Yeah the millisecond spam is why I thought multiple monsters stepping on tile. :p
 
Wait I remember. When you logout, it causes the onStepOut event, and cid no longer exists and it crashes the server.
I knew it was there for a reason. xD

Yeah the millisecond spam is why I thought multiple monsters stepping on tile. :p
ah
well shit gj catching that
broke my brain trying to figure out why that would happen lmao
 
ah
well shit gj catching that
broke my brain trying to figure out why that would happen lmao
The only praise I've ever received. :eek:

@ralke Put your trainers/monsters diagonal from tile, so they don't have a walk-space directly onto the tile. That should lessen the server strain as well.
 
Back
Top