• 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 Despite the server doesn't show any error, it doesn't work.

Memerto

PHP, JS, LUA, HTML...
Joined
Oct 18, 2009
Messages
131
Solutions
6
Reaction score
25
Hello guys! Some days ago Darkhaos did this script for me, but it doesn't work, in spite of the GUI does not show any errors. I need it working urgently. Can you help me?

Explanation of the script: I need a script that send an effect and some animated text to the corpse position, when the monster dies, if it loots a certain object(or some of them). Those items could be configurable in the script(local list = ....)

Distro 0.3.6 (8.60) V5 - Crying Damson


The creaturescript:
Lua:
function scanContainer(uid, list, position) --function by Jano. Edited by Darkhaos.
	for k = (getContainerSize(uid) - 1), 0, -1 do
		local tmp = getContainerItem(uid, k)
		if (isInArray(list, tmp.itemid)) then
			doSendAnimatedText(position, "Epic", TEXTCOLOR_ORANGE)
			doSendMagicEffect(position, 65)
			return true
		elseif isContainer(tmp.uid) then
			scanContainer(tmp.uid, list, position)
		end
	end
	return true
end
 
local list = {7382, 6528}
 
function onDeath(cid, corpse, deathList)
	if not isMonster(cid) then return true end
	return scanContainer(corpse.uid, list, getCreaturePosition(cid))
end

To creaturescript.xml
XML:
<event type="death" name="ScanContainer" event="script" value="blablabla.lua"/>

To login.lua
Lua:
registerCreatureEvent(cid, "ScanContainer")

Rep++ for the one who makes this script works properly, and I'll give him/her the new 9.8 Demon Outfit, IDF format just to import.
 
Last edited:
It is a script only for monsters, as monsters won't login that has no effect to add it in login.lua.
Remove that line from login.lua and add:
XML:
	<script>
		<event name="ScanContainer"/>
	</script>

in the .xml of the monster.
 
I summon the monster with the GM(normal monster /m), then I log in with a normal character and I kill the monster. It loots one of the two items that are in the list, but the animated text and the effect doesn't appear. That's all.
 
Replace the creaturescript part with that:
Lua:
function onDeath(cid, corpse, deathList)
    print("Test: " .. getCreatureName(cid))
	if not isMonster(cid) then return true end
	return scanContainer(corpse.uid, list, getCreaturePosition(cid))
end

and show monster file.
 
The monster file.

XML:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Epictest" nameDescription="an epictest monster" race="blood" experience="0" speed="330" manacost="10000">
	<health now="82" max="82"/>
	<look type="35" corpse="5995"/>
	<targetchange interval="5000" chance="8"/>
	<strategy attack="100" defense="0"/>
	<flags>
		<flag summonable="0"/>
		<flag attackable="1"/>
		<flag hostile="1"/>
		<flag illusionable="0"/>
		<flag convinceable="0"/>
		<flag pushable="0"/>
		<flag canpushitems="1"/>
		<flag canpushcreatures="1"/>
		<flag targetdistance="1"/>
		<flag staticattack="90"/>
		<flag runonhealth="0"/>
	</flags>
	<attacks>
	</attacks>
	<defenses armor="55" defense="55">
		<defense name="healing" interval="2000" chance="15" min="90" max="150">
			<attribute key="areaEffect" value="blueshimmer"/>
		</defense>
	</defenses>
	<elements>
		<element physicalPercent="25"/>
		<element icePercent="-15"/>
	</elements>
	 <script>
		<event name="ScanContainer"/>
	</script>
	<immunities>
		<immunity physical="0"/>
		<immunity energy="1"/>
		<immunity fire="1"/>
		<immunity poison="0"/>
		<immunity lifedrain="1"/>
		<immunity paralyze="1"/>
		<immunity outfit="1"/>
		<immunity drunk="1"/>
		<immunity invisible="1"/>
	</immunities>
	<voices interval="5000" chance="10">
		<voice sentence="I'll teach you that even heros can die" yell="1"/>
		<voice sentence="You wil die Begging like the others did" yell="1"/>
	</voices>
	<loot>
		<item id="7382" chance="5000000"/><!-- great mana potion -->
		<item id="6528" chance="0"/><!-- great health potion -->
	</loot>
</monster>

And the script printed on GUI this:

"Test: Epictest"
 
Try executing scanContainer with addEvent(scanContainer, 50, ...)
Also, I guess you need to get the corpse with getTileItemById(pos, id) then
 
Fine, I tried it, but I got some errors. Really thanks for your help, but I'm gonna leave this script for a time. I guess I'll take it again someday. I'll post the demon outfit soon anyway ;) .
 
Back
Top