Faller 93 Report post Posted November 12, 2016 (edited) Hey guys! I'd like to make a quick request, I want to make some giveaway events, which basically automatically gives rewards to every player online after determined time. I have tried 2 scripts from MEGA (I forgot the name of this folder now, but the one shared here). The scripts I've tried are the ones below: FREE Lunch System - It's a really nice script, very complete and stuff, but it have a few problems: some undefined strings (which could be easily fixed), if the player moves to another map, his timer resets, and it's not giving rewards to everyone online. Online Time Drop - It works, but have some problems: undefined script, causing server lags and not giving the rewards to every player online. Do you have any other scripts to share rather than these above? Thanks so much! ~Faller Edited November 12, 2016 by Faller Quote Share this post Link to post Share on other sites
MonkeyCode 453 Report post Posted November 12, 2016 11 hours ago, Faller said: FREE Lunch System - It's a really nice script, very complete and stuff, but it have a few problems: some undefined strings (which could be easily fixed), if the player moves to another map, his timer resets, and it's not giving rewards to everyone online. This is because each GameServer is allocated their own respective memory(s) (and so will luavm) I think the FREE Lunch System was designed to work on a single Gameserver. Better to ask @Sultan. 11 hours ago, Faller said: Online Time Drop - It works, but have some problems: undefined script, causing server lags and not giving the rewards to every player online. Post scripts, perhaps we can help debug. 1 Quote Share this post Link to post Share on other sites
Faller 93 Report post Posted November 12, 2016 (edited) 15 minutes ago, KONG said: This is because each GameServer is allocated their own respective memory(s) (and so will luavm) I think the FREE Lunch System was designed to work on a single Gameserver. Better to ask @Sultan. Post scripts, perhaps we can help debug. Hey KONG! Thanks for your reply So I'd need that patched gameserver to handle all the maps together? I wonder where I can obtain it Online Time Drop Scripts: FUNCTIONS: Spoiler #####Place this function inside cha_timer!##### -------------------------------------------------------------------- local TimeFreq = 3600 //Time in seconds. if math.mod(now_tick, TimeFreq) == 0 and now_tick > 0 then local item_type = BaoXiang_OOPD local item_type_rad = BaoXiang_OOPD_Rad local item_type_count = BaoXiang_OOPD_Count local maxitem = BaoXiang_OOPD_Mxcount -- ÖÕ½á±àºÅ local item_quality = BaoXiang_OOPD_Qua local General = 0 local ItemId = 0 local Item_CanGet = GetChaFreeBagGridNum ( role ) if Item_CanGet <= 0 then SystemNotice(role ,"Insufficient space in inventory. Unable to recieve prize.") UseItemFailed ( role ) return end for i = 1 , maxitem , 1 do General = item_type_rad [ i ] + General end local a = math.random ( 1, General ) local b = 0 local d = 0 local c = -1 --ÃüÖÐÎïÆ·±àºÅ for k = 1 , maxitem , 1 do -- Ëæ»ú³öÌí¼ÓµÄǰ׺±àºÅ d = item_type_rad [ k ] + b if a <= d and a > b then c = k break end b = d end if c == -1 then ItemId = 3124 else ItemId = item_type [c] ItemCount = item_type_count [c] end GiveItem ( role , 0 , ItemId , ItemCount , item_quality ) local itemname = GetItemName ( ItemId ) local cha_name = GetChaDefaultName ( role ) Notice ( "Congratulations Player " ..cha_name.." finds a "..itemname ) end VARIABLE: Spoiler Place anywhere in variable.lua When adding a new line change the line count which is = 9 // Example BaoXiang_OOPD [ 1 ] = ITEM_ID BaoXiang_OOPD_Rad [ 1 ] = 1 BaoXiang_OOPD_Count [ 1 ] = 1 \\ BaoXiang_OOPD_Qua = 9 BaoXiang_OOPD_Mxcount = 9 BaoXiang_OOPD = {} BaoXiang_OOPD_Rad = {} BaoXiang_OOPD_Count = {} BaoXiang_OOPD [ 1 ] = 237 BaoXiang_OOPD_Rad [ 1 ] = 1 BaoXiang_OOPD_Count [ 1 ] = 1 BaoXiang_OOPD [ 2 ] = 851 BaoXiang_OOPD_Rad [ 2 ] = 1 BaoXiang_OOPD_Count [ 2 ] = 1 BaoXiang_OOPD [ 3 ] = 852 BaoXiang_OOPD_Rad [ 3 ] = 1 BaoXiang_OOPD_Count [ 3 ] = 1 BaoXiang_OOPD [ 4 ] = 893 BaoXiang_OOPD_Rad [ 4 ] = 1 BaoXiang_OOPD_Count [ 4 ] = 1 BaoXiang_OOPD [ 5 ] = 894 BaoXiang_OOPD_Rad [ 5 ] = 1 BaoXiang_OOPD_Count [ 5 ] = 1 BaoXiang_OOPD [ 6 ] = 895 BaoXiang_OOPD_Rad [ 6 ] = 1 BaoXiang_OOPD_Count [ 6 ] = 1 BaoXiang_OOPD [ 7 ] = 896 BaoXiang_OOPD_Rad [ 7 ] = 1 BaoXiang_OOPD_Count [ 7 ] = 1 BaoXiang_OOPD [ 8 ] = 897 BaoXiang_OOPD_Rad [ 8 ] = 1 BaoXiang_OOPD_Count [ 8 ] = 1 BaoXiang_OOPD [ 9 ] = 1078 BaoXiang_OOPD_Rad [ 9 ] = 1 BaoXiang_OOPD_Count [ 9 ] = 1 #EDITTTTT I messed it up! I tried "Online Event" and not the one I posted above, so this one may be working as well, but take a look at it's script if you can The one I tried is this one: Spoiler What is it? Okay let me explain, The online event system is the same as TOP event that you should be online for certain time to obtain an prize, check http://top2.igg.com/event/freelunch/ for more information, its similar to this one. In this script you no need to restart your server to activate it, you can use command to activate or deactivate it anytime you want! How should it work? Player must be level 75+ and be online for 24 hours (Defaulted time) without being logged out. You can reduce the time, edit the prize in script below. Okay let's add it now! 1st: Open your functions.lua and add this into cha_timer -- Set Hours, Default is 24 hours means 1 day local SetHours = 24 local Level = GetChaAttr( role , ATTR_LV ) if OnlineEvent == true and math.mod(now_tick, SetHours*3600) == 0 and now_tick > 0 and Level > 75 then local Prize = {} -- Put the Item ID Prize[1] = 192 -- Chest of Kylin Prize[2] = 2843 -- Rightful Chest of Black Dragon Prize[3] = 2842 -- Carcass of Death -- Getting in Random local i = math.random (1,3) -- Add Prize local cha = TurnToCha (role) local ItemName = GetItemName (Prize) GiveItem ( cha , 0 , Prize , 1 , 4 ) -- Send notice to Player SystemNotice(cha,"Congratulations! You have been online for "..SetHours.." hours long and you've been awarded a "..ItemName.."! #10") end 2nd: Open your variable.lua and add this into the end OnlineEvent = false Okay now how to use them! To start activating the Event &lua_all OnlineEvent = true -- To stop activating the Event &lua_all OnlineEvent = false 100% tested and working enjoy it and don't forget to press Like This if you like Thanks!! ~Faller Edited November 12, 2016 by Faller Quote Share this post Link to post Share on other sites
Shako 97 Report post Posted November 12, 2016 (edited) @Faller I advise to put these into KONG's Player_Timer instead. for the errors, you must post us the lua_err related to this script. Edited November 12, 2016 by Shako 1 Quote Sunny Go! Online pko.host Share this post Link to post Share on other sites
Faller 93 Report post Posted November 12, 2016 Just now, Shako said: @Faller I advise to put these into KONG's Player_Timer instead. for the errors, you must post us the lua_err related to this script. Could you share KONG's script? And is it better than Cha_Timer? Would you recommended me changing all my cha_timer hooks for that one? Thanks! Quote Share this post Link to post Share on other sites
Shako 97 Report post Posted November 12, 2016 @Faller On 6/15/2016 at 6:10 AM, KONG said: as promised. Put into resource/scripts folder, and extract there. I will not upload full files, because It is not safe to upload full files, All things that I edited are transparent and are within the scope of the folder. Also, I use lucky's base, the only file that was touched was NpcScript08.lua, where i added: dofile(GetResPath("script\\extension\\index.lua")) some stuff are missing/not optimized... so will add them when I have time. A DLL for some server binary correction will be added soon too. If bugs are found, please report and know that they are not intentional. script.rar 1 Quote Sunny Go! Online pko.host Share this post Link to post Share on other sites
Shako 97 Report post Posted November 12, 2016 3 minutes ago, Faller said: And is it better than Cha_Timer? Would you recommended me changing all my cha_timer hooks for that one? It would help save gameserver memory. 1 Quote Sunny Go! Online pko.host Share this post Link to post Share on other sites
Faller 93 Report post Posted November 12, 2016 (edited) @Shako So basically it's just extract these files into my scripts folder? Any other changes I should apply? Thanks! I'm really in need of something to optimize my cha_timer, I have too many hooks into it, it's causing me some perfomance issues... Edited November 12, 2016 by Faller Quote Share this post Link to post Share on other sites
Shako 97 Report post Posted November 12, 2016 4 hours ago, Faller said: @Shako So basically it's just extract these files into my scripts folder? Any other changes I should apply? Thanks! I'm really in need of something to optimize my cha_timer, I have too many hooks into it, it's causing me some perfomance issues... I could help you through teamviewer later, if you don't know how to work with these files. But, I didn't load them as an extension, I selected a few and integrated them into my own scripts. 1 Quote Sunny Go! Online pko.host Share this post Link to post Share on other sites
Faller 93 Report post Posted November 12, 2016 Just now, Shako said: I could help you through teamviewer later, if you don't know how to work with these files. But, I didn't load them as an extension, I selected a few and integrated them into my own scripts. Alright, we can give it a try Thanks for all your attention, Shako! This thread is closed, the problem was solved. Quote Share this post Link to post Share on other sites
Faller 93 Report post Posted November 12, 2016 Sorry for double post! but... I thought it was working properely, but nop. I configurated it to give rewards every 3600 seconds, but it's giving at random times, and sometimes 3 at once. Also, it's not giving the reward to everyone online, any tips on this? I'm using the "Online Time Drop" scripts I posted above. Really in a hurry for this, so if any1 helps, I'll be so thankful! Quote Share this post Link to post Share on other sites
Angelix 376 Report post Posted November 12, 2016 Why not try this? if VarEvent == true if VarPlayer[Name].OnlineTime == nil then VarPlayer[Name].OnlineTime = 0 elseif VarPlayer[Name].OnlineTime == 300 then -- Give Item VarPlayer[Name].OnlineTime = 0 else VarPlayer[Name].Online = VarPlayer[Name].Online + 1 end end Something I just came up with if you just wanted help. Now if you want something you can use, then try this script. OnlineEvent = {} OnlineEvent.Items = {} OnlineEvent.Players = {} OnlineEvent.Active = false -- Whether event is active or not. OnlineEvent.Time = 60 -- In seconds. OnlineEvent.Items[1] = {ID = 0, Quantity = 0} OnlineEvent.Items[2] = {ID = 0, Quantity = 0} -- This should go into cha_timer function. local Name = GetChaDefaultName(Player) if OnlineEvent.Active == true then if OnlineEvent.Players[Name] == nil then OnlineEvent.Players[Name] = 0 elseif OnlineEvent.Players[Name] == OnlineEvent.Time then local Random = math.random(1, table.getn(OnlineEvent.Items)) GiveItem(Player, 0, OnlineEvent.Items[Random].ID, OnlineEvent.Items[Random].Quantity, 4) OnlineEvent.Players[Name] = 0 else OnlineEvent.Players[Name] = OnlineEvent.Players[Name] + 1 end end 1 Quote Share this post Link to post Share on other sites
Faller 93 Report post Posted November 13, 2016 Hey @Angelix! Thanks so much I ended up making my own script, I'm currently testing it, seems to be working fine. If I have any problems with mine, I'll give a try to yours, thanks alot! ~Faller 1 Quote Share this post Link to post Share on other sites
Sultan 68 Report post Posted November 15, 2016 Actually the best way to do Online giveaway is to store time value inside an attribute(ATTR) of an item. For example (In a table way): -----EXAMPLE TABLE TIME STORING------- local id = GetCharID(role); if(hourglass[id] == nil)then hourglass[id] = os.time() + 3600; -- Duration 1 hour else --if already stored local check = hourglass[id] - os.time() if(check > 0)then BickerNotice(role,'It is not yet time! ['..check..' seconds] remaining... Try again later!'); return; end end P/S: I've tried using TXT-database storing for multiple gameserver BUT the most convenient way I found to store values is within items. However, I found no idea how to store "os.time()" because the numbers were too long and lost interest. You can try converting the example script with TXT-database and will still work but it isn't my way... Anyways, I've given you my tips. You might find a better solution than mine! 2 Quote Share this post Link to post Share on other sites
Faller 93 Report post Posted November 15, 2016 @Sultan Thanks for the tip! I've build my own script using others and mixing them together, it seems to be working fine The only problem that still persists, is that, it doesn't give rewards to ALL players online, but it gives to most, atleast. Anyways, thanks again! 1 Quote Share this post Link to post Share on other sites
Angelix 376 Report post Posted November 16, 2016 2 hours ago, Faller said: @Sultan Thanks for the tip! I've build my own script using others and mixing them together, it seems to be working fine The only problem that still persists, is that, it doesn't give rewards to ALL players online, but it gives to most, atleast. Anyways, thanks again! Might be related to them switching GameServer (going from Map A in GS A to Map B in GS B), the variables start again. My scripts should work, just that flaw. The idea with the item seems nice, just that they'll have an item in their inventory at all times and switching GS won't affect them. Quote Share this post Link to post Share on other sites
Sultan 68 Report post Posted November 18, 2016 Best solution would be save record TXT for winners and let players REDEEM their rewards through NPC. Good luck Quote Share this post Link to post Share on other sites
Rinor 59 Report post Posted November 18, 2016 29 minutes ago, Sultan said: Best solution would be save record TXT for winners and let players REDEEM their rewards through NPC. I think thats a good idea. @Faller if you want try that check spko files Achievement folder it may can help you Quote Share this post Link to post Share on other sites