• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent Rewards on kill monsters!

averatec

Advanced OT User
Joined
Jun 1, 2007
Messages
2,243
Solutions
4
Reaction score
159
Location
Poland
data/creaturescripts/scripts/rewards_onkill.lua

Lua:
local quests =
{
	{ 1111, "Rat", 30, 2160, 10, "Congratulations! You finished a first quest of Rats!" },  -- storage of starts quest, monster, count to kill, gift id, gift count, message on finish
	{ 1112, "Demon", 100, 2400, 1, "Congratulations!" },
	{ 1113, "Rat", 5, 2160, 2, "Congratulations! You finished a second quest of Rats!" }
}

function onKill(cid, target, lastHit)
	if (not isMonster(target)) then
		return false
	end
	
	for i=1, #quests do
		if (getCreatureName(target) == quests[i][2] and not (getPlayerStorageValue(cid, quests[i][1]) > quests[i][3])) then
			if (getPlayerStorageValue(cid, quests[i][1]) == -1) then
				doPlayerSetStorageValue(cid, quests[i][1], 0)
			end
			doPlayerSetStorageValue(cid, quests[i][1], (getPlayerStorageValue(cid, quests[i][1])+1))
			if (getPlayerStorageValue(cid, quests[i][1]) == quests[i][3]) then
				doPlayerAddItem(cid, quests[i][4], quests[i][5])
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, quests[i][6])
			end
			return true
		end
	end
	return true
end

data/creaturescripts/creaturescripts.xml add
Code:
<event type="kill" name="Rewards OnKill" event="script" value="rewards_onkill.lua"/>

data/creaturescripts/scripts/login.lua
after
Code:
registerCreatureEvent(cid, "ReportBug")
add
Code:
registerCreatureEvent(cid, "Rewards OnKill")

Can be more than one quest with this same monster :)

support 0.3.5+

#edit
fixed
 
Last edited:
Can You add talkaction for example '!quest' rat' ?
And it will be give info how many rats u killed and how many u must kill yet
 
Back
Top