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

Searching for a movement for training rooms, trainers depends on player's vocation.

Hermes

dziwki kola gramy w lola
Joined
Nov 17, 2007
Messages
1,867
Reaction score
14
Location
Poland
Hello :)

I need a movement, which onStepIn summons 2 training monks in a room like this:
.___.
|M.M|
|. P .|
|-D-|


M - Training Monk
P - Player
D - Door
. - Stone


If player is paladin, it summons Paladin Monk, if knight, it summons Knight Monk and the same for sorcerer and druid.

And onStepOut deletes both monks (names depends on player's vocation).


Thanks,
Hermes
 
Data/movements/script/nazwa.lua
Code:
function onStepIn(cid, item, pos)
local monster1 = "Trainer2"  -- Nazwa 1 monstera
local monster2 = "Trainer2"  -- Nazwa 2 monstera
local monster1pos = {x=xxx, y=xxx, z=xx, stackpos=1}   -- Pozycja 1 monstera
local monster2pos = {x=xxx, y=xxx, z=xx, stackpos=1}   -- Pozycja 2 monstera
local efekt = zzz   -- Efekt, gdy potwory sie pojawiaja
doRemoveItem(getThingfromPos(monster1pos).uid, 1)
doRemoveItem(getThingfromPos(monster2pos).uid, 1)
doSummonCreature(monster1, monster1pos)
doSummonCreature(monster2, monster2pos)
doSendMagicEffect(monster1pos, efekt)
doSendMagicEffect(monster2pos, efekt)
end
Data/movements/script/nazwa.lua
Code:
function onStepOut(cid, item, pos)
local efekt = [COLOR="#006400"]zzz[/COLOR]
local monster1pos = {x=xxx, y=xxx, z=xx, stackpos=1}   -- Pozycja 1 monstera
local monster2pos = {x=xxx, y=xxx, z=xx, stackpos=1}   -- Pozycja 2 monstera
doRemoveCreature(getThingfromPos(monster1pos).uid)
doRemoveCreature(getThingfromPos(monster2pos).uid)
doSendMagicEffect(monster1pos, efekt)
doSendMagicEffect(monster2pos, efekt)
end

http://tibia.net.pl/movements/31550-train-room-advance-tfs.html

maybe this script
 
@up
Script is good but it does not exactly what I'm talking about. But it can be an example to start writing as it is in my idea.
 
Code:
local config = {
	[1] = { "Sorcerer Trainer", { x = x, y = y, z = z } },
	[2] = { "Druid Trainer", { x = x, y = y, z = z } },
	[3] = { "Paladin Trainer", { x = x, y = y, z = z } },
	[4] = { "Knight Trainer", { x = x, y = y, z = z } }
}

function onStepIn(cid, item)
	for vocation, trainer in pairs(config)
		if isInArray({vocation, vocation + 4}, getPlayerVocation(cid)) == TRUE then
			doSummonCreature(trainer[1], trainer[2])
		end
	end
	return TRUE
end

Try oki?????????
 
Yeah its nice, however it could be really boring to place same script, just with changed positions for every room.. I mean, that 1 simple script should be for all rooms, including all directions.

#Reserved space for script# ; O!
 
@marcinek
[17/12/2008 19:27:14] Warning: [Event::loadScript] Can not load script. data/movements/scripts/vocation_spawn.lua
[17/12/2008 19:27:14] data/movements/scripts/vocation_spawn.lua:10: 'do' expected near 'if'

okii :F

@slawkens
maybe this will help you.. (this is north.lua script made by Macroman)

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

    -- Define positions.
    local charPos = getCreaturePosition(cid)
    local doorPos = getThingPos(item.uid)
    local monkOne = {x = doorPos.x - 1, y = doorPos.y - 2, z = doorPos.z}
    local monkTwo = {x = doorPos.x + 1, y = doorPos.y - 2, z = doorPos.z}
    local checkPlayer = {x = doorPos.x, y = doorPos.y - 1, z = doorPos.z, stackpos = 253}
    -- Define directions.
    local newDir  = 0
    local oldDir  = 2
    
    -- Check where the player is located at.
    if ( charPos.y == doorPos.y + 1 and charPos.z == doorPos.z ) then
        -- Check if someone already uses the training booth.
        if isPlayer(getThingfromPos(checkPlayer).uid) == TRUE then
            doPlayerSendTextMessage(cid, 24, "Someone is already using this booth.")
            doSendMagicEffect(getCreaturePos(cid), 2)
        else
            -- Teleport player.
            doTeleportThing(cid, doorPos)
            doMoveCreature(cid, newDir)
            -- Summon training monks.
            doSummonCreature("Dummy", monkOne)
            doSummonCreature("Dummy", monkTwo)
        end
    else
        -- Teleport player.
        doTeleportThing(cid, doorPos)
        doMoveCreature(cid, oldDir)
        -- Remove training monks.
        doRemoveCreature(getThingfromPos({x = monkOne.x, y = monkOne.y, z = monkOne.z, stackpos = 253}).uid)
        doRemoveCreature(getThingfromPos({x = monkTwo.x, y = monkTwo.y, z = monkTwo.z, stackpos = 253}).uid)
        -- Send magic effect.
        doSendMagicEffect(monkOne, 2)
        doSendMagicEffect(monkTwo, 2)
    end
    return TRUE
end
 
Code:
local trainers = {
	[1] = { "Sorcerer Trainer"},
	[2] = { "Druid Trainer"},
	[3] = { "Paladin Trainer"},
	[4] = { "Knight Trainer"}
}

local positions = {
	[4000] = { { x = x, y = y, z = z }, { x = x, y = y, z = z } }, -- North
	[4002] = { { x = x, y = y, z = z }, { x = x, y = y, z = z } }, -- South
	[4003] = { { x = x, y = y, z = z }, { x = x, y = y, z = z } }, -- East
	[4004] = { { x = x, y = y, z = z }, { x = x, y = y, z = z } }  -- West
}

function onStepIn(cid, item)
	for vocation, trainer in pairs(config) do
		if isInArray({vocation, vocation + 4}, getPlayerVocation(cid)) == TRUE then
			for action, position in pairs(positions) do
				if item.actionid == action then
					doSummonCreature(trainer, position[1])
					doSummonCreature(trainer, position[2])
				end
			end
		end
	end
	return TRUE
end

Updated, try now okiiiiii
 
Hm,
Code:
[17/12/2008 19:57:22] Lua Script Error: [MoveEvents Interface] 
[17/12/2008 19:57:22] data/movements/scripts/vocation_spawn.lua:onStepIn

[17/12/2008 19:57:22] data/movements/scripts/vocation_spawn.lua:16: bad argument #1 to 'pairs' (table expected, got nil)
[17/12/2008 19:57:22] stack traceback:
[17/12/2008 19:57:22] 	[C]: in function 'pairs'
[17/12/2008 19:57:22] 	data/movements/scripts/vocation_spawn.lua:16: in function <data/movements/scripts/vocation_spawn.lua:15>

take a look on positions in example that I have posted. And make onStepOut that removes both monsters, and if server can't remove monster (for example player have killed trainer) then hm, won't remove trainer where isn't trainer xD
 
Afff........... misspelled table name.

@Added onStepOut:
Code:
local trainers = {
	[1] = { "Sorcerer Trainer"},
	[2] = { "Druid Trainer"},
	[3] = { "Paladin Trainer"},
	[4] = { "Knight Trainer"}
}

local positions = {
	[4000] = { { x = x, y = y, z = z }, { x = x, y = y, z = z } }, -- North
	[4002] = { { x = x, y = y, z = z }, { x = x, y = y, z = z } }, -- South
	[4003] = { { x = x, y = y, z = z }, { x = x, y = y, z = z } }, -- East
	[4004] = { { x = x, y = y, z = z }, { x = x, y = y, z = z } }  -- West
}

function onStepIn(cid, item)
	for vocation, trainer in pairs(trainers) do
		if isInArray({vocation, vocation + 4}, getPlayerVocation(cid)) == TRUE then
			for action, position in pairs(positions) do
				if item.actionid == action then
					doSummonCreature(trainer, position[1])
					doSummonCreature(trainer, position[2])
				end
			end
		end
	end
	return TRUE
end

function onStepOut(cid, item)
	for action, position in pairs(positions) do
		if item.actionid == action - 10 then
			doRemoveCreature(getThingfromPos(position[1]).uid)
			doRemoveCreature(getThingfromPos(position[2]).uid)
		end
	end
	return TRUE
end

Aeeeeee!

actionid 4000 = north room (summon)
actionid 3990 = north room (removal)

okiiiiiiiiiii
 
Code:
[17/12/2008 20:32:41] Lua Script Error: [MoveEvents Interface] 
[17/12/2008 20:32:41] data/movements/scripts/vocation_spawn.lua:onStepIn

[17/12/2008 20:32:41] luaDoSummonCreature(). Monster name() not found

Hm, I have set good names of monsters ._.

I tried even with:
Code:
	[1] = { "Demon"},
	[2] = { "Dragon Lord"},
 
I write the script for you soon here =D I have to optimize it now :P

@Edit


Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local trainers = {
	["Dog"] = 1,
	["Rat"] = 2,
	["Dog"] = 3,
	["Sheep"] = 4
}

local positions = {
	[4000] = { {x = toPosition.x-1, y = toPosition.y-2, z = toPosition.z, stackpos = 253}, {x = toPosition.x+1, y = toPosition.y-2, z = toPosition.z, stackpos = 253}, {x = toPosition.x, y = toPosition.y-1, z = toPosition.z}, {x = toPosition.x, y = toPosition.y+1, z = toPosition.z} }, -- North
	[4001] = { {x = toPosition.x-1, y = toPosition.y+2, z = toPosition.z, stackpos = 253}, {x = toPosition.x+1, y = toPosition.y+2, z = toPosition.z, stackpos = 253}, {x = toPosition.x, y = toPosition.y+2, z = toPosition.z}, {x = toPosition.x+1, y = toPosition.y-2, z = toPosition.z} }, -- South
	[4002] = { {x = toPosition.x+1, y = toPosition.y-2, z = toPosition.z, stackpos = 253}, {x = toPosition.x+1, y = toPosition.y+2, z = toPosition.z, stackpos = 253}, {x = toPosition.x+2, y = toPosition.y, z = toPosition.z}, {x = toPosition.x-2, y = toPosition.y, z = toPosition.z} }, -- East
	[4003] = { {x = toPosition.x-1, y = toPosition.y-2, z = toPosition.z, stackpos = 253}, {x = toPosition.x-1, y = toPosition.y+2, z = toPosition.z, stackpos = 253}, {x = toPosition.x-2, y = toPosition.y, z = toPosition.z}, {x = toPosition.x+2, y = toPosition.y, z = toPosition.z} }  -- West
}



local check = getPlayerStorageValue(cid,11111) -- checks if player is inside the room

	for trainer, vocation in pairs(trainers) do
		if check <= 0 then
			if getPlayerVocation(cid) == vocation then
				for action, position in pairs(positions) do
					
						if item.actionid == action then
							doPlayerSendTextMessage(cid, 22, trainer .. " " .. vocation)
							doTeleportThing(cid,position[3],1)
							doSummonCreature(trainer, position[1])
							doSummonCreature(trainer, position[2])
							setPlayerStorageValue(cid,11111,1)
					
						end
					
				end
			end

		elseif check == 1 then
			if getPlayerVocation(cid) == vocation then
				for action, position in pairs(positions) do
						if item.actionid == action then

					rem = getThingfromPos(position[1])
					rem2 = getThingfromPos(position[2])

							doPlayerSendTextMessage(cid, 22, trainer .. " " .. vocation)
							doTeleportThing(cid,position[4],1)
							doRemoveCreature(rem.uid)
							doRemoveCreature(rem2.uid)
							setPlayerStorageValue(cid,11111,0)
					
						end
					
				end
			end
		end
	end
	return TRUE
end
Code:
	<action actionid="4000" script="train.lua" />
	<action actionid="4001" script="train.lua" />
	<action actionid="4002" script="train.lua" />
	<action actionid="4003" script="train.lua" />
if you realy want to make it in movements I quess you can remake it for your own :P
And also check positions beacouse I can't promise there is no bug :P
 
Last edited:
@up
checking is player inside room could be like this:
Code:
    local charPos = getCreaturePosition(cid)
    local doorPos = getThingPos(item.uid)
-- for north
    local checkPlayer = {x = doorPos.x, y = doorPos.y - 1, z = doorPos.z, stackpos = 253}
        if isPlayer(getThingfromPos(checkPlayer).uid) == TRUE then
-- do something
        end

And could you rewrite this to movements? Because if player gets kicked and he stood on movement tile, he "steps out" of tile, making script to stop.
 
I dont exactly get how your train room will looks like. :P Could send some screenshot to wakeup my imagination? xD

Edit

Plx do it as fast as you can =] If you have gg msg me : 2510866
 
Last edited:
bug2ff3.png


And if you enter (onStepIn) two trainers spawns. Trainer name (ex. Trainer Druids, Trainer Knights) depends on player's vocation. If player stepsOut, those two trainers dissapears.
 
Aff.. How can you help me if you don't know how to use movements? STEP.OUT.FROM.A.TILE.ON.WHICH.PLAYER.WAS.STANDING :D
 
Why are you using all those "for" etc. I think that it can be made with "isDruid", "isSorcerer", "isPaladin", "isKnight". And with changing trainer. So (dunno how it should look :P)
Code:
if isPlayer(cid) == TRUE and isSorcerer(cid) == TRUE then
trainer == Trainer Sorcerer
elseif isPlayer(cid) == TRUE and isDruid(cid) == TRUE then
trainer == Trainer Druid

??
 
Soryy that I didn't answer for a whiel beacouse of some personal problems ;/
Any way..

I use for function beacouse it is easier to write scripts.
Secondary I finished for you this movements and onLogout. Lets begin:

data\movements\scripts
train.lua
Code:
function onStepIn(cid, item, toPosition, fromPosition)

local trainers = {
	["Dog"] = 1,
	["Rat"] = 2,
	["Dog"] = 3,
	["Sheep"] = 4
}

local positions = {
	[4000] = { {x = toPosition.x-1, y = toPosition.y-1, z = toPosition.z, stackpos = 253}, {x = toPosition.x+1, y = toPosition.y-1, z = toPosition.z, stackpos = 253} }, -- North
	[4001] = { {x = toPosition.x-1, y = toPosition.y+1, z = toPosition.z, stackpos = 253}, {x = toPosition.x+1, y = toPosition.y+1, z = toPosition.z, stackpos = 253} }, -- South
	[4002] = { {x = toPosition.x+1, y = toPosition.y-1, z = toPosition.z, stackpos = 253}, {x = toPosition.x+1, y = toPosition.y+1, z = toPosition.z, stackpos = 253} }, -- East
	[4003] = { {x = toPosition.x-1, y = toPosition.y-1, z = toPosition.z, stackpos = 253}, {x = toPosition.x-1, y = toPosition.y+1, z = toPosition.z, stackpos = 253} }  -- West
}



	for trainer, vocation in pairs(trainers) do
				if getPlayerVocation(cid) == vocation then
					for action, position in pairs(positions) do
						if isPlayer(getThingfromPos(getCreaturePosition(cid)).uid) == TRUE then
							if item.actionid == action then
							
								doSummonCreature(trainer, position[1])
								doSummonCreature(trainer, position[2])
								setPlayerStorageValue(cid,11111,1)
							break
							end
						end
					
					end
				end


	end
	return TRUE
end

train1.lua
Code:
function onStepOut(cid, item, toPosition, fromPosition)

local trainers = {
	["Dog"] = 1,
	["Rat"] = 2,
	["Dog"] = 3,
	["Sheep"] = 4
}


local positions = {
	[4000] = { {x = toPosition.x-1, y = toPosition.y-1, z = toPosition.z, stackpos = 253}, {x = toPosition.x+1, y = toPosition.y-1, z = toPosition.z, stackpos = 253} }, -- North
	[4001] = { {x = toPosition.x-1, y = toPosition.y+1, z = toPosition.z, stackpos = 253}, {x = toPosition.x+1, y = toPosition.y+1, z = toPosition.z, stackpos = 253} }, -- South
	[4002] = { {x = toPosition.x+1, y = toPosition.y-1, z = toPosition.z, stackpos = 253}, {x = toPosition.x+1, y = toPosition.y+1, z = toPosition.z, stackpos = 253} }, -- East
	[4003] = { {x = toPosition.x-1, y = toPosition.y-1, z = toPosition.z, stackpos = 253}, {x = toPosition.x-1, y = toPosition.y+1, z = toPosition.z, stackpos = 253} }  -- West
}



	for trainer, vocation in pairs(trainers) do
				if getPlayerVocation(cid) == vocation then
					for action, position in pairs(positions) do
						if isPlayer(getThingfromPos(getCreaturePosition(cid)).uid) == TRUE then
							if item.actionid == action then

			rem = getThingfromPos(position[1])
			rem2 = getThingfromPos(position[2])

							doRemoveCreature(rem.uid)
							doRemoveCreature(rem2.uid)
							break
							end
						end
					
					end
				end


	end
	return TRUE
end

movements.xml

Code:
	<movevent event="StepIn" actionid="4000" script="train.lua" />
	<movevent event="StepIn" actionid="4001" script="train.lua" />
	<movevent event="StepIn" actionid="4002" script="train.lua" />
	<movevent event="StepIn" actionid="4003" script="train.lua" />

	<movevent event="StepOut" actionid="4000" script="train1.lua" />
	<movevent event="StepOut" actionid="4001" script="train1.lua" />
	<movevent event="StepOut" actionid="4002" script="train1.lua" />
	<movevent event="StepOut" actionid="4003" script="train1.lua" />

Now if you want monsters disappear after logout, continue:

data\creaturescripts\scripts
train.lua

Code:
function onLogout(cid)
registerCreatureEvent(cid, "EndTrain")
local trainers = {
	["Dog"] = 1,
	["Rat"] = 2,
	["Dog"] = 3,
	["Sheep"] = 4
}

toPosition = getCreaturePosition(cid)
pos = {x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 0}
item = getThingFromPos(pos)


local positions = {
	[4000] = { {x = toPosition.x-1, y = toPosition.y-1, z = toPosition.z, stackpos = 253}, {x = toPosition.x+1, y = toPosition.y-1, z = toPosition.z, stackpos = 253}, {x = toPosition.x, y = toPosition.y+2, z = toPosition.z, stackpos = 253} }, -- North
	[4001] = { {x = toPosition.x-1, y = toPosition.y+1, z = toPosition.z, stackpos = 253}, {x = toPosition.x+1, y = toPosition.y+1, z = toPosition.z, stackpos = 253}, {x = toPosition.x, y = toPosition.y-2, z = toPosition.z, stackpos = 253} }, -- South
	[4002] = { {x = toPosition.x+1, y = toPosition.y-1, z = toPosition.z, stackpos = 253}, {x = toPosition.x+1, y = toPosition.y+1, z = toPosition.z, stackpos = 253}, {x = toPosition.x-2, y = toPosition.y, z = toPosition.z, stackpos = 253} }, -- East
	[4003] = { {x = toPosition.x-1, y = toPosition.y-1, z = toPosition.z, stackpos = 253}, {x = toPosition.x-1, y = toPosition.y+1, z = toPosition.z, stackpos = 253}, {x = toPosition.x+2, y = toPosition.y-1, z = toPosition.z, stackpos = 253} }  -- West
}



	for trainer, vocation in pairs(trainers) do
				if getPlayerVocation(cid) == vocation then
					for action, position in pairs(positions) do
						if isPlayer(getThingfromPos(getCreaturePosition(cid)).uid) == TRUE then
							if item.actionid == action then

			rem = getThingfromPos(position[1])
			rem2 = getThingfromPos(position[2])

							doRemoveCreature(rem.uid)
							doRemoveCreature(rem2.uid)
							doTeleportThing(cid,position[3])
							break
							end
						end
					
					end
				end


	end
	return TRUE
end

creaturescripts.xml
Code:
	<event type="logout" name="EndTrain" script="train.lua"/>

Enjoy ;d
 
Last edited:
Back
Top