Jump to content
InuYasha

Dialy Quest Function

Recommended Posts

You need serialize.lua run in you server

 


DailyFolder = "script/extension/DailyQuest/"

function CheckDayLog(role,ID)
    local CharID = GetCharID(role)
    if exists_file(GetResPath(DailyFolder..""..CharID..".txt")) == false then
        table.save({},GetResPath(DailyFolder..""..CharID..".txt"),"a")
    end
    local Table = {}
    local NowDay = GetNowDay()
    Table = table.load(GetResPath(DailyFolder..""..CharID..".txt"),"r")   
        if Table[ID] == nil then
            Table[ID] = { Day = 0 }
            table.save(Table,GetResPath(DailyFolder..""..CharID..".txt"),"r")
        end
    if Table[ID].Day ~= NowDay then
        return 1
    else
        return 0
    end
end   

function AddDayLog(role,ID)
    local CharID = GetCharID(role)
    Table = table.load(GetResPath(DailyFolder..""..CharID..".txt"),"r")
    local NowDay = GetNowDay()
    Table[ID].Day = NowDay
    table.save(Table,GetResPath(DailyFolder..""..CharID..".txt"),"r")
    return 1
end

in conditions inside MissionSdk.lua add:



elseif conditions[i].func == CheckDayLog then
                PRINT( "ConditionsTest:CheckDayLog, p1 = ", conditions[i].p1 )
                local ret = CheckDayLog( character , conditions[i].p1  )
                if ret ~= LUA_TRUE then
                    PRINT( "ConditionsTest:CheckDayLog = false" )
                    return LUA_FALSE
            end

in actions inside MissionSdk.lua add it:


elseif actions[i].func == AddDayLog then
            PRINT( "ActionsProc:AddDayLog, p1 = ", actions[i].p1 )
            local ret = AddDayLog( character , actions[i].p1 )
            if ret ~= LUA_TRUE then
                PRINT( "ActionsProc:AddDayLog failed!" )
                return LUA_FALSE
            end

Ex:

DefineMission(6888, "(Daily Quest) Kal Runestone", 1884)

    MisBeginTalk( "<t>Kal Runestone is a Item that can get with Novice, Standard and Expert Chests in Pk Areas And can be used to exchange some items.")
    MisBeginCondition(CheckDayLog,1884) -- here add checkday
    MisBeginCondition(NoMission,1884)
    MisBeginAction(AddMission, 1884)
    MisBeginAction(AddTrigger, 18841, TE_GETITEM , 3457 , 1 )
    MisCancelAction(ClearMission, 1884)

    MisNeed(MIS_NEED_DESP, "Colect 1x Kal Runestone in Demonic World, Chaos Argent and Arena Island.")
    MisNeed(MIS_NEED_ITEM, 3457, 1, 10, 1)

    MisPrize(MIS_PRIZE_ITEM, 7329, 1, 4)
    MisPrizeSelAll()

    MisHelpTalk("<t>You can get Kal Runestone With Novice, Standard and Expert Chests in Pk Areas.")
    MisResultTalk("<t>Thanks! You got that.")
    MisResultCondition(HasMission, 1884)
    MisResultCondition(HasItem, 3457, 1)
    MisResultAction(TakeItem, 3457, 1)
    MisResultAction(ClearMission, 1884)
    MisResultAction(AddDayLog,1884)        -- here add addDaylog 

 

Edited by Ximboliex
  • Like 1

xbx3.png

Share this post


Link to post
Share on other sites
On 24.10.2016 at 3:40 PM, Ximboliex said:

You need serialize.lua run in you server

 



DailyFolder = "script/extension/DailyQuest/"

function CheckDayLog(role,ID)
    local CharID = GetCharID(role)
    if exists_file(GetResPath(DailyFolder..""..CharID..".txt")) == false then
        table.save({},GetResPath(DailyFolder..""..CharID..".txt"),"a")
    end
    local Table = {}
    local NowDay = GetNowDay()
    Table = table.load(GetResPath(DailyFolder..""..CharID..".txt"),"r")   
        if Table[ID] == nil then
            Table[ID] = { Day = 0 }
            table.save(Table,GetResPath(DailyFolder..""..CharID..".txt"),"r")
        end
    if Table[ID].Day ~= NowDay then
        return 1
    else
        return 0
    end
end   

function AddDayLog(role,ID)
    local CharID = GetCharID(role)
    Table = table.load(GetResPath(DailyFolder..""..CharID..".txt"),"r")
    local NowDay = GetNowDay()
    Table[ID].Day = NowDay
    table.save(Table,GetResPath(DailyFolder..""..CharID..".txt"),"r")
    return 1
end

in conditions inside MissionSdk.lua add:



elseif conditions[i].func == CheckDayLog then
                PRINT( "ConditionsTest:CheckDayLog, p1 = ", conditions[i].p1 )
                local ret = CheckDayLog( character , conditions[i].p1  )
                if ret ~= LUA_TRUE then
                    PRINT( "ConditionsTest:CheckDayLog = false" )
                    return LUA_FALSE
            end

in actions inside MissionSdk.lua add it:


elseif actions[i].func == AddDayLog then
            PRINT( "ActionsProc:AddDayLog, p1 = ", actions[i].p1 )
            local ret = AddDayLog( character , actions[i].p1 )
            if ret ~= LUA_TRUE then
                PRINT( "ActionsProc:AddDayLog failed!" )
                return LUA_FALSE
            end

Ex:

DefineMission(6888, "(Daily Quest) Kal Runestone", 1884)

    MisBeginTalk( "<t>Kal Runestone is a Item that can get with Novice, Standard and Expert Chests in Pk Areas And can be used to exchange some items.")
    MisBeginCondition(CheckDayLog,1884) -- here add checkday
    MisBeginCondition(NoMission,1884)
    MisBeginAction(AddMission, 1884)
    MisBeginAction(AddTrigger, 18841, TE_GETITEM , 3457 , 1 )
    MisCancelAction(ClearMission, 1884)

    MisNeed(MIS_NEED_DESP, "Colect 1x Kal Runestone in Demonic World, Chaos Argent and Arena Island.")
    MisNeed(MIS_NEED_ITEM, 3457, 1, 10, 1)

    MisPrize(MIS_PRIZE_ITEM, 7329, 1, 4)
    MisPrizeSelAll()

    MisHelpTalk("<t>You can get Kal Runestone With Novice, Standard and Expert Chests in Pk Areas.")
    MisResultTalk("<t>Thanks! You got that.")
    MisResultCondition(HasMission, 1884)
    MisResultCondition(HasItem, 3457, 1)
    MisResultAction(TakeItem, 3457, 1)
    MisResultAction(ClearMission, 1884)
    MisResultAction(AddDayLog,1884)        -- here add addDaylog 

 

Can you help me? im getting error:

in game: "npc script quest stat[NpcState] trans fail

lua_err:

[02-11 15:03:14].../resource/script/extension/DailyQuest/DailyQuest.lua:6: attempt to call global `exists_file' (a nil value)

it's quest:

Spoiler

DefineMission( 2040, "Demonic World Daily", 2030 )

MisBeginTalk("You Going to Demonic World?")
MisBeginCondition(NoMission, 2030)
MisBeginCondition(NoRecord, 2030)
MisBeginCondition(LvCheck, ">", 65)
MisBeginCondition(CheckDayLog,2030) -- here add checkday
MisBeginAction(AddMission, 2030)
MisBeginAction(SetFlag, 2030, 1)
MisBeginAction(AddTrigger, 20301, TE_GETITEM, 3430, 40)
MisBeginAction(AddTrigger, 20302, TE_GETITEM, 3427, 99)
MisBeginAction(AddTrigger, 20303, TE_GETITEM, 7305, 20)
MisCancelAction(ClearMission, 2030)

MisPrize(MIS_PRIZE_MONEY, 400000, 1)
MisPrizeSelAll()

MisNeed(MIS_NEED_DESP, "Rune's and Magical rune fragment You can get in <rDemonic World>")
MisNeed(MIS_NEED_ITEM, 3430, 40, 10, 40)
MisNeed(MIS_NEED_ITEM, 3427, 99, 20, 99)
MisNeed(MIS_NEED_ITEM, 7305, 20, 30, 20)
MisResultTalk("Perfect! Come Back tommorow")
MisHelpTalk("The items you Can Get in <rDemonic World>")
MisResultCondition(HasMission, 2030)
MisResultCondition(HasItem, 3430, 40)
MisResultCondition(HasItem, 3427, 99)
MisResultCondition(HasItem, 7305, 20)
MisResultAction(TakeItem, 3430, 40)
MisResultAction(TakeItem, 3427, 99)
MisResultAction(TakeItem, 7305, 20)
MisResultAction(SetRecord, 2030 )
MisResultAction(ClearMission, 2030)
MisResultAction(AddDayLog,2030)        -- here add addDaylog 


InitTrigger()
TriggerCondition(1, IsItem, 3430)
TriggerAction(1, AddNextFlag, 2030, 10, 40)
RegCurTrigger(20301)
InitTrigger()
TriggerCondition(1, IsItem, 3427)
TriggerAction(1, AddNextFlag, 2030, 20, 99)
RegCurTrigger(20302)
InitTrigger()
TriggerCondition(1, IsItem, 7305)
TriggerAction(1, AddNextFlag, 2030, 30, 20)
RegCurTrigger(20303)
 

Quest's i need make in missionscript right? or in daily file?

Share this post


Link to post
Share on other sites

@blazi10

Make sure you have set these functions correctly

 

elseif conditions[i].func == CheckDayLog then PRINT( "ConditionsTest:CheckDayLog, p1 = ", conditions[i].p1 ) local ret = CheckDayLog( character , conditions[i].p1 ) if ret ~= LUA_TRUE then PRINT( "ConditionsTest:CheckDayLog = false" ) return LUA_FALSE end in actions inside MissionSdk.lua add it: elseif actions[i].func == AddDayLog then PRINT( "ActionsProc:AddDayLog, p1 = ", actions[i].p1 ) local ret = AddDayLog( character , actions[i].p1 ) if ret ~= LUA_TRUE then PRINT( "ActionsProc:AddDayLog failed!" ) return LUA_FALSE end

xbx3.png

Share this post


Link to post
Share on other sites
12 minutes ago, Ximboliex said:

@blazi10

Make sure you have set these functions correctly

 

 


elseif conditions[i].func == CheckDayLog then PRINT( "ConditionsTest:CheckDayLog, p1 = ", conditions[i].p1 ) local ret = CheckDayLog( character , conditions[i].p1 ) if ret ~= LUA_TRUE then PRINT( "ConditionsTest:CheckDayLog = false" ) return LUA_FALSE end in actions inside MissionSdk.lua add it: elseif actions[i].func == AddDayLog then PRINT( "ActionsProc:AddDayLog, p1 = ", actions[i].p1 ) local ret = AddDayLog( character , actions[i].p1 ) if ret ~= LUA_TRUE then PRINT( "ActionsProc:AddDayLog failed!" ) return LUA_FALSE end

I did it before run gameserver

Share this post


Link to post
Share on other sites
On 2/11/2017 at 9:14 PM, blazi10 said:

Can you help me? im getting error:

in game: "npc script quest stat[NpcState] trans fail

lua_err:


[02-11 15:03:14].../resource/script/extension/DailyQuest/DailyQuest.lua:6: attempt to call global `exists_file' (a nil value)


u need the function exists_file () to use it.

 

@Ximboliex

  • Like 1

logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites
36 minutes ago, Blanquitoh said:


function exists_file(name)
       local f=io.open(name,"r")
       if f~=nil then io.close(f) return true else return false end
end

You can get help by a group of devs on here:
https://discord.gg/bFWwmwx

thank you so much! i will try it

 

[03-21 16:53:10]resource/script/MisSdk/scriptsdk.lua:1283: attempt to index field `?' (a nil value)

[03-21 16:53:10]resource/script/MisSdk/scriptsdk.lua:1283: attempt to index field `?' (a nil value)

 

Edited by blazi10

Share this post


Link to post
Share on other sites

@blazi10 dont just paste the error, paste the lines in scriptsdk.lua that is in the range about 1283 also >.<


logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites

Sorry I have the same problem what was the solution or do you have a more detailed guide

 

gameserver 0 errror

image.png.81802cf08ef05cda4fd0371f4d7e9b70.png

image.png.2d64d98497d599b7c295c47cc29bb6ad.png

 

 

 

 

 

[01-22 16:56:15]./resource/script/MisSdk/MissionSdk.lua:2567: attempt to call global `CheckTeam1' (a nil value)
[01-22 16:56:17]./resource/script/MisSdk/MissionSdk.lua:2567: attempt to call global `CheckTeam1' (a nil value)
 

Share this post


Link to post
Share on other sites
On 1/22/2022 at 5:11 PM, dragontechi said:

I was able to make it work using this guide but there is a problem when I reset the server the mission is put back

 

Yes, they are saved on variables which removed upon server closing. You must find a way to keep those variables permanently or store all of that information within SQL (or alternatively in text files, but not recommended I guess).

Share this post


Link to post
Share on other sites

In case you still haven't known how to get the script up and running, here I will leave you the way.


In MissionSdk.lua find this line

			elseif conditions[i].func ==CheckTime then  ----Find This Line 
				PRINT( "ConditionsTest: CheckTime, p1 =, p2 =", conditions[i].p1)
				local ret = CheckTime( character, conditions[i].p1 )
				if ret ~= LUA_TRUE then
					PRINT( "ConditionsTest:CheckTime = false" )
					return LUA_FALSE
				end ----When you see the end, paste the new code

Must look like this:

			elseif conditions[i].func ==CheckTime then  ----Find This Line 
				PRINT( "ConditionsTest: CheckTime, p1 =, p2 =", conditions[i].p1)
				local ret = CheckTime( character, conditions[i].p1 )
				if ret ~= LUA_TRUE then
					PRINT( "ConditionsTest:CheckTime = false" )
					return LUA_FALSE
				end ----When you see the end, paste the new code

			elseif conditions[i].func == CheckDayLog then
                PRINT( "ConditionsTest:CheckDayLog, p1 = ", conditions[i].p1 )
                local ret = CheckDayLog( character , conditions[i].p1  )
                if ret ~= LUA_TRUE then
                    PRINT( "ConditionsTest:CheckDayLog = false" )
                    return LUA_FALSE
            end


The same in the following code

 

		elseif actions[i].func == AddExp_6 then  ------Find This Line 
				PRINT( "ActionProc: AddExp_6, p1 = ", actions[i].p1)
				local ret = AddExp_6( character,npc, actions[i].p1)
				if ret ~= LUA_TRUE then
					PRINT( "ActionProc:AddExp_6 = false" )
					return LUA_FALSE
				end ----When you see the end, paste the new code

Must Look Like This

 

		elseif actions[i].func == AddExp_6 then  ------Find This Line 
				PRINT( "ActionProc: AddExp_6, p1 = ", actions[i].p1)
				local ret = AddExp_6( character,npc, actions[i].p1)
				if ret ~= LUA_TRUE then
					PRINT( "ActionProc:AddExp_6 = false" )
					return LUA_FALSE
				end ----When you see the end, paste the new code

		elseif actions[i].func == AddDayLog then
            PRINT( "ActionsProc:AddDayLog, p1 = ", actions[i].p1 )
            local ret = AddDayLog( character , actions[i].p1 )
            if ret ~= LUA_TRUE then
                PRINT( "ActionsProc:AddDayLog failed!" )
                return LUA_FALSE
            end

After having placed the script correctly we go to MissionScript08.lua

 

DefineMission(6888, "(Daily Quest) Kal Runestone", 1884)

    MisBeginTalk( "<t>Kal Runestone is a Item that can get with Novice, Standard and Expert Chests in Pk Areas And can be used to exchange some items.")
    MisBeginCondition(CheckDayLog,1884) -- here add checkday
    MisBeginCondition(NoMission,1884)
    MisBeginAction(AddMission, 1884)
    MisBeginAction(AddTrigger, 18841, TE_GETITEM , 3457 , 1 )
    MisCancelAction(ClearMission, 1884)

    MisNeed(MIS_NEED_DESP, "Colect 1x Kal Runestone in Demonic World, Chaos Argent and Arena Island.")
    MisNeed(MIS_NEED_ITEM, 3457, 1, 10, 1)

    MisPrize(MIS_PRIZE_ITEM, 227, 99, 4)
    MisPrizeSelAll()

    MisHelpTalk("<t>You can get Kal Runestone With Novice, Standard and Expert Chests in Pk Areas.")
    MisResultTalk("<t>Thanks! You got that.")
    MisResultCondition(HasMission, 1884)
    MisResultCondition(HasItem, 3457, 1)
    MisResultAction(TakeItem, 3457, 1)
    MisResultAction(ClearMission, 1884)
    MisResultAction(AddDayLog,1884)        -- here add addDaylog 

Then we go to NPCScript08.lua and paste

 

function Script_Npc01 () ---Remember this has to go on garnernpc

	AddNpcMission	(6888) ---This is what activates the script

end

and then in garfnernpc.txt we place a new NPC

 

XXX	Quest Board	1	7	15	223200,279300	223200,279300	180	Argent City	3	0	Script_Npc01	0

That's the way it worked for me, I don't remember who came with the LuaSQL.dll integrated into GameServer.exe, but try with or without the LuaSQL.dll anyway.

I hope that works for someone who has the doubt, it worked for me the first time and by the way, excuse my English or my lack of spelling, I'm using Google Translate.

 

 

Game_xhqDpGbL9N.png


☠️🏴‍☠️💀ǤØĐ βŁ€ŞŞ ƤƗŘΔĆ¥💀🏴‍☠️☠️

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...