Jump to content

Question

Posted (edited)

Hello i have this code who include's html .. 

Well i want to take away the html from code because i want to make one AIO npc you will have this code+some other thinks but if html is on code is impossible

So i want take out the code .. code is :

/*
 * 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.NoSuchElementException;
import java.util.StringTokenizer;

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


import javolution.text.TextBuilder;

/**
 * @author
 *
 */
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("dlist"))
		      {
		    	  info(player);
		      }
		      
		      if(command.startsWith("donate"))
		      {
		    	  StringTokenizer st = new StringTokenizer(command);
		    	  st.nextToken();
		    	  String quantity = null;
		    	  int pin1 = 0;
		    	  int pin2 = 0;
		    	  int pin3 = 0;
		    	  int pin4 = 0;
		    	  String message = "";
		    	  
		    	  quantity = st.nextToken();
		    	  try
		    	  {
		    		  pin1 = Integer.parseInt(st.nextToken());
		    		  pin2 = Integer.parseInt(st.nextToken());
		    		  pin3 = Integer.parseInt(st.nextToken());
		    		  pin4 = Integer.parseInt(st.nextToken());
		    	  }
		    	  catch(NumberFormatException enf)
		    	  {
		    		  player.sendMessage("Enter a valid pin.");
return;
		    	  }
					
		    	  catch(NoSuchElementException enf)
		    	  {
		    		  player.sendMessage("Enter a valid pin.");
return;
		    	  }
		    	  
		    	  try
		    	  { 
		    		 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("You have already sent a donation , GMs must check it first");
		    		     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 "+ quantity +" "+ message + " "+ pin1+ " "+ pin2+ " "+ pin3+ " "+ pin4);
		    		 out.close();
		    		 player.sendMessage("Donation sent. GMs will check it soon. Thanks...");
		    		 
		    		 Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
		    			 for (L2PcInstance gms : pls)
		    				{
		    				 	if(gms.isGM())
		    				 	gms.sendMessage(player.getName() +" sent a donation.");
		    				}
		    	  }
		    	  catch(Exception e)
		    	  {
		    		  e.printStackTrace();
		    	  }

		      }
		      
	  }
	
	  @Override
	  public void onAction(L2PcInstance player)
	  {
		  if (this != player.getTarget())
			{
				player.setTarget(this);
				player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()));
				player.sendPacket(new ValidateLocation(this));
			}
			else if (isInsideRadius(player, INTERACTION_DISTANCE, false, false))
			{
				
				
				player.setLastFolkNPC(this);
				showHtmlWindow(player);
				player.sendPacket(ActionFailed.STATIC_PACKET);
			}
			else
			{
				player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
				player.sendPacket(ActionFailed.STATIC_PACKET);
			}

		  }
	    

	  
	
	  private void showHtmlWindow(L2PcInstance activeChar)
	  {
			TextBuilder tb = new TextBuilder();
			NpcHtmlMessage html = new NpcHtmlMessage(1);
			        
			tb.append("<html><head><title>Donation Manager</title></head><body><center><table width=\"250\" bgcolor=\"000000\"><tr><td align=center><font color=\"6fd3d1\">Easy Donation With Paysafe Card</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=5-Euro;10-Euro;15-Euro;20-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><button value=\"Donation List\" action=\"bypass -h npc_" + getObjectId() + "_dlist\" width=95 height=21 back=\"bigbutton_over\" fore=\"bigbutton\"><br><font color=\"a1df64\"></font></center></body></html>");
			        
			html.setHtml(tb.toString());
			activeChar.sendPacket(html);
	  }
	  
	  private void info(L2PcInstance activeChar)
	  {
			TextBuilder tb = new TextBuilder();
			NpcHtmlMessage html = new NpcHtmlMessage(1);
			        
			tb.append("<html><head><title>Donation Manager</title></head><body><center>blablabla<br><br><br><br><br><br><br><br>name</center></body></html>");
			html.setHtml(tb.toString());
			activeChar.sendPacket(html);
	  }
} 

I delete the tb.append line (html) 

I change the  html.setHtml(tb.toString()); to html.setFile("merchant/10000");

and i make htm file on Merhant/10000 (sorry for htm code mess but i copy/past it ...

<html><head><title>
Donation Manager</title></head>
<body><center><table width="250" bgcolor="000000">
<tr><td align=center>
<font color="6fd3d1">Easy Donation With Paysafe Card</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=5-Euro;10-Euro;15-Euro;20-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_%ObjectId%_donate $amount $pin1 $pin2 $pin3 $pin4 $message" width=95 height=21 back="bigbutton_over" fore="bigbutton"><br>
<button value="Donation List" action="bypass -h npc_"%ObjectId%"_dlist" width=95 height=21 back="bigbutton_over" fore="bigbutton"><br>
<font color="a1df64"></font></center></body>
</html>

Well the html work's fine but when i click Donate it doesnt work at all .. the normal is to send the psc pin on stat/donates .. but nothink .. not even players.message

 

I know is litlle difficult and huge but if you can help .. thanks 

Edited by L2LostWard

5 answers to this question

Recommended Posts

  • 0
Posted

Do you mean, you want to move hardcoded html from java file to .htm file?

If so:

- Create yourName.htm file in html/default(or any other folder you like)

- Paste html from java file, change \" to ", change " + getObjectId() + " to %objectId%

- Remove hardcoded html from java file, also remove html.setHtml(blabla); and add in there: html.setFile("default/yourName.htm");

  • 0
Posted

Replace "%ObjectId%" with %objectId% and check if Donation List button will work after that.

What pack are you using?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • You think you have good “l2j” files until you try running a low-rate server.   Saying “there’s not a single L2 server out there worth mentioning” just shows you probably only know the first 10 servers on voting sites, the same voting sites that owned by them. You call the forum dead, yet you’re here discussing your next projects… From my perspective, you don’t seem ready to run any L2 server in 2025. Around 70% of players are here for RMT or ask for payment just to bring their clan, and you really think the community cares about Premium or donations or files quality? The other 20% spend their time downloading and deleting servers all day, playing for one day, then quitting for whatever random reason. And finally, the last 10% are the only ones who actually play because they genuinely like your features, your server files, and your overall project. Good luck 🙂
    • I genuinely admire your bravery - in an age where AI can whip up something better in under a minute, you still stubbornly try to sell these "projects" of yours on a forum that’s been clinically dead for years. That’s no longer determination, that’s digital archaeology. I just can’t tell whether you’re actually trying to make money, or simply testing how much we can endure before we ask an AI to generate you some actual talent.   And ofc AI will make it for free, $220 saved.
    • I’m glad I’m not the only one who appreciates Maxthor’s involvement in group gay orgies, he can’t be bothered to reply to messages, but covering the entire forum in gay lights is absolutely no issue for him. As for the project - the forum is packed with feedback from the testers, the lads are spending every spare moment fixing even the tiniest typo in an NPC’s text. I’ll share the links as soon as I get the green light. Edit: I forgot to add that the GM recruitment will begin once the links are released. Three people will be accepted, and they’ll work in a three-shift rotation so that there’s always a GM available online.
    • Added: a brand-new default dashboard template. You can now add multiple game/login server builds. Full support for running both PTS & L2J servers simultaneously, with switching between them. Payment systems: added OmegaPay and Pally (new PayPal-style API). Account history now stores everything: donations, items delivered to characters, referrals, transfers between game accounts, and coin transfers to another master account. Personal Promo Code System: you can create a promo code and assign it to a user or promoter. When donating, a player can enter this promo code to receive bonus coins, and the promo code owner also receives a bonus — all fully configurable in the admin panel.     Look demo site: demo
    • One of best project i play last few years
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock