habs8024 2 Report post Posted February 24 Hello Pirates I have tried to add the FREE Lunch extension from lucky's archive the script works great, sort of it functions as it should but i found a weird problem, that i cannot figure out for the life of me Somehow the script messes up the entire Cha_timer, so such as rear fairy, cloaks and other cha_timer effects just stops working The script looks like this Does anyone have an idea on how to fix this? Not looking for a hand out, but a pointer of where to go would be nice print( " >> Loading FREE Lunch Ctrl" ) -- -------------------------- -- FREE Lunch Functions -- -------------------------- function FREELunch:SetHours(number) if FREELunch.Enable == true then print("=============================================================================") print("FREE Lunch: You can't edit hours right now because FREE Lunch Event is enabled. If you wish to edit hours, please disable the event first!") print("=============================================================================") return 0 end if number > 24 then print("=============================================================================") print("FREE Lunch: Maximum hours range is 24 hour(s). You can't make it higher!") print("=============================================================================") return 0 end FREELunch.Hours = number BickerNotice(role,"FREE Lunch: Time is not set up!") SystemNotice(role,"FREE Lunch: Please set up your FREE Lunch Hour before starting this extension.") print("FREE Lunch: Your set your hours to "..number.." for FREE Lunch Event, If you wish to proceed please start the event, if not, you can change the value again.") end function FuncFREELunch(ignore, role, freq, time) for i,v in pairs({GetChaDefaultName(role)}) do if(FREELunch.Hours ~= nil and FREELunch.Enable == true and IsPlayer(role) == 1 and FREELunch.Players[v] == nil)then FREELunch.Announce = true FREELunch.Players[v] = { Name = v, Time = FREELunch.Hours*3600, Role = role } BickerNotice(FREELunch.Players[v].Role,"FREE Lunch Event has started!") SystemNotice(FREELunch.Players[v].Role,"FREE Lunch: FREE Lunch Event has started! If you wish to receive rewards, you have to be online for "..FREELunch.Hours.." hour(s)!") elseif(FREELunch.Hours ~= nil and FREELunch.Enable == false and IsPlayer(role) == 1 and FREELunch.Announce == true)then BickerNotice(FREELunch.Players[v].Role,"FREE Lunch Event has ended!") Notice("FREE Lunch: The FREE Lunch Event has already ended! Congratulations to all who have won, and for who haven't won, we wish you a better luck next FREE Lunch. Thank you for joining the Event!") FREELunch:Init() FREELunch.Players[CharacterName] = nil elseif(FREELunch.Hours == nil and FREELunch.Enable == true and IsPlayer(role) == 1 and FREELunch.SetUp == true)then FREELunch:Init() BickerNotice(role,"FREE Lunch: Time is not set up!") SystemNotice(role,"FREE Lunch: Please set up your FREE Lunch Hour before starting this extension.") print("FREE Lunch: Please set up your FREE Lunch Hour before starting this extension.") else FREELunch.SetUp = true end end local CharacterName = GetChaDefaultName(role) local Roler = FREELunch.Players[CharacterName].Role local Random = math.random(1,FREELunch.RewardsCount) if(FREELunch.Enable == true)then if(IsPlayer(role) == 1 and FREELunch.Players[CharacterName] ~= nil)then FREELunch.Players[CharacterName].Time = FREELunch.Players[CharacterName].Time - 1 end end if(FREELunch.Players[CharacterName].Time == 86399)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 24 hour") elseif(FREELunch.Players[CharacterName].Time == 82800)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 23 hour") elseif(FREELunch.Players[CharacterName].Time == 79200)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 22 hour") elseif(FREELunch.Players[CharacterName].Time == 75600)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 21 hour") elseif(FREELunch.Players[CharacterName].Time == 72000)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 20 hour") elseif(FREELunch.Players[CharacterName].Time == 68400)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 19 hour") elseif(FREELunch.Players[CharacterName].Time == 64800)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 18 hour") elseif(FREELunch.Players[CharacterName].Time == 61200)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 17 hour") elseif(FREELunch.Players[CharacterName].Time == 57600)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 16 hour") elseif(FREELunch.Players[CharacterName].Time == 54000)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 15 hour") elseif(FREELunch.Players[CharacterName].Time == 50400)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 14 hour") elseif(FREELunch.Players[CharacterName].Time == 46800)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 13 hour") elseif(FREELunch.Players[CharacterName].Time == 43200)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 12 hour") elseif(FREELunch.Players[CharacterName].Time == 39600)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 11 hour") elseif(FREELunch.Players[CharacterName].Time == 36000)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 10 hour") elseif(FREELunch.Players[CharacterName].Time == 32400)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 9 hour") elseif(FREELunch.Players[CharacterName].Time == 28800)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 8 hour") elseif(FREELunch.Players[CharacterName].Time == 25200)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 7 hour") elseif(FREELunch.Players[CharacterName].Time == 21600)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 6 hour") elseif(FREELunch.Players[CharacterName].Time == 18000)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 5 hour") elseif(FREELunch.Players[CharacterName].Time == 14400)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 4 hour") elseif(FREELunch.Players[CharacterName].Time == 10800)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 3 hour") elseif(FREELunch.Players[CharacterName].Time == 7200)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 2 hour") elseif(FREELunch.Players[CharacterName].Time == 3600)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 1 hour") elseif(FREELunch.Players[CharacterName].Time == 1800)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 30 minute(s)") elseif(FREELunch.Players[CharacterName].Time == 900)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 15 minute(s)") elseif(FREELunch.Players[CharacterName].Time == 600)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 10 minute(s)") elseif(FREELunch.Players[CharacterName].Time == 300)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 5 minute(s)") elseif(FREELunch.Players[CharacterName].Time == 60)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 1 minute(s)") elseif(FREELunch.Players[CharacterName].Time == 30)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 30 second(s)") elseif(FREELunch.Players[CharacterName].Time == 15)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 15 second(s)") elseif(FREELunch.Players[CharacterName].Time == 5)then SystemNotice(Roler,"FREE Lunch: "..FREELunch.Players[CharacterName].Name..", your remaining time to receive FREE Lunch reward is: 5 second(s)") end if(FREELunch.Players[CharacterName].Time <= 0)then if GetChaFreeBagGridNum(Roler) <= FREELunch.RewardsCount then GiveItemX (Roler,0, FREELunch.Rewards[Random].ID, FREELunch.Rewards[Random].QTY, 4 ) else GiveItem (Roler,0, FREELunch.Rewards[Random].ID, FREELunch.Rewards[Random].QTY, 4 ) end BickerNotice(Roler,"Congratulations! You win a "..FREELunch.Rewards[Random].QTY.."x of "..GetItemName(FREELunch.Rewards[Random].ID).."!") Notice("FREE Lunch: Congratulations to "..FREELunch.Players[CharacterName].Name.."! he/she has been online for "..FREELunch.Hours.." hour(s) and he/she received "..FREELunch.Rewards[Random].QTY.."x of "..GetItemName(FREELunch.Rewards[Random].ID).."!") FREELunch.Players[CharacterName] = nil end end Hook:AddPostHook("cha_timer", FuncFREELunch,1) Quote Share this post Link to post Share on other sites
Angelix 374 Report post Posted February 25 Just a few points: Just from seeing the script, I don't think that's the full script? Does this work across GameServers? I think it's ticking down 1 by 1, so a player has to stay connected in the same GameServer for 24 hours? If they move to another GameServer, maybe another timer starts if they change GS. I think this might be overloading "cha_timer" as well? Doing server loops on a function that gets called every second for every player is kinda bad. What's the problem? We don't know what's wrong if we don't know the problem. We can't help with "it messes up this function". Post the actual errors from console or logs (your logs are probably being spammed as well if it's causing errors within "cha_timer"). Quote Share this post Link to post Share on other sites
habs8024 2 Report post Posted February 25 3 hours ago, Angelix said: Just a few points: Just from seeing the script, I don't think that's the full script? Does this work across GameServers? I think it's ticking down 1 by 1, so a player has to stay connected in the same GameServer for 24 hours? If they move to another GameServer, maybe another timer starts if they change GS. I think this might be overloading "cha_timer" as well? Doing server loops on a function that gets called every second for every player is kinda bad. What's the problem? We don't know what's wrong if we don't know the problem. We can't help with "it messes up this function". Post the actual errors from console or logs (your logs are probably being spammed as well if it's causing errors within "cha_timer"). Hi Angelix, im not getting any gameserver console errors Also my gameserver log is filled with this, nothing else Quote [02-25 20:07:21]SaveMap End! [02-25 20:07:21]GameAppRun End! [02-25 20:07:21]PEEKPACKET End! [02-25 20:07:21]Loop End, RunTime[62]ms! [02-25 20:07:21]Loop Begin... [02-25 20:07:21]MgrUnitRun End! [02-25 20:07:21]GameItemRun End! [02-25 20:07:21]MapMgrRun End! [02-25 20:07:21]TimeSkillMgrRun End! [02-25 20:07:21]SaveMap End! [02-25 20:07:21]GameAppRun End! [02-25 20:07:21]PEEKPACKET End! [02-25 20:07:21]Loop End, RunTime[63]ms! [02-25 20:07:21]Loop Begin... [02-25 20:07:21]MgrUnitRun End! No, you're right there's also this script called "Start.lua" Quote --[[ FREE Lunch * Once it is activated, player will have his own time. ]]-- local PLUGIN_NAME = "FREE Lunch" local PLUGIN_AUTHOR = "Sultan" -- -------------------------- -- Display loading message on startup -- -------------------------- print(" >> Loading plugin "..PLUGIN_NAME.." from "..PLUGIN_AUTHOR) -- -------------------------- -- Load Balloon Event Variables -- -------------------------- dofile(GetResPath("script/extension/FREE Lunch/Variables.lua")) -- -------------------------- -- Load Balloon Event Ctrl -- -------------------------- dofile(GetResPath("script/extension/FREE Lunch/Ctrl.lua")) and Variables.Lua Quote print( " >> Loading FREE Lunch Variables" ) -- -------------------------- -- FREE Lunch Variables -- -------------------------- FREELunch = {} FREELunch.Rewards = {} -- -------------------------- -- FREE Lunch Init -- -------------------------- function FREELunch:Init() FREELunch.Players = {} FREELunch.Enable = false FREELunch.Hours = nil FREELunch.Announce = false FREELunch.SetUp = false end FREELunch:Init() -- -------------------------- -- FREE Lunch Rewards {Random Pick} -- -------------------------- FREELunch.Rewards[1] = { ID = 2729, QTY = 15 } -- Sand Bag Lv2 FREELunch.Rewards[2] = { ID = 849, QTY = 2 } -- Party EXP Fruit FREELunch.Rewards[3] = { ID = 2898, QTY = 3 } -- Christmas Dinner FREELunch.Rewards[4] = { ID = 2753, QTY = 5 } -- Sand Bag Lv3 FREELunch.Rewards[5] = { ID = 2312, QTY = 10 } -- Refining Gem Voucher FREELunch.Rewards[6] = { ID = 5845, QTY = 1 } -- Azrael's Glare FREELunch.Rewards[7] = { ID = 5846, QTY = 1 } -- Undead Azrael FREELunch.Rewards[8] = { ID = 5847, QTY = 1 } -- Azrael's Light FREELunch.Rewards[9] = { ID = 5848, QTY = 1 } -- Azrael's Aggregation FREELunch.Rewards[10] = { ID = 5849, QTY = 1 } -- Azrael's Dance FREELunch.RewardsCount = 10 -- (Last item num/total item number) Quote Share this post Link to post Share on other sites