Thread: Adding admin and owner exception to restricted items.

Results 1 to 2 of 2
  1. #1 Adding admin and owner exception to restricted items. 
    Registered Member
    Join Date
    Jan 2013
    Posts
    1
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    I'm using this code to put a restriction on items:

    Code:
    public class Commands implements PacketType {
    	private int[] restrictedItems = { 13531, 0, 1, 2};
    with the spawn code

    Code:
    if(playerCommand.startsWith("item"))
    
        {
            try
            {
                if (c.playerRights < 3)
                {
                    return;
                }
                String[] args = playerCommand.split(" ");
                if (args.length == 3)
                {
                    int newItemID = Integer.parseInt(args[1]);
                    for(int i : restrictedItems) {
                        if(i == newItemID) {
                            c.sendMessage("Spawning that item is restricted!");
                            return;
                        }
                    }
                    int newItemAmount = Integer.parseInt(args[2]);
                    if ((newItemID <= 20000) && (newItemID >= 0))
                    {
                        c.getItems().addItem(newItemID, newItemAmount);
                    } else
                    {
                        c.sendMessage("That item ID does not exist.");
                    }
                } else
                {
                    c.sendMessage("Wrong usage: (Ex:(::item_ID_Amount)(::item 995 1))");
                }
            } catch (Exception e)
            {
    
            }
        }
    How would I make it so owners and admins (rights = 2 & 3) are not effected by these restrictions?
    Reply With Quote  
     

  2. #2  
    Registered Member TheLetterQArousesMe's Avatar
    Join Date
    Jan 2013
    Posts
    125
    Thanks given
    18
    Thanks received
    13
    Rep Power
    14
    Why is there need for restricted items when only owners can do the command?
    Code:
                if (c.playerRights < 3)
                {
                    return;
                }
    Also,
    Code:
                    for(int i : restrictedItems) {
                        if((i == newItemID) && (c.playerRights < 2)) {
                            c.sendMessage("Spawning that item is restricted!");
                            return;
                        }
                    }
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

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


User Tag List

Similar Threads

  1. How to make items donater/owner/admin only
    By pwnage8 in forum Tutorials
    Replies: 20
    Last Post: 12-18-2011, 11:29 AM
  2. Replies: 22
    Last Post: 08-30-2011, 12:33 AM
  3. [525] Adding ranks Owner, Co owner, donater in yell
    By Ramsin in forum Configuration
    Replies: 20
    Last Post: 10-23-2010, 01:37 AM
  4. How To Make Your Self Owner,Admin,Mod,Hidden Admin
    By SocialCrisis in forum Tutorials
    Replies: 14
    Last Post: 08-20-2007, 04:32 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •