• 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 Help with creaturescript

Delvire

°£°
Joined
Feb 24, 2008
Messages
236
Reaction score
9
Hello everybody, here goes my request:

Player kills a monster 'X' then
his stamina should be set to 0 (or, if possible, reduced by some amount of time)

I tried doing that, but I got some weird bugs (for me creaturescript is a bit embarassing)


Thank you, rep ++
 
LUA:
local config = {
	monsterName = 'Demon',
	times = 2,
	storage = 4578
}
 
function onKill(cid, target, damage, flags)
	if isPlayer(cid) then
		if getCreatureName(target):lower() == config.monsterName:lower() then
			doCreatureSetStorage(cid, config.storage, math.max(0, getCreatureStorage(cid, config.storage)) + 1)
			if getCreatureStorage(cid, config.storage) == config.times then
				doPlayerSetStamina(cid, 0)
			end
		end
	end
	return true
end
 
Last edited:
I had mistakes with this line:
LUA:
doCreatureSetStorage(cid, config.storage, math.max(0, getCreatureStorage(cid, config.storage + 1)))

I changed to:
LUA:
doCreatureSetStorage(cid, config.storage, math.max(0, getCreatureStorage(cid, config.storage)) + 1)
 
Worked perfectly! Now I will make some adjustments, such as warning that player will loss stamina if he kills one more monster... That I can do it by myself
It will be a funny anti bot solution..thank you a lot!
 
Back
Top