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

Lua script help.

AnarchGov

Member
Joined
Oct 3, 2011
Messages
263
Reaction score
6
I am looking for a script that creates a teleport when you kill a certain monster. I would like to be able to decide where the teleport appears and the location it takes you. Thanks guys <3

Rep++
 
LUA:
local config = {
	["Monster"] = {time = 60, to = {x = 1000, y = 1000, z = 7}, tp = {x = 1000, y = 1000, z = 7}}
}
 
function onKill(cid, target)
	local monster = config[getCreatureName(target)]

		local function deleteTeleport()
			local teleport = getTileItemById(monster.tp, 1387)
			if(teleport.uid > 0) then
				doRemoveItem(teleport.uid)
				doSendMagicEffect(monster.tp, CONST_ME_POFF)
				doSendAnimatedText(monster.tp, "Closed", TEXTCOLOR_RED)
			end
			return true
		end

	if isPlayer(target) or not monster then
		return true
	else
		doCreateTeleport(1387, monster.to, monster.tp)
		addEvent(deleteTeleport, monster.time * 1000)
		doSendMagicEffect(monster.tp, CONST_ME_ENERGYAREA)
		doCreatureSay(cid, "You have 60 seconds to enter the teleport!", TALKTYPE_ORANGE_1)
	end
	return true
end
 
Now if i just add a monster, won't it create this teleport from anyone killing this monster anywhere? Like a typical monster such as a demon or a destroyer? How is it only set to specific monsters?
 
Be sure you don't have an other onKill script for that monster too. But best is to make a new monster, just copy the monster you want to use and change the name a bit. Then you can be sure it doesn't have effect on anything else on your server.
 
[27/01/2013 05:14:58] [Error - CreatureEvent::configureEvent] No valid type for creature event.onkill
[27/01/2013 05:14:58] [Warning - BaseEvents::loadFromXml] Cannot configure an event
[27/01/2013 05:14:58] [Warning - Event::loadScript] Event onKill not found (data/creaturescripts/scripts/idle.lua)
 
<event type="kill" name="ew" event="script" value="ew.lua"/>

and what i have to add in login

- - - Updated - - -

<event type="kill" name="ew" event="script" value="ew.lua"/>

and what i have to add in login
 
ew.lua is the script from the first page?

Btw the error says idle.lua and that script uses event type think, so I assume you already changed it to the correct script>
You have to add the name you used in the xml line in login.lua like this:
LUA:
	registerCreatureEvent(cid, "ew")
 
Back
Top