Jump to content

Setting variable in java


Cha0s Blitz

Recommended Posts

can anyone tell me how i can set this as a variable

 

if (p.rights >= 2) {
				Engine.playerItems.addItem(p, itemID,itemAmount);
				return;
			}
			if (p.wildernessZone(p.absX, p.absY)) {
				p.getActionSender().sendMessage(p, "You cannot spawn items while inside of the wilderness.");
				return;
			}
			int freeSpace = Engine.playerItems.freeSlotCount(p);
			if (Engine.playerItems.freeSlotCount(p) < 1) {
				p.getActionSender().sendMessage(p, "You do not have enough space in your inventory.");
				return;
			}
			if (itemAmount > freeSpace && !Engine.items.stackable(itemID)) {
				itemAmount = freeSpace;
			}
			boolean costsKills = false;
			int killCost = itemAmount * p.getKillCost(itemID);
			if (killCost > 0) {
				if (p.kills < killCost) {
					p.getActionSender().sendMessage(p, "You do not have enough kills to spawn this item.");
					p.getActionSender().sendMessage(p, "You need <col=991100>"+killCost+" kills</col> to spawn this item.");
					return;
				}
				costsKills = true;
			}
			if (p.getKillRequirment(itemID) > 0) {
				int killRequirment = p.getKillRequirment(itemID);
				if (p.totalKills < killRequirment) {
					p.getActionSender().sendMessage(p, "You have not unlocked the ability to spawn this item.");
					p.getActionSender().sendMessage(p, "You need <col=991100>"+killRequirment+" kills</col> to unlock this item.");
					p.getActionSender().addSoundEffect(p, 4039, 1, 0, 0);
					return;
				}
			}
			int playerGold = Engine.playerItems.invItemCount(p, 995);
			String itemName = Engine.items.getItemName(itemID);
			String[] spawnDisabled = {"'perfect' ring", "'perfect'_ring", "null", "Coins", "(h", "/10", "100", "75", "50", "25"};
			for (String s : spawnDisabled) {
				if (itemName.contains(s)) {
					p.getActionSender().sendMessage(p, "This item cannot be spawned.");
					p.getActionSender().addSoundEffect(p, 4039, 1, 0, 0);
					return;
				}
			}
			if ((itemID >= 12000 && itemID != 13290)) {
				p.getActionSender().sendMessage(p, "This item cannot be spawned.");
				p.getActionSender().addSoundEffect(p, 4039, 1, 0, 0);
				return;
			}
			int price = (int)Math.round(1.10 * (itemAmount * p.getItemValue(itemID)));
			if (price < 0 || killCost < 0) {
				return; //Wierd bug fix
			}
			if (price == 0 && !costsKills) {
                    			Engine.playerItems.addItem(p, itemID,itemAmount);
				p.getActionSender().addSoundEffect(p, 4041, 1, 0, 0);
			} else {
				if (playerGold < price) {
					p.getActionSender().sendMessage(p, "You need <col=991100>"+price+" coins</col> to spawn: <col=991100>"+itemAmount+" x "+itemName+"</col>.");
					p.getActionSender().addSoundEffect(p, 4039, 1, 0, 0);

				} else {
					if (!costsKills) {
						p.getActionSender().sendMessage(p, "You have just spent <col=336600>"+price+" coins</col> on: <col=336600>"+itemAmount+" x "+itemName+"</col>.");
						Engine.playerItems.addItem(p, itemID, itemAmount);
						p.getActionSender().addSoundEffect(p, 4044, 1, 0, 0);
						Engine.playerItems.deleteItem(p, 995, Engine.playerItems.getItemSlot(p, 995), price);
					} else {
						p.getActionSender().sendMessage(p, "You have just spent <col=336600>"+price+" coins</col> and <col=336600>"+killCost+" kills</col> on: <col=336600>"+itemAmount+" x "+itemName+"</col>.");
						Engine.playerItems.addItem(p, itemID, itemAmount);
						p.getActionSender().addSoundEffect(p, 4044, 1, 0, 0);
						Engine.playerItems.deleteItem(p, 995, Engine.playerItems.getItemSlot(p, 995), price);
						p.kills -= killCost;
						p.getActionSender().sendMessage(p, "You now have <col="+(p.kills > 0 ? "336600" : "991100")+">"+(p.kills > 0 ? p.kills : "no")+" kills</col> remaining.");
					}
				}
			}
		}


Link to comment
Share on other sites

What is "this"...?

 

this is a reference to the current object ;)

 

I know that...  My question was what does he want to set as a variable, the reserved word 'this'?  I don't believe that's possible, there's no reason you would need to anyway.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

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.