Jump to content

Recommended Posts

Posted

Greetings!

 

 

I coded this small but rly,rly useful code for a pvp server.

 

No exaplanations need,read the configs & code and you'll understand.

 

### Eclipse Workspace Patch 1.0
#P L2_GameServer_It
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 5603)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -204,6 +204,23 @@
  */
public final class L2PcInstance extends L2PlayableInstance
{
+	
+	//noob system
+   
+    private boolean _noob;
+    private int noobdeaths = 0;
+                   
+    public boolean isNoob()
+    {
+    return _noob;
+    }
+    public void setNoob(boolean isNoob)
+    {
+                   _noob = isNoob;
+    }
+    
+	
+	
	private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? AND class_index=?";
	private static final String ADD_NEW_SKILL = "INSERT INTO character_skills (char_obj_id,skill_id,skill_level,skill_name,class_index) VALUES (?,?,?,?,?)";
	private static final String UPDATE_CHARACTER_SKILL_LEVEL = "UPDATE character_skills SET skill_level=? WHERE skill_id=? AND char_obj_id=? AND class_index=?";
@@ -5150,7 +5167,15 @@
		{
			return false;
		}
+		noobdeaths++;

+		 if (noobdeaths == Config.HOW_MANY_DEATHS_FOR_NOOB)
+			                {
+			                sendMessage("You gain Noob status,you can press .noob for more informations");
+			                setNoob(true);
+			                noobdeaths = 0;
+			                 }
+		
		if (killer != null)
		{
			L2PcInstance pk = null;
Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Noob.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Noob.java	(revision 0)
+++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Noob.java	(revision 0)
@@ -0,0 +1,60 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.util.Rnd;
+
+/**
+ * @author fanky
+ *
+ */
+public class Noob implements IVoicedCommandHandler
+{
+
+
+	private static final String[] VOICED_COMMANDS = { "noob" };
+	
+	@Override
+	public String[] getVoicedCommandList()
+	{
+		return VOICED_COMMANDS;
+	}
+
+	@Override
+	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+	{	
+		if(command.equalsIgnoreCase("noob"))
+		{
+			if (activeChar.isNoob())
+			{
+
+				int[][] items = { {Config.ITEM_ID_1, Config.ITEM_A-beep-T_1}, {Config.ITEM_ID_2, Config.ITEM_A-beep-T_2}, { Config.ITEM_ID_3, Config.ITEM_A-beep-T_3}, { Config.ITEM_ID_4, Config.ITEM_A-beep-T_4}, { Config.ITEM_ID_5, Config.ITEM_A-beep-T_5} };
+				int[] ar = items[Rnd.get(5)];
+				activeChar.addItem(command,  ar[0], ar[1], activeChar, true);
+				activeChar.sendMessage("You've recieved a random gift from server in order to help you");
+				activeChar.setNoob(false);
+			}
+			else
+			{
+				activeChar.sendMessage("You can't use this command because you are not noob!");
+				return false;
+			}
+		}
+		
+		return false; 
+	}
+	
+}
Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java	(revision 5603)
+++ java/net/sf/l2j/Config.java	(working copy)
@@ -882,6 +882,19 @@
     public static boolean L2JMOD_WEDDING_SAMESEX;
     public static boolean L2JMOD_WEDDING_FORMALWEAR;
     public static int L2JMOD_WEDDING_DIVORCE_COSTS;
+    
+    // noob system
+   public static int HOW_MANY_DEATHS_FOR_NOOB;
+   public static int ITEM_ID_1;
+   public static int ITEM_ID_2;
+   public static int ITEM_ID_3;
+   public static int ITEM_ID_4;
+   public static int ITEM_ID_5;
+   public static int ITEM_A-beep-T_1;
+   public static int ITEM_A-beep-T_2;
+   public static int ITEM_A-beep-T_3;
+   public static int ITEM_A-beep-T_4;
+   public static int ITEM_A-beep-T_5;

     // Packet information
     /** Count the a-beep-t of packets per minute ? */
@@ -1859,7 +1872,20 @@
                 L2JMOD_WEDDING_SAMESEX                  = Boolean.parseBoolean(L2JModSettings.getProperty("WeddingAllowSameSex", "False"));
                 L2JMOD_WEDDING_FORMALWEAR               = Boolean.parseBoolean(L2JModSettings.getProperty("WeddingFormalWear", "True"));
                 L2JMOD_WEDDING_DIVORCE_COSTS            = Integer.parseInt(L2JModSettings.getProperty("WeddingDivorceCosts", "20"));
-
+                
+                //noob system
+                HOW_MANY_DEATHS_FOR_NOOB                = Integer.parseInt(L2JModSettings.getProperty("HowManyDeaths","12"));
+                ITEM_ID_1                               = Integer.parseInt(L2JModSettings.getProperty("RandomItemId1","10"));
+                ITEM_ID_2                               = Integer.parseInt(L2JModSettings.getProperty("RandomItemId2","11"));
+                ITEM_ID_3                               = Integer.parseInt(L2JModSettings.getProperty("RandomItemId3","12"));
+                ITEM_ID_4                               = Integer.parseInt(L2JModSettings.getProperty("RandomItemId4","13"));
+                ITEM_ID_5                               = Integer.parseInt(L2JModSettings.getProperty("RandomItemId5","14"));
+                ITEM_A-beep-T_1                           = Integer.parseInt(L2JModSettings.getProperty("RandomItemA-beep-t1","1"));
+                ITEM_A-beep-T_2                           = Integer.parseInt(L2JModSettings.getProperty("RandomItemA-beep-t2","1"));
+                ITEM_A-beep-T_3                           = Integer.parseInt(L2JModSettings.getProperty("RandomItemA-beep-t3","1"));
+                ITEM_A-beep-T_4                           = Integer.parseInt(L2JModSettings.getProperty("RandomItemA-beep-t4","1"));
+                ITEM_A-beep-T_5                           = Integer.parseInt(L2JModSettings.getProperty("RandomItemA-beep-t5","1"));
+                
                 if (TVT_EVENT_PARTICIPATION_NPC_ID == 0)
                 {
                     TVT_EVENT_ENABLED = false;
Index: java/config/l2jmods.properties
===================================================================
--- java/config/l2jmods.properties	(revision 5603)
+++ java/config/l2jmods.properties	(working copy)
@@ -132,3 +132,27 @@
# ex.: 1;2;3;4;5;6
# no ";" at the start or end
TvTEventDoorsCloseOpenOnStartEnd =
+
+
+
+#---------------------------------------------------------------
+# Noob system by fanky                     -
+#---------------------------------------------------------------
+# In order to be noob a char has to die X times in a row
+# When he 'achieved'(lol) to die X times in a row he 'll be able to press
+# .noob,after that server will give him a gift(random item between five(5) items) and remove his noob status
+# How many deaths in a row in order to be noob?
+# by default 12
+HowManyDeaths = 12
+# IDs of random items which will be given as gift
+RandomItemId1 = 10
+RandomItemId2 = 11
+RandomItemId3 = 12
+RandomItemId4 = 13
+RandomItemId5 = 14
+# A-beep-ts of random items which will be given as gift
+RandomItemA-beep-t1 = 1
+RandomItemA-beep-t2 = 1
+RandomItemA-beep-t3 = 1
+RandomItemA-beep-t4 = 1
+RandomItemA-beep-t5 = 1
\ No newline at end of file

 

 

kkthnxbb

Guest Elfocrash
Posted

coded this small but rly,rly useless code for a pvp server.

useful maybe?

Guest Elfocrash
Posted

+		if (activeChar.isNoob())
+		{
+			if(command.equalsIgnoreCase("noob"))
+			{
+				int[][] items = { {Config.ITEM_ID_1, Config.ITEM_A-beep-T_1}, {Config.ITEM_ID_2, Config.ITEM_A-beep-T_2}, { Config.ITEM_ID_3, Config.ITEM_A-beep-T_3}, { Config.ITEM_ID_4, Config.ITEM_A-beep-T_4}, { Config.ITEM_ID_5, Config.ITEM_A-beep-T_5} };
+				int[] ar = items[Rnd.get(5)];
+				activeChar.addItem(command,  ar[0], ar[1], activeChar, true);
+				activeChar.sendMessage("You've recieved a random gift from server in order to help you");
+				activeChar.setNoob(false);
+			}
+			else
+			{
+				activeChar.sendMessage("You can't use this command because you are not noob!");
+				return false;
+			}
+		}
+		return false;

 

to

 

+		if(command.equalsIgnoreCase("noob"))
+		{
+			if (activeChar.isNoob())
+			{

+				int[][] items = { {Config.ITEM_ID_1, Config.ITEM_A-beep-T_1}, {Config.ITEM_ID_2, Config.ITEM_A-beep-T_2}, { Config.ITEM_ID_3, Config.ITEM_A-beep-T_3}, { Config.ITEM_ID_4, Config.ITEM_A-beep-T_4}, { Config.ITEM_ID_5, Config.ITEM_A-beep-T_5} };
+				int[] ar = items[Rnd.get(5)];
+				activeChar.addItem(command,  ar[0], ar[1], activeChar, true);
+				activeChar.sendMessage("You've recieved a random gift from server in order to help you");
+				activeChar.setNoob(false);
+			}
+			else
+			{
+				activeChar.sendMessage("You can't use this command because you are not noob!");
+				return false;
+			}
+		}
+		return false;

 

you also don't need the this in pcinstance as long as you are already talking about pcinstance without it.

Posted

+       if (this.noobdeaths == Config.HOW_MANY_DEATHS_FOR_NOOB)
+                         {
+                         this.sendMessage("You gain Noob status,you can press .noob for more informations");
+                         this.setNoob(true);
+                         noobdeaths = 0;
+                          }

this. not needed

  
+     if (noobdeaths == Config.HOW_MANY_DEATHS_FOR_NOOB)
+                         {
+                         sendMessage("You gain Noob status,you can press .noob for more informations");
+                         setNoob(true);
+                         noobdeaths = 0;
+                          }
+    

Good share.

edit: dafuk elfocrash corrected all what I was posting so fast -.-...

Posted

+		if (activeChar.isNoob())
+		{
+			if(command.equalsIgnoreCase("noob"))
+			{
+				int[][] items = { {Config.ITEM_ID_1, Config.ITEM_A-beep-T_1}, {Config.ITEM_ID_2, Config.ITEM_A-beep-T_2}, { Config.ITEM_ID_3, Config.ITEM_A-beep-T_3}, { Config.ITEM_ID_4, Config.ITEM_A-beep-T_4}, { Config.ITEM_ID_5, Config.ITEM_A-beep-T_5} };
+				int[] ar = items[Rnd.get(5)];
+				activeChar.addItem(command,  ar[0], ar[1], activeChar, true);
+				activeChar.sendMessage("You've recieved a random gift from server in order to help you");
+				activeChar.setNoob(false);
+			}
+			else
+			{
+				activeChar.sendMessage("You can't use this command because you are not noob!");
+				return false;
+			}
+		}
+		return false;

 

to

 

+		if(command.equalsIgnoreCase("noob"))
+		{
+			if (activeChar.isNoob())
+			{

+				int[][] items = { {Config.ITEM_ID_1, Config.ITEM_A-beep-T_1}, {Config.ITEM_ID_2, Config.ITEM_A-beep-T_2}, { Config.ITEM_ID_3, Config.ITEM_A-beep-T_3}, { Config.ITEM_ID_4, Config.ITEM_A-beep-T_4}, { Config.ITEM_ID_5, Config.ITEM_A-beep-T_5} };
+				int[] ar = items[Rnd.get(5)];
+				activeChar.addItem(command,  ar[0], ar[1], activeChar, true);
+				activeChar.sendMessage("You've recieved a random gift from server in order to help you");
+				activeChar.setNoob(false);
+			}
+		}
+		else
+		{
+			activeChar.sendMessage("You can't use this command because you are not noob!");
+			return false;
+		}
+		return false;

 

you also don't need the this in pcinstance as long as you are already talking about pcinstance without it.

fixed dat typo.

 

k,ty.

Posted

Hm... you had it correct Fanky... the first one is correct, not the second one...

edit: both are incorrect.

 

+		if(command.equalsIgnoreCase("noob"))
		+		{
		+			if (activeChar.isNoob())
		+			{
		+
		+				int[][] items = { {Config.ITEM_ID_1, Config.ITEM_A-beep-T_1}, {Config.ITEM_ID_2, Config.ITEM_A-beep-T_2}, { Config.ITEM_ID_3, Config.ITEM_A-beep-T_3}, { Config.ITEM_ID_4, Config.ITEM_A-beep-T_4}, { Config.ITEM_ID_5, Config.ITEM_A-beep-T_5} };
		+				int[] ar = items[Rnd.get(5)];
		+				activeChar.addItem(command,  ar[0], ar[1], activeChar, true);
		+				activeChar.sendMessage("You've recieved a random gift from server in order to help you");
		+				activeChar.setNoob(false);
		+			}
		+			else
		+			{
		+				activeChar.sendMessage("You can't use this command because you are not noob!");
		+				return false;
		+			}
		+		}
		+		
		+		return false; 

Guest Elfocrash
Posted

Hm... you had it correct Fanky... the first one is correct, not the second one...

edit: both are incorrect.

 

+		if(command.equalsIgnoreCase("noob"))
		+		{
		+			if (activeChar.isNoob())
		+			{
		+
		+				int[][] items = { {Config.ITEM_ID_1, Config.ITEM_A-beep-T_1}, {Config.ITEM_ID_2, Config.ITEM_A-beep-T_2}, { Config.ITEM_ID_3, Config.ITEM_A-beep-T_3}, { Config.ITEM_ID_4, Config.ITEM_A-beep-T_4}, { Config.ITEM_ID_5, Config.ITEM_A-beep-T_5} };
		+				int[] ar = items[Rnd.get(5)];
		+				activeChar.addItem(command,  ar[0], ar[1], activeChar, true);
		+				activeChar.sendMessage("You've recieved a random gift from server in order to help you");
		+				activeChar.setNoob(false);
		+			}
		+			else
		+			{
		+				activeChar.sendMessage("You can't use this command because you are not noob!");
		+				return false;
		+			}
		+		}
		+		
		+		return false; 

this is what i did too lol :P i edited it before you post

Posted

Well, cool share... But maybe we still need to add more protections, becouse now I can simply call my friend (or just use dual box) and kill my self X times, write ".noob" and take the reward.... So this is usefull, but need some fixes. :)

Good luck and keep sharing :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...