SilabGarza - RS Private Server  
Home Forum Play Register Store Market Highscores Mark Forums Read
Go Back   SilabGarza - RS Private Server > SilGar Media > Computers > Programming
Reload this Page [PI] Hide tanning


[PI] Hide tanning
Old
  (#1 (permalink))
phl0w is Offline
ARE YOU MAD?
image
 
phl0w's Avatar
 
Posts: 59
Cookies Given: 0
Cookies Received: 0
Time Online: 20 h 55 m
   
Default [PI] Hide tanning - 01-24-2012, 12:15 PM

TanHide.java [server.model.players]
Code:
package server.model.players;

public class TanHide {

	private Client c;

	public TanHide(Client c) {
		this.c = c;
	}
	private enum Tan {
		SOFTLEATHER(1739, 1741, 1),
		HARDLEATHER(1739, 1743, 3),
		GREENDHIDE(1753, 1745, 20),
		BLUEDHIDE(1751, 2505, 20),
		REDDHIDE(1749, 2507, 20),
		BLACKDHIDE(1747, 2509, 20);

		private int hide, tannedHide, cost;

		private Tan(int hide, int tannedHide, int cost) {
			this.hide = hide;
			this.tannedHide = tannedHide;
			this.cost = cost;
		}

		public int getHide() {
			return hide;
		}

		public int getTannedHide() {
			return tannedHide;
		}

		public int getCost() {
			return cost;
		}
	}

	private Tan forHide(int id) {
		for (Tan t : Tan.values()) {
			if (t.getTannedHide() == id) {
				return t;
			}
		}
		return null;
	}

	public void tanHide(Tan hide) {
		Tan t = forHide(hide.getTannedHide());
		if (t != null) {
			int amtOfHides, cost; 
			if (c.getItems().getItemCount(t.getHide()) > 0) {
				amtOfHides = c.getItems().getItemCount(t.getHide());
				cost = amtOfHides * t.getCost();
				if (c.getItems().playerHasItem(995, cost)) {
					amtOfHides = c.getItems().getItemCount(t.getHide());
				} else {
					c.sendMessage("You do not have enough money with you to tan all the hides at once.");
					return;
				}
				c.getItems().deleteItem(t.getHide(), amtOfHides);
				c.getItems().deleteItem(995, c.getItems().getItemSlot(995), cost);
				c.getItems().addItem(t.getTannedHide(), amtOfHides);
				c.sendMessage("You tan "+amtOfHides+(amtOfHides > 1 ? " hides" : " hide")+" for "+cost+" coins.");
			} else {
				c.sendMessage("You don't have any hides you can tan.");
			}
			resetCrafting();
		}
	}

	private void resetCrafting() {
		c.tanning = false;
	}

	public void handleActionButton(int abutton) {
		switch(abutton) {
		case 57225: //Soft leather 
			tanHide(Tan.SOFTLEATHER);
			break;
		case 57226: //Hard leather
			tanHide(Tan.HARDLEATHER);
			break;
		case 57227: //Green d-hide
			tanHide(Tan.GREENDHIDE);
			break;
		case 57228: //Blue d-hide
			tanHide(Tan.BLUEDHIDE);
			break;
		case 57229: //Red d-hide
			tanHide(Tan.REDDHIDE);
			break;
		case 57230: //Black d-hide
			tanHide(Tan.BLACKDHIDE);
			break;
		case 57231: //Unused
			c.sendMessage("This option is currently not featured.");
			break;
		case 57232: //Unused
			c.sendMessage("This option is currently not featured.");
			break;
		}
	}

	public void setupInterface() {
		for (int i = 14791; i < 14797; i++) {
			c.getPA().sendFrame126("", i);
		}
		c.getPA().sendFrame126("@[email protected]", 14777);
		c.getPA().sendFrame126("@[email protected] Leather", 14778);
		c.getPA().sendFrame126("@[email protected] D'hide", 14779);
		c.getPA().sendFrame126("@[email protected] D'hide", 14780);
		c.getPA().sendFrame126("@[email protected] D'hide", 14781);
		c.getPA().sendFrame126("@[email protected] D'hide", 14782);
		c.getPA().sendFrame126("@[email protected] Coin", 14785);
		c.getPA().sendFrame126("@[email protected] Coins", 14786);
		c.getPA().sendFrame126("@[email protected] Coins", 14787);
		c.getPA().sendFrame126("@[email protected] Coins", 14788);
		c.getPA().sendFrame126("@[email protected] Coins", 14789);
		c.getPA().sendFrame126("@[email protected] Coins", 14790);
		c.getPA().showInterface(14670);
		c.tanning = true;
	}

}
Player.java:
Declare
Code:
public boolean tanning;
Client.java:
Add
Code:
	public TanHide getTanning() {
		return tan;
	}
under
Code:
	public PlayerKilling getKill() {
		return playerKilling;
	}
Add
Code:
	private TanHide tan = new TanHide(this);
under
Code:
	private Potions potions = new Potions(this);
Clickingbuttons.java:
Add
Code:
			case 57226: //Soft leather 
			case 57225: //Hard leather
			case 57227: //Green d-hide
			case 57228: //Blue d-hide
			case 57229: //Red d-hide
			case 57230: //Black d-hide
			case 57231: //Unused
			case 57232: //Unused
				if (c.tanning) {
					c.getTanning().handleActionButton(actionButtonId);
				}
Not full, just converted this to PI.

Credits to arrowzftw for the variables.




~[email protected]
  
adsense code2.3
Closed Thread

Bookmarks

[PI] Hide tanning

Programming




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
adsense2.6
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 06:37 PM.





Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.