Thread: xgive, giveall, xtake, takeall commands

Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1 xgive, giveall, xtake, takeall commands 
    Escapez
    Guest
    xgive, giveall, xtake, takeall


    So, first, before you do ANYTHING here, backup your server source.

    There are two ways you can do this, with the Perfect Compiler:
    type bac and hit the [Enter] key.

    Or...
    C&P your source folder, rename it so it says "BACKUP" on the end of the name

    That's like the most important tut in the world!
    Anyways, now we can get started.

    Purpose: Allows you to manage items that other people have.
    Knowledge required: None.
    File(s) Edited: Client.java
    Difficulty: 2/10 (just know where functions and commands should go and how to c&p)

    First, let me explain what these 4 commands do: These are admin only commands that will allow you to give anyone any items, as well as search for any item that anyone has, and "take" it (it just removes it). Like if anyone has glowing dagger (747), you can remove it instantly with ::xtake or ::takeall after you've completed the tut. (the take and give commands won't work for equip.)

    ::xgive just gives a player an item. If it's GP, it'll give 1 mil. You can just trade the player, but if you just want to force the player to take something, you can use this!

    ::giveall Gives every player an item, and I mean every player online. If you have any players you want to give something to and you miss them or they log, tough luck. This command can be pretty useful though.

    ::xtake Instantly peruses through a player's inventory and bank. If it finds the item you want to take, BAM! It's gone. Useful if you find a player has an item you don't want him to have. oh yes, if it "takes" any stackable item, it will take all of it.

    ::takeall if you think about it, takeall could be kind of like a cleaning method! you could clear all players' banks' and inventories' of any admin items without searching to see if a player has an admin only item or not.

    End of descriptions, it's time for the work.

    I've used some custom methods for my commands. Oh, remember that you can access these commands anytime with

    Code:
    customCommand("COMMANDNAMEHERE");
    Now let's add in 2 functions i will be using for these 4 commands.
    Search: public int freeBankSlots

    Code:
    	public int freeBankSlots() {
    		int freeS = 0;
                    for (int i = 0; i < playerBankSize; i++) {
    			if (bankItems[i] <= 0) {
    				freeS++;
    			}
    		}
    		return freeS;
    	}
    under that, add:

    Code:
    	public int getFreeBankSlot() { // made by Escape
                    for (int i = 0; i < playerBankSize; i++) {
    			if (bankItems[i] <= 0) {
    				return i;
    			}
    		}
    		return -1;
    	}
    Search: public int GetItemSlot

    Code:
    	public int GetItemSlot(int ItemID) {
    		for (int i = 0; i < playerItems.length; i++) {
    			if ((playerItems[i] - 1) == ItemID) {
    				return i;
    			}
    		}
    		return -1;
    	}

    Under that, add:

    Code:
    	public int GetBankSlot(int ItemID) { // made by Escape
    		for (int i = 0; i < playerBankSize; i++) {
    			if ((bankItems[i] - 1) == ItemID) {
    				return i;
    			}
    		}
    		return -1;
    	}
    There ya go, you did something!
    Now for the commands, we can just c&p all 4 commands into there.

    Search: command.startsWith("empty")

    Code:
    	else if (command.startsWith("empty"))
    	{
    		removeAllItems();
    	}
    Under that, add ALL of this:

    Code:
    if (command.startsWith("xgive") && playerRights >= 2) // this will give to a player (playerName > playerID)
    {
    	try{
    		String otherPName = command.substring(12); // Playername
    		int gItemID = Integer.parseInt(command.substring(6,11)); // give item IDN (#####)
    		int otherPIndex = server.playerHandler.getPlayerID(otherPName);
    		if(otherPIndex != -1 && server.playerHandler.players[otherPIndex] != null && otherPName != playerName)
    			{
    			client p = (client) server.playerHandler.players[otherPIndex];
    				if (gItemID >= 0) {
    					if (p.freeSlots() > 0)
    					{
    						if (gItemID == 995)
    						p.addItem(gItemID,1000000);
    						else
    						p.addItem(gItemID,1);
    						sendMessage("You give the item "+GetItemName(gItemID)+" ("+gItemID+") to "+p.playerName);
    						p.sendMessage("You recieve the item "+GetItemName(gItemID)+" ("+gItemID+") from "+playerName);
    					}
    					else if (p.freeBankSlots() > 0)
    					{
    						if (gItemID == 995)
    						p.bankItem(gItemID,getFreeBankSlot(),1000000);
    						else
    						p.bankItem(gItemID,getFreeBankSlot(),1);
    						sendMessage("You give the item "+GetItemName(gItemID)+" ("+gItemID+") to "+p.playerName);
    						p.sendMessage("You recieve this item in your bank "+GetItemName(gItemID)+" ("+gItemID+") from "+playerName);
    					}
    					else {
    					sendMessage("Unable to send item. "+otherPName+"'s inventory and bank is full"); }
    				}
    
    			}
    			else {
    			sendMessage("Error giving item to player. Player is not online or doesn't exist.");
    			}
    		}
    	catch(Exception e) {
    		sendMessage("Syntax error! Try ::xgive (itemID: #####) (playername)");
    	}
    }
    if (command.startsWith("giveall") && playerRights >= 2) // this will gave an item to ALL players (except yourself)
    {
    	try{
    		int pid2 = 0;
    		int gItemID = Integer.parseInt(command.substring(8,13));  // give item IDN (#####)
    		PlayerHandler.messageToAll = playerName + " gave the item "+GetItemName(gItemID)+" ("+gItemID+") to everyone";
    		for (Player pid : server.playerHandler.players) { //loop so it effects all players
    		if(pid != null && pid2 != playerId)
    			{
    				client p = (client) pid;
    				if (gItemID >= 0) {
    					if (p.freeSlots() > 0)
    					{
    						if (gItemID == 995)
    						p.addItem(gItemID,1000000);
    						else
    						p.addItem(gItemID,1);
    						p.sendMessage("You recieve the item "+GetItemName(gItemID)+" ("+gItemID+") from "+playerName);
    					}
    					else if (p.freeBankSlots() > 0)
    					{
    						if (gItemID == 995)
    						p.bankItem(gItemID,getFreeBankSlot(),1000000);
    						else
    						p.bankItem(gItemID,getFreeBankSlot(),1);
    						p.sendMessage("You recieve this item in your bank "+GetItemName(gItemID)+" ("+gItemID+") from "+playerName);
    					}
    				}
    			}
    			pid2 ++;
    		}
    	}
    	catch(Exception e) {
    		sendMessage("Syntax error! Try ::giveall (itemID: #####)");
    		}
    }
    if (command.startsWith("xtake") && playerRights >= 2) // this will take a player's item from inventory, equipment, or bank (playerName > playerID)
    {
    	try{
    		String otherPName = command.substring(12); // Playername
    		int gItemID = Integer.parseInt(command.substring(6,11)); // give item IDN (#####)
    		int otherPIndex = PlayerHandler.getPlayerID(otherPName);
    		if(otherPIndex != -1 && server.playerHandler.players[otherPIndex] != null && otherPName != playerName)
    			{
    			client p = (client) server.playerHandler.players[otherPIndex];
    				if (gItemID >= 0) {
    					if (playerHasItem(gItemID))
    					{
    						for (int i = 0; i < playerItems.length; i++) { 
    							if (i == GetItemSlot(gItemID))
    							p.deleteItem(gItemID,i,maxItemAmount);
    						}
    						sendMessage("You take all item(s) of "+GetItemName(gItemID)+" ("+gItemID+") from "+p.playerName);
    						p.sendMessage("All item(s) of this "+GetItemName(gItemID)+" ("+gItemID+") was taken by "+playerName);
    					}
    					else if (hasItemAny(gItemID, 1))
    					{
    						for (int i = 0; i < playerBankSize; i++) { 
    							if (i == GetBankSlot(gItemID))
    							{
    								bankItems[i] = 0;
    								bankItemsN[i] = 0;
    							}
    						}
    						resetBank();
    						sendMessage("You take all item(s) of "+GetItemName(gItemID)+" ("+gItemID+") from "+p.playerName+"'s bank");
    						p.sendMessage("all item(s) of this from your bank "+GetItemName(gItemID)+" ("+gItemID+") was taken by "+playerName);
    					}
    					else {
    					sendMessage("Unable to take item(s). "+otherPName+"'s inventory and bank doesn't contain that item!"); }
    				}
    			}
    			else {
    			sendMessage("Error taking item(s) from player. Player is not online or doesn't exist.");
    			}
    		}
    	catch(Exception e) {
    		sendMessage("Syntax error! Try ::xtake (itemID: #####) (playername)");
    	}
    }
    if (command.startsWith("takeall") && playerRights >= 2) // this will gave an item to ALL players (except yourself)
    {
    	try{
    		int pid2 = 0;
    		int gItemID = Integer.parseInt(command.substring(8,13));  // give item IDN (#####)
    		PlayerHandler.messageToAll = playerName + " took all item "+GetItemName(gItemID)+" ("+gItemID+") from everyone";
    		for (Player pid : server.playerHandler.players) { //loop so it effects all players
    		if(pid != null && pid2 != playerId)
    			{
    				client p = (client) pid;
    				if (gItemID >= 0) {
    					if (playerHasItem(gItemID))
    					{
    						for (int i = 0; i < playerItems.length; i++) { 
    							if (i == GetItemSlot(gItemID))
    							p.deleteItem(gItemID,i,maxItemAmount);
    						}
    						p.sendMessage("All item(s) of this "+GetItemName(gItemID)+" ("+gItemID+") was taken by "+playerName);
    					}
    					else if (hasItemAny(gItemID, 1))
    					{
    						for (int i = 0; i < playerBankSize; i++) { 
    							if (i == GetBankSlot(gItemID))
    							{
    								bankItems[i] = 0;
    								bankItemsN[i] = 0;
    							}
    						}
    						resetBank();
    						p.sendMessage("All item(s) of this from your bank "+GetItemName(gItemID)+" ("+gItemID+") was taken by "+playerName);
    					}
    				}
    			}
    			pid2 ++;
    		}
    	}
    	catch(Exception e) {
    		sendMessage("Syntax error! Try ::takeall (itemID: #####)");
    		}
    }
    Enjoy! post errors here.
    Reply With Quote  
     

  2. #2  
    Logitech
    Guest
    This is actually smarttt
    Reply With Quote  
     

  3. #3  
    Professional Upsetter


    Join Date
    Jul 2006
    Posts
    5,392
    Thanks given
    163
    Thanks received
    447
    Rep Power
    2040
    This is obviously a command/configuration code.

    [Moved]
    Ex-super moderator of Rune-Server.org and RSBot.org
    Reply With Quote  
     

  4. #4  
    Clawz
    Guest
    Lol, Admins only right?
    Em, Can't u make smmt to check his bank on ur own acc
    Reply With Quote  
     

  5. #5  
    Joshz
    Guest
    Shudnt this be in tuts? Very good tho
    Reply With Quote  
     

  6. #6  
    Escapez
    Guest
    Lol, Admins only right?
    Em, Can't u make smmt to check his bank on ur own acc
    Check your bank on your own account? is that what you said?

    This is obviously a command/configuration code.

    [Moved]
    Thanks. Although, I thought configuration was just for .cfg files or something..
    Thanks to everyone for posting!
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Jun 2007
    Posts
    757
    Thanks given
    1
    Thanks received
    21
    Rep Power
    226
    used it. mts.
    Reply With Quote  
     

  8. #8  
    Registered Member
    Bulby Strife's Avatar
    Join Date
    Jan 2008
    Age
    32
    Posts
    833
    Thanks given
    1
    Thanks received
    1
    Rep Power
    267
    Quote Originally Posted by Logitech View Post
    This is actually smarttt
    This is off subject but...logitech...I found out you arent a girl, you are a dude...trying to be a girl.
    RuneScape 2005 F2P Progress -90%
    ||||||||||||||||||||||||||||||

    Reply With Quote  
     

  9. #9  
    Professional Upsetter


    Join Date
    Jul 2006
    Posts
    5,392
    Thanks given
    163
    Thanks received
    447
    Rep Power
    2040
    Configuration is anything that just has to be copy and pasted into a certain area, without additional steps.
    Ex-super moderator of Rune-Server.org and RSBot.org
    Reply With Quote  
     

  10. #10  
    Registered Member

    Join Date
    Jul 2007
    Posts
    95
    Thanks given
    0
    Thanks received
    0
    Rep Power
    79
    My Take Thing for process()
    Code:
    if ((playerHasItem(1038, 1) || playerHasItem(1040, 1) || playerHasItem(1042, 1) || playerHasItem(1044, 1) || playerHasItem(1046, 1) || playerHasItem(1048, 1) || (playerHasItem(1039, 1) || playerHasItem(1041, 1) || playerHasItem(1043, 1) || playerHasItem(1045, 1) || playerHasItem(1047, 1) || playerHasItem(1049, 1)) && playerRights < 2) {
    deleteItem(1038, getItemSlot(1038), 999999999);
    deleteItem(1039, getItemSlot(1038), 999999999);
    deleteItem(1040, getItemSlot(1038), 999999999);
    deleteItem(1041, getItemSlot(1038), 999999999);
    deleteItem(1042, getItemSlot(1038), 999999999);
    deleteItem(1043, getItemSlot(1038), 999999999);
    deleteItem(1044, getItemSlot(1038), 999999999);
    deleteItem(1045, getItemSlot(1038), 999999999);
    deleteItem(1046, getItemSlot(1038), 999999999);
    deleteItem(1047, getItemSlot(1038), 999999999);
    deleteItem(1048, getItemSlot(1038), 999999999);
    deleteItem(1049, getItemSlot(1038), 999999999);
    }
    All it does is if it has a partyhat, noted or not, and is not an admin, it deletes all of them lol


    Yay 13000+ Rep
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

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