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

Solved Creaturescripts - Function reading drop ?

Status
Not open for further replies.

Advent

Custom RPG Maker
Joined
Oct 3, 2009
Messages
306
Reaction score
7
Hello I require assistance. I have problem with reading item from loot of killed monsters and do something if id == xxxx.
I wanted to make it like this

READ LOOT

If one item from loot is 2160 then
do ...
elseif one item from loot is 3104 then
do ...
elseif one item from loot is 2304 then
do ...

It doesnt have to read from containers like backpack/bag. From dead creature is enough.
I would appreciate any help.
I am going to try solve it myself but I am taking my time and can't solve this myself by now.
 
How many different monsters will it work with? You will need to use either a kill or death creaturescript.
 
Ye, I knew that its going to be this but I couldn't get good instruction/function to make it. I tried remaking some things using party loot or random attributes but once it made bag and gold not appear, once it made corpse disappear, other time it was crash.
 
you can easily do it with this kill creaturescript, registering the event to player obviously
Code:
EVENT_ITEMS = {1112,2323,4323}


function getTopItem(p) -- from Darkhaos's arena script
    p.stackpos = 0
    local v = getThingFromPos(p)
    repeat
        p.stackpos = p.stackpos + 1
        v = getThingFromPos(p)
    until v.itemid == 0
    p.stackpos = p.stackpos - 1
    return getThingFromPos(p)
end


function scanCorpseLoot(cid, pos)
    local corpse = getTopItem(pos)
    if isContainer(corpse.uid) then
        for n = (getContainerSize(corpse.uid) - 1), 0, -1 do
            if isInArray(EVENT_ITEMS, getContainerItem(corpse.uid, n).itemid) then
                --do something
                break
            end
        end
    end
end


function onKill(cid, target, lastHit)
    if isMonster(target) then
        addEvent(scanCorpseLoot, 150, cid, getThingPos(target))
    end
    return true
end

just edit the items array that will trigger an action, and the action is right there:
Code:
function scanCorpseLoot(cid, pos)
    local corpse = getTopItem(pos)
    if isContainer(corpse.uid) then
        for n = (getContainerSize(corpse.uid) - 1), 0, -1 do
            if isInArray(EVENT_ITEMS, getContainerItem(corpse.uid, n).itemid) then
[B][COLOR=#ff0000]                --do something
[/COLOR][/B]            break
            end
        end
    end
end
 
Last edited:
Thanks. I am going to test it and reply if it works and of course rep if it does.

- - - Updated - - -

When I add

doSendAnimatedText(toPosition, "Cling", TEXTCOLOR_ORANGE)

under

if isInArray(EVENT_ITEMS, getContainerItem(corpse.uid, n).itemid) then

then nothing happens but its because value with ToPosition is nil

but if I use

doSendAnimatedText(pos, "Cling", TEXTCOLOR_ORANGE)

Whole server crashes, same with textcolor and effects.
 
Last edited:
try with

doSendAnimatedText(getThingPos(cid), "Cling",
192)
break

Which server distribution do you use?
 
It does work ! Thank you very much. Last question. Will it make my server a lot slower ? I want to make it pop up when lets say you drop magic plate armor from Demon which will be very rare but its checking this on every kill, isnt it ?
 
It should not really affect your server's performance and RAM, tfs has already a lot of scripts to care of
 
Status
Not open for further replies.
Back
Top