Jump to content
  • 0

I Stuck after targeting this npc,and after untargeting i can move again.


Question

Posted

[share]Paysafe Donation Manager Npc

 

 

/*
* 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 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("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 (!canTarget(player)) 
    {
      return;
    }
      showHtmlWindow(player);
  }

  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 quantity:</font></td><td><combobox width=80 height=17 var=quantity 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 $quantity $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\">Created by KnipeX (if he says so, huh)</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>Info goes here</center></body></html>");
		html.setHtml(tb.toString());
		activeChar.sendPacket(html);
  }
} 


  •  
    • I added the java code as it say's in the description
    • I Compiled and everything else
    • I put a npc with that type it ask's
    • I spawned it

But when i target it the player stuck's and i must remove the target to move,can anyone tell me why,and when i put paysafecard etc and press Donate,nothing happend's!

 

Can anyone tell me why?

Recommended Posts

  • 0
Posted

- onAction being overidden, it misses an ActionFailed packet.

- you should use getHtmPath and organize HTMs inside it rather than hardcoding HTMs with TextBuilder (which is, by the way, slower than StringBuilder).

- commands on onBypass... should be if / else if / else if (or switched, as Frozen uses JDK7 and you can switch over strings)

  • 0
Posted

- onAction being overidden, it misses an ActionFailed packet.

- you should use getHtmPath and organize HTMs inside it rather than hardcoding HTMs with TextBuilder (which is, by the way, slower than StringBuilder).

- commands on onBypass... should be if / else if / else if (or switched, as Frozen uses JDK7 and you can switch over strings)

As i told you my english knowledge is limited,so i didn't understand anything about what did you just said :P

Can you help me via teamviewer about it? Also my java knowledge's are also limited too,so i don't know nothing more from adding a code.

  • 0
Posted

I don't help people via TV, that's not helping ppl to make what they should do by themselves.

 

You know the story about hungry man, fishpole and fishes, right ? I prefer to give fishpole rather than fishes to an hungry man, because I'm not a bird mom assisting his babies giving food everyday.

 


 

I gave you an answer, so now seek infos about ActionFailed packet. The miss of that packet on onAction make you stuck. You can also compare existing onAction, as probably all other are correctly working and see by yourself about what I'm talking about.

 

And use Google translate if your english sucks so bad, and continue to read english forums. I'm not english aswell, and I learnt playing video games.

  • 0
Posted

Dude.. Tryskell allready told you what do to.. omg..

Just do do this

 

  @Override
  public void onAction(L2PcInstance player)
  {
    if (!canTarget(player)) 
    {
      return;
    }
      showHtmlWindow(player);
              player.sendPacket(ActionFailed.STATIC_PACKET);
  }

  • 0
Posted

Junk code has:

    Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();

    for (L2PcInstance gms : pls)

    {

    if(gms.isGM())

    gms.sendMessage(player.getName() +" sent a donation.");

    }

 

instead of:

 

for (L2PcInstance gm:AdminTable.getInstance().getAllGms(true))

{

if (gm.isOnline())

gm.sendMessage(player.getName()+" sent a donation");

}

 

with a quick glance spotted this, now imagine with an intensive look

 

Ontopic: Did you imported the actionfailed packet?

Guest
This topic is now closed to further replies.


  • Posts

    • Hello everyone I'm Albert, Starting now with the dream on have a L2 server, I'm having several issues with RS and I need someone help to Create an skill and implement to the correct class ID and make it work. Skill Required from me is  Festival Sweep  Skill or Item with the ability. I really need help guys and then after if possible i would need NPC and skins with .dressme        
    • Changeset 410 (3371)   Makers, NpcAi / Desires, Cursed Weapon rework, Bugfixes, Admincommands, Movement, Organization   Makers Fix ghost corpses. Introduce task manager for MultiSpawn spawn schedule. Introduce task managers for Npc respawn and despawn tasks. Add missing random treasurebox maker. NpcAi / Desires AttackableAttack > NpcAttack, allowing ATTACK_FINISHED event over Npc. Merge all reduceWeight from NpcAI operations. Don't broadcast MoveToPawn packet for cast hold scenarii. CH and CP managers use hold cast. Probably way more to add. Rework DesireQueue#addOrUpdate to avoid to generate a List. Drop _isInHitAnimation, avoid twice runAI calls upon attack end animation, save a ThreadPool. Implement Desire#isInvalid, used over the main loop to clean invalid Desires. All sided getDesires().removeIf are dropped, notably over AggroList/HateList. Cursed Weapon rework Fix potential task scheduling issues, reworking the whole layers. Reduce code by 1/3. Use L2OFF formulas/data for item drop rate, staging process. CW end duration now decreases when killing other Players. Bugfixes Revert schedule part from ThreadPool. Fix Pet inventory IU. Ty Denzel for the report. Fix Pet item timestamp reuse delay. Ty artemis for the fix. Disable automatic beastshots when his owner dies. Ty Root for the report. Player cannot craft while casting a skill, nor trade. Ty Root for the report. Add missing weight checks for player/summon pickup, and player craft. Ty Root for the report. Implement /graduatelist command, which displays a list of clan academy graduates for the past week. Ty RooT for the report. Fix PLAYING_FOR_LONG_TIME concept ; rest message is server related, not Player related. Ty RooT for the report. Player should stop movement when opening store. Fix Q351 occurences of itemId 4310 by 4407 one + slight fix. Fix Q365 missing memoState + poison skillId. Ty Root for the report. Fix Q417 Torai despawn over cond 11. Fix Q216 4 missing npcIds. Ty Karudin for the report. Fix the invalid comment of DeleteCharAfterDays Config. Fix NPC drop penalty level calculation. Ty Bandnentans for the report. Items are now dropped in a 30/45 donut shape around dropper. Ty Bandnentans for the report. PartyMatch fixes Don't show Party members or CW holder as available waiting members. You can't show overall List or join a PartyMatch room as CW holder. CW owner, upon acquisition, leave PartyMatch system. PartyMatch window is now automatically closed upon Player#removeMeFromPartyMatch. Remove Player from PartyMatch if Player and newly joined Party leader PartyMatch rooms differ. You can't join or be invited in a PartyMatch room if already partying/CW holding. Fix ShowLicence config when set to false. Ty artemis for the fix. Fix maximum number of macros. Ty artemis for the fix. Fix invalid IU update over //enchant. Ty artemis for the fix. Fix Castle Mass Gatekeeper HTMs. Ty kingNik0n for the fix. Drop _disabledItems implementation. Won't be used by next refactors. Ty artemis for the report. Fix loading handlers under debug. Ty Keku for the fix. Fix character_macroses table structure (commands = 12x32 chars minimum). Admincommands Merge all old spawn admincommands (//list_spawns, //spawn, //unspawnall, //respawnall, //delete) to //spawn and //unspawn (previously //delete). Generate //help. //unspawn works over all ASpawn. Merge all old fence admincommands (//spawnfence, //deletefence, //listfence) to //fence [add|remove], generate AdminFence. They now use proper Pagination. You can also teleport to it. Implementation of //show manor. Implementation of //set quest <id> [cond]. Related items must be hand-given. Implementation of //set henna [page] [add|remove symbolId]. The hennas are still bound to game logic (slots, canBeUsedBy). Movement - Ty LaRoja, Bandnentans Fix Boats IOOBE. Adapt getHeight logic from L2OFF. Introduce back WASD movement, handle boat board/unboard. Fix WATER/FLY movement logic. Avoid to pathfind diagonal cells with detected obstacle. Organization Addition of QuestVars class, holding all related variables from quests (itemIds, npcIds, questNames, sounds, etc), allowing to reduce length of each script while reusing variables. 100+ cloned variables were deleted. Refactor geometry package and Territory. Territory is now a unique 3D shape, holding any type of 2D geometry.  Remove few useless Location#clone uses. Implementation of ItemContainer#forEachItem. Clean many unused FrequentSkill. The whole enum is questionable. Drop MathUtil#checkIfInRange, implement WorldObject#isInStrictRadius (involve collision of that WorldObject, and potential WorldObject parameter). WorldObject#isIn2DRadius parameter is now a Point2D, not a Location (since a Location inherits Point2D, Location are still usable as parameter). Rework Pagination#generatePages to handle page number > 1000. Use Pagination over Tryskell SchemeBuffer. Ty CUCU23 for the share.
    • It's a custom instance used as Event not retail - like. You can re-create it easily.
    • GRAND OPENING TODAY !!! FROM - 16/05/2025, FRIDAY, 20:00 +3 GMT !
  • Topics

×
×
  • Create New...