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

Solved Kill monster and be able to do quest.

Progenosis

Member
Joined
Sep 6, 2011
Messages
131
Reaction score
18
I've some days trying to make work this system, the idea is to kill a monster(in my case, kill a Grand Ferumbras) and after killing it click on a rock and have a chance to receive an item (in my case, a ferumbras' staff). I've inserted some scripts but somehow after killing Grand Ferumbras the rock still asks to complete quest (to kill Grand ferumbras). I hope been clear.
I'll write here the scripts.

On actions.xml:
Code:
<action uniqueid="1999" event="script" value="KingdomsOT/ferumbrasstaff.lua"/>

action's script:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
  
 local storage = 2625 --Storage value of the quest done
 local object = 2626 --Itemid of the object
 local uni = 1999 --uniqueId of the object
 local temple = {x=1000, y=1000, z=7} --Temple position
 local success = "Has logrado obtener la reliquia del gran mago!" --Got the item message
 local fail = "Al parecer la fortuna no está de tu lado, intenta en otra ocasión!" --fail message
 local chance = 5 --Chance percentage, now 5%
 local reward = 2625 --Itemid of the reward
 local ammount = 1 --Numbers of items to get, in case that is stackable
 local done = "Tu ya has obtenido la reliquia del mago" --Message if you try to take again the prize
 local doquest = "You need first finish the quest" --Message if you havent finish the preview quest
 
 if getPlayerStorageValue(cid, storage) == 1 and item.uid == uni and itemEx.itemid == object then
	local chance1 = math.random(1,100)
	if chance1 > chance then
		doPlayerSendTextMessage(cid, 22, fail)
		doTeleportThing(cid, temple)
		doSetPlayerStorageValue(cid, storage, 2)
		else
		doPlayerSendTextMessage(cid, 22, success)
		doTeleportThing(cid, temple)
		doSetPlayerStorageValue(cid, storage, 2)
		doPlayerAddItem(cid, reward, ammount)
	end
else
	if getPlayerStorageValue(cid, storage) < 1 then
		doPlayerSendCancel(cid, doquest)
		else
	if getPlayerStorageValue(cid, storage) > 1 then
		doPlayerSendCancel(cid, done)
	end
end
return true
end
end

On creaturescripts.xml:
Code:
<event type="kill" name="StorageGrandFerumbras" script="storage-grandferumbras.lua"/>
creaturescripts' script:
Code:
local name = "Grand Ferumbras"
local storage = 2625
function onKill(cid, target)
if getCreatureName(target) == name then
setPlayerStorageValue(cid, storage, -1)
return true
end
return true
end

Grand Ferumbras' script:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Grand Ferumbras" nameDescription="Grand Ferumbras" race="venom" experience="100000" speed="420" manacost="0">
	<health now="85000" max="85000"/>
	<look type="229" corpse="6078"/>
	<targetchange interval="5000" chance="8"/>
	<strategy attack="130" 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>
		<attack name="melee" interval="2000" min="-600" max="-1650"/>
		<attack name="manadrain" interval="2000" chance="20" range="7" min="-700" max="-1200">
			<attribute key="areaEffect" value="redshimmer"/>
		</attack>
		<attack name="poison" interval="3000" chance="20" radius="6" target="0" min="-650" max="-850">
			<attribute key="areaEffect" value="poison"/>
		</attack>
		<attack name="energy" interval="2000" chance="18" radius="6" target="0" min="-700" max="-1900">
			<attribute key="areaEffect" value="energy"/>
		</attack>
		<attack name="manadrain" interval="2000" chance="16" radius="6" target="0" min="-525" max="-1875">
			<attribute key="areaEffect" value="redshimmer"/>
		</attack>
		<attack name="lifedrain" interval="2000" chance="21" radius="6" target="0" min="-600" max="-1750">
			<attribute key="areaEffect" value="poff"/>
		</attack>
		<attack name="effect" interval="3000" chance="20" radius="5" target="0" min="-500" max="-1300">
			<attribute key="areaEffect" value="blackspark"/>
		</attack>
		<attack name="firecondition" interval="3000" chance="20" range="7" radius="7" target="1" min="-600" max="-1000">
			<attribute key="shootEffect" value="fire"/>
			<attribute key="areaEffect" value="firearea"/>
		</attack>
		<attack name="lifedrain" interval="2000" chance="25" length="8" spread="0" min="-500" max="-1650">
			<attribute key="areaEffect" value="greenspark"/>
		</attack>
	</attacks>
	<defenses armor="100" defense="120">
		<defense name="healing" interval="2000" chance="10" min="4900" max="8500">
			<attribute key="areaEffect" value="greenshimmer"/>
		</defense>
		<defense name="speed" interval="3000" chance="30" speedchange="560" duration="7000">
			<attribute key="areaEffect" value="blueshimmer"/>
		</defense>
		<defense name="invisible" interval="4000" chance="20" duration="5000">
			<attribute key="areaEffect" value="blueshimmer"/>
		</defense>
	</defenses>
	<elements>
		<element physicalPercent="70"/>
		<element firePercent="90"/>
		<element icePercent="50"/>
		<element earthPercent="50"/>
		<element energyPercent="20"/>
		<element holyPercent="15"/>
	</elements>
	<immunities>
		<immunity lifedrain="1"/>
		<immunity paralyze="1"/>
		<immunity outfit="1"/>
		<immunity drunk="1"/>
		<immunity invisible="1"/>
	</immunities>
	<summons maxSummons="3">
		<summon name="Juggernaut" interval="3000" chance="12" max="3"/>
		<summon name="Demon" interval="3000" chance="12" max="3"/>
		<summon name="Ferumbras" interval="3000" chance="12" max="3"/>
	</summons>
	<voices interval="5000" chance="20">
		<voice sentence="You killed ferumbras? Hahahaha Try to kil meee!!!!" yell="1"/>
		<voice sentence="I am the strongest wizard of all times!!" yell="1"/>
	</voices>
	<loot>
		<item id="2393" chance="16060"/><!-- giant sword -->
		<item id="2514" chance="12050"/><!-- mastermind shield -->
		<item id="2472" chance="7000"/><!-- magic plate armor -->
		<item id="2151" countmax="4" chance="12000"/><!-- talon -->
		<item id="5903" chance="2000"/><!-- ferumbras' hat -->
		<item id="2171" chance="30000"/><!-- platinum amulet -->
		<item id="2415" chance="6000"/><!-- great axe -->
	</loot>
	<script>
	<event name="openteleport-grandferumbras"/>
	<event name="StorageGrandFerumbras"/>
	</script>
</monster>
 
LUA:
setPlayerStorageValue(cid, storage, -1)
change to
LUA:
setPlayerStorageValue(cid, storage, 1)
In the action script you check for if storage is 1, if it's less then 1, it sends you a cancel message.
Setting the storage to -1 is less then 1.

Also don't forget to register the name in login.lua.
LUA:
registerCreatureEvent(cid, "StorageGrandFerumbras")

Btw, use event and value for the creaturescript too, same as you did with the action script.
 
Last edited:

Attachments

  • error_zps08e3af3d.jpg
    error_zps08e3af3d.jpg
    8.4 KB · Views: 3 · VirusTotal
LUA:
doSetPlayerStorageValue(cid, storage, 2)
Change to
LUA:
setPlayerStorageValue(cid, storage, 2)
nil value means it doesn't exist in your server, so it means nothing.
 
Now it shows this error:
error_zpsa9da17fc.png


This is the script:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
  
 local storage = 2625 --Storage value of the quest done
 local object = 2626 --Itemid of the object
 local uni = 1999 --uniqueId of the object
 local temple = {x=1000, y=1000, z=7} --Temple position
 local success = "Has logrado obtener la reliquia del gran mago!" --Got the item message
 local fail = "Al parecer la fortuna no esta de tu lado, intenta en otra ocasion!" --fail message
 local chance = 5 --Chance percentage, now 5%
 local reward = 2625 --Itemid of the reward
 local ammount = 1 --Numbers of items to get, in case that is stackable
 local done = "Tu ya has obtenido la reliquia del mago" --Message if you try to take again the prize
 local doquest = "You need first finish the quest" --Message if you havent finish the preview quest
 
 if getPlayerStorageValue(cid, storage) == 1 and item.uid == uni and itemEx.itemid == object then
	local chance1 = math.random(1,100)
	if chance1 > chance then
		doPlayerSendTextMessage(cid, 22, fail)
		doCreatureSay(cid, "Al parecer la fortuna no esta de tu lado, intenta en otra ocasion!", TALKTYPE_ORANGE_1)
		doSetPlayerStorageValue(cid, storage, 2)
		else
		doPlayerSendTextMessage(cid, 22, success)
		doCreatureSay(cid, "Has logrado obtener la reliquia del gran mago!", TALKTYPE_ORANGE_1)
		setPlayerStorageValue(cid, storage, 2)
		doPlayerAddItem(cid, reward, ammount)
	end
else
	if getPlayerStorageValue(cid, storage) < 1 then
		doPlayerSendCancel(cid, doquest)
		else
	if getPlayerStorageValue(cid, storage) > 1 then
		doPlayerSendCancel(cid, done)
	end
end
return true
end
end

Do I need to change also that line for this?:
Code:
setPlayerStorageValue(cid, storage, 2)

- - - Updated - - -

No more errors shown, I just changed the line to what you said Limos, everything works fine now.
Thanks!

Topic Solved!
 

Attachments

  • error_zpsa9da17fc.jpg
    error_zpsa9da17fc.jpg
    8.3 KB · Views: 0 · VirusTotal
Yes, change all doSetPlayerStorageValue to setPlayerStorageValue.

Edit: didn't see the updated part.
 
Last edited:
Back
Top