I'm making a quest where you kill X creature for Y times.
As you kill more creatures your storage value is going up.
When you have killed enough creatures you come back to npc and it will reward you.
The whole thing works quite well, but when I complete the quest and kill random creatures, the counter still goes up and keep counting creature for negative (ex: you still have to kill -1 troll)
I don't know what to do, I have already tried some way on script structure but it did'nt work, it is a creaturescript.
This is the original version:
The one I thought could work by using the checkStorage function:
I would like to make it first check if player have a storagevalue bigger than 20 and if yes then finish itself.
But I just fail really badly at structuring script. I'm counting on your help guys!!
Thanks a lot!!
PS: 21 is the final storagevalue of quest, the value of completed.
As you kill more creatures your storage value is going up.
When you have killed enough creatures you come back to npc and it will reward you.
The whole thing works quite well, but when I complete the quest and kill random creatures, the counter still goes up and keep counting creature for negative (ex: you still have to kill -1 troll)
I don't know what to do, I have already tried some way on script structure but it did'nt work, it is a creaturescript.
This is the original version:
Lua:
local storage = 6004
function onDeath(cid, corpse, deathList)
local killer = deathList
local monster = getCreatureName(cid)
local troll = getPlayerStorageValue(killer, storage)
if ((monster:lower() == 'troll') and not isInArray({-1, 20}, troll)) then
doPlayerSendTextMessage(killer, MESSAGE_STATUS_CONSOLE_BLUE, 'You still need to kill '.. 20 - troll ..' more trolls for Liutenant Simas Hawk.')
setPlayerStorageValue(killer, storage, troll + 1)
elseif troll == 20 then
doPlayerSendTextMessage(killer, MESSAGE_STATUS_CONSOLE_BLUE, 'You have killed enough trolls. Come back and talk to Liutenant Simas Hawk to receive your reward.')
end
return true
end
The one I thought could work by using the checkStorage function:
Lua:
local storage = 6004
function onDeath(cid, corpse, deathList)
local killer = deathList
local monster = getCreatureName(cid)
local troll = getPlayerStorageValue(killer, storage)
if troll > 20 then
if ((monster:lower() == 'troll') and not isInArray({-1, 20}, troll)) then
doPlayerSendTextMessage(killer, MESSAGE_STATUS_CONSOLE_BLUE, 'You still need to kill '.. 20 - troll ..' more trolls for Liutenant Simas Hawk.')
setPlayerStorageValue(killer, storage, troll + 1)
elseif troll == 20 then
doPlayerSendTextMessage(killer, MESSAGE_STATUS_CONSOLE_BLUE, 'You have killed enough trolls. Come back and talk to Liutenant Simas Hawk to receive your reward.')
end
end
return true
end
I would like to make it first check if player have a storagevalue bigger than 20 and if yes then finish itself.
But I just fail really badly at structuring script. I'm counting on your help guys!!
Thanks a lot!!
PS: 21 is the final storagevalue of quest, the value of completed.
Last edited: