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

[Almost Solved] Need this script edited. Kill monster finish quest

  • Thread starter Thread starter Xikini
  • Start date Start date
X

Xikini

Guest
* Want *
- To be able to set the start/end of quest in the "local t" as 45005,3 instead of just 45005
- Send the player a message every 5 kills over the kills limit telling them to go see the npc.

This is the current semi working script.
As it is now, it counts to 30/30 monsters killed, but does not tell you to go see the npc,
Also I have to currently edit this line to make 'started quests' in the middle of a storyline.
My objective is to be able to add all kill monster quests to this script.
LUA:
if(getCreatureStorage(cid, k.started) == 3) then
LUA:
local t = {
	[{"rat", "cave rat"}] = {started = 45005, storage = 45006, kills = 30, raceName = "Rats", npcName = "Monk Tonir",}
}
 
function onKill(cid, target, damage, flags)
	for v, k in pairs(t) do
		local master = getCreatureMaster(target)
		if(master and master ~= target) then return true end
		if(bit.band(flags, 1) == 1 and isMonster(target) and isInArray(v, getCreatureName(target))) then
			if(getCreatureStorage(cid, k.started) == 3) then
				if(getCreatureStorage(cid, k.storage) < 0) then
					doCreatureSetStorage(cid, k.storage, 0)
				end
				if(getCreatureStorage(cid, k.storage) < k.kills) then
					doCreatureSetStorage(cid, k.storage, getCreatureStorage(cid, k.storage) + 1)
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have defeated " .. getCreatureStorage(cid, k.storage) .. " out of " .. k.kills .. " " .. k.raceName .. "!")
				elseif getCreatureStorage(cid, k.storage) >= k.kills then
					local mr = math.random(5)
					if (mr == 5) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have defeated enough " .. k.raceName .. "!\n" .. npcName .. " is waiting to hear the results of your mission!")
					end
				end
			end
		end
	end
	return true
end
as far as I can tell, this part and below does not currently work.
LUA:
elseif getCreatureStorage(cid, k.storage) >= k.kills then
If anyone needs more information please ask me for it, and I'll post when I get a chance.
Crying Damson Forgotten Server 0.3.7
 
Last edited by a moderator:
Code:
local mr = math.random(5)
if (mr == 5) then
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have defeated enough " .. [COLOR="#FF0000"]k.raceName[/COLOR] .. "!\n" .. [COLOR="#FF0000"]npcName[/COLOR] .. " is waiting to hear the results of your mission!")
end
as far as I can tell, this part and below does not currently work.
LUA:
elseif getCreatureStorage(cid, k.storage) >= k.kills then
If anyone needs more information please ask me for it, and I'll post when I get a chance.
Crying Damson Forgotten Server 0.3.7

Hmm, think again. Look at what I've highlighted in the code above. Notice anything missing? ;)

Edit: "math.random" doesn't automatically work how you're expecting it to. Currently, you have a 1 out of 5 (20%) chance of getting that message for each monster you kill - not out of every 5 monsters. So, you may not be seeing the message as often as you like.
 
I was using math.random because I cannot think of a way to ask the script to count 5 above the "kills" to send the message.
As for testing I have killed 56 rats without it giving me a message. :(
 
I was using math.random because I cannot think of a way to ask the script to count 5 above the "kills" to send the message.
As for testing I have killed 56 rats without it giving me a message. :(

Not sure if you noticed what I was referring to, but I meant: "k.npcName" instead of "npcName".
 
Back
Top