• 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
 
you try it:D
Code:
local Actionid = 20000

local MonsterName = "Training Monk"
local Trash = {x = 3185, y = 601, z = 7}

function onStepIn(cid, item, pos)
local delta = {}
if (item.actionid == Actionid) then
delta[1] = {x = -1, y = -1}
delta[2] = {x = 1, y = -1}
elseif (item.actionid == Actionid + 1) then
delta[1] = {x = 1, y = -1}
delta[2] = {x = 1, y = 1}
elseif (item.actionid == Actionid + 2) then
delta[1] = {x = 1, y = 1}
delta[2] = {x = -1, y = 1}
elseif (item.actionid == Actionid + 3) then
delta[1] = {x = -1, y = 1}
delta[2] = {x = -1, y = -1}
end

if (isPlayer(cid) == TRUE) then
doSummonCreature(MonsterName, {x = pos.x + delta[1].x, y = pos.y + delta[1].y, z = pos.z})
doSummonCreature(MonsterName, {x = pos.x + delta[2].x, y = pos.y + delta[2].y, z = pos.z})
end
return TRUE
end

function onStepOut(cid, item, pos)
local delta = {}
if (item.actionid == Actionid) then
delta[1] = {x = -1, y = -1}
delta[2] = {x = 1, y = -1}
elseif (item.actionid == Actionid + 1) then
delta[1] = {x = 1, y = -1}
delta[2] = {x = 1, y = 1}
elseif (item.actionid == Actionid + 2) then
delta[1] = {x = 1, y = 1}
delta[2] = {x = -1, y = 1}
elseif (item.actionid == Actionid + 3) then
delta[1] = {x = -1, y = 1}
delta[2] = {x = -1, y = -1}
end
if (isPlayer(cid) == TRUE) then
local monster1 = getThingfromPos({x = pos.x + delta[1].x, y = pos.y + delta[1].y, z = pos.z, stackpos = 255})
local monster2 = getThingfromPos({x = pos.x + delta[2].x, y = pos.y + delta[2].y, z = pos.z, stackpos = 255})
if ((isCreature(monster1.uid) == TRUE) and (isPlayer(monster1.uid) == FALSE)) then
if (doRemoveCreature ~= nil) then
doRemoveCreature(monster1.uid)
else
doTeleportThing(monster1.uid, Trash)
end
end
if ((isCreature(monster2.uid) == TRUE) and (isPlayer(monster2.uid) == FALSE)) then
if (doRemoveCreature ~= nil) then
doRemoveCreature(monster2.uid)
else
doTeleportThing(monster2.uid, Trash)
end
end
end
return TRUE
end

Code:
<movevent event="StepIn" actionid="20000" script="train.lua" />
<movevent event="StepIn" actionid="20001" script="train.lua" />
<movevent event="StepIn" actionid="20002" script="train.lua" />
<movevent event="StepIn" actionid="20003" script="train.lua" />
<movevent event="StepOut" actionid="20000" script="train.lua" />
<movevent event="StepOut" actionid="20001" script="train.lua" />
<movevent event="StepOut" actionid="20002" script="train.lua" />
<movevent event="StepOut" actionid="20003" script="train.lua" />

maybe it is correct.
 
Last edited:
Back
Top