Jump to content

Recommended Posts

Posted (edited)

Hello i am re-sharing PSC donation instant npc (not because it not shared anymore) but because i "fix" the target problem.

 

The original post i think is this(credits in the end of post)  click me

 

So..

 

1)Create a new instant in head-src/com/l2jfrozen/gameserver/more/actor/instance with name L2PscDonateInstance.java

and then paste the code inside (tip:you can edit your text just find in code the examples "text" "text1" "text2")

                                                       (tip2:you can edit the location of the .txt file for example String fname = "data/donates/"+player.getName()+".txt";)

*
 * 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.l2jfrozen.gameserver.model.actor.instance;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.Collection;
import java.util.StringTokenizer;

import com.l2jfrozen.gameserver.model.L2World;
import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
import com.l2jfrozen.gameserver.ai.CtrlIntention;
import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;

import javolution.text.TextBuilder;

/**
 * @author Autos! 1-0
 *
 */
public class L2PscDonateInstance extends L2FolkInstance
{
	
	
	public L2PscDonateInstance(int objectId, L2NpcTemplate template)
	{
		super(objectId, template);
	
	}

	@Override
	public void onBypassFeedback(final L2PcInstance player, String command)
	  {
		      if(player == null)
		      {
		         return;
		      }
		      
		      if(command.startsWith("donate"))
		      {
		    	  StringTokenizer st = new StringTokenizer(command);
		    	  st.nextToken();
		    	  String amount = null;
		    	  int pin1 = 0;
		    	  int pin2 = 0;
		    	  int pin3 = 0;
		    	  int pin4 = 0;
		    	  String message = "";
		    	  
		    	  try
		    	  {
		    		 amount = st.nextToken();
		    		 pin1 = Integer.parseInt(st.nextToken());
		    		 pin2 = Integer.parseInt(st.nextToken());
		    		 pin3 = Integer.parseInt(st.nextToken());
		    		 pin4 = Integer.parseInt(st.nextToken());
		    		 while(st.hasMoreTokens())
		    			 message = message + st.nextToken() + " ";
		    		 
		    		 String fname = "data/donates/"+player.getName()+".txt";
		    		 File file = new File(fname);
		    		 boolean exist = file.createNewFile();
		    		 if(!exist)
		    		 {
		    		     player.sendMessage("This is the text which when a player have allready send a donation try to do again without admin check the first one");
		    		     return;
		    		 }
		    		 FileWriter fstream = new FileWriter(fname);
		    		 BufferedWriter out = new BufferedWriter(fstream);
		    		 out.write("Character Info: [Character: "+ player.getName() +"["+ player.getObjectId()+"] - Account: "+ player.getAccountName()+" - IP: "+player.getClient().getConnection().getInetAddress().getHostAddress()+"]\nMessage : donate "+ amount +" "+ message + " "+ pin1+ " "+ pin2+ " "+ pin3+ " "+ pin4);
		    		 out.close();
		    		 player.sendMessage("Thank you for the donation<-This is while a player send a donation");
		    		 
		    		 Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
		    			 for (L2PcInstance gms : pls)
		    				{
		    				 	if(gms.isGM())
		    				 	gms.sendMessage(player.getName() +" sent a donation.<-This is when a player send a donation admin get a pm . ");
		    				}
		    	  }
		    	  catch(Exception e)
		    	  {
		    		  e.printStackTrace();
		    	  }
		      }
		      
	  }
	
	  @Override
		public void onAction(final L2PcInstance player)
		{
			if (!canTarget(player))
				
			player.setLastFolkNPC(this);
			
			// Check if the L2PcInstance already target the L2NpcInstance
			if (this != player.getTarget())
			{
				// Set the target of the L2PcInstance player
				player.setTarget(this);
				
				// Send a Server->Client packet MyTargetSelected to the L2PcInstance player
				MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
				player.sendPacket(my);
				my = null;
				
				// Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
				player.sendPacket(new ValidateLocation(this));
				
				
			}
			else
			{
				// Calculate the distance between the L2PcInstance and the L2NpcInstance
				if (!canInteract(player))
				{
					// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
					player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
					  showHtmlWindow(player);

				}
                        showHtmlWindow(player);
			}
			// Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
			player.sendPacket(ActionFailed.STATIC_PACKET);
			

			
		}
	  
	  private void showHtmlWindow(L2PcInstance activeChar)
	  {
			TextBuilder tb = new TextBuilder();
			NpcHtmlMessage html = new NpcHtmlMessage(1);
			        
			tb.append("<html><head><title>Instant Donation</title></head><body><center><table width=\"250\" bgcolor=\"000000\"><tr><td align=center><font color=\"6fd3d1\">Donate now online</font></td></tr></table>_______________________________________<br><br><table width=\"250\"><tr><td><font color=\"ddc16d\">Select Donation Amount:</font></td><td><combobox width=80 height=17 var=amount list=10-Euro;25-Euro;50-Euro;100-Euro;></td></tr></table><br><br><font color=\"ddc16d\">Paysafe Card Pin:</font><table width=\"250\"><tr><td><edit var=\"pin1\" width=50 height=12 type=number></td><td><edit var=\"pin2\" width=50 height=12 type=number></td><td><edit var=\"pin3\" width=50 height=12 type=number></td><td><edit var=\"pin4\" width=50 height=12 type=number></td></table><br><br><multiedit var=\"message\" width=240 height=40><br><br><button value=\"Donate!\" action=\"bypass -h npc_"+getObjectId()+"_donate $amount $pin1 $pin2 $pin3 $pin4 $message\" width=95 height=21 back=\"bigbutton_over\" fore=\"bigbutton\"><br></center></body></html>");
			        
			html.setHtml(tb.toString());
			activeChar.sendPacket(html);
			
	  }

	
}

Then go to your database,open custom_npc table

create new line,put the npc_id who you prefer (but make sure to be type:L2PscDonate)

 

Enjoy :D

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Credits:Ponyrides as the friend said below

ponyrider is the first who create this and i think he have posted somewhere 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Edited by L2LostWard
Posted (edited)

Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
for (L2PcInstance gms : pls)
{
	if(gms.isGM())
		gms.sendMessage(player.getName() +" sent a donation.<-This is when a player send a donation admin get a pm . ");
}

There is GmListTable for that.

 

https://www.assembla.com/spaces/L2jFrozenInterlude/subversion/source/HEAD/gameserver/trunk/head-src/com/l2jfrozen/gameserver/datatables/GmListTable.java

 

GmListTable.broadcastMessageToGMs(player.getName() + " sent a donation.");

--------------

 

onAction can be dropped entirely, showHtmlWindow can be renamed showChatWindow with a Override. HTM should be called from HtmCache and put on datapack, atm you regenerate it each time you use your NPC.

 

----------------

 

You forget to fstream.close() which is a potential ressource leak.

 

---------------------

if(!exist)
 {
           player.sendMessage("This is the text which when a player have allready send a donation try to do again without admin check the first one");
           return;
}

is probably wrong for numerous points : it returns false if the file is already created, so what happens if the same player donates twice ? And you don't want to send such messgae to player, it's not the point of player to get administration messages.

 

-------------------

                  while(st.hasMoreTokens())
                      message = message + st.nextToken() + " ";

Performance wise, it's probably really, really fucked up.

---------------

              String amount = null;
              int pin1 = 0;
              int pin2 = 0;
              int pin3 = 0;
              int pin4 = 0;
              String message = "";

Pointless to set default values, simply merge them with uses. That saves you 6 lines.

Edited by Tryskell
Posted

We are in 2016, still this code... 

really how many times this code has been shared? 3.250? or 3.251 i lost count ..

screw you humanity you aint gonna die :'(

so what????????????????

Posted (edited)

so what? ???? ???? ???? ???

Crawl back to your cave.. tomorrow i'll start share the same code over and over until you bleed from your fucking eyes :) :)

If you support the idea of re-share the same code without changes over and over and fill 1 page with them, then you're a code leecher nothing more

Edited by AccessDenied
Posted

Crawl back to your cave.. tomorrow i'll start share the same code over and over until you bleed from your fucking eyes :) :)

If you support the idea of re-share the same code without changes over and over and fill 1 page with them, then you're a code leecher nothing more

 

Well if ppl could AT LEAST share a cleaner code, that would go from 3251 to a single, valid, and not needed to edit, 1.

Posted

Well if ppl could AT LEAST share a cleaner code, that would go from 3251 to a single, valid, and not needed to edit, 1.

tryskell screw share,, i can make a version of it with 5 lines clean the problem is not the code but the fact that they re-share something that already mademore than 3 times. i had a fast search and there are 7 topics about paypal only in maxcheaters.. lets no talk about other forums

Posted (edited)

-AccessDenied  i can make a version of it with 5 lines clean

So when you have time to do that you can post it here to avoid 3252 .. or send me msg and i will update this one :) thanks .. 

Edited by L2LostWard
Posted

-AccessDenied  i can make a version of it with 5 lines clean

So when you have time to do that you can post it here to avoid 3252 .. or send me msg and i will update this one :) thanks .. 

Seriously i doubt if you can even open an external jar into eclipse why the hell u even talk to me? In the begin i just trolled the whole forum but now i just see

90% of people are low IQ..  u didnt even make the code or u didnt even change anything u just copy paste... u didnt fix anything 

Posted

thanks for fix. :)

Mwro mou gluko what you mean "thank for fix" :DDD he didnt fix anything at all he is just a wannabe "php, java, c++, ajax, json," <3 i love you

also still searching for Stacy's legs photos

Posted

Well AcessDenied i never told i know how to code and also i never told i create this code i just fix the target compare the previus code and this one and see the difference..

Also you spam in my topic about my picture like i give you the right to talk about that .. no i am not a php,java or whatever you think developer i am just start do thinks with eclipse and until now i dont rly know many things but my skills while time past is better .. ok?

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.



  • Posts

    • hello everyone! I am wanting to save the files (Ini. - Data - ) of the EP5 Client: Salvation... But they generate the error "corrupt files"... I tried several versions of L2FileEditor without good results. I need help! Thank you!
    • Opening December 6th at 19:00 (GMT +3)! Open Beta Test from November 30th!   https://l2soe.com/   🌟 Introducing L2 Saga of Eternia: A Revolution in Lineage 2 High Five! 🌟   Dear Lineage 2 enthusiasts, Prepare to witness the future of private servers! L2 Saga of Eternia is not just another High Five project—it’s a game-changing experience designed to compete with the giants of the Lineage 2 private server scene. Built for the community, by the community, we’re here to raise the bar in quality, innovation, and longevity. What Sets Us Apart? 💎 No Wipes, Ever Say goodbye to the fear of losing your progress. Our server is built to last and will never close. Stability and consistency are our promises to you. ⚔️ Weekly New Content Our dedicated development team ensures fresh challenges, events, and updates every week. From custom quests to exclusive features, there will always be something exciting to explore. 💰 No Pay-to-Win Skill and strategy matter most here. Enjoy a balanced gameplay environment where your achievements come from effort, not your wallet. 🌍 A Massive Community With 2000+ players expected, join a vibrant and active community of like-minded adventurers ready to conquer the world of Aden. 🏆 Fair and Competitive Gameplay Our systems are designed to promote healthy competition while avoiding abusive mechanics and exploits. 🔧 Professional Development From advanced bug fixes to carefully curated content, we pride ourselves on smooth performance, no lag, and unparalleled server quality. Key Features Chronicle: High Five with unique interface Rate: Dynamic x10 rates Class Balance: Carefully fine-tuned for a fair experience PvP Focused: PvP Ranking & aura display effect for 3 Top PvPers every week Custom Events: Seasonal and permanent events to keep you engaged Additional Features:   Custom Endgame Content: Introduce unique dungeons, raids, or zones unavailable in other servers. Player-Driven Economy: Implement a strong market system and avoid overinflated drops or rewards. Epic Siege Battles: Announce special large-scale sieges and PvP events. Incentives for Streamers and Clans: Attract influencers and big clans to boost server publicity. Roadmap Transparency: Share a public roadmap of planned updates to build trust and excitemen   Here you can read all the features: https://l2soe.com/features   Video preview: Join the Revolution! This is your chance to be part of something legendary. L2 Saga of Eternia is not just a server; it’s a movement to redefine what Lineage 2 can be. Whether you’re a seasoned veteran or a newcomer to the world of Aden, we invite you to experience Lineage 2 at its finest.   Official Launch Date: December 6th 2024 Website: https://l2soe.com/ Facebook: https://www.facebook.com/l2soe Discord: https://discord.com/invite/l2eternia   Let’s build the ultimate Lineage 2 experience together. See you in-game! 🎮
    • That's like a tutorial on how to run l2 on MacOS Xd but good job for the investigation. 
    • small update: dc robe set sold   wts adena 1kk = 1.5$ 
    • DISCORD : utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/hood-services https://campsite.bio/utchihaamkt
  • Topics

×
×
  • Create New...