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

[HELP] Training Monk Summon Script

Awesome Slayer

New Member
Joined
Jul 16, 2008
Messages
58
Reaction score
0
i have made this script that summons trainers to the north east,west and south east,west of the player when they stand on a square, i need help to make the script remove the monks when the player steps off the square (the tile i use is id-426 when us tand on it it chnages to 425 if that helps... anyway here is my script.

P.S sorry i didnt credit anyone as i forget who helped me it was like 4 months ago :D

Code:
function onStepIn(cid, item, pos)
 Player = getPlayerPosition(cid)

	NorthWest = {x=Player.x-1, y=Player.y-1, z=Player.z}
	NorthEast = {x=Player.x+1, y=Player.y-1, z=Player.z}
	SouthWest = {x=Player.x-1, y=Player.y+1, z=Player.z}
	SouthEast = {x=Player.x+1, y=Player.y+1, z=Player.z}

	doSummonCreature("Trainer", NorthWest)
	doSummonCreature("Trainer", NorthEast)
	doSummonCreature("Trainer", SouthWest)
	doSummonCreature("Trainer", SouthEast)

return 1
end

I tried to make a script for when u step out it looked like this:

Code:
function onStepOut(cid, item, pos)
 Player = getPlayerPosition(cid)

	NorthWest = {x=Player.x-1, y=Player.y-1, z=Player.z}
	NorthEast = {x=Player.x+1, y=Player.y-1, z=Player.z}
	SouthWest = {x=Player.x-1, y=Player.y+1, z=Player.z}
	SouthEast = {x=Player.x+1, y=Player.y+1, z=Player.z}

	doRemoveCreature("Trainer", NorthWest)
	doRemoveCreature("Trainer", NorthEast)
	doRemoveCreature("Trainer", SouthWest)
	doRemoveCreature("Trainer", SouthEast)

return 1
end

i know its going to be something really simple, i am not very good at this, if you could please help me i would be very greatful :D
 
Try

Code:
function onStepOut(cid, item, pos)
 Player = getPlayerPosition(cid)

	NorthWest = {x=Player.x-1, y=Player.y-1, z=Player.z}
	NorthEast = {x=Player.x+1, y=Player.y-1, z=Player.z}
	SouthWest = {x=Player.x-1, y=Player.y+1, z=Player.z}
	SouthEast = {x=Player.x+1, y=Player.y+1, z=Player.z}

	doRemoveCreature(getThingfromPos(NorthWest).uid)
	doRemoveCreature(getThingfromPos(NorthEast).uid)
	doRemoveCreature(getThingfromPos(SouthWest).uid)
	doRemoveCreature(getThingfromPos(SouthEast).uid)

return 1
end
 
Last edited:
i got these errors

[17/11/2008 14:37:16] Lua Script Error: [MoveEvents Interface]
[17/11/2008 14:37:16] data/movements/scripts/Custom\desummon.lua:eek:nStepOut

[17/11/2008 14:37:16] luaDoRemoveCreature(). Creature not found

[17/11/2008 14:37:16] Lua Script Error: [MoveEvents Interface]
[17/11/2008 14:37:16] data/movements/scripts/Custom\desummon.lua:eek:nStepOut

[17/11/2008 14:37:16] luaDoRemoveCreature(). Creature not found

[17/11/2008 14:37:16] Lua Script Error: [MoveEvents Interface]
[17/11/2008 14:37:16] data/movements/scripts/Custom\desummon.lua:eek:nStepOut

[17/11/2008 14:37:16] luaDoRemoveCreature(). Creature not found

[17/11/2008 14:37:16] Lua Script Error: [MoveEvents Interface]
[17/11/2008 14:37:16] data/movements/scripts/Custom\desummon.lua:eek:nStepOut

[17/11/2008 14:37:16] luaDoRemoveCreature(). Creature not found
 
Last edited:
@up try this

PHP:
function onStepOut(cid, item, frompos, pos)
local remove = {
[1] = {x=frompos.x-1, y=frompos.y-1, z=frompos.z, stackpos=253},
[2] = {x=frompos.x+1, y=frompos.y-1, z=frompos.z, stackpos=253},
[3] = {x=frompos.x-1, y=frompos.y+1, z=frompos.z, stackpos=253},
[4] = {x=frompos.x+1, y=frompos.y+1, z=frompos.z, stackpos=253}
}
for i = 1, #remove do
	doRemoveCreature(getThingfromPos(remove[i]).uid)
end

return 1
end

P.S. I didn tested it but should work
 
Last edited:
Thanks, But =/

Code:
[17/11/2008  20:45:02] Lua Script Error: [MoveEvents Interface] 
[17/11/2008  20:45:02] data/movements/scripts/Custom\desummon.lua:onStepOut

[17/11/2008  20:45:02] luaDoRemoveCreature(). Creature not found

[17/11/2008  20:45:02] Lua Script Error: [MoveEvents Interface] 
[17/11/2008  20:45:02] data/movements/scripts/Custom\desummon.lua:onStepOut

[17/11/2008  20:45:02] luaDoRemoveCreature(). Creature not found

[17/11/2008  20:45:02] Lua Script Error: [MoveEvents Interface] 
[17/11/2008  20:45:02] data/movements/scripts/Custom\desummon.lua:onStepOut

[17/11/2008  20:45:02] luaDoRemoveCreature(). Creature not found

[17/11/2008  20:45:02] Lua Script Error: [MoveEvents Interface] 
[17/11/2008  20:45:02] data/movements/scripts/Custom\desummon.lua:onStepOut

[17/11/2008  20:45:02] luaDoRemoveCreature(). Creature not found
 
try that just a little fix of dark warrior's one

Code:
function onStepOut(cid, item, frompos, pos)
local remove = {
[1] = {x=frompos.x-1, y=frompos.y-1, z=frompos.z, stackpos=253},
[2] = {x=frompos.x+1, y=frompos.y-1, z=frompos.z, stackpos=253},
[3] = {x=frompos.x-1, y=frompos.y+1, z=frompos.z, stackpos=253},
[4] = {x=frompos.x+1, y=frompos.y+1, z=frompos.z, stackpos=253}
}
	for i = 1, #remove do
		if isMonster(getThingfromPos(remove[i]) > 0 then
    			doRemoveCreature(getThingfromPos(remove[i]).uid)
		else
			error("Monsters not found.")
		end
	end
	return TRUE
end

not 100% sure if the errors will be fixed now but it's worth a shoot :p

kind regards, Evil Hero
 
Last edited:
@ above i tried it, got this error =/

Code:
[17/11/2008  21:19:19] Lua Script Error: [MoveEvents Interface] 
[17/11/2008  21:19:19] data/movements/scripts/Custom\desummon.lua:onStepOut

[17/11/2008  21:19:19] data/movements/scripts/Custom\desummon.lua:9: attempt to call global 'getThingFromPos' (a nil value)
[17/11/2008  21:19:19] stack traceback:
[17/11/2008  21:19:19] 	data/movements/scripts/Custom\desummon.lua:9: in function <data/movements/scripts/Custom\desummon.lua:1>
 
ERROR =/
[18/11/2008 08:45:11] Lua Script Error: [MoveEvents Interface]
[18/11/2008 08:45:11] data/movements/scripts/Custom\desummon.lua:eek:nStepOut

[18/11/2008 08:45:11] data/movements/scripts/Custom\desummon.lua:9: attempt to compare number with table
[18/11/2008 08:45:11] stack traceback:
[18/11/2008 08:45:11] data/movements/scripts/Custom\desummon.lua:9: in function <data/movements/scripts/Custom\desummon.lua:1>
 
Ive tried by making this script as well but i get an error...

Code:
function1 = onStepIn(cid, item, pos)
function2 = onStepOut(cid, item, pos)
 Player = getPlayerPosition(cid)

local monkOne = {x=Player.x-1, y=Player.y-1, z=Player.z}
local monkTwo = {x=Player.x+1, y=Player.y-1, z=Player.z}
local monkThree = {x=Player.x-1, y=Player.y+1, z=Player.z}
local monkFour = {x=Player.x+1, y=Player.y+1, z=Player.z}
function1 =
	doSummonCreature("Trainer", monkOne)
	doSummonCreature("Trainer", monkTwo)
	doSummonCreature("Trainer", monkThree)
	doSummonCreature("Trainer", monkFour)
function2 =
	doRemoveCreature(getThingfromPos({x = monkOne.x-1, y = monkOne.y-1, z = monkOne.z, stackpos = 253}).uid)
	doRemoveCreature(getThingfromPos({x = monkTwo.x, y = monkTwo.y, z = monkTwo.z, stackpos = 253}).uid)
	doRemoveCreature(getThingfromPos({x = monkThree.x, y = monkThree.y, z = monkThree.z, stackpos = 253}).uid)
	doRemoveCreature(getThingfromPos({x = monkFour.x, y = monkFour.y, z = monkFour.z, stackpos = 253}).uid)
        doSendMagicEffect(monkOne, 2)
        doSendMagicEffect(monkTwo, 2)
        doSendMagicEffect(monkThree, 2)
        doSendMagicEffect(monkFour, 2)
end

BUT ON RELOADING MOVEMENTS I GET THIS ERROR
Code:
[18/11/2008  08:46:13] Warning: [Event::loadScript] Can not load script. data/movements/scripts/Custom\trainer.lua
[18/11/2008  08:46:13] data/movements/scripts/Custom\trainer.lua:23: '<eof>' expected near 'end'
 
@Up

Your script it's really messed up...

Just try the one i made or the one evil hero made...
P.S. if you get
Code:
[17/11/2008  20:45:02] luaDoRemoveCreature(). Creature not found

Then your positions are bad... Remember on the script i made above it will check the position you was not the one you are when you walk...

Here a example

Code:
----
-C->M
----
C = character
M = the new position when you move
It will take the pos of C not the one on M
 
Last edited:
try this:
Code:
function onStepIn(cid, item, position, fromPosition)

local Player = getPlayerPosition(cid)

local monkOne = {x=Player.x-1, y=Player.y-1, z=Player.z}
local monkTwo = {x=Player.x+1, y=Player.y-1, z=Player.z}
local monkThree = {x=Player.x-1, y=Player.y+1, z=Player.z}
local monkFour = {x=Player.x+1, y=Player.y+1, z=Player.z}

	doSummonCreature("Trainer", monkOne)
	doSummonCreature("Trainer", monkTwo)
	doSummonCreature("Trainer", monkThree)
	doSummonCreature("Trainer", monkFour)
	
function onStepOut(cid, item, position, fromPosition)

	doRemoveCreature(getThingfromPos({x = monkOne.x-1, y = monkOne.y-1, z = monkOne.z, stackpos = 253}).uid)
	doRemoveCreature(getThingfromPos({x = monkTwo.x, y = monkTwo.y, z = monkTwo.z, stackpos = 253}).uid)
	doRemoveCreature(getThingfromPos({x = monkThree.x, y = monkThree.y, z = monkThree.z, stackpos = 253}).uid)
	doRemoveCreature(getThingfromPos({x = monkFour.x, y = monkFour.y, z = monkFour.z, stackpos = 253}).uid)
        doSendMagicEffect(monkOne, 2)
        doSendMagicEffect(monkTwo, 2)
        doSendMagicEffect(monkThree, 2)
        doSendMagicEffect(monkFour, 2)
        end
        end

P.S.: I dont know lua xdd!
 
Last edited:
@StreamSide, thanx but didnt remove the monks, no errors either :D

@master-m, i am noob at lua and i need one that summons 4 monks (1 at each diagonal) when u stand on a square and removes them when u step off the square so it realy doesnt help me the way it is, but thnx anyway.

Thanks, Awesome Slayer.
 
PHP:
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
								doPlayerSendTextMessage(cid, 22, trainer .. " " .. vocation)
								doSummonCreature(trainer, position[1])
								doSummonCreature(trainer, position[2])
								setPlayerStorageValue(cid,11111,1)
							break
							end
						end
					
					end
				end


	end
	return TRUE
end

function onStepOut(cid, item, toPosition, fromPosition)


	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

That was sript i made for someone. It depends on vocation : if you have vocation 1 it summon dog.
Ofcourse you can change mosnters to train monks or whatever you want:D

in 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="train.lua" />
	<movevent event="StepOut" actionid="4001" script="train.lua" />
	<movevent event="StepOut" actionid="4002" script="train.lua" />
	<movevent event="StepOut" actionid="4003" script="train.lua" />

If you want me to add something to this script, write it down here or write privete message to me ;)
 
Colandus, Can you help me find a few examples how to connect to sql database from lua? I would be thankfull =]

Code:
local newPass = "asdasd"
local cur = assert(con:execute("UPDATE accounts AS a INNER JOIN players AS p ON p.id="..getPlayerGUID(cid).." SET a.password="..newPass..";"))

I just wonder if there exists any tutorial to this ? :p

(I wrote it there beacouse, I did not want to start new thread :p)
 
Colandus, Can you help me find a few examples how to connect to sql database from lua? I would be thankfull =]

Code:
local newPass = "asdasd"
local cur = assert(con:execute("UPDATE accounts AS a INNER JOIN players AS p ON p.id="..getPlayerGUID(cid).." SET a.password="..newPass..";"))

I just wonder if there exists any tutorial to this ? :p

(I wrote it there beacouse, I did not want to start new thread :p)

You should make a new thread, until then I won't answer you as it will be offtopic which is against the rules.
 
Back
Top