Jump to content

Search the Community

Showing results for tags 'reward'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Russian Section
    • Новости и объявления
    • Пиратия: Документация
    • Пиратия: Релизы
    • Пиратия: Разработка
    • Пиратия: Web
    • Пиратия: Помощь
    • Совместные проекты / набор команды
    • Доска объявлений
    • Программирование
    • Оффтопик
    • Корзина
  • English Section
    • News & Announcements
    • Guides
    • Releases
    • Development
    • Web
    • Questions & Help
    • Shared Projects / Team search
    • Paid services & Requests
    • Programming
    • Offtopic
    • Recycle bin
  • Portuguese Section
    • Dúvidas & Ajuda
  • Spanish Section
    • Preguntas y Ayuda
  • Servers
    • Russian servers
    • English servers

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 2 results

  1. [Mod] System of daily rewards for entering the game This mod implements a system of daily rewards for entering the game. Players need to enter the game every day in order to receive the next reward - with each new day the reward becomes more valuable. The chain resets and starts over from the first day if a player misses a day. The chain is also reset every week. The chain of rewards is configured by the administrator in a special lua function and is generated for a week forward, after which it is saved in the server database. Requirements Installed mod loading system for server and client (PKOdev.NET mod loader). Modification information Name: pkodev.mod.reward; Version: 1.0; Author: V3ct0r; Type: for client and server (Game.exe and GameServer.exe); Supported executable .exe files: GAME_13X_0, GAME_13X_1, GAME_13X_2, GAME_13X_3, GAME_13X_4, GAME_13X_5, GAMESERVER_136 and GAMESERVER_138. Installation Server: 1) In the "GameServer\mods" directory of your server, create a "pkodev.mod.reward" folder; 2) Place into the folder the mod DLL file "pkodev.mod.reward.server.13<x>.dll" for your version of GameServer.exe; 3) In the functions.lua file ("GameServer\resource\script\calculate\") write the following script: -- Daily reward system (pkodev.mod.reward) -- Transfer the list of items to the system function GetRewardArrayAdapter(role) -- Get a list of items for daily reward local arr = GetRewardArray(role) -- Transfer the list to the system return arr[1].id, arr[1].number, arr[2].id, arr[2].number, arr[3].id, arr[3].number, arr[4].id, arr[4].number, arr[5].id, arr[5].number, arr[6].id, arr[6].number, arr[7].id, arr[7].number end -- Daily reward system (pkodev.mod.reward) -- Get a list of items for daily reward function GetRewardArray(role) -- Select an item depending on character race local hairstyle_book = function(role) -- List of items -- ID: 931 Lance Trendy Hairstyle Book -- ID: 932 Carsise Trendy Hairstyle Book -- ID: 933 Phyllis Trendy Hairstyle Book -- ID: 934 Ami Trendy Hairstyle Book local items = {931, 932, 933, 934} -- Get character type ID local id = GetChaTypeID(role) -- Return item id depending on the type ID return items[id] or 0 end -- Make a list of items for daily reward local items = { -- Day 1 (Short Sword x 1 or Long Sword x 1 or Fencing Sword x 1) {id = math.random(1, 3), number = 1}, -- Day 2 (Apple x 99 or Bread x 99 or Cake x 99) {id = math.random(1847, 1849), number = 99}, -- Day 3 (Fairy Coin x 50) {id = 855, number = 50}, -- Day 4 (Random fairy ID 183 ... 193 x 1) {id = math.random(183, 193), number = 1}, -- Day 5 (Hairstyle Book x 1) {id = hairstyle_book(role), number = 1}, -- Day 6 (Fairy Ration x 10) {id = 227, number = 10}, -- Day 7 (Refining Gem x 1) {id = 885, number = 1} } -- We have to return an array of items to caller function return items end 4) In MSSQL Management Studio, execute the SQL query: USE GameDB ALTER TABLE character ADD reward VARCHAR(128) NOT NULL DEFAULT '0' WITH VALUES Client: 1) In the "mods" directory of your client create a "pkodev.mod.reward" folder; 2) Place into the folder the mod DLL file "pkodev.mod.reward.client.13x_<x>.dll" for your version of Game.exe; 3) Place the daily reward form texture files "main.png" and "buttons.tga" into the "texture\mods\pkodev.mod.reward\" directory of your client; 4) Add the code for the daily reward form into the "main.clu" script file ("scripts\lua\forms\"): ---------------------------------------------------------------------------------------------------- -- Daily login reward form ---------------------------------------------------------------------------------------------------- -- The form frmReward = UI_CreateForm( "frmReward", FALSE, 366, 158, 150, 200, TRUE, FALSE ) UI_SetFormStyle( frmReward , 0 ) UI_AddFormToTemplete( frmReward, FORM_MAIN ) UI_FormSetIsEscClose( frmReward, FALSE ) UI_SetIsDrag( frmReward, TRUE ) -- Form background frmRewardImg = UI_CreateCompent( frmReward, IMAGE_TYPE, "frmRewardImg", 366, 158, 0, 0 ) UI_LoadImage( frmRewardImg, "texture/mods/pkodev.mod.reward/main.png", NORMAL, 366, 158, 0, 0 ) -- Form title labTitle = UI_CreateCompent( frmReward, LABELEX_TYPE, "labTitle", 400, 150, 10, 7 ) UI_SetCaption( labTitle, "Daily reward!") UI_SetTextColor( labTitle, COLOR_WHITE ) -- Reward button btnGetReward = UI_CreateCompent( frmReward, BUTTON_TYPE, "btnGetReward", 67, 24, 150, 120 ) UI_LoadButtonImage( btnGetReward, "texture/mods/pkodev.mod.reward/main.png", 67, 24, 0, 158, TRUE ) -- Close button btnClose = UI_CreateCompent( frmReward, BUTTON_TYPE, "btnClose", 21, 21, 343, 2 ) UI_LoadButtonImage( btnClose, "texture/mods/pkodev.mod.reward/buttons.tga", 21, 21, 270, 0, TRUE ) UI_SetButtonModalResult( btnClose, BUTTON_CLOSE ) -- Item slots cmdItemSlot0 = UI_CreateCompent( frmReward, COMMAND_ONE_TYPE, "cmdItemSlot0", 32, 32, 20, 73 ) UI_SetIsDrag( cmdItemSlot0, FALSE ) cmdItemSlot1 = UI_CreateCompent( frmReward, COMMAND_ONE_TYPE, "cmdItemSlot1", 32, 32, 69, 73 ) UI_SetIsDrag( cmdItemSlot1, FALSE ) cmdItemSlot2 = UI_CreateCompent( frmReward, COMMAND_ONE_TYPE, "cmdItemSlot2", 32, 32, 118, 73 ) UI_SetIsDrag( cmdItemSlot2, FALSE ) cmdItemSlot3 = UI_CreateCompent( frmReward, COMMAND_ONE_TYPE, "cmdItemSlot3", 32, 32, 167, 73 ) UI_SetIsDrag( cmdItemSlot3, FALSE ) cmdItemSlot4 = UI_CreateCompent( frmReward, COMMAND_ONE_TYPE, "cmdItemSlot4", 32, 32, 216, 73 ) UI_SetIsDrag( cmdItemSlot4, FALSE ) cmdItemSlot5 = UI_CreateCompent( frmReward, COMMAND_ONE_TYPE, "cmdItemSlot5", 32, 32, 265, 73 ) UI_SetIsDrag( cmdItemSlot5, FALSE ) cmdItemSlot6 = UI_CreateCompent( frmReward, COMMAND_ONE_TYPE, "cmdItemSlot6", 32, 32, 314, 73 ) UI_SetIsDrag( cmdItemSlot6, FALSE ) ---------------------------------------------------------------------------------------------------- Mod customization 1) In the GetRewardArray(role) function, write the code that will generate the chain of rewards for the character role for the next seven days. The function must return a table of 7 elements with fields id and number, where id is the ID of the item that is issued as a reward, and number is the number of items in the reward. Each element corresponds to its own day (1st element is the first day, 2nd element is the second day, and so on). Example: function GetRewardArray(role) local items = { -- Day 1: Apple x 20 {id = 1847, number = 20}, -- Day 2: Bread x 40 {id = 1848, number = 40}, -- Day 3: Cake x 60 {id = 1849, number = 60}, -- Day 4: Fairy coin x 55 {id = 855, number = 55}, -- Day 5: Fairy ration x 15 {id = 227, number = 15}, -- Day 6: Bread x 99 {id = 1848, number = 99}, -- Day 7: Cake x 99 {id = 1849, number = 99} } return items end Item IDs and their number can be generated randomly or depending on the character's race, profession, etc 2) By default, the reward period is 24 hours. You can change this value in the mod server-side source code (pkodev.mod.reward.server project, structure.h file), then compile the project: // Reward interval in seconds static const unsigned int interval{ 24 * 60 * 60 }; // 24 hours 3) No client side configuration required. Old style GUI (Thanks to @Masuka00!) main.clu: -- Close button btnClose = UI_CreateCompent( frmReward, BUTTON_TYPE, "btnClose", 14, 14, 342, 4 ) UI_LoadButtonImage( btnClose, "texture/mods/pkodev.mod.reward/main.png", 14, 14, 271, 174, TRUE ) UI_SetButtonModalResult( btnClose, BUTTON_CLOSE ) Download Download 1) Binary release (.dll); 2) The source code of the mod for Visual Studio 2019 Community (C++). If you encounter any problem, bug or have any questions, then feel free to write in this thread.
  2. Scheduled player reward system With the help of this system, it is possible to give out to all players on the server at a certain time the reward (gift) specified in the schedule: all players who are currently online will receive an item. How to install 1) Create a file named "pkodev.gift.lua" in folder "GameServer\resource\script\calculate\mods"; 2) Put the following code to the file: -------------------------------------------------------------- -- Gift system script -- -- Author: V3ct0r from PKODev.NET -- Version: 1.0 (11/08/2021) -- -- How to install the system: -- 1) Put this file to '\GameServer\resource\script\calculate\mods' folder -- 2) Put the following line at the beginning of 'mlist.lua' file: -- dofile(GetResPath("script\\calculate\\mods\\pkodev.gift.lua")) -- 3) Done! -- -- Interface: -- 1) Add a gift to queue: -- local gift_id = giftmod:addGift(item_id, number, hour, minute, second, month, day, year) -- 2) Remove a gift from queue -- local success = giftmod:removeGift(gift_id) -- Where 'success' can be 'true' or 'false' -- 3) Get gift number in queue -- local number = giftmod:getGiftNumber() -- 4) Print a list of queued gifts in GameServer window: -- giftmod:printGifts() -- -- These commands also can be used with &lua_all GM-command, for example: -- &lua_all giftmod:addGift(item_id, number, hour, minute, second, month, day, year) -- Note: After GameServer.exe restart gifts. which were added using GM-command, will be removed -------------------------------------------------------------- -- Update guard if (PKODEV_GIFT_GUARD ~= nil) then -- Exit the script return end -- Define update guard PKODEV_GIFT_GUARD = true -- Print a log print("Loading pkodev.gift.lua") -- Class Gift Gift = {} -- Make a Gift function Gift:new(id, item_id, count, gift_time) -- Private fields local private = { id = id or -1, item_id = item_id or -1, count = count or 0, gift_time = gift_time or 0, is_given = false } -- Public fields local public = { } -- Get an gift ID function public:getId() return private.id end -- Get an item id function public:getItemId() return private.item_id end -- Get an item count function public:getItemCount() return private.count end -- Get a time at which to give the gift function public:getTime() return private.gift_time end setmetatable(public, self) self.__index = self; return public end -- Class GiftSystem GiftSystem = {} -- Make a Gift system function GiftSystem:new() -- Private fields local private = { -- List of gifts to give gifts = { }, -- List of active players players = { }, -- Timer function timer_func = nil, -- List of hooks hooks = { } } -- Public fields local public = { } -- Player entered a map event function private:on_player_entered_map(role, mapdesc, map) -- Check that map exists in the list if ( private.hooks[map] ~= nil ) then -- Check that enter function is hooked if ( private.hooks[map].enter ~= nil ) then -- Call original function private.hooks[map].enter(role, mapdesc) end end -- Add player to the list private.players[ GetRoleID(role) ] = role end -- Player leaved a map event function private:on_player_leaved_map(role, map) -- Check that map exists in the list if ( private.hooks[map] ~= nil ) then -- Check that leave function is hooked if ( private.hooks[map].leave ~= nil ) then -- Call original function private.hooks[map].leave(role) end end -- Remove player from the list private.players[ GetRoleID(role) ] = nil end -- Timer event function private:on_timer_event(map) -- Check that timer function is hooked if ( private.timer_func ~= nil ) then -- Call original function private.timer_func(map) end -- Get current system time local t = os.time() -- Update gifts for i = table.getn(private.gifts), 1, -1 do -- Get a gift local gift = private.gifts[i] -- Check that it's time to give out the gift if ( t >= gift:getTime() ) then -- Give the gift to players for cha_id, role in pairs(private.players) do GiveItem(role, 0, gift:getItemId(), gift:getItemCount(), 4) end -- Remove the gift from the list table.remove(private.gifts, i) end end end -- Set hooks function private:setHook() -- Search for 'after_enter_', 'before_leave_' and timer functions for key, value in pairs(_G) do -- Get a global item name in lower case local name = string.lower(key) -- Player entered a map if ( string.find(name, "after_enter_") == 1 ) then -- Get map name local map = string.sub(name, string.len("after_enter_") + 1) -- Add map to the list private.hooks[map] = private.hooks[map] or {} -- Associate original enter function address with map name private.hooks[map].enter = value -- Set the hook _G[key] = function(role, mapdesc) private:on_player_entered_map(role, mapdesc, map) end end -- Player leaved a map if ( string.find(name, "before_leave_") == 1 ) then -- Get map name local map = string.sub(name, string.len("before_leave_") + 1) -- Add map to the list private.hooks[map] = private.hooks[map] or {} -- Associate original leave function address with map name private.hooks[map].leave = value -- Set the hook _G[key] = function(role) private:on_player_leaved_map(role, map) end end -- Timer if ( private.timer_func == nil ) then -- Search for timer function if ( string.find(name, "map_copy_run_") == 1 ) then -- Number of underscore characters local n = 0 -- Count the number of underscore characters string.gsub(name, ".", function(c) if ( c == '_' ) then n = n + 1 end end) -- Number of underscore characters should be equal to 3 if (n == 3) then -- Set timer function private.timer_func = value -- Set the hook _G[key] = function(map) private:on_timer_event(map) end end end end end -- Check that timer hook is enabled if ( private.timer_func == nil ) then print("pkodev.gift: Warning, suitable timer function is not found!") end end -- Add a gift to the list function public:addGift(item_id, count, h, m, s, mon, day, year) -- Check item ID if ( string.lower(GetItemName(item_id)) == "unknown" ) then -- Do not add a gift return -1 end -- Check item count if (count <= 0) then -- Do not add a gift return -1 end -- Get item timestamp local gift_timestamp = os.time{ month = mon, day = day, year = year, hour = h, min = m, sec = s } -- Check that item time is not expired if ( gift_timestamp <= os.time() ) then -- Do not add a gift return -1 end -- Get an ID for new gift local gift_id = public:getGiftNumber() -- Create a gift local gift = Gift:new(gift_id, item_id, count, gift_timestamp) -- Add a gift to the list table.insert(private.gifts, gift) -- Return gift ID return gift_id end -- Remove a gift by ID function public:removeGift(gift_id) -- Find a gift in the list for index, gift in pairs(private.gifts) do -- Check gift ID if ( gift_id == gift:getId() ) then -- Remove the gift from the list table.remove(private.gifts, index) -- Gift removed return true end end -- Gift not found return false end -- Get gift number function public:getGiftNumber() return table.getn(private.gifts) end -- Print a list of gifts function public:printGifts() -- Get gift number local n = public:getGiftNumber() -- Check that there are gifts in the list if (n > 0) then -- Print all gifts for index, gift in pairs(private.gifts) do -- Get time data local temp = os.date("*t", gift:getTime()) -- Print a gift print( string.format( "pkodev.gift: %d) [Gift ID: %d] - %s x %d at %02d:%02d:%02d %02d/%02d/%02d", index, gift:getId(), GetItemName(gift:getItemId()), gift:getItemCount(), temp.hour, temp.min, temp.sec, temp.month, temp.day, temp.year ) ) end else -- No gifts print("There are no active gifts!") end end -- Enable the necessary hooks for the gift system to work private:setHook() setmetatable(public, self) self.__index = self; return public end -- Create an instance of the gift system giftmod = GiftSystem:new() -- Add gifts to the queue giftmod:addGift(863, 1, 16, 6, 30, 11, 9, 2022) -- 'Gem of Rage' x 1 at 16:06:30 11/09/2022 giftmod:addGift(684, 1, 16, 7, 25, 11, 15, 2022) -- 'New Sheepskin Scroll' x 1 at 16:07:25 15/09/2022 giftmod:addGift(1849, 99, 12, 7, 0, 11, 18, 2022) -- 'Cake' x 99 at 12:07:00 18/09/2022 -- Print queued gifts giftmod:printGifts() 3) Open file "GameServer\resource\script\monster\mlist.lua" and put at the beginning the line: 4) Start GameServer.exe. You should see in it's console window the following lines: pkodev.gift: 1) [Gift ID: 0] - Gem of Rage x 1 at 16:06:30 11/09/2022 pkodev.gift: 2) [Gift ID: 1] - New Sheepskin Scroll x 1 at 16:07:25 11/15/2022 pkodev.gift: 3) [Gift ID: 2] - Cake x 99 at 12:07:00 11/18/2022 5) Configure the system at your discretion (see the "How to use" section below); 6) The installation process is complete. How to use 1) You can define a queue of gifts at the end of "pkodev.gift.lua" file using giftmod:addGift() command: local gift_id = giftmod:addGift(item_id, number, hour, minute, second, month, day, year) Also you can add a gift to the queue using GM-command*: &lua_all giftmod:addGift(item_id, number, hour, minute, second, month, day, year) *Note: After GameServer.exe restart gifts. which were added using GM-command, will be removed. 2) You can remove pending gifts from the queue using giftmod:removeGift() command: local success = giftmod:removeGift(gift_id) -- Where 'success' can be 'true' or 'false' Where variable gift_id is ID of pending gift which was returned from giftmod:addGift() command. 3) You can get an amount of pending gifts using giftmod:getGiftNumber() command: local number = giftmod:getGiftNumber() 4) Finally, you can display pending gifts in the GameServer.exe window: giftmod:printGifts() That's all! Download the script of the system (3 KB)
×
×
  • Create New...