Jump to content

Recommended Posts

Posted

Its simple,

Its an new instance,npc,there's box at its html and you write the name of char that you wish to vote for jail.

GM/Offline characters can not be voted by none.

At 50 votes,character get jail for 10min.

Here it is:

 

Made by www.i-code.us

 

Dp part:

### Eclipse Workspace Patch 1.0
#P vfs_dp
Index: datapack_development/sql/characters.sql
===================================================================
--- datapack_development/sql/characters.sql	(revision 6)
+++ datapack_development/sql/characters.sql	(working copy)
@@ -79,6 +79,8 @@
   clan_join_expiry_time DECIMAL(20,0) NOT NULL DEFAULT 0,
   clan_create_expiry_time DECIMAL(20,0) NOT NULL DEFAULT 0,
   death_penalty_level int(2) NOT NULL DEFAULT 0,
+  jailplayer varchar(35) default NULL,
+  jailvotes decimal(11,0) default NULL,
   PRIMARY KEY  (obj_Id),
   KEY `clanid` (`clanid`)
) ;
Index: datapack_development/data/html/jailmanager/65535.htm
===================================================================
--- datapack_development/data/html/jailmanager/65535.htm	(revision 0)
+++ datapack_development/data/html/jailmanager/65535.htm	(revision 0)
@@ -0,0 +1,11 @@
+<html>
+<title>Jail Manager Instance
+</title>
+<head>
+<tittle>
+<center>
+<br>
+CharName:<edit var="pname" width=50 height=20>
+<center><button value="Vote" action="bypass -h npc_%objectId%_voteJail $pname" width=204 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></center>
+</body>
+</html>
\ No newline at end of file

 

Core part:


### Eclipse Workspace Patch 1.0
#P vfs
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 6)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -89,7 +89,6 @@
import net.sf.l2j.gameserver.model.L2Character;
import net.sf.l2j.gameserver.model.L2Clan;
import net.sf.l2j.gameserver.model.L2ClanMember;
-import net.sf.l2j.gameserver.model.L2DropData;
import net.sf.l2j.gameserver.model.L2Effect;
import net.sf.l2j.gameserver.model.L2Fishing;
import net.sf.l2j.gameserver.model.L2HennaInstance;
@@ -205,6 +204,30 @@
  */
public final class L2PcInstance extends L2PlayableInstance
{
+	// Jail system.
+	private String jailplayer = null;
+	private int jailvotes = 0;
+	
+	public String getJailPlayer()
+	{
+		return jailplayer;
+	}
+	
+	public void setJailPlayer(String jailplayer)
+	{
+		this.jailplayer = jailplayer;
+	}
+	
+	public int getJailVotes()
+	{
+		return jailvotes;
+	}
+	
+	public void setJailVotes(int jailvotes)
+	{
+		this.jailvotes = jailvotes;
+	}
+	
	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=?";
@@ -215,8 +238,8 @@
	private static final String RESTORE_SKILL_SAVE = "SELECT skill_id,skill_level,effect_count,effect_cur_time, reuse_delay FROM character_skills_save WHERE char_obj_id=? AND class_index=? AND restore_type=? ORDER BY buff_index ASC";
	private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";

-    private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,in_jail=?,jail_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=? WHERE obj_id=?";
-    private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level FROM characters WHERE obj_id=?";
+    private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,in_jail=?,jail_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,jailplayer=?,jailvotes=? WHERE obj_id=?";
+    private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,jailplayer,jailvotes FROM characters WHERE obj_id=?";
     private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE char_obj_id=? ORDER BY class_index ASC";
     private static final String ADD_CHAR_SUBCLASS = "INSERT INTO character_subclasses (char_obj_id,class_id,exp,sp,level,class_index) VALUES (?,?,?,?,?,?)";
     private static final String UPDATE_CHAR_SUBCLASS = "UPDATE character_subclasses SET exp=?,sp=?,level=?,class_id=? WHERE char_obj_id=? AND class_index =?";
@@ -5597,6 +5620,9 @@
				player.setOnlineTime(rset.getLong("onlinetime"));
				player.setNewbie(rset.getInt("newbie")==1);
				player.setNoble(rset.getInt("nobless")==1);
+				
+				player.setJailPlayer(rset.getString("jailplayer"));
+				player.setJailVotes(rset.getInt("jailvotes"));

				player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
				if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
@@ -6061,7 +6087,9 @@
			statement.setLong(54, getClanCreateExpiryTime());
			statement.setString(55, getName());
			statement.setLong(56, getDeathPenaltyBuffLevel());
-            statement.setInt(57, getObjectId());
+			statement.setString(57, getJailPlayer());
+			statement.setInt(58, getJailVotes());
+            statement.setInt(59, getObjectId());

			statement.execute();
			statement.close();
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2JailNpcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2JailNpcInstance.java	(revision 0)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2JailNpcInstance.java	(revision 0)
@@ -0,0 +1,147 @@
+/* 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 2, 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package net.sf.l2j.gameserver.model.actor.instance;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.StringTokenizer;
+
+
+
+import net.sf.l2j.L2DatabaseFactory;
+import net.sf.l2j.gameserver.Announcements;
+import net.sf.l2j.gameserver.model.L2World;
+import net.sf.l2j.gameserver.templates.L2NpcTemplate;
+/**
+ *
+ * @author  www.i-code.us
+ */
+public class L2JailNpcInstance extends L2NpcInstance
+{
+	
+	public L2JailNpcInstance(int objectId, L2NpcTemplate template)
+	{
+		super(objectId, template);
+	}
+
+    @Override
+    public void onBypassFeedback(L2PcInstance player, String command)
+    {
+    	if (command.startsWith("voteJail"))
+    	{
+    		String val = command.substring(8);
+    		StringTokenizer st = new StringTokenizer(val);
+    		
+    		if (st.countTokens() > 1 || st.countTokens() < 1)
+    		{
+    			return;
+    		}
+    		
+    		if (player.getJailPlayer() != null)
+    		{
+    			player.sendMessage("You have already voted for a player, "+player.getJailPlayer()+".");
+    			return;
+    		}
+    		
+    		L2PcInstance target = L2World.getInstance().getPlayer(st.nextToken());
+    		
+    		if (target == null)
+    		{
+    			player.sendMessage("The player you requested to vote for does not exist or is not online.");
+    			return;
+    		}
+    		if (target.isInJail())
+    		{
+    			player.sendMessage("The player you requested to vote for is already in jail.");
+    			return;
+    		}
+    		
+    		if (target.getAccessLevel() > 99)
+    		{
+    			player.sendMessage("The player you requested to vote is GM/ADMIN you cant vote for them");
+    			return;
+    		}
+    		
+    		if (target.getPvpFlag() > 0)
+    		{
+    			player.sendMessage("The player you requested to vote is Pvping now,try later");
+    			return;
+    		}
+    		
+    		
+    		target.setJailVotes(target.getJailVotes()+1);
+    		player.sendMessage("You have successfully voted for "+target.getName()+".");
+    		target.sendMessage(player.getName()+" has voted for you to go in jail.");
+    		if (target.getJailVotes() == 50)
+    		{
+    			target.setInJail(true, 10);
+    			Announcements.getInstance().announceToAll(target.getName()+" has been jailed for 10 minutes, after reaching 50 jail votes.");
+    			target.setJailVotes(0);
+    			cleanDatabase(target.getName());
+    			target.sendMessage("You have been jailed for 10 minutes because you reached 50 jail votes.");
+    		}
+    	}
+    }
+    
+    private void cleanDatabase(String pname)
+    {
+    	Connection con = null;
+    	try
+    	{
+    		con = L2DatabaseFactory.getInstance().getConnection();
+    		PreparedStatement st = con.prepareStatement("UPDATE characters SET jailplayer=null WHERE jailplayer="+pname);
+    		st.execute();
+    		st.close();
+    	}
+    	catch (SQLException sqle)
+    	{
+    		for (L2PcInstance gm : L2World.getInstance().getAllGMs())
+    		{
+    			gm.sendMessage("There was a problem while updating database on jailplayer column. Please check it...");
+    		}
+    	}
+    	finally
+    	{
+    		try
+    		{
+    			con.close();
+    		}
+    		catch (SQLException sqle2)
+    		{ 
+    			
+    		}
+    	}
+    }
+    
+    @Override
+	public String getHtmlPath(int npcId, int val)
+    {
+        String pom = "";
+        if (val == 0)
+        {
+            pom = "" + npcId;
+        }
+        else
+        {
+            pom = npcId + "-" + val;
+        }
+
+        return "data/html/jailmanager/" + pom + ".htm";
+    }
+}
\ No newline at end of file

 

You can also find it here

Posted

its kinda useless , what is the point of jailing character with out any reason

there will be hateness then....

I thought the same when someone suggest it to me.Then i thought,it wont be so useless e.g

if someone says noobserver or something or dunno,and gm is offline players can vote for jail xd

 

Posted

I thought the same when someone suggest it to me.Then i thought,it wont be so useless e.g

if someone says noobserver or something or dunno,and gm is offline players can vote for jail xd

 

its online 10 minutes dude

Posted

st.countTokens() > 1 || st.countTokens() <

st.countTokens() != 1 looks better

 

if (player.getJailPlayer() != null)

+     {

+     player.sendMessage("You have already voted for a player, "+player.getJailPlayer()+".");

+     return;

+     }

this is useless coz player.setJailPlayer isnt used anywhere and you would need to make it null in some moment so there wont be something like they can vote for jail only once forever

 

Anyway saving vote count is useless, if 1 guy would start making bots, sooner or later he would jail that player, better to make list which would contain votes just untill restart, same with jailplayer.

 

Also you can make restrictions for level etc

Also its possible to jail player that is on olympiad or such kind of shi ts

 

Also what if there is siege, whole clan is voting for enemy clan leader?

Or just hero is writing on hero chat to vote for some1 :)

 

Its not that stupid, just need to work on it a little bit :)

 

 

Edit: :S Fanky, i thought you can code something better and share it with us :)

Posted

In one point you'r true,also as I said above

Ehm ><

Anyway,I know it may be useless but with some edits on it could be ok xd

anyway,thanks

.

and no,there's not any protection about IP.

But I'am thinking to add a protection,if a char didnt got 24 hours online he cant vote,or something like that.

Also yes vampir,some checks are missing.

 

 

 

Edit: :S Fanky, i thought you can code something better and share it with us :)

I think i can but,gimme one reason to do it.

Anyway,thanks.Also do you really think that peoples respect other peoples work here?

Ofc not,btw

 

EDIT: dont forget that,that's just a based idea.I think its funny xd.Anyway,its just a gift,a guy with decent knoweldge can edit this npc however he wants.A

 

Posted

Ofc nobody respect other's ppl work here, nice share isnt counting for me...

You could share some things for same reason as i did, get some karma and get known, many ppl are pming me nowadays to create something for them so it wont be problem later for me to work for money :)

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...