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

Lua Move lever when kill monster

doSetStorage/doCreatureSetStorage in onKill creatureevent, or you can use getCreatureByName in lever script (if the monster name is unique and there's no player with that name)
 
Last edited:
The Forgotten Server 0.3.7

data/creaturescripts/scripts/login.lua
LUA:
registerCreatureEvent(cid, "Event")

data/creaturescripts/creaturescripts.xml
XML:
<event type="kill" name="Event" event="script" value="script.lua"/>

data/creaturescripts/scripts/script.lua
LUA:
local t = {
	['demon'] = {1337}
}

function onKill(cid, target, damage, flags)
	local k = t[string.lower(getCreatureName(target))]
	if(k and (damage == true or bit.band(flags, 1) == 1) and isMonster(target)) then
		if(getCreatureStorage(cid, k[1]) < 0) then
			doCreatureSetStorage(cid, k[1], 1)
		end
	end
	return true
end

data/actions/actions.xml
XML:
<action actionid="13375" event="script" value="script.lua"/>

data/actions/scripts/script.lua
LUA:
local t = {
	[1337] = {x = 100, y = 100, z = 7}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	for st, position in pairs(t) do
		if(getCreatureStorage(cid, st) > 0) then
			doTeleportThing(cid, position, false)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
			doCreatureSay(cid, "Teleported!", TALKTYPE_MONSTER)
		else
			return doPlayerSendCancel(cid, "Sorry, not possible.")
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Last edited:
Back
Top