• 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!

convert autokick system for trainers from 0.4 to 1.3

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,470
Solutions
27
Reaction score
844
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
hi, i was wondering if someone can help me with this as a request, i got this script that i used a lot on my 0.4 server and i want to have it for tfs 1.3, its a moveevent that set a timer when player stepin, when time is finished it will teleport player to a default position. also timer is reset if you stepOut and stepIn on tile again

Lua:
local config = {
   timer = 120, -- time in minutes (0.1 = 6 seconds, for easy testing)
   teleport = {x = 1035, y = 1002, z = 7} -- 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, MESSAGE_STATUS_CONSOLE_BLUE, "[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

thanks in advance!!
 
Im guessing you've only changed the addEvent on line 40 seeing that your stepOut now works, if you look in the console, the error states that the third parameter of the addEvent function on line 31 is the same...

Just apply the same change to that.
 
Im guessing you've only changed the addEvent on line 40 seeing that your stepOut now works, if you look in the console, the error states that the third parameter of the addEvent function on line 31 is the same...

Just apply the same change to that.

thanks!! changed addEvent(kickPlayer, config.timer * 60 * 1000, cid) to -- addEvent(kickPlayer, config.timer * 60 * 1000, cid:getId())
thread solved
 
Back
Top