Hi guys, I would like to change the reward the player receive when he completes the task. Right now it's set for the player to receive mount, however I would like for the player to receive a item, I've tried to look at similar scripts, but I didn't manage to make it on my own.
Credits for @Xikini for the original script.
Lua:
local config = {
[{"centipede", "bug", "moss bug", "cockroach"}] = {mountReward = 93, killGoal = 1000, storage = 84755, monsterType = "bugs"}, -- check mounts.xml for the mountIds
[{"ancient scarab", "giant spider"}] = {mountReward = 1111, killGoal = 2500, storage = 45002, monsterType = "crawly things"},
[{"kollos", "spidris"}] = {mountReward = 1111, killGoal = 3500, storage = 45003, monsterType = "bosses"}
}
local killEvent = CreatureEvent("newOnKillEvent")
killEvent:type("kill")
function killEvent.onKill(creature, target)
if not creature:isPlayer() then
return true
end
if not target:isMonster() then
return true
end
local monsterName = target:getName():lower()
for v, k in pairs(config) do
if table.contains(v, monsterName) then
local currentStorage = creature:getStorageValue(k.storage)
if currentStorage >= k.killGoal then
return true
end
currentStorage = currentStorage < 1 and 1 or currentStorage + 1
creature:setStorageValue(k.storage, currentStorage)
if currentStorage == k.killGoal then
creature:addMount(k.mountReward)
end
creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. currentStorage .. "/" .. k.killGoal .. " " .. k.monsterType .. ".")
return true
end
end
return true
end
killEvent:register()
local loginEvent = CreatureEvent("registerOnKill")
loginEvent:type("login")
function loginEvent.onLogin(player)
player:registerEvent("newOnKillEvent")
return true
end
loginEvent:register()
Credits for @Xikini for the original script.