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

Check area, kill monster get teleported.

bybbzan

mapper
Joined
Aug 4, 2012
Messages
809
Solutions
2
Reaction score
136
Location
Sweden
Hello!

I'll request a script that i'll be needing for my server.

You enter a teleport and will face a monster. When you kill the monster you will get teleported to reward room.
No one else can enter the teleport until the player has killed the monster, or died. When the next player can enter the room, the monster will spawn immediately.
You can only enter this teleport once. Else it would say like, "You have already done this quest".

I would be very happy if someone could make this script for me. ^_^

Thanks in advance.
 
First the Creaturescript: (This will teleport you to the quest room after killing the monster)

Filename - "killQuest.lua"
Lua:
local questBoss = "Rat" -- Name of the quest monster
local questPos = {x=9999, y=9999, z=7}
local questStorage = 9999 -- Storage value for the quest

function onKill(cid, target, damage, flags, war)
	if (getCreatureName(target) == questBoss) and (not isPlayer(target)) then
		doTeleportThing(cid, questPos)
	end
	return true
end

This will also need to add the following to login.lua creaturescript.
Lua:
registerCreatureEvent(cid, killQuest)

Now the Movement Script: (This will make it so only 1 player can be in the quest room at a time)

Lua:
local questCenterPos = {x=9999, y=9999, z=7} -- Center of the Quest Room (Where you fight the monster)
local roomHeight = 10 -- Height of the room (start counting from the center)
local roomWidth = 10 -- Width of the room (start counting from the center)
local questStorage = 9999 -- Storage Value you get when you click the quest chest (detects if you have finished the quest)

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	local specs = getSpectators(questCenterPos, roomHeight, roomWidth)
        if specs == nil then
			if getPlayerStorageValue(cid, questStorage) ~= 1 then
				doTeleportThing(cid, questCenterPos)
			else
				doCreatureSay(cid, "I have already done this quest.", 1)
				doTeleportThing(cid, fromPosition, false)
			end
                        return true
         end
	for _, tid in ipairs(specs) do
		if isPlayer(tid) then
			doCreatureSay(cid, "A Player is in this quest already.", 1)
			doTeleportThing(cid, fromPosition, false)
		else
			if getPlayerStorageValue(cid, questStorage) ~= 1 then
				doTeleportThing(cid, questCenterPos)
			else
				doCreatureSay(cid, "I have already done this quest.", 1)
				doTeleportThing(cid, fromPosition, false)
			end
		end
	end
	return true
end
 
Last edited:
I get this error:

Code:
[Error - MoveEvents Interface]
data/movements/scripts/KillQuest.lua:onStepIn
Description:
data/movements/scripts/KillQuest.lua:8: bad argument #1 to 'ipairs' (table expec
ted, got nil)
stack traceback:
        [C]: in function 'ipairs'
        data/movements/scripts/KillQuest.lua:8: in function <data/movements/scri
pts/KillQuest.lua:6>
 

New error:

Code:
[Error - MoveEvents Interface]
data/movements/scripts/KillQuest.lua:onStepIn
Description:
data/movements/scripts/KillQuest.lua:8: attempt to get length of local 'specs' (
a nil value)
stack traceback:
        data/movements/scripts/KillQuest.lua:8: in function <data/movements/scri
pts/KillQuest.lua:6>
 
try this (not tested)

Movements.xml
Code:
        <movevent type="StepIn" actionid="10100" event="script" value="tp config.lua"/>

Movements ~~ scripts


tp config.lua
Code:
pos = {x=857, y=964, z=7} --- Position monster summon
function onStepIn(cid, item, position, fromPosition)
    local newPosition = {x=857, y=965, z=7} --- new position
	local noPosition = {x=857, y=972, z=7} --- no position
		if(getGlobalStorageValue(10101) < 1) and (getPlayerStorageValue(cid, 10100) == EMPTY_STORAGE) then
		    	doTeleportThing(cid, newPosition, TRUE)
			doSummonCreature("Dog", getClosestFreeTile(cid, pos))--- insert creaturename
			doPlayerSendTextMessage(cid,18,'You need kill boss.')
			setGlobalStorageValue(10101, 1)

		else
			doTeleportThing(cid, noPosition, TRUE)
			doPlayerSendTextMessage(cid,18,'You have already done this quest.')
	end
end

Creaturescripts.xml

Code:
	<event type="kill" name="monsterkill" event="script" value="monsterkill.lua"/>

creaturescripts ~~~ scripts


monsterkill.lua
Code:
local a = {
	newPos = {x=857, y=970, z=7}, ---new pos after kill boss
	msg = "You have won! As new champion take the boss name boss as reward before you leave.",
	area = {
		fromX = 853, toX = 861, 
		fromY = 961, toY = 969,
		z = 7
	}
}
function onKill(cid, target, damage, flags)
	local name = getCreatureName(target):lower()
	if name == 'dog' then
		local players = getCreaturesInRange({x=857, y=965,z=7}, 10, 9, FALSE, TRUE) --- pos range monster
		for i = 1, #players do
			doTeleportThing(players[i], a.newPos)
			doCreatureSay(players[i], a.msg, TALKTYPE_ORANGE_1, false, players[i], getCreaturePosition(players[i]))
		setPlayerStorageValue(cid,10100,1)
		setGlobalStorageValue(10101, -1)
     		end
	end
	return true
end

login.lua insert this
Code:
	registerCreatureEvent(cid, "monsterkill")

again not tested, report errors plz
 
Last edited:
When i try to kill the monster, it actually never dies. The HP disappears but its not dying properly.

Please help.. No errors in console.
Also, added one more 'end' in monsterkill.lua, it was showing error before.

Thanks
 
When i try to kill the monster, it actually never dies. The HP disappears but its not dying properly.

Please help.. No errors in console.
Also, added one more 'end' in monsterkill.lua, it was showing error before.

Thanks
Try now...
It took me to answer because I had to leave, I tested this and it worked here if there are any errors let me know. I changed the script in the same post.
 
@alissonfgp

Move return true above the last end, so it will always return true no matter if the monster has that name or not, else monsters that don't have that name won't die.

@script edit
I mean move, not remove :p
Lua:
-- it should end like this 
     		end
	end
	return true
end
 
Last edited:
Back
Top