convert autokick system for trainers from 0.4 to 1.3

ralke

Felipe
Joined
Dec 17, 2011
Messages
331
Best answers
3
Reaction score
50
Location
Chile
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!!
 
OP
ralke

ralke

Felipe
Joined
Dec 17, 2011
Messages
331
Best answers
3
Reaction score
50
Location
Chile
I have this error when installing on Tfs 1.3 (happen when player stepIn/stepOut)

error akick.png

Please help, thanks in advance!
 
OP
ralke

ralke

Felipe
Joined
Dec 17, 2011
Messages
331
Best answers
3
Reaction score
50
Location
Chile
Change addEvent(stopKick, 0, cid) to addEvent(stopKick, 0, cid:getId())
thanks for responding! now im having this: stepIn debugs an error but stepOut is working fine (i guess)
stepin error.png
 

Boy67

Active Member
Joined
Jul 4, 2007
Messages
127
Best answers
0
Reaction score
26
Location
England
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.
 
OP
ralke

ralke

Felipe
Joined
Dec 17, 2011
Messages
331
Best answers
3
Reaction score
50
Location
Chile
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
 
Top