Jump to content

SamDev-Coder

Legendary Member
  • Posts

    129
  • Credits

  • Joined

  • Last visited

  • Days Won

    9
  • Feedback

    0%

Everything posted by SamDev-Coder

  1. Well i'll add your suggestion to the features list, i like it ... just click on a texture or icon and it show to a small preview Also about Server Side ... what tools that can help Server Side Developers, i'm still planning for the HTML Designer i want to make a WYSIWYG so people can edit HTML files visually
  2. Thank you, Glad that you may find it useful. About UTX Files you can work with files that coming from L2 Files or from UnReal directly and Encrypt,Decrypt, Explore, Search, Export ... etc both ways Also thinking about remove all buttons and make a more clean design where you can just drag 'n drop a Client/Server file directly to the application and it will recognize the file and load proper Editor/Tool, as well as Shell Execute where you can just right click on a Client/Server file > Decrypt, Encrypt, Edit, Preview ..... etc Lemme know your opinions about this Please .
  3. English Section, English Title > non English post :)
  4. Well maybe because i'm a fan of Ninja Assassin and also Ninjas capable of completing the task fast and clean and this is my main goal in this program :D
  5. Thank you dear , likes you as well :) btw i dunno about anything running in Greek sections since i dunno even a Greek word
  6. Big Thanks for your support mate, i really Thanks a lot for being supportive and motivating, hope you like it and use it someday :) Really happy to hear that, i'll not leave that project til the last bug :) and Thanks, but i need more info tbh :) losers ?? well thanks anyway :)
  7. Thank you, til now i got only one error when columns total width is more than 65535, but got that handled with few event handlers and mathematics Well it's started as a personal project that i made just to help me when working with L2 development, that's why i didn't made it public cause maybe the community think it's useless to share, but of course if will help anyone then i don't mind share even the source code, specially an expert like you can tell me if there is a better way to do something... and Thanks for feedback and support :)
  8. Well then , think i'll give it a try maybe always when you relax or become in peace fury drop down over time as well as u get attacked and not attack....etc Continent of Ninth Seal is really inspiring, it has a lot of GamePlay that i would like if implemented in Lineage II Anyway, Thank you :)
  9. Nice share, and Thanks :) btw it remember me with Fury System in C9 Game, i think about extend this to make a system like Fury of C9.... it's like when you get hit more your rage is increasing til you fill the fury and then u can use fury which increase your stats for 30 seconds (with percentage) ..... would you think it will cause unbalances if implement this ?
  10. - UPDATED with FileEdit Progress I will just when finish FileEdit :)
  11. Thank you, hope that it's useful for the community :)
  12. No worries i'll try to find aCis and create a tutorial for a GM Shop :) ... Thanks for info
  13. I'm Glad that you like it, and can you tell me what guide you would want for interlude ? and could you suggest a pack to demonstrate guide for interludes on ? i see many people go for aCis and say it's different structure, some go with another so let me know which pack community go for more , and Thanks :)
  14. Thanks friend, and of course a test hand would be very appreciated :)
  15. Hello Cheaters, I wanna introduce to you my new Project which is a Desktop Application based on .NET named L2Ninja. Table of Contents : – What is L2Ninja – System Requirements – Objectives – The Plan & Main Features – Feedback and Suggestions – Current State – Future Plans – Reported Bugs – ScreenShots – How to Help ? – Releasing Information - Update Log What is L2Ninja ? L2Ninja is a desktop application based on .NET core that aim to help L2 Server and Client Developers to be able to work with L2 Files and do their routine task easily with the less bugs possible. System Requirements : – Operating System : It’s mainly built for Windows OS, maybe in feature will consider working for a Linux version, have no decision about this yet. Application been developed and pretested on Windows 10 64 bit-based Processor, but should be working fine with Windows 8 and 7. will confirm that when testers prepare their report. – .NET Framework : This Application based on .NET core which means you need the proper .NET version to be installed in order to run it. Required .NET version for this to run is .NET Framework 4.5 . Also there will be two Installer Packages for this Software one of them will be shipped with proper .NET Offline Installer, and the other one without to reduce installer Disk Size. – Disk Space : For the current State and version the application needs approximately 50 MegaBytes as Diskspace Objectives and Aims : First i started this project a private little tool that help me to work with Lineage Development to reduce time and efforts, also i was using a lot of well known tools which was annoying process routine to use about 2 or 3 programs to do a simple task, so i wanted to create a tool that combine what’s needed to do Lineage stuff. It had a very non-organized interface and a mess everywhere but who cares it was just a private thing to make job done no more, after that i decided to make more researches on Lineage communities to see what applications they use and what known bugs are out there to improve my little application … and after some fixes i decided to improve it more to be usable but someone else so i started a Discussion to ask people in MxC community, about what they think about it and how to make it useful to others. By the community members feedback i got new suggestions, ideas and problems that L2 Developers face when working with there daily tasks. At that point i had new objectives : – Create an organized and clean interface – Best User Experience …..by working on Accessibility and Easy to Use concepts to be usable by anyone without very extensive experience requirements – Provide many tools in one application so you can give your Alt-tab a lil mercy – As most Coders/Developers spend a lot of time in front of their screens so they need an Eyes relaxing mechanism, that why i work on multi Interface Colors Schemes so applications users can adjust it to fit better in their working environment lightning – Reliability ….. i got reported by a friend on MxC community that some L2 Tools out there sometimes deletes and corrupt files by mistake, so i try to work hard on reliability and backups mechanism, and the main concept here is to make that application never use your files directly or replace it until it’s verified as a valid modification process. – Listening and Listening then Listening …. i believe that something made for the community should be made by the community it self, that’s why i insist to ask people about their opinions and listen for their problems and suggestions . – Responsibility … wont leave this project and stop updating at least until i can rely on another .NET developer to take the flag so i can take a break then i back again, until then i’ll be responsible for the updates and fixing bugs ( i don’t pretend to be a good coder and will never do but i’ll try my best) – Eyes Catches First … i’ll try to achieve a beautiful interface to make it at least non-disturbing looking if not catchy The Plan & Main Features : – UTX Files : Supporting the main tasks for UTX Files such as decrypting, encrypting, searching inside the file, view items, export a single/multi/all to readable and editable files – System Files (dat, ini, int) : The ability to work with System files and edit them in a more readable way by listing it’s contents into a Grid for more readability, save them back or export, as well as searching, replacing and validation, also providing a new feature which is Applying patch so you can share modifications with others to import it into there system – Splash Tool : Capability of working with L2 Splash Image files with features as encrypt, decrypt, replace original with new one and viewing an encrypted file with respect of Transparency mechanism in Lineage so it will show it after applying the transparency mechanism so you wont see that green and pinky colors. Also the capability of replacing original BMP Splashes with almost any image format and support transparency so the application will process your transparent pixels and apply the original Lineage Transparency Keys and definitions – Server XML Files : Editing XML Server Files visually without caring to open/closing tags, attributes … etc, which can cause big problems for a simple mistake if done by hand. Well we all know that XML Files structure are different so i’ll implement an XSD Validation to detect the XSD that XML uses and apply it to it . But older chronicles pack doesn’t support XSD, in this case i’ll make it skip XSD Validation and just scan the file to detect scheme, but i have plans to add custom XSDs to the application for certain packs like aCis, since it has fans so i can’t skip fans of aCis so application we have a special support for aCis server files – Config Editor : Work with .properties file, i know it’s plain easy to edit files, but why not just having all in one with some extra features and auto complete organized editor – HTML Designer : Not a regular HTML Designer but a special WYSIWYG HTML designer and Editor made for Lineage, how many time you had to start the server and log just to see how the html button will look like or if some color fit or not, it’s just pain also most of us got Critical Errors just for an HTML mistake. – Database Tools Just a little tool that helps you with backups, monitoring and custom modifications such as adding agumentations, change access levels, change passwords, scan for dual boxes and much more … but how can i know the database structure ? Well i’ll implement a database scheme definitions for most known packs (at least known to me) so you can you can select the pack you work with and application will load proper definitions – Icon Finder A tool that help you search and find the icon you want and it will be working in three ways : First : Search by src .. ex. : Icon.blablabla and this will show you the icon preview Second : looking into a list of icons and get the src location of what you selected, based on extensive search into a file you select or default files set by application Third : Search by Item ID, ex. : 57 > will show Adena Icon Also this tool will be integrated into HTML Designer, so you add icons to HTML document on the fly without even know the src for it. – Color Tools Here you will get a color picker so no need to open Photoshop just for picking a color, also get the valid color codes Lineage system files or HTML files – Report Tool So if you got a bug or problem or something you can send me a report without leaving the application and go to forums or emails … etc – Snippets Desktops are screaming nowadays .. everytime we found a good snippet, link, guide … etc we create a new text file to desktop and save it to it, by time ending up with many text files, so with this tool you can save your snippets, todo lists, links in organized categories that’s created by you. – More features coming to futures plans or maybe to current plan if requested by the community Feedback and Suggestions : – Some editors deletes file even when doing the process right Credits : VanGon Status : Fixed – Try to improve it as much as you can Credits : baksteen Status : I’m on it – Being able to import files and create ready to use utx Credits : SweeTs Status : It Supports UTX files operation but working on more operations – You could add drag’n’drop as a optional way to load files Credits : SweeTs Status : Done – add a small ‘preview’ window for the UTX files. So, you can see what icon it is, if you want to see it bigger/detailed, then you click ‘view selected’ button. Credits : SweeTs Status : Done – Improving DDF Files Credits : Sdw Status : Fixed Some as npcgrp.ddf, itemname-e.ddf and need testing to detect other problems to fix - Thing of creating your own project's website, and gather all the traffic from your users there (reports,requests,download etc). Credits : @`NeverMore Status : Published at http://l2ninja.samdev.org - have a script to automatically encrypt+overwrite existing in directory Credit : @big man bill Status : In Progress Current State : – Metro Style Interface – Multi Themes adjustable by use via Application Settings Panel – Encrypt a UTX file with one-click – Decrypt a UTX file with one-click – UTX Browser : Browse UTX Encrypted Files, look inside contents with a grid sortable by type and name, search inside it, export selected textures, export all at once, view selected texture or content, (Adding a live preview without a click) – System File Editor : Open Lineage system Files, Show Contents to a sortable grid, Modify, Search, Replace, Patch, Export to Text File, Save them after validation to original file or another location based on user decision – File Editor Chronicles Support : it support from C3 to GrandCursade – Modified DDF files for the System File Editor to reduce errors and bugs – Splash Tool : Open an Encrypted Lineage Image such as Splash screen and live preview it – Splash Tool Automatic Encryption or Decryption State, so the application will recognize if the loaded image is encrypted or not – Decrypt Encrypted Lineage Image – Convert Encrypted or Decrypted Lineage Images to another Formats – Replace Encrypted Original Lineage Image with none Encrypted Image – Transparent Preserve for L2 Images so you see a transparent image into the preview without green and pink extra colors – Ability to replace original Lineage Bmp Image with non-BMP files with automatic Transparency translation for PNG files to Original Lineage Transparency Mechanism – Drag and Drop Editor : you can now drag and drop a lineage file to the application and it will load the proper tool for it – Shortcuts for most Application Functions - UTX Browser Now have a live preview support which means when you click on a texture from the grid you'll see how it look like in a preview box, and you can click Full Definition Button for full preview - Adapted File Edit Grid with the Selected theme for better visualization Future Plans : I’m aiming high for the future to this application to a very handy tool for Lineage Development progress and make it easy to attach a server project to it to provide a management tool for the server as well as monitoring and maybe it will come with a server pack in future… who knows …. Reported Bugs : will be posted here when receive it from testers …. Screenshots : - Live Preview Added September 2nd - File Edit Theme Adaption : Added 10th September 2017 - Color Detection : Added 10th September 2017 - Advanced Color Picker : Added 10th September 2017 Note : Will add more Screens over time How to help ? Well any hand will be appreciated, here is a list with things i could use a hand at : – Report bug or Problem that exist now days when work with L2 Files – Suggest a Feature or Update or even a simple modification for any thing even if buttons order – Pm me if you can join the project as a Tester to find bugs – Share any opinion with me Releasing Information : The plan is that Project should be Ready on 15th of September, getting more hands and help as listed in “How to help ?” section will make things faster Update Log : - 2nd September 2017 Add Live Preview to UTX Browser > Thanks to @SweeTs Enhance Search Process , you can now just type in and out and it will be processed without a single button click Modify Grids to Adapt automatically with Selected Theme and Style for better Visualization Add Screen shot of Live Preview and Search within UTX Browser - 10th September 2017 - Adapt File Edit Grid with the Selected theme for better visualization - Automatically Detect Colors Parameters and Add it as Background, for accessibility purpose. So you don't need to check how this color looks like anymore - With Double Click on a Colored Element you get an Adobe-Like Color picker, which automatically translate values to the valid syntax of dat files (rgb and rgba) Note : A Video will be available soon
  16. Hello Mates, Here we back again with another Lineage Development Tutorial, this time we will learn how to work and create a Java NPC, Well what is this ? NPC is stands for Non-Playable Character, which is a Character in server that provide some help or services like Buffer, GateKeeper, Agumenter ….. etc, y’all know what NPC is i guess , so let’s get to the point. Table of Contents : Tools and Requirements Work With NPC XML Files Register your new NPC Type Create your Java NPC Type Class Build and Test Tools and Requirements : - Your favorite XML Editor (I Prefer Notepad++ / Download) or you can use Eclipse for that - Eclipse or Netbeans for Java Edits and Builds ( Eclipse Download – Netbeans Download ) - A Server Pack (for this tutorial i use Private Pack Based on L2JServer – Download) - Lineage 2 Client (I will use High Five Client, but you can Adapt it to any Chronicle Except for XML Part i guess) Work with NPC XML Files : Okay Before we go any further we need to let the server know that we have a new NPC and tell it’s type, id, stats …. etc, to do this you need to go to this path of game/data/stats/npcs inside your server files, there you’ll find some XML files, you can create your own XML file here or go to the folder custom/ and there you’ll find an XML file named custom.xml , i’ll put my new NPC there for the sake of simplicity . Open this File with your favorite Editor (Notepad++ in my case) and go to the end of the file, you’ll see something like </list> , Add this code just before it : <npc id="750002" displayId="32140" name="MxC Guide" usingServerSideName="true" title="Java NPC" usingServerSideTitle="true" type="L2MxCNPC"> <collision> <radius normal="11" /> <height normal="22.25" /> </collision> </npc> We will end up with something like this : Let’s Break it down and focus on few parts of this code : - (id=”750002″) : this is the ID of your new NPC that you will use it to spawn, so make sure it’s unique and try to find your unique numeric schema to avoid conflicts - (displayId=”32140″) : this indicated how your NPC will look like, it can be considered as Template Id, and of course you can change it to the template your want - (name=”MxC Guide”) : it’s the NPC name that will appear - (title=”Java NPC”) : is the NPC Title - (type=”L2MxCNPC”) : it’s the most important parameter since it’s declaring what type this NPC will be and will look for that Type in your java files, so that’s they type we will be Creating L2MxCNPC So you can manipulate this values according to your needs, but be away of displayId since the collision parameters are very vary based on the NPC Template you use. Register Your new NPC Type : Now we need to register our new Type as we said before our type for this tutorial will be L2MxCNPC, so we will register L2MxCNPCInstance as a type, and to do this you need to go to your server java files and find the package called com.l2jserver.gameserver.enums or could be com.PACKNAME.gameserver.enums , it doesn’t really matter since it can be vary from Pack to Pack but i use Official Structure. Inside this package you will find a Java File called InstanceType.java . Open this Java File and find the Section named Custom, and add this code at the beginning of this section : L2MxCNPCInstance(L2Npc), So it will look like this : Now we have our new NPC Instance Type Registered, so lets move to the next step. Create Your Java NPC Type Class : Here we got to the fun part, to create your NPC Class find a package with name com.l2jserver.gameserver.model.actor.instance or com.PACKNAME.gameserver.model.actor.instance , name can be vary from pack to pack but almost same structure. Step .1 : Right Click on this Package then choose >New > Class You’ll get a “New Java Class” window, we need to set some options there, First of all set name to L2MxCNPCInstance , second Click on Browse in front of Superclass input, you’ll get another window , search for L2Npc, and when you find it just click on it and hit Ok Step .2 : Now we need to add what’s called Constructor which is a block of code that Execute at the beginning of initialization of the Type, so just add this code inside your new class (between open and close curly braces of your class { } ) public L2MxCNPCInstance(L2NpcTemplate template) { super(template); setInstanceType(InstanceType.L2MxCNPCInstance); } So it will look like : as you can see here we set instance type to L2MxCNPCInstance which we registered in InstanceType.java file. Step .3 : Now what we need to do is to override 1 or 2 methods depends on NPC functionality, by overriding we mean that we are replacing the main functionality of L2Npc (since our type extends L2Npc) with a new functionality or implementation, the first method we need to override is showChatWindow which responsible to show the chat window of the NPC to the player when interact with it. To override this method just go to below L2MxCNPCInstance method (Constructor) and add this code : @Override public void showChatWindow(L2PcInstance player, int val) { } Well, we need to add some java code inside this method to show our HTML Document, but guess what , we didn’t created our HTML Document yet, so we don’t we go and create it now …. Step .4 : Go to your game html folder (usually at game/data/html ) and create an HTML document there or in any sub folder, for me i’ll create mxcnpc.html in custom subfolder, and initially i’ll put that html code in : <html><title>L2JSamDev MxC NPC</title> <body> <center> <br><br> <img src="L2UI_CH3.herotower_deco" width=256 height=32><br> <font name="hs9" color="00aff0">Hello From MxC Java NPC</font><br> <button action="bypass -h npc_%objectId%_MyCommand" value="Click Me (ByPass)" width=130 height=30 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"> <br> <img src="L2UI_CH3.herotower_deco" width=256 height=32><br> </center> </body> </html> Of course you can do the HTML code / design you want, but this is just for demonstration, but in real life, you’re free to do any HTML design you want. Step .5 : Go back to your Java file and add this code to the showChatWindow method, that we overrided before : //Try to load the HTML document String content = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/custom/mxcnpc.html"); //If not found ? if(content == null) { //Set a Fallback Content content = "Sorry we cannot find your document for MxC NPC"; } //Create a new NPC Message and set Object ID NpcHtmlMessage message = new NpcHtmlMessage(getObjectId()); //Set Message Content message.setHtml(content); //Replace %objecId% in HTMl with Real Object ID message.replace("%objectId%", String.valueOf(getObjectId())); //Send HTML to Player player.sendPacket(message); Step .6 : Well I Guess we are ready to go, but our new NPC actually do nothing, just showing an HTML, so what we can do to give this npc some power ? …. What makes NPC much powerful and full of features is what called ByPass which means it’s the ability to let players able to click on some Buttons or link and with that click they will send a command to the server, and in Java side we implement the feature or the action that will be taken when the player bypass any command. If you look closely to the HTML Code we’ve created you will notice this line : <button action="bypass -h npc_%objectId%_MyCommand" value="Click Me (ByPass)" width=130 height=30 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"> Focus on action parameter here it’s equal to ( bypass -h npc_%objectId%_MyCommand ) this means by clicking on this button player will pass a command of MyCommand to the Java NPC handler which has the valid Object ID . but how we can handle commands bypassed by player using our new NPC ? It’s simple, all we need is to override another method which is onBypassFeedback .. and to do so add this code below showChatWindow method : @Override public void onBypassFeedback(L2PcInstance player, String command) { } Here i’ll add some little simple code to implement the feature of trading 50KK Adena for 1K Clan Reputation if you are the clan leader, so add this code to on onBypassFeedback method : //Check for Player and Last NPC if Same if(player == null || player.getLastFolkNPC() == null || player.getLastFolkNPC().getObjectId() != getObjectId()) { return; } if(command.startsWith("MyCommand")) { //Check if Player is the clan Leader if(player.isClanLeader()) { //Is he has 50kk Adena ? if(player.getAdena() >= 50000000) { L2Clan clan = player.getClan(); //Give Reputation clan.addReputationScore(1000, true); //Take Adena player.getInventory().reduceAdena("Clan Requtation", 50000000, player, this); player.sendMessage("Your Clan has Earned 1000 Rep for 50 Millions Adena"); } else {player.sendMessage("You don't have Enough Adena");} } else {player.sendMessage("You are not a Clan Leader");} } of course you can maintain and make the code much smarter, but we seek simplicity to be easy to any one to start creating amazing Java NPCs . Step .7 : Now our NPC Java class will look like : package com.l2jserver.gameserver.model.actor.instance; import com.l2jserver.gameserver.cache.HtmCache; import com.l2jserver.gameserver.enums.InstanceType; import com.l2jserver.gameserver.model.L2Clan; import com.l2jserver.gameserver.model.actor.L2Npc; import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate; import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage; public class L2MxCNPCInstance extends L2Npc { public L2MxCNPCInstance(L2NpcTemplate template) { super(template); setInstanceType(InstanceType.L2MxCNPCInstance); } @Override public void showChatWindow(L2PcInstance player, int val) { //Try to load the HTML document String content = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/custom/mxcnpc.html"); //If not found ? if(content == null) { //Set a Fallback Content content = "Sorry we cannot find your document for MxC NPC"; } //Create a new NPC Message and set Object ID NpcHtmlMessage message = new NpcHtmlMessage(getObjectId()); //Set Message Content message.setHtml(content); //Replace %objecId% in HTMl with Real Object ID message.replace("%objectId%", String.valueOf(getObjectId())); //Send HTML to Player player.sendPacket(message); } @Override public void onBypassFeedback(L2PcInstance player, String command) { //Check for Player and Last NPC if Same if(player == null || player.getLastFolkNPC() == null || player.getLastFolkNPC().getObjectId() != getObjectId()) { return; } if(command.startsWith("MyCommand")) { //Check if Player is the clan Leader if(player.isClanLeader()) { //Is he has 50kk Adena ? if(player.getAdena() >= 50000000) { L2Clan clan = player.getClan(); //Give Reputation clan.addReputationScore(1000, true); //Take Adena player.getInventory().reduceAdena("Clan Requtation", 50000000, player, this); player.sendMessage("Your Clan has Earned 1000 Rep for 50 Millions Adena"); } else {player.sendMessage("You don't have Enough Adena");} } else {player.sendMessage("You are not a Clan Leader");} } } } So let’s Build our Project and Login into our server to check what we got … – Lets Spawn our NPC – and Try to interact with …. – Finally let’s Check if our command work Yeah, Finally it's working ... :) Sorry if any mistakes and if you got any question or need a specific Guide just let me know Thanks Everyone.
  17. Thank you brother, and i hope i can help others :) and of course meIron is talking right, so i'll update the main post
  18. @melron You're totally right brother i agree with you, your code is pretty to be honest :) But you can say it's just a habit as Programming Instructor, used to reduce topics and try to focus on basics to not let readers get confused about strange terms like : Constructors, OOP, Design Patterns, Encapsulation, Polymorphism .... etc . For my self i would like to add it in a custom package to make things organized and i have a Handlers class that register all voiced, bypasses, admin ... etc. I like readability as you do :)
  19. Thank you Brother for you comment :) well VoicedCommandHandler.getInstance() will call the Constructor Method and in Constructor method, this is the code protected VoicedCommandHandler() { _datatable = new HashMap<>(); } this will just initiate the HashMap, but it wont initiate it more than once since this class implement Singleton Pattern, which means Constructor being called one time only
  20. Hello Cheaters, It's my First Topic in this great forums, that's why i decided to try to help the community as i got help here before , by creating some tutorials specially for Backend (Java / C# if needed / PHP), and forgive me if this breaking any rules and let me know as soon as you notice that to correct :) . So let's cut that talk and get started. Table of Contents : What is Voiced Commands about ? For which Pack/Version is this tutorial ? Create your first Command Register your Command into GameServer What is Voiced Commands About : Well, Voiced Commands are that commands that Player can use into chat input and it's starting with a dot (.) , for example (.dressme, .join , .register ....... etc). and we usually add such commands to private servers to make life easier for players like adding a command which will convert player adena to Goldbars, another one for teleporting to custom location ..... and so on. For which Pack/Version is this Tutorial : Screenshot, Codes and the one i work on is a my private modified pack that's based on L2JServer for Hi5, but to be honest it should be working fine with all Packs if you can find some files locations like IVoicedCommandHandler.java and GameServer.java , so if you have a search skills then you can apply it to any pack and any chronicle and we will discuss that, dun worry. Com'on this is too much talk why we i don't just shut up get started :gusta: . Create your first Voiced Command : We can create our command code in two places (Server Pack or Data Pack), personally i prefer add it to Data Pack Scripts, but for the sake of simplicity and to make it easy for you to implement it in different packs and older version of L2 i'll do it this time in Server Pack. Step 1 : So go to your Server Pack Java Source and fine a Package called com.l2jserver.gameserver.handler or you can create your own package if you can work with Java well. once you get to that location (or your own package), right click on that > New > Class Step 2 : - Choose a Name for your Voiced Command Handler File, i'll name it ServerInfoVoicedCommandHandler , since i will make this command show player the server info document , well it's not useful but this tutorial meant for educations purpose not a product, so you can use your imagination and make your amazing command :) - Clear what's inside Superclass text - Click on Add in front of Interfaces section and Search for IVoicedCommandHandler, and when u find it Click Ok Step 3 : Once our class Created we will notice that we have 2 important sections (methods), useVoicedCommand and getVoicedCommandList. useVoicedCommand : is the method of block of code that will execute when a player use our command, so this is where our code will be getVoicedCommandList : is where our server will look to know which command(s) this file/class can handle . Note : if you are not familiar with Java , here is a note .. we usually add the code of any method between the curly-braces ( { } ) and any thing between { } we call it code block, if any need a guide for Java let me know and see if i can help :) So inside getVoicedCommandList code block we need to add this code : return new String[] {"serverinfo"}; this line of code will tell Game Server that this class can handle voiced command .serverinfo Step 4 : Now we need to Implement the actual feature of this command, so we need to write the right code that do that job, in our case we need to show and html file to the player this file can contain server info, so we need first to create an html file into our data/html/custom folder and i'll name it serverinfo.html, and here is a simple code that we can test it with . <html><title>L2JSamDev Info</title> <body> <center> <br><br> <center> <img src="L2UI_CH3.herotower_deco" width=256 height=32><br> <font name="hs9" color="00aff0">Hello This is the Server Info</font><br> <img src="L2UI_CH3.herotower_deco" width=256 height=32><br> </center> </body> </html> Step 5 : We need to add the code to useVoicedCommand method that show this html document to user, and here is the simplest code for this task //Get Html Content String documentContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/custom/serverinfo.html"); //If not Found then Stop if(documentContent == null) {return false;} //If Document Found then Prepare a new Message to Send it to Player NpcHtmlMessage message = new NpcHtmlMessage(); message.setHtml(documentContent); //Send Document to Player activeChar.sendPacket(message); //Well it's Success return true; Note : if you get errors like HtmCache or NpcHtmlMessage cannot resolve, just hover over it and click Import HtmCache/NpcHtmlMessa So our final Code will look like : package com.l2jserver.gameserver.handler; import com.l2jserver.gameserver.cache.HtmCache; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage; public class ServerInfoVoicedCommand implements IVoicedCommandHandler { @Override public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params) { //Get Html Content String documentContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/custom/serverinfo.html"); //If not Found then Stop if(documentContent == null) {return false;} //If Document Found then Prepare a new Message to Send it to Player NpcHtmlMessage message = new NpcHtmlMessage(); message.setHtml(documentContent); //Send Document to Player activeChar.sendPacket(message); //Well it's Success return true; } @Override public String[] getVoicedCommandList() { return new String[] {"serverinfo"}; } } Step 6 : - UPDATED as suggested By @meIron ( Thanks for Suggestion :) ) Just one more task to be good to go and test our new command, we need to register this command to the main VoicedCommandHandler, simple go to VoicedCommandHandler.java file which usually located at com.l2jserver.gameserver.handler or com.PACKNAME.gameserver.handler and in constructor which is the method called VoicedCommandHandler() add this like of code AFTER : _datatable = new HashMap<>(); Add this registerHandler(new ServerInfoVoicedCommand()); in the end it will look like Tip : you can register it in another way by adding it to MasterHandle.java in Datapack but we seek simplicity in this tutorial Step 7 : Let's Build that Project and Log in Game to test it Voila, Our Useless command Working :-beep- yeah: If you have any question or need another java tutorial or even have an idea to implement and wonder how it could be just lemme know, maybe i can help :)
×
×
  • Create New...