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

  1. Description: I've modified the lua scripts from @V3ct0r's Contract System Mod to be a bit more customizable. With this script you don't need to give player contracts directly via NPC since they can now be random map drops (given directly to their inventory). Download: GitHub It's hosted on GitHub to prevent loss of the script and potentially fix issues in the future if I feel like it. Installation: Just load the file in your server! If you have a mod/extension folder, you can go ahead and call it from there. Obviously you need V3ctor's Contract System Mod. This script can work on sources, but you will need to modify client source to show the item hints properly. Not hard to do, but I won't be providing anything related to that here! Like I said, just load the file, I won't help with that, sorry! The script is a stand-alone, no other functions are needed (hopefully). The only function neeeded is already hooked. Usage Details: As stated on V3ctor's original thread, create a new item within your ItemInfo. The item's ID must match what is defined in ContractSys.Conf.ItemID. ContractSys.Conf.ItemID = XXXXX The item's type must match ContractSys.Conf.ItemType. ContractSys.Conf.ItemType = 99 The item's function must be the following: ItemUse_ContractSys The system must be enabled by setting ContractSys.Conf.Enabled to true. ContractSys.Conf.Enabled = true If you want contract to be given randomly by killing monsters, then this variable ContractSys.Conf.World.Enabled must be set to true. ContractSys.Conf.World.Enabled = true In reality, this must be always set to true since there's no other option to get contracts from, they were not implemented! Adjust the maximum of active contracts a player can have at a single time. ContractSys.Conf.Limit Add your map to the allowed list, set it to true and adjust the probability to your needs. The probability is from 0 to 100. ContractSys.Conf.Maps['<MAP_NAME>'] = {Allow = true, Probability = 10} I have some examples in there for Forsaken City, Dark Swamp and Demonic World. You can follow those as guidance. Add some monsters that spawn in your map, along with their probability, minimum and maximum quantities. ContractSys.Monsters['<MAP_NAME>'] = { {Allow = true, ID = <MONSTER_ID>, Min = <MIN_QTY>, Max = <MAX_QTY>, Rate = <MONSTER_RATE>}, } <MAP_NAME>: This is your map's name like "abandonedcity". <MONSTER_ID>: The monster's ID that spawns in that map. <MIN_QTY> / <MAX_QTY>: The minimum and maximum quantity that the player can be tasked to killed. <MONSTER_RATE>: The rate as a number that is used to add weight to the item. This number will be added with the other rates from the monsters in this map's monster list, the lower the number compared to others, the lower probability this monster will appear in a contract. I have some examples in there from Forsaken City, Dark Swamp and Demonic World. Add some rewards to be given when completing contracts obtained from your map. ContractSys.Rewards.Maps['<MAP_NAME>'] = { {Allow = true, Gold = <GOLD_AMOUNT>, ID = <ITEM_ID>, Min = <MIN_QTY>, Max = <MAX_QTY>, Quality = <ITEM_QUALITY>, Rate = <REWARD_RATE>}, {Allow = true, Gold = <GOLD_AMOUNT>, ID = <ITEM_ID>, Min = <MIN_QTY>, Max = <MAX_QTY>, Quality = <ITEM_QUALITY>, Rate = <REWARD_RATE>}, {Allow = true, Gold = <GOLD_AMOUNT>, ID = <ITEM_ID>, Min = <MIN_QTY>, Max = <MAX_QTY>, Quality = <ITEM_QUALITY>, Rate = <REWARD_RATE>}, {Allow = true, Gold = <GOLD_AMOUNT>, ID = <ITEM_ID>, Min = <MIN_QTY>, Max = <MAX_QTY>, Quality = <ITEM_QUALITY>, Rate = <REWARD_RATE>}, } <MAP_NAME>: Your maps' name, such as "abandonedcity". <GOLD_AMOUNT>: The amount of gold to be given (if none, just set to zero). <ITEM_ID>: The item's ID to be given. <MIN_QTY> / <MAX_QTY>: The minimum and maximum quantity that can be given from the previous item. <ITEM_QUALITY>: The quality of the item (mostly used for gems). <REWARD_RATE>: The rate as a number that is used to add weight to the reward. This number will be added with the other rates from the items in this map's reward list, the lower the number compared to others, the lower probability this reward will appear in a contract. Now, if you want a monster to have specific reward, you can also add that. This will override other reward tables. ContractSys.Rewards.Specific[<MONSTER_ID>] = { {Allow = true, Gold = <GOLD_AMOUNT>, ID = <ITEM_ID>, Min = <MIN_QTY>, Max = <MAX_QTY>, Quality = <ITEM_QUALITY>, Rate = <REWARD_RATE>}, {Allow = true, Gold = <GOLD_AMOUNT>, ID = <ITEM_ID>, Min = <MIN_QTY>, Max = <MAX_QTY>, Quality = <ITEM_QUALITY>, Rate = <REWARD_RATE>}, {Allow = true, Gold = <GOLD_AMOUNT>, ID = <ITEM_ID>, Min = <MIN_QTY>, Max = <MAX_QTY>, Quality = <ITEM_QUALITY>, Rate = <REWARD_RATE>}, {Allow = true, Gold = <GOLD_AMOUNT>, ID = <ITEM_ID>, Min = <MIN_QTY>, Max = <MAX_QTY>, Quality = <ITEM_QUALITY>, Rate = <REWARD_RATE>}, } <MONSTER_ID>: The monster's ID that will have specific rewards. <GOLD_AMOUNT>: The amount of gold to be given (if none, just set to zero). <ITEM_ID>: The item's ID to be given. <MIN_QTY> / <MAX_QTY>: The minimum and maximum quantity that can be given from the previous item. <ITEM_QUALITY>: The quality of the item (mostly used for gems). <REWARD_RATE>: The rate as a number that is used to add weight to the reward. This number will be added with the other rates from the items in this map's reward list, the lower the number compared to others, the lower probability this reward will appear in a contract. Script Logic: Player defeats a monster. System will look if the map where the player is located is defined. If defined, then it will grab a monster from that list. If not defined, it will grab a monster from the generic list. It will set the monster to the contract and a random amount between the minimum and maximum quantity available. Player must defeat the quantity of the monster set within the contract. Upon completion, player must double click the contract to finish. System will look if the monster has a specific reward and choose one from there. If no specific reward is set for that monster, then it will iterate through all the maps defined to see if the monster is defined within there. If a defined monster is found, then it will grab a reward from that map's list. If no reward has been chosen, then it will grab a reward from the generic list. The gold (if any) and item (if any) will be given to player. The quantity will be random from the minimum and maximum set.
  2. 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
  3. [Mod] Contracts system This system is a "Monster Hunt" type quest, the purpose of which is to defeat a certain amount of specific monsters. A player is given a special item - “Contract”, which indicates which monster and how many the player have to defeat. As monsters are defeated, the player's current progress is updated in the "Contract". After defeating the required number of monsters, the "Contract" is considered completed, and the player can receive a reward by using the "Contract" item. The system consists of a pkodev.mod.loader modification for the game client (Game.exe) and a Lua script for the game server (GameServer.exe). Modification of the client is necessary to visualize the specified characteristics of the item in the hint field for the "Contract" when the player hover the mouse cursor over it's item. The target monster ID, the number of monsters already defeated, and the number of monsters needed to complete the "Contract" are stored in the following item stats: ITEMATTR_VAL_STR, ITEMATTR_VAL_DEX, and ITEMATTR_VAL_AGI, respectively. The purpose of the mod is to display these item characteristics in a form understandable to the player. For example, if ITEMATTR_VAL_STR = 103, ITEMATTR_VAL_DEX = 5, and ITEMATTR_VAL_AGI = 10, then the player will see the following information when hovering the mouse over "Contract": Hunt: 'Forest Spirit' x 10 Progress: 5 / 10 The Lua script for the game server is the core of the Contracts system, which contains the System settings and the logic of its operation. For example, when defeating next monster, the script will search the character's inventory for a suitable active "Contract", and if such the item is found, the System will update its state. An important setting of the script is the function that is necessary for issuing a reward after the player successfully completes the "Contract". Some features of the System: 1. "Contract" can be picked up, thrown away, transferred to another player, put in a bank or sold; 2. If a player has multiple "Contracts" in his inventory to hunt the same monster, then when defeating this monster, the "Contract" is selected randomly; 3. To receive a reward after completing a "Contract", the player should use an item of the "Contract", for example by double-clicking on it. The player will see a corresponding message in the system chat if the "Contract" has not yet been completed; 4. The content and amount of the reward are determined by the administrator in a special function of the System script; 5. ID and item type for "Contract" must be unique and set by the administrator in the System settings. The default item type is 99, the default item ID is undefined. Information about the modification Name: pkodev.mod.contract; Version: 1.1; Author: V3ct0r; Type: for the game client (Game.exe); Supported executable files (.exe): GAME_13X_0, GAME_13X_1, GAME_13X_2, GAME_13X_3, GAME_13X_4 and GAME_13X_5. Installing the Contracts system Game server 1. Add a "Contract" item to the GameServer\resource\ItemInfo.txt file. To do this, select any suitable ID (XXXX) and item type (99 by default): 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! 2. Place Lua script pkodev.contract.lua in GameServer\resource\script\calculate\mods directory (create mods folder if necessary). 3. Open the pkodev.contract.lua file and configure it as follows: 3.1 Write the "Contract" item ID from ItemInfo.txt (XXXX) to the item_id variable: item_id = XXXX, 3.2 In the CompletionCallback() function, write a code that will give players a reward after completing "Contracts". By default, the function gives a player 1,000 gold coins, a random item (Refining Gem x 1, or Gem of Rage x 2, or Cake x 60, or Fairy of Luck x 1) and launches fireworks: CompletionCallback = function(role, item) -- Give 1,000 gold AddMoney (role, 0, 1000) -- Set of items local arr = { {id = 885, count = 1 }, -- Refining Gem x 1 {id = 863, count = 2 }, -- Gem of Rage x 2 {id = 1849, count = 60}, -- Cake x 60 {id = 231, count = 1 } -- Fairy of Luck x 1 } -- Give a random item local idx = math.random(1, table.getn(arr)) GiveItem(role, 0, arr[idx].id , arr[idx].count, 4) -- Launch fireworks PlayEffect(role, 361) end 3.3 Open the file GameServer\resource\script\calculate\SkillEffect.lua and at the very beginning write the line: dofile(GetResPath("script\\calculate\\mods\\pkodev.contract.lua")) 4. The Contracts system has been successfully installed on your server. Congratulations! Also take a look at @Angelix's Contract System script implementation. It is more flexible and advanced than the one suggested above. Description of the script and installation instructions can be found in the corresponding topic: Game client 1. Add a "Contract" item to the Client\scripts\table\ItemInfo.txt file (see above "Installing the Contracts system" > "Game server" > point 1). Compile ItemInfo.txt. 2. Add to the file Client\scripts\table\StringSet.txt the following strings that a player will see when hovering the mouse over the "Contract": [1000] "(Completed)" [1001] "(Active)" [1002] "Hunt: '{0}' x {1}" [1003] "Progress: {0} / {1}" Note 1: If IDs of strings 1000 - 1003 are already taken, then write any free IDs instead. Note 2: After adding these strings to the StringSet.txt file, delete the StringSet.bin file if it exists, otherwise the changes will not be applied. Note 3: In string 1002, marker {0} is the name of the monster, and {1} is the number of monsters to defeat. In string 1003 marker {0} indicates the number of monsters already defeated, marker {1} is similar to string 1002. 3. Install mod loading system pkodev.mod.loader if it hasn't already been installed. 4. Place the mod DLL file pkodev.mod.contract.client.13x_{ID}.dll for your version of Game.exe and the mod settings file pkodev.mod.contract.json in the mods\pkodev.mod.contract folder of the game client. 5. Open the mod's settings file pkodev.mod.contract.json and write the following parameters into it according to your choice: 1. itemType - type of the item "Contract" specified in the ItemInfo.txt file. The default value is 99. 2. colorCompleted - the color of the "(Completed)" label in the hint for the "Contract" item in the format 0xAARRGGBB. The default value is 0xFF00FF00 (Green). 3. colorActive - the color of the "(Completed)" label in the hint for the "Contract" item in the format 0xAARRGGBB. The default value is 0xFFFFA500 (Orange). 4. STRING_001 - string ID for the "(Completed)" label from the StringSet.txt file. The default value is 1000. 5. STRING_002 - string ID for the "(Active)" label from the StringSet.txt file. The default value is 1001. 6. STRING_003 - string ID for the "Hunt: '{0}' x {1}" label from the StringSet.txt file. The default value is 1002. 7. STRING_004 - string ID for the "Progress: {0} / {1}" label from the StringSet.txt file. The default value is 1003. Note: This file can be left unchanged if you used the default values in the ItemInfo.txt and StringSet.txt files. 6. The contracts system setup for the game client is now complete! Creating "Contracts" and issuing them to the players "Contracts" are created using the contract.create() function, which takes as its arguments the handle of a character to which the contract is to be issued, the ID of a monster a player will need to defeat, and a number of monsters that the player have to defeat. As a result, the function returns a tuple of three elements: success flag, new item descriptor, and item slot number in the character's inventory. 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 the result, a "Contract" will be created to defeat the seven Forest Spirits, which will appear in the inventory of the role character. In case of an error, the function will return the value LUA_FALSE to the ret variable and write a log message to the pkodev.contract.txt file. Note: Creation of "Contracts" can be organized, for example, through a special NPC or other item. Useful links 1) Modification binary files for the client (.dll); 2) The file with the modification settings for the client (pkodev.mod.contract.json); 3) Repository on GitHub with the source code of the modification for Visual Studio 2022 Community (C++); 4) Lua script of the Contracts system for the game server; 5) ItemInfo.txt with an example of the "Contract" item; 6) Strings for the file StringSet.txt; 7) Mod loading system pkodev.mod.loader. If you encounter any problem, bug or have any questions, then feel free to write in this thread.
  4. 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?
  5. [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.
  6. 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
  7. [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.
  8. 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)
  9. 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
  10. Hello world! I buy the System Guild Bank. If anyone knows, please contact me. Thank you.
  11. 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!
  12. 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!
  13. Вопрос: Зачем это нужно? Ответ: Красиво. Так же все будут видеть какой игрок открыл тот или иной сундук (к примеру). Установка: Я буду привязывать эффект к сундуку из Мира демонов, находим функцию в 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 ) -- Заставляем проигрывать эффект при открытии сундука Общая картина скрипта после привязки эффекта такова:
  14. 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
  15. Someone would have to NPC Pucca files 1.38?
×
×
  • Create New...