Page 1 of 1

SUG: QuestIsComplete and SetStepComplete + others

Posted: Wed Mar 27, 2019 4:27 pm
by Ememjr
these two lua functions always require you to check to see if you have the quest with hasquest first unless you are absolutely sure you already have it
if you dont check and you dont have the quest it will crash the server

I have in testing and so far it is working when these to functions are executed the lua function will check if you have the quest and just return 0 if it doesnt, no more crashes, and as a sid benifit
you do not have to have a if hasquest state prior to using the above functions, which will make our scripts much cleaner

thoughts comments, are welcome, ie there is a situation where this might not work. before i commit

there are other functions as well i just didnt list them

Re: SUG: QuestIsComplete and SetStepComplete + others

Posted: Wed Mar 27, 2019 6:56 pm
by Jabantiz
That is fine, I would have thought those functions would check for the quest first to begin with but I guess not.

Re: SUG: QuestIsComplete and SetStepComplete + others

Posted: Thu Mar 28, 2019 2:54 am
by Ememjr

Code: Select all

function enter_poi_location(zone, player, location)
    if location == 10 then
        if HasQuest(player,477) then
            SetStepComplete(player,477,1)
        end
        if HasQuest(player,474) then
            SetStepComplete(player,474,2)
        end
        if HasQuest(player,475) then
            SetStepComplete(player,475,3)
        end
        if HasQuest(player,478) then
            SetStepComplete(player,478,1)
        end
            end
end
that now can be reduced to this

Code: Select all

function enter_poi_location(zone, player, location)
    if location == 10 then
        SetStepComplete(player,477,1)
        SetStepComplete(player,474,2)
        SetStepComplete(player,475,3)
        SetStepComplete(player,478,1)
     end
end
much cleaner