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

TFS 0.3.4 loot when kill %

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,764
Solutions
1
Reaction score
227
Location
Chile, Santiago
Hello everyone, Im thinking about making a system that you have a % to get a x item... If you kill rats, you have 0,01% to get the item, if you kill demons, you have 5% to get it, if you kill orshabaals, you have 10% to get the item, if you kill other monsters that are not in the list, you have 1% to get the item...

It shouldn't be edited in monsters... it should be for creaturescripts I think, when kill the monster...

PD: Need it for tfs 0.3.4pl2, thanks.
 
Code:
local monsters = {
	["Rat"] = 10,
	["Demon"] = 5000,
	["Orshabaal"] = 10000
}
local item = {2472, 1}
local default = 1000

function onKill(cid, target)
	if math.random(100000) <= (monsters[getCreatureName(target)] or default) then
		doPlayerAddItem(cid, item[1], item[2])
	end
	return true
end
Don't forget to register it in creaturescripts.xml and login.lua
 
Instead of adding it to login.lua you're supposed to create something like kill.lua
Also,
creaturescripts.xml
Code:
	<event type="kill" name="PlayerKill" event="script" value="kill.lua"/>
login.lua
Code:
	registerCreatureEvent(cid, "PlayerKill")
 
Back
Top