• 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] My scripts isnt working :S

Dantarrix

Member
Joined
Aug 27, 2010
Messages
546
Reaction score
18
Location
Stgo, Chile
Well, I made this script a few days ago:
Code:
local monsters = {
["demon"] = {item = 2160, cant = 2, chance = 70},
["rat"] = {item = 2160, cant = 2, chance = 10},
["cyclops"] = {item = 2160, cant = 2, chance = 30},
["dragon"] = {item = 2160, cant = 2, chance = 55},
["rabbit"] = {item = 2160, cant = 10, chance = 100}
}
local percent = math.random(1, 100)
function onDeath(cid, corpse, deathList)
	for k, v in pairs(monsters) do
		if (isMonster(cid) and ((string.lower(getCreatureName(cid))) == k)) then
			if percent <= v.chance then
					doAddContainerItem(corpse.uid, v.item, math.random(1, v.cant))
					doPlayerSendTextMessage(cid, 22, "You get special loot!")
			end
		end
	end
return true
end

I try it with rabbit, it should give randomly, 1 to 10 cc and add them on rabbit's corpse, but it dont....
And it dont show any errors in console or crash or debug :(
If someone could help me please... :S
 
I was unable to test this, although, I do believe it will work.

Lua:
local t = {
	["rat"] = {
		id = 2160, countMax = 4, chance = 20
	},
	["dog"] = {
		id = 2160, countMax = 5, chance = 25
	}
}

function onDeath(cid, corpse, deathList)
	local k = t[getCreatureName(cid):lower()]
	if k then
		if isPlayer(k) or isSummon(k) then return true end
		if isMonster(k) then
			local percent = math.random(1, 100)
			if percent <= k.chance then
				doAddContainerItem(corpse.uid, k.id, math.random(1, k.countMax) or 1)
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Today is your lucky day! You received extra loot.")
			end
		end
	end
	
	return true
end
If you have any problems, send me a private message. ;)
 
Back
Top