*This script will add to monster container special item named in config and works only if a player have special storage to obdain that item.
for 0.3.6~ and 0.4.~ use this code
creaturescripts.xml
register it to login.lua
create lua file named bubu.lua
for 0.2.~ users this code
creaturescripts.xml
create lua file named bubu.lua
Also for everyMonster you write in config register event example:
monsters/rat.xml
before <loot> add
final edit will look like this
Feel free to ask questions or report bugs.
Thank for this thread creator to fire my spirit http://otland.net/f132/bring-head-script-based-world-warcraft-155781/#post1501665 and also for dantarrix
for 0.3.6~ and 0.4.~ use this code
creaturescripts.xml
Code:
<event type="kill" name="bubu" event="script" value="bubu.lua"/>
register it to login.lua
Code:
registerCreatureEvent(cid, "bubu")
create lua file named bubu.lua
Lua:
local monsters = {
["demon"] = {item = 2160, count = 2, chance = 70},
["rat"] = {item = 2160, count = 2, chance = 80}
}
function onKill(cid, target, lastHit)
local storage = 7474
local v = getMonsterInfo(getCreatureName(target)).lookCorpse
local chance = math.random(1, 100)
if getPlayerStorageValue(cid, storage) == 1 then
for k, a in pairs(monsters) do
if (isMonster(target) and ((string.lower(getCreatureName(target))) == k)) then
if a.chance >= chance then
local function dropLoot(pos, v, cid)
local corpse = getTileItemById(pos, v).uid
doAddContainerItem(corpse, a.item, math.random(1, a.count))
end
addEvent(dropLoot, 0, getThingPos(target), v,cid)
end
end
end
end
return true
end
for 0.2.~ users this code
creaturescripts.xml
Code:
<event type="death" name="bubu" script="bubu.lua"/>
create lua file named bubu.lua
Lua:
local monsters = {
["demon"] = {item = 2160, cant = 2, chance = 70},
["rat"] = {item = 2160, cant = 2, chance = 100}
}
local storage = 7474
function onDeath(cid, corpse)
local chance = math.random(1, 100)
if getPlayerStorageValue(getPlayerByName(getPlayerName(getCreatureTarget(cid))), storage) == 1 then
for k, v in pairs(monsters) do
if (isMonster(cid) and ((string.lower(getCreatureName(cid))) == k)) then
if v.chance >= chance then
doAddContainerItem(corpse.uid, v.item, math.random(1, v.cant))
end
end
end
end
return true
end
Also for everyMonster you write in config register event example:
monsters/rat.xml
before <loot> add
Code:
<script>
<event name="bubu"/>
</script>
final edit will look like this
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="rat" nameDescription="a rat" race="blood" experience="5" speed="140" manacost="200">
<health now="20" max="20"/>
<look type="21" head="20" body="30" legs="40" feet="50" corpse="5964"/>
<targetchange interval="2000" chance="0"/>
<strategy attack="100" defense="0"/>
<flags>
<flag summonable="1"/>
<flag attackable="1"/>
<flag hostile="1"/>
<flag illusionable="1"/>
<flag convinceable="1"/>
<flag pushable="1"/>
<flag canpushitems="0"/>
<flag canpushcreatures="0"/>
<flag targetdistance="1"/>
<flag staticattack="90"/>
<flag runonhealth="5"/>
</flags>
<attacks>
<attack name="melee" interval="2000" skill="8" attack="9"/>
</attacks>
<defenses armor="7" defense="5"/>
<immunities/>
<script>
<event name="bubu"/>
</script>
<loot>
<item id="3976" countmax="6" chance1="50000" chancemax="0"/>
<item id="2148" countmax="7" chance1="80000" chancemax="0"/>
<item id="2696" chance="20000"/>
</loot>
</monster>
Feel free to ask questions or report bugs.
Thank for this thread creator to fire my spirit http://otland.net/f132/bring-head-script-based-world-warcraft-155781/#post1501665 and also for dantarrix