Jump to content

Recommended Posts

Posted

System Configuration options:

#------------------------------------
#-      Custom PvP Reward System       -
#------------------------------------
# INFO: For better system view disable this option:
# EnablePkInfo = False

# Enable Custom Pvp Reward System
CustomPvpRewardEnabled = True

# If the same player to kill, then after X times the reward Will not Increase (0 - Disabled)
CustomPvpRewardProtection = 2

# If the same player to kill, then after X times the reward Will not Increase,
# but it can be reset every Y portion of time (in minutes) from first daily kill (0 - disabled).
# It's reset only daily kills counter.
# Default: 0, Preferred: 1440 [24h].
CustomPvpRewardProtectionReset = 0

# Reward item id
CustomPvpRewardItemId = 6392
# Reward item amount
CustomPvpRewardAmmount = 1

# Minimum player level to obtain reward.
CustomPvpRewardMinLvl = 1

# Gives reward for kill PK player
CustomPvpPkReward = true
#------------------------------------

 

Screenshots:

img1v.png

img2uo.png

img3q.png

 

Patch is easy to implementation, only 4 lines in L2PcInstance, 1 CustomPvpRewardSystem class, 1 sql procedure, 1 sql table, and pvp.properties patch.

 

INFO: This system not ingerate in current pvp reward system. both system can work together, but better turn on one of both.

 

http://www.4shared.com/rar/DIOb4EDv/cprs_10.html

 

SYSTEM CREATED BY matthewmaster04

BIG BIG THANKS TO HIM!!!

Posted

great idea !!!! but i think u was in wrong section br0 but !!! it's a great idea nice work !

Posted

Hi

I did it for Freya l2jserver

 

Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(revision 5550)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -264,6 +264,7 @@
import com.l2jserver.gameserver.util.Util;
import com.l2jserver.util.Point3D;
import com.l2jserver.util.Rnd;
+import com.l2jserver.gameserver.model.actor.instance.PvpRewardSystem;

/**
  * This class represents all player characters in the world.
@@ -5340,7 +5341,11 @@
			L2PcInstance pk = killer.getActingPlayer();

			TvTEvent.onKill(killer, this);
-			
+			if(Config.CUSTOM_PVP_REWARD_ENABLED)
+							{
+								PvpRewardSystem.doCustomPvpReward(pk, this);
+							}
+							
			if (atEvent && pk != null)
			{
				pk.kills.add(getName());
Index: java/com/l2jserver/gameserver/model/actor/instance/PvpRewardSystem.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/PvpRewardSystem.java	(revision 0)
+++ java/com/l2jserver/gameserver/model/actor/instance/PvpRewardSystem.java	(revision 0)
@@ -0,0 +1,180 @@
+/*
+ * 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 com.l2jserver.gameserver.model.actor.instance;
+
+
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.logging.Logger;
+
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.datatables.ItemTable;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.templates.item.L2Item;
+
+import com.l2jserver.L2DatabaseFactory;
+
+
+/**
+ * @author Matthew Mazan
+ *
+ */
+public class PvpRewardSystem {
+	
+	private static Logger _log = Logger.getLogger(PvpRewardSystem.class.getName());
+	
+	/** 
+	 * Executed when kill player (from victim side)
+	 * @param killer
+	 * @param victim
+	 */
+	public static void doCustomPvpReward(L2PcInstance killer, L2PcInstance victim)
+	{
+		//int error_code = 0;
+		int kills = 0;
+		int kills_today = 0;
+		long kill_time = 0;
+		
+		long sys_time = System.currentTimeMillis();
+		long prot_time = (1000 * 60 * Config.CUSTOM_PVP_REWARD_PROTECTION_RESET);
+		
+		Connection con = null;
+		try{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement = con.prepareStatement("CALL CPRS_add(?,?,?,?)"); //query returns updated killer data
+			statement.setInt(1, killer.getObjectId());
+			statement.setInt(2, victim.getObjectId());
+			statement.setLong(3, sys_time);
+			statement.setLong(4, prot_time);
+			
+			ResultSet rset = statement.executeQuery();
+			
+			while(rset.next()){
+				//error_code = rset.getInt("error_code");
+				kills = rset.getInt("kills");
+				kills_today = rset.getInt("kills_today");
+				kill_time = rset.getLong("kill_time");
+				break;
+			}
+			rset.close();
+			statement.close();
+		}catch(SQLException e){
+			e.printStackTrace();
+		}
+		finally{
+			L2DatabaseFactory.close(con);
+		}
+		
+		
+		if(kills_today <= Config.CUSTOM_PVP_REWARD_PROTECTION){
+			if(killer !=null){
+				addItemRewardForKiller(killer, victim);
+			}
+		}else{
+			if((Config.CUSTOM_PVP_PK_REWARD)&&(killer.getKarma() == 0)){
+				if(Config.CUSTOM_PVP_REWARD_PROTECTION > 0){
+					if((Config.CUSTOM_PVP_REWARD_ENABLED)){
+						if(Config.CUSTOM_PVP_REWARD_PROTECTION_RESET == 0){
+							killer.sendMessage("Reward has been awarded for kill this player!");
+						}else{
+							killer.sendMessage("Reward has been awarded for kill this player today!");
+							killer.sendMessage("Next for "+calculateTimeToString(sys_time, kill_time));
+						}
+					}
+				}
+			}
+		}
+
+		
+		
+		if(kills > 1){
+			String timeStr1 = "times";
+			if(kills_today == 1){ timeStr1 = "time"; }
+			String msgVictim1 = killer.getName() + " killed you " + kills + " times.";
+			String msgVictim2 = killer.getName() + " killed you " + kills + " times ( "+ kills_today +" "+timeStr1+" today ).";
+			String msgKiller1 = "You have killed " + victim.getName() + " " + kills + " times.";
+			String msgKiller2 = "You have killed " + killer.getName() + " " + kills + " times ( "+ kills_today +" "+timeStr1+" today ).";
+			
+			if(Config.CUSTOM_PVP_REWARD_PROTECTION_RESET == 0){
+				victim.sendMessage(msgVictim1);
+				killer.sendMessage(msgKiller1);
+			}else{
+				victim.sendMessage(msgVictim2);
+				killer.sendMessage(msgKiller2);
+			}
+		}else{
+			victim.sendMessage("This is the first time you have been killed by " + killer.getName() + ".");
+			killer.sendMessage("You have killed " + victim.getName() + " for the first time."); 
+		}
+
+		killer = null;
+		victim = null;
+		
+	}
+	
+	/**
+	 * Adds the item reward.
+	 *
+	 * @param killer Player who killed.
+	 * @param victim victim Player.
+	 */
+	public static void addItemRewardForKiller(L2PcInstance killer, L2PcInstance victim){	
+		//Anti FARM Reward, level player >= reward_min_lvl
+		if((Config.CUSTOM_PVP_REWARD_MIN_LVL > victim.getLevel())||(Config.CUSTOM_PVP_REWARD_MIN_LVL > killer.getLevel()))
+		{
+			killer.sendMessage("Rewards are awarded on "+ Config.CUSTOM_PVP_REWARD_MIN_LVL + "+ level.");
+		}else{
+	        //IP check
+			if(killer.getClient()!=null)
+			if(killer.getClient().getConnection().getInetAddress() != victim.getClient().getConnection().getInetAddress())
+			{
+	
+				if((killer.getKarma() == 0)&&(killer.getPvpFlag() > 0)||((Config.CUSTOM_PVP_PK_REWARD)&&(killer.getKarma() == 0)&&(victim.getKarma() > 0))){
+					if(Config.CUSTOM_PVP_REWARD_ENABLED)
+					{
+						L2Item reward = ItemTable.getInstance().getTemplate(Config.CUSTOM_PVP_REWARD_ID);
+						
+						//killer.getInventory().addItem("Winning PvP", Config.CUSTOM_PVP_REWARD_ID, Config.PVP_REWARD_A-beep-T, killer, null);
+						killer.addItem("PvP Reward", Config.CUSTOM_PVP_REWARD_ID, Config.PVP_REWARD_A-beep-T, killer, false);
+						killer.sendMessage("You have earned " + Config.PVP_REWARD_A-beep-T + " x " + reward.getName() + ".");
+					}
+				}
+			}else{
+				 victim.sendMessage("Farm is punishable with Ban! Don't kill your Box!");
+		        _log.warning("PVP POINT FARM ATTEMPT: " + victim.getName() + " AND " + killer.getName() +" HAVE SAME IP!");
+			}
+		}
+	}
+	
+	private static String calculateTimeToString(long sys_time, long kill_time){
+		long TimeToRewardInMilli = ((kill_time + (1000 * 60 * Config.CUSTOM_PVP_REWARD_PROTECTION_RESET)) - sys_time);
+        long TimeToRewardHours = TimeToRewardInMilli / (60 * 60 * 1000);
+        long TimeToRewardMinutes = (TimeToRewardInMilli % (60 * 60 * 1000)) / (60 *1000);
+        long TimeToRewardSeconds = (TimeToRewardInMilli % (60 * 1000)) / (1000);
+        
+        String H = Long.toString(TimeToRewardHours);
+        String M = Long.toString(TimeToRewardMinutes);
+        String S = Long.toString(TimeToRewardSeconds);
+        if(TimeToRewardMinutes <= 9){ M = "0" + M; }
+        if(TimeToRewardSeconds <= 9){ S = "0" + S; }
+        
+        return H+":"+M+":"+S;
+	}
+	
+}
+
Index: java/com/l2jserver/Config.java
===================================================================
--- java/com/l2jserver/Config.java	(revision 5550)
+++ java/com/l2jserver/Config.java	(working copy)
@@ -81,8 +81,10 @@
	public static final String GRANDBOSS_CONFIG_FILE = "./config/Grandboss.properties";
	public static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.properties";
	public static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
+


+	
	//--------------------------------------------------
	// L2J Variable Definitions
	//--------------------------------------------------
@@ -725,7 +727,16 @@
	public static int L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP;
	public static int L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP;
	public static TIntIntHashMap L2JMOD_DUALBOX_CHECK_WHITELIST;
+	public static int CUSTOM_PVP_REWARD_PROTECTION_RESET;
+	public static int CUSTOM_PVP_REWARD_PROTECTION;
+	public static boolean CUSTOM_PVP_PK_REWARD;
+	public static boolean CUSTOM_PVP_REWARD_ENABLED;
+	public static int CUSTOM_PVP_REWARD_MIN_LVL;
+	public static int CUSTOM_PVP_REWARD_ID;
+	public static int PVP_REWARD_A-beep-T;

+	
+	
	//--------------------------------------------------
	// NPC Settings
	//--------------------------------------------------
@@ -2246,7 +2257,14 @@

					L2JMOD_ENABLE_WAREHOUSESORTING_CLAN = Boolean.valueOf(L2JModSettings.getProperty("EnableWarehouseSortingClan", "False"));
					L2JMOD_ENABLE_WAREHOUSESORTING_PRIVATE = Boolean.valueOf(L2JModSettings.getProperty("EnableWarehouseSortingPrivate", "False"));
-					
+					CUSTOM_PVP_REWARD_PROTECTION_RESET = Integer.parseInt(L2JModSettings.getProperty("CustomPvpRewardProtectionReset", "0"));
+					CUSTOM_PVP_REWARD_PROTECTION = Integer.parseInt(L2JModSettings.getProperty("CustomPvpRewardProtection", "2"));
+					CUSTOM_PVP_PK_REWARD = Boolean.parseBoolean(L2JModSettings.getProperty("CustomPvpPkReward", "true"));
+					CUSTOM_PVP_REWARD_ENABLED = Boolean.parseBoolean(L2JModSettings.getProperty("CustomPvpRewardEnabled", "true"));
+					CUSTOM_PVP_REWARD_MIN_LVL = Integer.parseInt(L2JModSettings.getProperty("CustomPvpRewardMinLvl", "1"));
+					CUSTOM_PVP_REWARD_ID = Integer.parseInt(L2JModSettings.getProperty("CustomPvpRewardItemId", "6392"));
+					PVP_REWARD_A-beep-T = Integer.parseInt(L2JModSettings.getProperty("CustomPvpRewardA-beep-t", "1"));
+
					if (TVT_EVENT_PARTICIPATION_NPC_ID == 0)
					{
						TVT_EVENT_ENABLED = false;

 

had a problem here

 

 

if(kills_today <= Config.CUSTOM_PVP_REWARD_PROTECTION){

if(victim.checkAntiFarm(killer)){

addItemRewardForKiller(killer, victim);

}

}else{

if((Config.CUSTOM_PVP_PK_REWARD)&&(killer.getKarma() == 0)){

 

so i changed for

 

if(kills_today <= Config.CUSTOM_PVP_REWARD_PROTECTION){

if(killer !=null){

addItemRewardForKiller(killer, victim);

}

}else{

if((Config.CUSTOM_PVP_PK_REWARD)&&(killer.getKarma() == 0)){

 

in l2pcinstance isnothing about "checkAntiFarm"

Posted

About:

checkAntiFarm(player);

 

This method is in L2jFrozen core. In other projects should exists other methods to check anti farm for players (like same IP, etc).

 

Posted

if(kills_today <= Config.CUSTOM_PVP_REWARD_PROTECTION){

if (AntiFeedManager.getInstance().check(killer, victim)){

addItemRewardForKiller(killer, victim);

}

}else{

 

or maybe am i wrong

Posted

Hello, today i want present new features in my system:

+ Rank Points

+ Player Ranks

 

INFO: All files are in cprs_1.5.rar, in attachment.

It's compatible with L2jFrozen rev.948, for other needed some work, but DB core is universal :D

 

Screen:

50656140049330477517.jpg

 

Config file:

#------------------------------------
#- 	  Custom PvP Reward System	    -
#------------------------------------
# INFO: For better system view disable this option:
# EnablePkInfo = False

# Enable Custom Pvp Reward System
CustomPvpRewardEnabled = False

# If the same player to kill, then after X times the reward Will not Increase (0 - Disabled)
CustomPvpRewardProtection = 0

# If the same player to kill, then after X times the reward Will not Increase, 
# but it can be reset every Y portion of time (in minutes) from first daily kill (0 - disabled).
# It's reset only daily kills counter.
# Default: 1440, Preferred: 1440 [24h].
# INFO: Used in Rank System too.
CustomPvpRewardProtectionReset = 1440

# Reward item id
CustomPvpRewardItemId = 6392
# Reward item amount
CustomPvpRewardAmmount = 1

# Minimum player level to obtain reward.
CustomPvpRewardMinLvl = 1

# Gives reward for kill PK player
CustomPvpPkReward = true

#------------------------------------------------
# Enable Ranks. 								-
#------------------------------------------------
# INFO: CustomPvpRewardEnabled can be disabled.
CustomPvpRankEnabled = false

# Rank names (first element is the best):
# Format: name1,name2,name3
# Example: CustomPvpRankName = God finger,Mass killer,Killer,No Rank
CustomPvpRankName = Rank 1,Rank 2,Rank3

# INFO: Be careful with points. MySql database allow DECIMAL(20) total rank_points.

# Rank require points (first element is points count for obtain 1st rank title, in example: God finger):
# Format: count1,count2,count3
# (count1 > count2 > count3) > 0
# Example: CustomPvpRankMinPoints = 10000,1000,400,1
# IMPORTANT: property elements count must be same like in CustomPvpRankName.
CustomPvpRankMinPoints = 300,100,50

# Example: For God finger kills reward is 100 points.
# Format: count1,count2,count3
# IMPORTANT: properties count must be same like in CustomPvpRankName.
CustomPvpRankPointsForKill = 100,30,15

# If the same player to kill, then after X times the points will not increase (0 - Disabled).
# If CustomPvpRankFarmProtect = 3, then it return 0 Rank Points for kill 4 time the same player.
CustomPvpRankFarmProtect = 0

# Enable other points counting for players.
# If enabled CustomPvpRankPointsForKill is ignored.
# Example: CustomPvpRankKillPointsDown = 100,50,10,1,0
# For first daily kill awards 100, 2nd kill give 50, ... , 0.
CustomPvpRankKillPointsDownEnabled = false
CustomPvpRankKillPointsDown = 100,50,10,1,0

# Shout current Points info to killer & victim.
CustomPvpRankShoutInfo = true

# Enable Rank Points for kill innocent players. (PK mode ON)
CustomPvpRankAwardPK = false

#------------------------------------ 

 

PS. Thx for using ;)

 

PS. Sorry for english in code but i am from poland :D

 

Download:

http://www64.zippyshare.com/v/72548404/file.html

 

http://www.4shared.com/rar/-TWIDSTU/cprs_15.html

 

Posted

Fixed: wrong victim name in info message.

Added: Minimum players level option for obtain Rank Points.

 

Links:

http://www.4shared.com/rar/ncjH-m92/cprs_16.html

http://www5.zippyshare.com/v/60558512/file.html

 

Guest
This topic is now closed to further replies.

×
×
  • Create New...