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

Kick from training place after 1h? Script help.

Tofflarn

New Member
Joined
Mar 22, 2008
Messages
360
Reaction score
1
Location
Sweden
Hello. As the title says, i need a script that moves the training player from his pos to another after 1h.

I tried on my own and this is what i've done :p haha

Code:
config = {
topos = {x=32727, y=31964, z=14},
standpos = {x=32724, y=31970, z=15}
}
function onStepIn(cid, item, position, fromPosition)
	if item.uid == 64187 then
			addEvent(doRelocate,10 * 1000, config.standpos, config.topos)
end
return 1
end

The problem is. I wan't to use the uid = 64187 more the one time. And since i have alot of trainers the "standpos" need to be adjustable to the different training rooms.

Most of my training rooms looks like this.
1 - trainers
2 - Player & uid tile.
* - Non walkable tile

*2*
1*1

Would be awesome if someone could help me with this.
Hope you understand how i mean!
Don't have more time to write now!!

Thx in advanced.
 
make on step in set storage valu 1 and global event if storagevalu 1 then after 1 sec add 1 if storage == 3600 tp player
 
Try this:
Lua:
local timed = 60
					local czas = 0
						local function timer(i)
							if(getPlayerStorageValue(cid, 11553)==1)then
							xpos = {x=1000, y=1000, z=7}
							npos = {x=1000, y=1000, z=7}
							end
						doTeleportThing(i.cid, xpos)
						doPlayerSendTextMessage(cid, 19, Your time has expired!')
						end
						if(czas == 0)then
						addEvent(timer, (timed*60000), {cid=cid, npos=getThingfromPos(getPlayerPosition(cid))})
						doPlayerSendTextMessage(cid, 19, 'You have 60 minutes for train!')
						czas = os.time()
						end
						if(os.time() <= (czas+timed*30))then
						stopEvent(timer)

Just fill it in your script :p
If don't know how, just write :D
 
Try this:
Lua:
local timed = 60
					local czas = 0
						local function timer(i)
							if(getPlayerStorageValue(cid, 11553)==1)then
							xpos = {x=1000, y=1000, z=7}
							npos = {x=1000, y=1000, z=7}
							end
						doTeleportThing(i.cid, xpos)
						doPlayerSendTextMessage(cid, 19, Your time has expired!')
						end
						if(czas == 0)then
						addEvent(timer, (timed*60000), {cid=cid, npos=getThingfromPos(getPlayerPosition(cid))})
						doPlayerSendTextMessage(cid, 19, 'You have 60 minutes for train!')
						czas = os.time()
						end
						if(os.time() <= (czas+timed*30))then
						stopEvent(timer)

Just fill it in your script :p
If don't know how, just write :D

You mean like this?

Code:
function onStepIn(cid, item, position, fromPosition)
local timed = 60
                                        local czas = 0
                                                local function timer(i)
                                                        if(getPlayerStorageValue(cid, 11553)==1)then
                                                        xpos = {x=1000, y=1000, z=7}
                                                        npos = {x=1000, y=1000, z=7}
                                                        end
                                                doTeleportThing(i.cid, xpos)
                                                doPlayerSendTextMessage(cid, 19, Your time has expired!')
                                                end
                                                if(czas == 0)then
                                                addEvent(timer, (timed*60000), {cid=cid, npos=getThingfromPos(getPlayerPosition(cid))})
                                                doPlayerSendTextMessage(cid, 19, 'You have 60 minutes for train!')
                                                czas = os.time()
                                                end
                                                if(os.time() <= (czas+timed*30))then
                                                stopEvent(timer)
end
return 1
end


If so, it gives me error in the console.


errorwp.jpg
 
I missed ' there
Lua:
function onStepIn(cid, item, position, fromPosition)
local timed = 60
local czas = 0
    local function timer(i)
        if(getPlayerStorageValue(cid, 11553)==1)then
        xpos = {x=1000, y=1000, z=7}
        npos = {x=1000, y=1000, z=7}
        end
    doTeleportThing(i.cid, xpos)
    doPlayerSendTextMessage(cid, 19, 'Your time has expired!')
    end
    if(czas == 0)then
    addEvent(timer, (timed*60000), {cid=cid, npos=getThingfromPos(getPlayerPosition(cid))})
    doPlayerSendTextMessage(cid, 19, 'You have 60 minutes for train!')
    czas = os.time()
    end
    if(os.time() <= (czas+timed*30))then
    stopEvent(timer)
end
return 1
end

Test it, I'm not sure it will work P:p
 
Tried it and got this.. One question, like i said in the first post. How will i make this work on many training spots without having 700 lua files? :)
errors2.jpg
 
1. Add line in movements.xml
and add the same actionid to tiles where is your training...
2. try this
Lua:
function onStepIn(cid, item, position, fromPosition)
local timed = 60
local czas = 0
    local function timer(i)
        if(getPlayerStorageValue(cid, 11553)==1)then
        xpos = {x=1000, y=1000, z=7}
        npos = {x=1000, y=1000, z=7}
		playerpos = {x=fromPosition.x, y=fromPosition.y, z=fromPosition.z, stackpos=253}
		player = getThingFromPos(playerpos)
        end
    doTeleportThing(player, xpos)
    doPlayerSendTextMessage(cid, 19, 'Your time has expired!')
    end
    if(czas == 0)then
    addEvent(timer, (timed*60000), {cid=cid, npos=getThingfromPos(getPlayerPosition(cid))})
    doPlayerSendTextMessage(cid, 19, 'You have 60 minutes for train!')
    czas = os.time()
    end
    if(os.time() <= (czas+timed*30))then
    stopEvent(timer)
end
return 1
end
 
I will test it soon, but please tell me. What should i put in:
xpos = {x=1000, y=1000, z=7}
npos = {x=1000, y=1000, z=7}

I have this in movements.xml
Code:
  <movevent type="StepIn" actionid="64187" event="script" value="training.lua" />

unfortunately a problem remains.

error3c.jpg
 
Last edited:
sorry for revive this post
Ralke said:
[29/12/2016 15:15:51] [Error - MoveEvents Interface]
[29/12/2016 15:15:51] In a timer event called from:
[29/12/2016 15:15:51] data/movements/scripts/trainlimit.lua:eek:nStepIn
[29/12/2016 15:15:51] Description:
[29/12/2016 15:15:51] attempt to index a nil value
[29/12/2016 15:15:51] stack traceback:
[29/12/2016 15:15:52] [C]: in function 'doTeleportThing'
[29/12/2016 15:15:52] data/movements/scripts/trainlimit.lua:11: in function <data/movements/scripts/trainlimit.lua:4>

using wesoly136 script
how to fix? please ^^ using OTX 2.5

Ralke said:
<movevent type="StepIn" actionid="19232" event="script" value="trainlimit.lua"/>

Ralke said:
function onStepIn(cid, item, position, fromPosition)
local timed = 60
local czas = 0
local function timer(i)
if(getPlayerStorageValue(cid, 11553)==1)then
xpos = {x=32347, y=32224, z=7}
npos = {x=32347, y=32224, z=7}
playerpos = {x=fromPosition.x, y=fromPosition.y, z=fromPosition.z, stackpos=253}
player = getThingFromPos(playerpos)
end
doTeleportThing(player, xpos)
doPlayerSendTextMessage(cid, 19, 'Your time has expired!')
end
if(czas == 0)then
addEvent(timer, (timed*60000), {cid=cid, npos=getThingfromPos(getPlayerPosition(cid))})
doPlayerSendTextMessage(cid, 19, 'You have 60 minutes for train!')
czas = os.time()
end
if(os.time() <= (czas+timed*30))then
stopEvent(timer)
end
return 1
end

Edit: i realize that i did not write coordinates on player pos, any chance to make this script works on multiple tiles with same id? Somthing like getting fromPosition by a storage?? I'm beginner with LUA
 
Last edited:
bump!! is there any function to replace
Ralke said:
playerpos = {x=fromPosition.x, y=fromPosition.y, z=fromPosition.z, stackpos=253}
player = getThingFromPos(playerpos)

to get fromPosition by
onStepIn -> action ID/unique id

EDIT: SOLVED! using this one

Ralke said:
function onStepIn(cid, item, position, fromPosition)
telpDelay = 30
koniec = addEvent(koniecrob,telpDelay*1000*60, cid)
koncowka = addEvent(koncowkarob,telpDelay*1000*60-1000*60, cid)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have started Your training. You have "..telpDelay.." minutes left.")
end
function onStepOut(cid, item, position, fromPosition)
stopEvent(koniec)
stopEvent(koncowka)
doPlayerSendCancel(cid, MESSAGE_EVENT_ADVANCE, "Your timer has been stopped. You can start again.")
end
function koncowkarob(cid)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "After 1 minute you will be teleported. You can move to restart timer!")
end

function koniecrob(cid)
pozycja={x=32347, y=32224, z=7}
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Its end of your training.")
doTeleportThing(cid,pozycja,FALSE)
doSendMagicEffect(pozycja,NM_ME_LOSE_ENERGY)
end

 
Last edited:
does not work. when you go on a card with a given aid, you will get off it and after a certain time you will be moved to the position in script

tfs 1.3
 
does not work. when you go on a card with a given aid, you will get off it and after a certain time you will be moved to the position in script

tfs 1.3
Probably best to make a new thread at this point. xP

In order to stop the issue you've encountered you'd want to use onStepIn to create the addEvent and onStepOut to remove the previously created addEvent.
That way if a player leaves the tile earlier then the addEvent timer, nothing will happen to the player.
 
So it should like this?

<movevent event="StepIn" actionid="25005" script="check1.lua" />
<movevent event="StepOut" actionid="25005" script="check1.lua" />

script dont work :(
 
Last edited:
So it should like this?

<movevent event="StepIn" actionid="25005" script="check1.lua" />
<movevent event="StepOut" actionid="25005" script="check1.lua" />

script dont work :(
Very old thread jaja, @Janusz1337 this moveevent will teleport you to a certain position and kick you out after a certain time. Also, the player won't be kicked by idle time during the training.

XML:
    <movevent event="StepIn" actionid="25003" script="others/kick.lua" />
    <movevent event="StepOut" actionid="25003" script="others/kick.lua" />

kick.lua

Lua:
local config = {
   timer = 60, -- time in minutes
   teleport = {x = 1277, y = 969, 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:getId())
   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "[Advanced 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:getId())
   return true
end

I'm not 100% sure if that time value (timer = 60, -- time in minutes) will work as intended, please test.
Regards!
 
Very old thread jaja, @Janusz1337 this moveevent will teleport you to a certain position and kick you out after a certain time. Also, the player won't be kicked by idle time during the training.

XML:
    <movevent event="StepIn" actionid="25003" script="others/kick.lua" />
    <movevent event="StepOut" actionid="25003" script="others/kick.lua" />

kick.lua

Lua:
local config = {
   timer = 60, -- time in minutes
   teleport = {x = 1277, y = 969, 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:getId())
   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "[Advanced 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:getId())
   return true
end

I'm not 100% sure if that time value (timer = 60, -- time in minutes) will work as intended, please test.
Regards!
Should make kick_player = {} a local variable since it's not being used outside of this script, but otherwise looks good. :)
 
Should make kick_player = {} a local variable since it's not being used outside of this script, but otherwise looks good. :)
For sure looks good, you did it :cool:
 
Very old thread jaja, @Janusz1337 this moveevent will teleport you to a certain position and kick you out after a certain time. Also, the player won't be kicked by idle time during the training.

XML:
    <movevent event="StepIn" actionid="25003" script="others/kick.lua" />
    <movevent event="StepOut" actionid="25003" script="others/kick.lua" />

kick.lua

Lua:
local config = {
   timer = 60, -- time in minutes
   teleport = {x = 1277, y = 969, 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:getId())
   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "[Advanced 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:getId())
   return true
end

I'm not 100% sure if that time value (timer = 60, -- time in minutes) will work as intended, please test.
Regards!
can u write it in revscriptsys please
 
Back
Top