Jump to content
  • 0

Question

14 answers to this question

Recommended Posts

  • 0
Posted (edited)

Omg ... he want Donate NPC.... and he this called "SmartShop" cuz elfo named SmartShop

RLtuC.png

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

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.StringTokenizer;

import com.l2jfrozen.gameserver.ai.CtrlIntention;
import com.l2jfrozen.gameserver.datatables.sql.ItemTable;
import com.l2jfrozen.gameserver.network.SystemMessageId;
import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
import com.l2jfrozen.gameserver.network.serverpackets.CharInfo;
import com.l2jfrozen.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jfrozen.gameserver.network.serverpackets.SystemMessage;
import com.l2jfrozen.gameserver.network.serverpackets.UserInfo;
import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
import com.l2jfrozen.util.CloseUtil;
import com.l2jfrozen.util.database.L2DatabaseFactory;

import javolution.text.TextBuilder;

/**
 * 
 * @author Elfocrash
 *
 */

public class L2SmartMultisellInstance extends L2FolkInstance
{
  public L2SmartMultisellInstance(int objectId, L2NpcTemplate template)
  {
    super(objectId, template);
  }

  @Override
public void onBypassFeedback(L2PcInstance player, String command)
  {
         if(player == null)
         {
            return;
         }
         
         if(command.startsWith("buyItem "))
         {
        	String itemId = null;
        	StringTokenizer st = new StringTokenizer(command, " ");
        	 
        	while (st.hasMoreTokens())
        	{
        		itemId = st.nextToken();
        	}
        	
        	int id = Integer.parseInt(itemId);
        	
        	if(player.getInventory().getItemByItemId(getItemCostId(id)).getCount() >= getItemCostCount(id))
        	{
        		player.getInventory().destroyItemByItemId("delete", getItemCostId(id), getItemCostCount(id), player, null);
        		
			    L2ItemInstance item = null;		     
			    item = player.getInventory().addItem("Elfo", getItemId(id), 1, null, null);
			    item.setEnchantLevel(getItemEnchant(id));
			    
				// send packets
				InventoryUpdate iu = new InventoryUpdate();
				iu.addItem(item);
				player.sendPacket(iu);
				player.broadcastPacket(new CharInfo(player));
				player.sendPacket(new UserInfo(player));
			
				SystemMessage sm = new SystemMessage(SystemMessageId.YOU_PICKED_UP_S1_S2);
				sm.addItemName(item.getItemId());
				sm.addNumber(1);
				player.sendPacket(sm);
				iu = null;
        	}
        	else
        	{
        		player.sendMessage("You don't have enough items in order to buy this one");
        		return;
        	}
         }
        
  }

  @Override
	public void onAction(L2PcInstance player)
	  {
	    if (!canTarget(player)) {
	      return;
	    }
	
	    if (this != player.getTarget())
	    {
	      player.setTarget(this);
	
	      player.sendPacket(new MyTargetSelected(getObjectId(), 0));
	
	      player.sendPacket(new ValidateLocation(this));
	    }
	    else if (!canInteract(player))
	    {
	      player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
	    }
	    else
	    {
	    		showHtmlWindow(player);
	    }
	
	    player.sendPacket(new ActionFailed());
	  }

  private void showHtmlWindow(L2PcInstance activeChar)
  {
    NpcHtmlMessage nhm = new NpcHtmlMessage(5);
    TextBuilder tb = new TextBuilder("");
   
    tb.append("<html><head><title>Smart Shop</title></head><body>");
    tb.append("<center>");
    tb.append("<table width=\"250\" cellpadding=\"5\" bgcolor=\"000000\">");
    tb.append("<tr>");
    tb.append("<td width=\"45\" valign=\"top\" align=\"center\"><img src=\"L2ui_ch3.menubutton4\" width=\"38\" height=\"38\"></td>");
    tb.append("<td valign=\"top\"><font color=\"FF6600\">Smart Shop</font>"); 
    tb.append("<br1><font color=\"00FF00\">"+activeChar.getName()+"</font>, Here you can buy Enchanted Gear.</td>");
    tb.append("</tr>");
    tb.append("</table>");
    tb.append("</center>");
    tb.append("<center>");
    
    for(int i = 1; i<= getRowsCount(); i++)
    	tb.append("<br><a action=\"bypass -h npc_" + getObjectId() + "_buyItem " + i + "\">Item name: " + ItemTable.getInstance().getTemplate(getItemId(i)).getName() + " Enchant: +"+ getItemEnchant(i) + " Cost: " + getItemCostCount(i) + " " + ItemTable.getInstance().getTemplate(getItemCostId(i)).getName() + "</a>");
    
    tb.append("</center>");
    tb.append("<center>");
    tb.append("<img src=\"l2ui_ch3.herotower_deco\" width=256 height=32 align=center>");
    tb.append("<font color=\"FF6600\">By Elfocrash</font>"); 
    tb.append("</center>");
    tb.append("</body></html>");

    nhm.setHtml(tb.toString());
    activeChar.sendPacket(nhm);

    activeChar.sendPacket(new ActionFailed());
  }
  
  private int getRowsCount()
  {
      int rows = 0;
      Connection con = null;
      try
      {
              con = L2DatabaseFactory.getInstance().getConnection();
                 
              PreparedStatement statement = con.prepareStatement("SELECT * FROM smart_shop");
              
              ResultSet rset = statement.executeQuery();
              while (rset.next())
              {
                  rows++;
              }
  			rset.close();
  			statement.close();
                  
      }
		catch(Exception e)
		{
			e.printStackTrace();
		}finally{
			CloseUtil.close(con);
			con = null;
		}
      return rows;
      
  }
  
  private int getItemId(int itemId)
  {
      int itemIdd = 0;
      Connection con = null;
      try
      {
              con = L2DatabaseFactory.getInstance().getConnection();
                 
              PreparedStatement statement = con.prepareStatement("SELECT item_id FROM smart_shop WHERE id=?");
              statement.setInt(1, itemId);
              
              ResultSet rset = statement.executeQuery();
              while (rset.next())
              {
            	  itemIdd = rset.getInt("item_id");
              }
    			rset.close();
      			statement.close();
                  
      }
		catch(Exception e)
		{
			e.printStackTrace();
		}finally{
			CloseUtil.close(con);
			con = null;
		}
      return itemIdd;
      
  }
  
  private int getItemCostId(int costid)
  {
      int costIt = 0;
      Connection con = null;
      try
      {
              con = L2DatabaseFactory.getInstance().getConnection();
                 
              PreparedStatement statement = con.prepareStatement("SELECT cost_item_id FROM smart_shop WHERE id=?");
              statement.setInt(1, costid);
              
              ResultSet rset = statement.executeQuery();
              while (rset.next())
              {
            	  costIt = rset.getInt("cost_item_id");
              }
    			rset.close();
      			statement.close();
                  
      }
		catch(Exception e)
		{
			e.printStackTrace();
		}finally{
			CloseUtil.close(con);
			con = null;
		}
      return costIt;
      
  }
  
  private int getItemCostCount(int costid)
  {
      int costIt = 0;
      Connection con = null;
      try
      {
              con = L2DatabaseFactory.getInstance().getConnection();
                 
              PreparedStatement statement = con.prepareStatement("SELECT cost_item_count FROM smart_shop WHERE id=?");
              statement.setInt(1, costid);
              
              ResultSet rset = statement.executeQuery();
              while (rset.next())
              {
            	  costIt = rset.getInt("cost_item_count");
              }
    			rset.close();
      			statement.close();
                  
      }
		catch(Exception e)
		{
			e.printStackTrace();
		}finally{
			CloseUtil.close(con);
			con = null;
		}
      return costIt;
      
  }
  
  private int getItemEnchant(int id)
  {
      int itemEnch = 0;
      Connection con = null;
      PreparedStatement statement = null;
      try
      {
              con = L2DatabaseFactory.getInstance().getConnection();
                 
              statement = con.prepareStatement("SELECT item_enchant FROM smart_shop WHERE id=?");
              statement.setInt(1, id);
              
              ResultSet rset = statement.executeQuery();
              while (rset.next())
              {
            	  itemEnch = rset.getInt("item_enchant");
              }
    			rset.close();
      			statement.close();
                  
      }
		catch(Exception e)
		{
			e.printStackTrace();
		}finally{
			CloseUtil.close(con);
			con = null;
		}
      return itemEnch;
      
  }

}
Edited by T9Text
  • 0
Posted

SmartShop - you talk to the npc and it's giving you everything you have in your mind. Sort of a Witcher, your wish list comes true.

  • 0
Posted

SmartShop - you talk to the npc and it's giving you everything you have in your mind. Sort of a Witcher, your wish list comes true.

what the.. how i suppose to make that when i dont know what they need 

 

 

are you trolling ?  :troll:

  • 0
Posted

I need a Donation Npc with Donate Coin. Example : For +16 weapon required donate coin,but i can't make to give from a ingredient a weapons/armors ++.

This is all,Help me Tnk's.

  • 0
Posted

I thought "Smart Shop" can be achieved by adding a class and / or mage / fighter detection so the shop offers only the proper equipment. :lol:

For example: You are Hawkeye, so the shop shows you only bows, arrows, soul shots etc.

I've done something like that in the past, using python... unfortunately some people think that Java's syntax is better than Python and writing 50 lines of code instead of 20 is something cool, so Jython is gone! :P

  • 0
Posted (edited)

A SQL table for 4 static entries ? No static HTM ? A connection each time you want the price, itemid, etc ? Omg where is the respect.

 

Don't use thisssssssss, I beg you. Do a static int[][] array, one static HTM and you can erase 80% of the code. Even the overriden onAction is useless. It's probably 2011 Elfocrash. 2015 Elfocrash would probably facepalm.

Edited by Tryskell
  • 0
Posted

A SQL table for 4 static entries ? No static HTM ? A connection each time you want the price, itemid, etc ? Omg where is the respect.

 

Don't use thisssssssss, I beg you. Do a static int[][] array, one static HTM and you can erase 80% of the code. Even the overriden onAction is useless. It's probably 2011 Elfocrash. 2015 Elfocrash would probably facepalm.

 

[share]Smart Enchanted Item Shop « on: January 17, 2013, 05:26:55 PM »
  • 0
Posted

 


The values and the stuff must be set in the database. (To bored to code an ingame edit environment)

 

Right :troll:

 

Locked.

Guest
This topic is now closed to further replies.


  • Posts

    • Fresh "White" Liquidity. Reserve Update.   ✔ Many ask about the origin of our funds and whether "tainted" assets get recycled within the service. Let’s be clear: we are not a tumbler. We don’t cycle your own coins back to you.   ✔ We’ve replenished our reserves with primary liquidity sourced from mining operations and OTC desks. To verify the status, we maintain volume processed through major platforms (direct withdrawals from Exchange accounts). For those requiring virgin purity - we provide cold storage reserves.   ✔ The fate of your "tainted" coins is entirely our concern. What happens to your crypto after the swap is no longer your business.   ✔ This is the definitive solution for Tier-1 exchange deposits (Binance, Coinbase), cashing out, or settling real-world transactions where a clean on-chain history is mandatory. In 2026, even the slightest suspicion leads to immediate freezes.   ✔ We do not handle small-cap volumes. Respect our time and yours.
    • I'll upload new updates to SVN tomorrow, I've been a bit busy :=)
    • I’ve been playing with LLM-driven autofarm bots too, and giving them some visual cues made a big difference. I ended up using art pieces from https://allcorrectgames.com/service/game-art/ as placeholders while training my detection prompts, and it actually helped the models parse scenes more reliably. If you add a bit of lightweight state tracking on top, your fake players start behaving way more naturally.
    • Roblox has become one of the world’s most influential user‑generated gaming platforms, attracting millions of players and creators every day. What makes Roblox unique is that it is not just a place to play games—it is a place where anyone can build their own. With Roblox Studio, even complete beginners can design immersive worlds, interactive experiences, and full‑fledged games. This guide will walk you through the essential steps to create your first Roblox game, while also helping you understand how features like Roblox Robux fit into the creator ecosystem.       1. What Is Roblox Studio and Why Use It? Roblox Studio is the official development environment used to create every game on the platform. It is free, accessible, and designed for creators of all skill levels. Whether you want to build a simple obstacle course or a complex simulation game, Roblox Studio provides the tools you need. The platform’s success comes from its user‑generated content model. Players can create games, publish them, and even earn Roblox Robux through in‑game purchases, game passes, or developer products. While earning Robux is not the focus for beginners, understanding its role can motivate you to improve your creations over time.   2. Setting Up Roblox Studio Before you start building, you need to install and set up Roblox Studio. Steps to get started Download Roblox Studio from the official Roblox website. Install and open the application. Log in using your Roblox account. Choose a template or start with a blank Baseplate. For beginners, templates like Obby, Village, or Racing provide a structured starting point. They include pre‑built elements that help you learn how different parts of a game work.   3. Understanding the Interface Roblox Studio may look overwhelming at first, but each panel has a clear purpose. Learning the interface early will make your development process smoother. Key panels Explorer: Shows all objects in your game world. Properties: Displays editable settings for selected objects. Viewport: The 3D workspace where you build your world. Toolbox: Contains free models, scripts, and assets. Home / Model / Test tabs: Provide tools for building, editing, and testing. Spend a few minutes clicking around, selecting objects, and adjusting their properties. This hands‑on exploration helps you understand how everything fits together.   4. Building Your First Game World Once you’re familiar with the interface, it’s time to start building. Using Parts Roblox Studio uses “Parts” as the basic building blocks. You can insert: Blocks Spheres Cylinders Wedges These can be resized, rotated, and moved to create platforms, walls, buildings, or obstacles. Using the Toolbox The Toolbox allows you to drag pre‑made assets into your game. This is extremely helpful for beginners, but choose assets carefully. Some community models include unnecessary scripts that may affect performance. Look for items marked as “Verified” or created by trusted developers. Organizing Your Workspace As your game grows, organization becomes important. Use folders in the Explorer panel to group objects logically: “Obstacles” “SpawnPoints” “Decorations” Good organization saves time and prevents confusion later.   5. Adding Gameplay with Scripts Roblox games use Lua, a beginner‑friendly scripting language. You don’t need to be a programmer to start, but learning basic scripting will greatly expand what you can create. Simple scripts you can try Making a part disappear when touched Creating a moving platform Adding checkpoints Giving players speed boosts Here’s a simple example: a script that prints a message when a player touches a part. Lua: local part = script.Parent   part.Touched:Connect(function(hit)     print("A player touched the part!") end) Even small scripts like this help you understand how interactions work in Roblox.   6. Testing Your Game Testing is essential. Roblox Studio provides several testing modes to simulate gameplay. Use the “Play” button to: Walk around your world Test scripts Check spawn points Look for bugs Ensure platforms and obstacles work correctly You can also use Play Here, Run, and Play Solo to test different aspects of your game.   7. Adding UI and Game Logic A polished game needs more than objects—it needs user interface elements and clear rules. Common UI elements Timers Score counters Health bars Buttons Pop‑up messages You can create UI using ScreenGui objects inside the StarterGui folder. Roblox provides templates for text labels, buttons, and frames, making it easy to design simple interfaces.   8. Optimizing Your Game A smooth game keeps players engaged. Here are some optimization tips: Remove unused parts and scripts. Avoid too many moving objects. Use low‑poly models when possible. Test on mobile devices—many Roblox players use phones. Keep lighting simple to improve performance. Optimization ensures your game runs well for all players, not just those with powerful devices.   9. Publishing Your Game Once your game is playable, you can publish it to Roblox. Steps to publish Click File → Publish to Roblox. Enter a name, description, and genre. Choose whether the game is public or private. Set permissions and access settings. After publishing, you can share the link with friends or the Roblox community. If you eventually want to monetize your game, you can add game passes or developer products that players can purchase using Roblox Robux. This is optional for beginners, but it becomes important as your game grows.   10. Improving Your Game Over Time The best Roblox games are updated regularly. After publishing, pay attention to: Player feedback Bug reports Suggestions from friends Analytics (visits, playtime, retention) Add new levels, improve visuals, or introduce new mechanics to keep players coming back.   11. Learning and Growing as a Creator Roblox provides many resources to help you improve: Roblox Creator Hub Developer Forum YouTube tutorials Community Discord servers The more you practice, the more confident you’ll become. Many successful developers started as beginners just like you—and some now earn significant amounts of Roblox Robux through their creations.   Final Thoughts Creating your first Roblox game is an exciting journey. You don’t need advanced skills or expensive tools—just creativity and curiosity. Start small, experiment with templates, learn basic scripting, and gradually build your skills. With time and persistence, you can create a game that players around the world will enjoy.
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..