Hello Eleven Warrior,
If I understand you correctly, you must :
-Check if it's the correct item
-If all three items were given to the npc, it trigger the reward function. ?
I'm not an expert in LUA scripting, so they are maybe better way to do it, but in your shoes, I would do something like this :
-Call checkItemReceived instead of Reward1.
-checkItemReceived, in the if statement, will call checkReward, it will return true if it was a proper item (and in the process, destroy the item, print something to the player, the global variable rewardCheckVar will be incremented before the second part of the statement is called) and IF rewardCheckVar is equal to 3, then it means the players gave all items to the npc
-If both condition are true, then call Reward1
Please note
I didn't test the code below, but it should be close enough for your needs. If you need more help, p.m. me.
Code: Select all
function checkItemReceived(self, npc, item)
if checkReward(self, npc, item) and rewardCheckVar == 3 then
Reward1(npc)
end
end
function checkReward(self, npc, item)
if item.go.name == "rock" then
hudPrint("Thank You.")
rewardCheckVar = rewardCheckVar + 1 --global var, you could use a counter too
item.go:destroy()
return true
end
if item.go.name == "ancient_claymore" then
rewardCheckVar = rewardCheckVar + 1
hudPrint("Thank You.")
item.go:destroy()
return true
end
if item.go.name == "power_gem" then
rewardCheckVar = rewardCheckVar + 1
hudPrint("Thank You.")
item.go:destroy()
return true
end
hudPrint("I have no need for this item.")
return false
end
function Reward1(self, npc)
--Do whatever you want, give XP or items.
end
Regards,
Vand