Thread: Preventing players from buying admin items or premium items from shops

Results 1 to 10 of 10
  1. #1 Preventing players from buying admin items or premium items from shops 
    Banned

    Join Date
    Oct 2008
    Posts
    842
    Thanks given
    81
    Thanks received
    53
    Rep Power
    0
    Well its simple but it works good.

    It prevents players from buying set items from all shops. You can set player rights level, certain XP to buy, or even premium.

    Right lets get started:

    Step 1:
    Code:
    Find:
    deleteItem(995, GetItemSlot(995), TotPrice2);
    It should look somethings like this:
    Code:
    if (playerItemsN[Slot] >= TotPrice2) {
    					if (freeSlots() > 0) {
    						deleteItem(995, GetItemSlot(995), TotPrice2);
    						addItem(itemID, 1);
    						server.shopHandler.ShopItemsN[MyShopID][fromSlot] -= 1;
    						server.shopHandler.ShopItemsDelay[MyShopID][fromSlot] = 0;
    						if ((fromSlot + 1) > server.shopHandler.ShopItemsStandard[MyShopID]) {
    							server.shopHandler.ShopItems[MyShopID][fromSlot] = 0;
    						}
    					} else {
    						sendMessage("you need more space.");
    						break;
    					}
    				} else {
    					sendMessage("You don't have enough coins.");
    					break;
    				}
    Replace that whole code with:
    Code:
    				if (playerItemsN[Slot] >= TotPrice2) {
    					if (freeSlots() > 0) {
    						if(itemID == 773 && playerRights <= 1) {
    						sendMessage("You can't purchase this item!");
    						} else {
    						deleteItem(995, GetItemSlot(995), TotPrice2);
    						addItem(itemID, 1);
    						server.shopHandler.ShopItemsN[MyShopID][fromSlot] -= 1;
    						server.shopHandler.ShopItemsDelay[MyShopID][fromSlot] = 0;
    						}
    						if ((fromSlot + 1) > server.shopHandler.ShopItemsStandard[MyShopID]) {
    							server.shopHandler.ShopItems[MyShopID][fromSlot] = 0;
    						}
    					} else {
    						sendMessage("you need more space.");
    						break;
    					}
    				} else {
    					sendMessage("You don't have enough coins.");
    					break;
    				}
    You see where it has if(itemID == 773 && playerRights <= 1) {

    thats where you enter the items which you whish to block.

    So if you want to block whip, blue party hat, and 'perfect ring' from being purchased by non-staff members, your code would look like this:
    Code:
    if(itemID == 773 || itemID == 4151 || itemID == 1038 && playerRights <= 1) {
    Also you could if you wanted set your untradable int to connect through that code.

    Well don't flame or you can gtfo.
    Reply With Quote  
     

  2. #2  
    .:Programing God:.
    Guest
    Woot first post,

    Looks good, Ill check it out
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Jan 2009
    Posts
    777
    Thanks given
    74
    Thanks received
    61
    Rep Power
    0
    You can use this for blocking buying from whole shops also, good job.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Wiffles's Avatar
    Join Date
    Dec 2007
    Posts
    1,168
    Thanks given
    100
    Thanks received
    198
    Rep Power
    493
    leeched.

    I knows it o.O
    Reply With Quote  
     

  5. #5  
    .:Programing God:.
    Guest
    Unless you can proove, and provide evidence, then its not noob, so stop flaming.



    __________________________________________________ _____________
    Tested, and it works great!!! . .... Here is the code for delta, for anyone who wants it!


    Code:
    				if (playerItemsN[Slot] >= TotPrice2) {
    					if (freeSlots() > 0) {
    						if(itemID == 773 || itemID == 4151 || itemID == 1038 && playerRights <= 1) {
    						sM("You can't purchase this item!");
    						} else {
    						deleteItem(995, GetItemSlot(995), TotPrice2);
    						addItem(itemID, 1);
    						server.shopHandler.ShopItemsN[MyShopID][fromSlot] -= 1;
    						server.shopHandler.ShopItemsDelay[MyShopID][fromSlot] = 0;
    						}
    						if ((fromSlot + 1) > server.shopHandler.ShopItemsStandard[MyShopID]) {
    							server.shopHandler.ShopItems[MyShopID][fromSlot] = 0;
    						}
    					} else {
    						sM("you need more space.");
    						break;
    					}
    				} else {
    					sM("You don't have enough coins.");
    					break;
    				}
    Reply With Quote  
     

  6. #6  
    Member

    Join Date
    Sep 2007
    Posts
    614
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    Or just do this.

    Code:
    if (playerRights == 2 && MyShopID == 1) {
    Send("You can has FAIL for breakfast");
    return;
    }
    if (!donator && itemID == 2300) {
    Send("Bullshit");
    return;
    }
    return; will stop the method wherever it is and not execute anything after. Your shopID and itemID go in there accordingly.

    If your buy method is a boolean "public boolean buyItem(int itemID, int fromSlot, int amount)" then change "return" to "return false"
    Reply With Quote  
     

  7. #7  
    Banned

    Join Date
    Jul 2008
    Posts
    2,056
    Thanks given
    26
    Thanks received
    98
    Rep Power
    0
    This is all well and good, but who really still has admin only items? isnt that kinda lame?
    Reply With Quote  
     

  8. #8  
    Banned
    Tyler, the creator's Avatar
    Join Date
    Jun 2009
    Posts
    1,339
    Thanks given
    30
    Thanks received
    61
    Rep Power
    0

    but premium, i guess.
    Reply With Quote  
     

  9. #9  
    Registered Member
    Coder Alex's Avatar
    Join Date
    Apr 2009
    Age
    30
    Posts
    1,755
    Thanks given
    86
    Thanks received
    83
    Rep Power
    231
    Erm
    Code:
    if(itemID == 773 || itemID == 4151 || itemID == 1038 && playerRights <= 1) {
    Won't work... I'm sure. Make it

    if(itemID == 773 && playerRights <= 1 || itemID == 4151 && playerRights <= 1 || itemID == 1038 && playerRights <= 1) {


    +This is rly stupid =P... why put admin items in shop , they can spawn lol
    Reply With Quote  
     

  10. #10  
    Member

    Join Date
    Sep 2007
    Posts
    614
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    Quote Originally Posted by Coder Alex View Post
    Erm
    Code:
    if(itemID == 773 || itemID == 4151 || itemID == 1038 && playerRights <= 1) {
    Won't work... I'm sure. Make it

    if(itemID == 773 && playerRights <= 1 || itemID == 4151 && playerRights <= 1 || itemID == 1038 && playerRights <= 1) {


    +This is rly stupid =P... why put admin items in shop , they can spawn lol
    His code is almost there, yours is just fail.

    Code:
    if((itemID == 773 || itemID == 4151 || itemID == 1038) && playerRights <= 1) {
    Notice the extra ( ). This means any of those items AND player rights. Before it was just the last item and admin rights, NO ONE could buy the first two.
    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

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