Jump to content

Search the Community

Showing results for tags 'script'.



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
  • 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 14 results

  1. [Mod] Contract system This system is a "Monster Hunt" type quest, the purpose of which is to kill a certain number of specific monsters. The player is given a special item - "Contract", which says which monster to hunt. It also records the number of monsters and current progress. After killing the required number of monsters, the contract is considered completed, and the player receives a reward. Some specifics of the system: 1) The item type for the contract should be 99. A unique ID is also selected for the item; 2) The contract can be picked up, thrown away, transferred to another player, put in the bank or sold; 3) To receive a reward after the completion of the contract, a player should use the item of the contract by double-clicking. If the contract has not been completed, the player will see a corresponding message in the system chat; 4) The composition and amount of the reward is determined by the administrator in a special function in the script of the contract system; 5) If a player has several contracts for killing the same monster in his inventory, then when killing this monster, one or another contract is selected randomly. Installation All necessary files and scripts can be downloaded at the end of the topic. Server 1) Add an item for the contract to the ItemInfo.txt file: XXXX Contract n0184 10130005 0 0 0 0 0 00 99 0 0 0 0 0 1 1 1 1 1 1 0 -1 0 -1 0 0 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0 10,10 0,0 0 0 0 0 0 0 0 0 0 ItemUse_PKOdevContract 0 0 0 0 0 0 After completion you will receive a reward! where XXXX is any unused ID. 2) Create a file with name "pkodev.contract.lua" in the directory "GameServer\resource\script\calculate\mods"; 3) Write the following code in this file: -------------------------------------------------------------- -- The contract system script -- -- Author: V3ct0r from PKOdev.NET -- Version: 1.0 (01/12/2022) -- -- 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 'SkillEffect.lua' file: -- dofile(GetResPath("script\\calculate\\mods\\pkodev.contract.lua")) -- 3) Add the contract item in the ItemInfo.txt file -- XXXX Contract n0184 10130005 0 0 0 0 0 00 99 0 0 0 0 0 1 1 1 1 1 1 0 -1 0 -1 0 0 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0 10,10 0,0 0 0 0 0 0 0 0 0 0 ItemUse_PKOdevContract 0 0 0 0 0 0 Upon completion, you are entitled to a reward -- 4) Specify the item ID in 'contract.conf.item_id' table below: -- item_id = XXXX -- 5) Write the code for issuing a reward for completing a contract in the 'contract.conf.reward_cb' function -- 6) To create a new contract use the function 'contract.create': -- local <result (0 or 1)>, <item_descriptor>, <slot (from 0 to bag_size - 1)> -- = contract.create(<character_descriptor>, <monster_id>, <monster_number>) -- For example: -- local ret, item, slot = contract.create(role, 103, 7) -- 7) Done! -------------------------------------------------------------- -- Print a log print("Loading pkodev.contract.lua") -- The contract system contract = contract or {} --------------------------------------- -- Settings --------------------------------------- contract.conf = { -- Contract item ID item_id = XXXX, -- User-defined function for reward reward_cb = function(role, item) -- Give 1,000 gold AddMoney (role, 0, 1000) -- Give an random item local arr = { -- Refining Gem x 1 {id = 885, count = 1}, -- or Gem of Rage x 2 {id = 863, count = 2}, -- or Cake x 60 {id = 1849, count = 60}, -- or Fairy of Luck x 1 {id = 231, count = 1} } local r = math.random(1, table.getn(arr)) GiveItem(role, 0, arr[r].id , arr[r].count, 4) -- Launch fireworks PlayEffect(role, 361) end } --------------------------------------- -- Constants --------------------------------------- contract.const = { item_type = 99, -- Contract item type target_id = ITEMATTR_VAL_STR, -- Item attribute ID with the ID of target monster target_max = ITEMATTR_VAL_AGI, -- Item attribute ID with the total amount of monsters to hunt target_cur = ITEMATTR_VAL_DEX -- Item attribute ID with the total amount of monsters already hunted } --------------------------------------- -- Hooks --------------------------------------- -- Adding an item to inventory event contract.Creat_Item__original = Creat_Item Creat_Item = function(item, item_type, item_lv, item_event) -- Check the item type if ( item_type == contract.const['item_type'] ) then -- Reset the previous attrbiutes Reset_item_add() -- Add new attributes to the item Add_Item_Attr(contract.const['target_id'], 0) Add_Item_Attr(contract.const['target_max'], 0) Add_Item_Attr(contract.const['target_cur'], 0) return item_add.cnt, item_add.attr[1][1], item_add.attr[1][2], item_add.attr[2][1], item_add.attr[2][2], item_add.attr[3][1], item_add.attr[3][2], item_add.attr[4][1], item_add.attr[4][2], item_add.attr[5][1], item_add.attr[5][2], item_add.attr[6][1], item_add.attr[6][2], item_add.attr[7][1], item_add.attr[7][2] end -- Call the original function Creat_Item(item, item_type, item_lv, item_event) return contract.Creat_Item__original(item, item_type, item_lv, item_event) end -- Player killed monster event contract.GetExp_PKM__original = GetExp_PKM GetExp_PKM = function(monster, role) -- Call the original function GetExp_PKM(dead, atk) contract.GetExp_PKM__original(monster, role) -- Get the main character's descriptor role = TurnToCha(role) -- Number of contracts in the player's bag local ret = CheckBagItem(role, contract.conf['item_id']) -- Check that player has contracts if ( ret > 0 ) then -- Monster ID local id = GetChaTypeID(monster) -- List of contracts in the bag local arr = {} local k = 0 -- Build the list of contracts for i = 0, ( GetKbCap(role) - 1 ), 1 do -- Get the item descriptor local item = GetChaItem(role, 2, i) -- Check the item ID if ( GetItemID(item) == contract.conf['item_id'] ) then -- Get the monster ID from contract local target_id = GetItemAttr(item, contract.const['target_id']) -- Check the monster ID if ( id == target_id ) then -- Get amount of monsters to hunt local target_cur = GetItemAttr(item, contract.const['target_cur']) local target_max = GetItemAttr(item, contract.const['target_max']) -- Check that the contract is not completed if ( target_cur < target_max ) then -- Add the item to the list k = k + 1 arr[k] = { item_ = item, cur_ = target_cur, max_ = target_max } end end end end -- Check that matching contracts have been found if ( k > 0 ) then -- Randomly select a contract local r = math.random(1, k) -- Increase the number of hunted monsters arr[r].cur_ = arr[r].cur_ + 1 -- Update amount of hunted monsters SetItemAttr(arr[r].item_, contract.const['target_cur'], arr[r].cur_) -- Synchronize the bag SynChaKitbag(role, 13) -- Check that the contract is not completed if ( arr[r].cur_ < arr[r].max_ ) then -- Write a message BickerNotice( role, string.format( "Contract: Remaining '%s' to hunt: %d / %d!", GetMonsterName(id), arr[r].cur_, arr[r].max_ ) ) else -- Write a message BickerNotice( role, string.format( "Contract: All '%s' are killed! The contract is completed.", GetMonsterName(id) ) ) end end end end --------------------------------------- -- Useful functions --------------------------------------- -- Create a contract contract.create = function(role, target_id, number) -- Get the main character's descriptor role = TurnToCha(role) -- Check that the bag is not locked if ( KitbagLock(role, 0) == LUA_FALSE ) then -- Error LG("pkodev.contract", "Can't create the contract item (id:", contract.conf['item_id'], ") because the bag is locked!") return LUA_FALSE, nil, 0 end -- Check that the bag has one free slot if ( GetChaFreeBagGridNum(role) == 0 ) then -- Error LG("pkodev.contract", "Can't create the contract item (id:", contract.conf['item_id'], ") because there are no free slots in the bag!") return LUA_FALSE, nil, 0 end -- Create an item local r1, r2 = MakeItem(role, contract.conf['item_id'], 1, 4) -- Check the result if ( r1 == 0 ) then -- Error LG("pkodev.contract", "Can't create the contract item (id:", contract.conf['item_id'], ")!") return LUA_FALSE, nil, 0 end -- Get the item descriptor local item = GetChaItem(role, 2, r2) -- Set contract data local a1 = SetItemAttr(item, contract.const['target_id'], target_id) local a2 = SetItemAttr(item, contract.const['target_max'], number) local a3 = SetItemAttr(item, contract.const['target_cur'], 0) -- Check that the data is set if ( (a1 == 0) or (a2 == 0) or (a3 == 0) ) then -- Error LG("pkodev.contract", "Can't set the contract data! a1 = ", a1, ", a2 = ", a2, ", a3 = ", a3) return LUA_FALSE, item, r2 end -- Synchronize the kitbag SynChaKitbag(role, 13) -- Write a message to the player SystemNotice(role, string.format("You received a monster hunt contract [%s] x %d!", GetMonsterName(target_id), number)) -- The contract is successfully created! return LUA_TRUE, item, r2 end -- Contract item use event ItemUse_PKOdevContract = function(role, item) -- Get the main character's descriptor role = TurnToCha(role) -- Get contract data local target_id = GetItemAttr(item, contract.const['target_id']) local target_max = GetItemAttr(item, contract.const['target_max']) local target_cur = GetItemAttr(item, contract.const['target_cur']) -- Check that the contract is not completed if ( target_cur < target_max ) then -- Print a message SystemNotice( role, string.format("You have to kill [%s] x %d more to complete this contract!", GetMonsterName(target_id), (target_max - target_cur) ) ) -- Cancel the item usage UseItemFailed(role) else -- Print a message SystemNotice(role, "You have successfully completed the contract, congratulations!") -- Call user-defined reward function if ( contract.conf['reward_cb'] ~= nil ) then contract.conf['reward_cb'](role, item) end end end 5) Write the contract item ID from ItemInfo.txt into the script of the system : contract.conf = { -- Contract item ID item_id = XXXX, . . . 6) Write your code for giving a reward for completing the contract in the function reward_cb(): -- User-defined function for reward reward_cb = function(role, item) -- Give 1,000 gold AddMoney (role, 0, 1000) -- Give an random item local arr = { -- Refining Gem x 1 {id = 885, count = 1}, -- or Gem of Rage x 2 {id = 863, count = 2}, -- or Cake x 60 {id = 1849, count = 60}, -- or Fairy of Luck x 1 {id = 231, count = 1} } local r = math.random(1, table.getn(arr)) GiveItem(role, 0, arr[r].id , arr[r].count, 4) -- Launch fireworks PlayEffect(role, 361) end 7) Open the file "GameServer\resource\script\calculate\SkillEffect.lua" and at the beginning of the file write the line: dofile(GetResPath("script\\calculate\\mods\\pkodev.contract.lua")) Client 1) Install the mod loading system PKOdev.NET mod loader; 2) Place the mod DLL file "pkodev.mod.contract.client.13x_<ID>.dll" for your version of Game.exe into the "mods" folder of the game client; 3) Add the item for the contract to the ItemInfo.txt file (see point 1 of the instructions for installing the system on the server). Creation and issuance of contracts Each contract must only be created using the contract.create() function. Using the GiveItem(), MakeItem() functions, or the &make GM command and other ways to create items is not allowed. The syntax: local <Result LUA_TRUE|LUA_FALSE>, <Item descriptor>, <Item slot> = contract.create(<Character descriptor>, <Monster ID>, <Number of monsters>) Example: local ret, item, pos = contract.create(role, 103, 7) As a result, a contract will be created for killing seven "Forest Spirits" as in the image from the topic header. You can give contracts to players, for example, through a special NPC or with the another item. 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. How can I add welcome notice? I have seen it in many server. ex: Hey, [Char Name] Welcome to [Server Name]. How can I add this feature?
  3. [Script] Promo code system This script implements a simple promo code system. Players can use promo codes to get items. Promo codes are entered into the local chat channel through a slash, for example: /agjtjSfsaAS34 The promo code can only be used once. A text file is used to store promo codes. Requirements The script requires GameServer.exe with the HandleChat() function support - local chat messages handler. Installing the script 1) Create a file named "pkodev.promo.lua" in the folder "GameServer\resource\script\calculate\mods" with the following contents: -- Print a log print("Loading pkodev.promo.lua") -- Check that HandleChat function exists if (HandleChat == nil) then -- Write a log print("pkodev.promo.lua: Warning, the HandleChat() function is not exist!") -- Do not load the script return end -- Promocodes system promo = promo or { } -- Name of the file with promocodes promo.file = "promocodes.dat" -- List with promocodes promo.list = {} -- Save data to file promo.save = function(path) -- Open the file local file, msg = io.open(path, "w") -- Check that file is open if (file == nil) then -- Write a log LG("pkodev.mod.promo", string.format("Can't save the list with promocodes to the file '%s': '%s'!", path, msg)) return false end -- Write data for key, value in promo.list do -- Write a line local ret = file:write(string.format("{%s, %d, %d}\n", value.code, value.id, value.count)) -- Check that line is written if (ret == false) then -- Write a log LG("pkodev.mod.promo", string.format("Can't write the data to the file '%s'!", path)) return false end end -- Flush the data file:flush() -- Close the file file:close() -- Write a log LG("pkodev.mod.promo", string.format("The list with promocodes has been successfully saved to the file '%s'!", path)) return true end -- Load data from file promo.load = function(path) -- Remove old promocodes for k in pairs (promo.list) do promo.list[k] = nil end -- Open the file local file, msg = io.open(path, "r") -- Check that file is open if (file == nil) then -- Write a log LG("pkodev.mod.promo", string.format("Can't load the list with promocodes from the file '%s': '%s'!", path, msg)) return false end -- Read file line by line for line in file:lines() do -- Extract data from the line local ret, _, code_, id_, count_ = string.find(line, "^{([A-Za-z0-9]+)%s*,%s*([0-9]+)%s*,%s*([0-9]+)}$") -- Check that string matches the pattern if (ret ~= nil) then -- Add data to the list table.insert( promo.list, { code = code_, id = id_, count = count_, } ) end end -- Close the file file:close() -- Write a log LG("pkodev.mod.promo", string.format("%d promocodes have been succsessfully loaded from file '%s'!", table.getn(promo.list), path)) return true end -- Handle chat function hook promo.hadle_chat__original = HandleChat HandleChat = function(role, msg) -- Check that message has the '/' symbol if ( string.sub(msg, 1, 1) == "/" ) then -- Get promocode local ret, _, code_ = string.find(msg, "^/([A-Za-z0-9]+)%s*$") -- Check that promocode is found if (ret ~= nil) then -- Search the promocode in the list for key, value in pairs(promo.list) do -- Compare promocodes if (value.code == code_) then -- Write a message BickerNotice(role, string.format("You entered the promocode '%s': %s x %d!", value.code, GetItemName(value.id), value.count) ) -- Give an item GiveItem(role, 0, value.id, value.count, 0) -- Write a log LG("pkodev.mod.promo", string.format("Player '%s' entered a promocode '%s' and received '%s' x %d!", GetChaDefaultName(role), value.code, GetItemName(value.id), value.count) ) -- Remove the promocode from the list promo.list[key] = nil -- Save the list to the file promo.save(promo.file) -- Synchronize the promocodes list local packet = GetPacket() WriteCmd(packet, 4015) WriteDword(packet, GetRoleID(role)) WriteString(packet, string.format("promo.list[%d]=nil", key)) SendPacket(role, packet) -- Do not call the original function HandleChat() return 0 end end end end -- Call the original function HandleChat() return promo.hadle_chat__original(role, msg) end promo.load(promo.file) 2) Include it in the file "SkillEffect.lua" (\GameServer\resource\script\calculate) after "functions.lua" inclusion: dofile(GetResPath("script\\calculate\\mods\\pkodev.promo.lua")) 3) In the root directory of the GameServer create a file named "promocodes.dat" and write the list of promocodes in the following format: {<Promocode>, <Item ID>, <Item number>} Example: {agjtjSfsaAS34, 1849, 45} {kgjKKKsnggklsaa, 885, 1} {0004121aAf, 1848, 10} Using the script 1) To use a promocode, player should enter it in the local chat: /agjtjSfsaAS34 The player will get Cake x 45. 2) All logs regarding promo codes usage can be found in the file: GameServer\LOG\log\pkodev.mod.promo.txt What can be improved 1) As a reward, you can also give gold, buffs and other bonuses; 2) The list of promotional codes can be stored in the database, for example, using the LuaSQL library; 3) You can make promotional codes reusable, but one player can use the promotional code only once.
  4. With this PHP script you can search for different items in characters bag, temporary bag and bank. Requirements: PHP 7.0+; PDO support; sqlsrv driver for PDO. How to install and use: 1) Put the script to your web server working folder, usually it named htdocs. 2) Open index.php and configure it; First of all, fill the data to connect to the MSSQL server: // MSSQL Settings $db_host = ''; $db_user = ''; $db_pass = ''; $db_name = 'GameDB'; Then enter the access key. It is needed to access the script from the web browser. // Secret key $access_key = 'E10ADC3949BA59ABBE56E057F20F883E'; Fill the list of items you need to search for: // List of items to search for // ID, Name, Icon $items = array( // new Item(Item_ID, 'Item_Name', 'Item_Icon'), new Item(1, 'Short sword', 'w0001'), new Item(2, 'Long sword', 'w0002'), new Item(863, 'Gem of Rage', 'n1182'), new Item(855, 'Fairy Coin', 'n1482'), new Item(1847, 'Apple', 'n0275') ); That's all! 3) Run the script in the your web browser and you will see the results of the search. http://localhost/search_items/index.php The script is based on the PHP class for working with inventory from user Matt from forum serverdev.net. Icons of items are included. Do not use on a production server for security reasons. Download
  5. [Script] Quest requires 'X' hours after the start Hello! In this thread I am posting an example of script that will allow you to check the condition when the player completes the quest: 'X' time has to pass after starting the quest to complete it. Usage MisResultCondition(MissionTimeExpired, <quest_id>, <time_in_seconds_to_wait>) Installation Add the following code to the file 'vairable.lua': -- Table with the time of taking quests by characters if (quest_table_guard == nil) then quest_table_guard = true quest_table = { } end Add to the file 'functions.lua': -- Quest added event AddMission__Original = AddMission AddMission = function(role, id, param) -- Call original AddMission function local ret = AddMission__Original(role, id, param) -- Check the result if ( ret == LUA_TRUE ) then -- Add the quest to the table quest_table[id] = quest_table[id] or {} -- Remember the time when the character took the quest quest_table[id][ GetRoleID(role) ] = os.time() end -- Return original result return ret end -- Check that some time expired since character taken the quest function MissionTimeExpired(role, id, t) -- Check that quest exists in the table if ( quest_table[id] == nil ) then -- Quest not found return LUA_TRUE end -- Get character ID local cha_id = GetRoleID(role) -- Check that the character has the quest if ( quest_table[id][cha_id] == nil ) then -- Character doesn't have the quest ?! return LUA_TRUE end -- Calculte time delta local delta = ( os.time() - quest_table[id][cha_id] ) -- Check that t seconds expired since quest started if ( delta >= t ) then -- Remove character from table quest_table[id][cha_id] = nil -- Condition is completed return LUA_TRUE end -- Condition is not completed return LUA_FALSE end And finally register the new function in the file 'MissionSdk.lua' ('ConditionsTest' function): . . . elseif conditions[i].func == MissionTimeExpired then local ret = MissionTimeExpired( character, conditions[i].p1, conditions[i].p2 ) if ret ~= LUA_TRUE then PRINT( "ConditionsTest: MissionTimeExpired = false" ) return LUA_FALSE end . . . That's all! Note: 1) All data about the time of taking quests by characters will be lost when the server is restarted. You need to come up with a mechanism for saving the table 'quest_table' to a file or database if this is critical for your application; 2) NPCs that give and accept a quest with this condition must be within the same GameServer instance.
  6. 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)
  7. Script link Credits to @Sultan for being an inspiration =) note: It has items from 2.4, feel free to remove them if you are planning to use it on older versions
  8. Hi PKODev! ; I bring you a Guide .. rather a script that will guide you to many people who are embarking on the development of private servers! function ItemUse_Example27( role, Item ) local GemSlotAID3 = 15 -- Gem Stone ID A ( Can be founded in stoneinfo.txt ) local GemSlotBID3 = 29 -- Gem Stone ID B ( Can be founded in stoneinfo.txt ) local GemSlotCID3 = 22 -- Gem Stone ID C ( Can be founded in stoneinfo.txt ) local GemSlotALevel3 = 9 -- Gem Level - 1 ~ 9 local GemSlotBLevel3 = 9 -- Gem Level - 1 ~ 9 local GemSlotCLevel3 = 9 -- Gem Level - 1 ~ 9 r13,r23 = MakeItem(role,####,1,18)-- Your Equip local Equipp3 = GetChaItem(role,2,r23) local param3 = GetItemForgeParam(Equipp3,1) local Item_Stone3 = {} local Item_StoneLv3 = {} param3 = TansferNum(param3) Item_Stone3[0] = GetNum_Part2(param3) Item_StoneLv3[0] = GetNum_Part3(param3) Item_Stone3[0] = GemSlotAID3 Item_StoneLv3[0] = GemSlotALevel3 param3 = SetNum_Part2(param3, Item_Stone3[0]) param3 = SetNum_Part3(param3, Item_StoneLv3[0]) SetItemForgeParam(Equipp3, 1, param3) param3= TansferNum(param3) Item_Stone3[1] = GetNum_Part2(param3) Item_StoneLv3[1] = GetNum_Part3(param3) Item_Stone3[1] = GemSlotBID3 Item_StoneLv3[1] = GemSlotBLevel3 param3 = SetNum_Part4(param3, Item_Stone3[1]) param3 = SetNum_Part5(param3, Item_StoneLv3[1]) SetItemForgeParam(Equipp3, 1, param3) param3 = TansferNum(param3) Item_Stone3[2] = GetNum_Part2(param3) Item_StoneLv3[2] = GetNum_Part3(param3) Item_Stone3[2] = GemSlotCID3 Item_StoneLv3[2] = GemSlotCLevel3 param3 = SetNum_Part6(param3, Item_Stone3[2]) param3 = SetNum_Part7(param3, Item_StoneLv3[2]) SetItemForgeParam(Equipp3, 1, param3) local Socket3 = GetItemForgeParam(Equipp3, 1) Socket3 = TansferNum(Socket3) Socket3 = SetNum_Part1(Socket3, 3) SetItemForgeParam(Equipp3, 1, Socket3) RefreshCha(role) end
  9. Hello world! I buy the System Guild Bank. If anyone knows, please contact me. Thank you.
  10. Hello! I have a question, can anyone help me how to do a function to merge the Ring? I need fusion Ring Unseal to Ring Apparel... Thank you!
  11. Hi all! I'm trying to edit the rebirth skills base damage. Ideally, I'm thinking of having skill level increases similar to how normal skills work. I've tried different calulations, but I can't seem to get the damage to increase beyond the default. function SkillArea_Circle_WuYin( sklv ) local side = 1000 SetSkillRange ( 4 , side ) end function SkillCooldown_WuYin( sklv ) local Cooldown = 30000 return Cooldown end function SkillSp_WuYin ( sklv ) local sp_reduce = 125 return sp_reduce end function Skill_WuYin_Begin ( role , sklv ) local sp = Sp(role) local sp_reduce = SkillSp_WuYin ( sklv ) if sp - sp_reduce < 0 then SkillUnable(role) return end Sp_Red (role , sp_reduce ) end function Skill_WuYin_End ( ATKER , DEFER , sklv ) --Ethereal Slash local sklv = sklv local dmg = math.random ( 999 , 1000 ) * sklv Hp_Endure_Dmg ( DEFER , dmg ) end This is the latest one, which you can see I've tried assigning math.random to it, and then just tightening up my damage levels to be within the 1 point of 1,000 that I wanted. And here's the original code: function SkillArea_Circle_WuYin( sklv ) local side = 800 SetSkillRange ( 4 , side ) end function SkillCooldown_WuYin( sklv ) local Cooldown = 30000 return Cooldown end function SkillSp_WuYin ( sklv ) local sp_reduce = 125 return sp_reduce end function Skill_WuYin_Begin ( role , sklv ) local sp = Sp(role) local sp_reduce = SkillSp_WuYin ( sklv ) if sp - sp_reduce < 0 then SkillUnable(role) return end Sp_Red (role , sp_reduce ) end function Skill_WuYin_End ( ATKER , DEFER , sklv ) local dmg = math.random ( 350 , 650 ) Hp_Endure_Dmg ( DEFER , dmg ) end Ideally, I'm looking for the correct part to add where the damage would be 1,000 base + an additional 1,000 per skill level. And admittedly, if anyone has a solid understanding of Headshot (where PR is not calculated), I'd like that to be configured in as well. Thanks so much!
  12. Вопрос: Зачем это нужно? Ответ: Красиво. Так же все будут видеть какой игрок открыл тот или иной сундук (к примеру). Установка: Я буду привязывать эффект к сундуку из Мира демонов, находим функцию в ItemEffect.lua -- Сундук из Мира демонов (ID 3424) function ItemUse_MFBX ( role , Item ) local item_type = BaoXiang_MFBX local item_type_rad = BaoXiang_MFBX_Rad local item_type_count = BaoXiang_MFBX_Count local maxitem = BaoXiang_MFBX_Mxcount local item_quality = BaoXiang_MFBX_Qua local General = 0 local ItemId = 0 local Item_CanGet = GetChaFreeBagGridNum ( role ) if Item_CanGet <= 0 then SystemNotice(role ,"\205\229\228\238\241\242\224\242\238\247\237\238 \236\229\241\242\224 \226 \232\237\226\229\237\242\224\240\229. \205\229\226\238\231\236\238\230\237\238 \238\242\234\240\251\242\252 \241\243\237\228\243\234") --SystemNotice(role ,"Недостаточно места в инвентаре. Невозможно открыть сундук") --SystemNotice(role ,"Insufficient space in inventory. Unable to open chest" 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 ) local message = cha_name.." \238\242\234\240\251\226\224\229\242 \241\243\237\228\243\234 \241 \241\238\234\240\238\226\232\249\224\236\232 \232 \239\238\235\243\247\224\229\242 "..itemname --local message = cha_name.." открывает сундук с сокровищами и получает "..itemname --local message = cha_name.." opens a treasure chest and obtained "..itemname Notice ( message ) end И в конце скрипта дописываем следующие: -- Эффект при открытии сундука local effect = 361 -- ID эффекта из sceneffectinfo.txt PlayEffect (role, effect ) -- Заставляем проигрывать эффект при открытии сундука Общая картина скрипта после привязки эффекта такова:
  13. http://pastebin.com/nv1NpRKY there are also instructions at the end of this script page. Hope it helps =) EDIT: It has troubles with big checksums. Seems like on GS does truncation with 64bits numbers. If you want to use for production(which is not recommended), the temporary bag can be a good option, because it has small checksums (and avoid dbparam usage). You can check those problems with gemmed items, due they have big checksums. I'm gonna try to fix it soon. EDIT: tested with 2.4, 1.X shouldn't work
  14. Someone would have to NPC Pucca files 1.38?
×
×
  • Create New...