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

on kill monster player get random item

xavierek

New Member
Joined
Apr 11, 2009
Messages
209
Reaction score
0
hello i found some like it only dont know how make it to..
i whant to player get random item 1,2,3,4,5,6 or 7 when kill monster some like random function some one can help me with it ?
sorry for english

PHP:
function onKill(cid, target) 
    if isPlayer(cid) == 1 and isCreature(target) == 1 then
        if getCreatureName(target) == "Demon Boss" then
            setPlayerStorageValue(cid,21902,1) 
        end 
    end 
    return TRUE 
end
 
Ahmm im just a NoOb! Scripter... but i think u need something like:

doPlayerAddItem(cid, 2160, 1)

But... check piggybank script...

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(math.random(1, 6) == 1) then
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		doPlayerAddItem(cid, ITEM_GOLD_COIN, 1)
		doTransformItem(item.uid, 2115)
	else
		doSendMagicEffect(fromPosition, CONST_ME_SOUND_YELLOW)
		doPlayerAddItem(cid, 2160, 1)
	end
	return true
end

Then maybe can be...

LUA:
function onKill(cid, target) 
    if isPlayer(cid) == 1 and isCreature(target) == 1 then
        if getCreatureName(target) == "Demon Boss" then
            setPlayerStorageValue(cid,21902,1) 
			do(math.random(1, 6) == 1) then
			doPlayerAddItem(cid, 2160, 1)
		else
			doPlayerAddItem(cid, 2640, 1)
        end 
    end 
    return true
end

But repeat, im a noob scripting, i dont know if that shit i did can work...

try ;p

Hope help u ;)
 
LUA:
function onKill(cid, target)
	local monsters = {
		["Demon"] = {
			items = {
				{2160,10}, -- [Random] Items -- Will recieve only one.
				{2152,10}
			}
		},
		["Dragon"] = {
			items = {
				{2160,10}, -- [Random] Items -- Will recieve only one.
				{2152,10}
			}
		}
	}
	for name, pos in pairs(monsters) do
                if (name == getCreatureName(target)) then
			local rand = math.random(1, #monsters.items)
			setPlayerStorageValue(cid, 21902, 1)
			addEvent(doPlayerAddItem, 2*1000, cid, monsters.items[rand][1], monsters.items[rand][2])
			addEvent(doSendMagicEffect, 2*1000, getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
		end
		return true
	end
end
 
Last edited:
hmm i give in creaturescrips
<event type="onKill" name="Demon" event="function" script="ungreez.lua"/>

and its dont work why ?
 
Back
Top