Advertisement
Nuxeel

Remove a Specific Item v2 | Nuxeel

Jun 6th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. ## Newer version: https://pastebin.com/gc3uUnq5
  2.  
  3. # What's new:
  4. 1. You can now specify the quantity. (Usage: /rmitem <player> <item id> <quantity>)
  5. 2. If you don't specify the quantity, it will assume that you want to remove all of the item specified.
  6. 3. The meta id or variant will now work. For exmaple, `/rmitem Nuxeel 35:4 32`.
  7. 4. Remember to specify the persons allowed to run the command at line 5, %allowed% variable.
  8.  
  9. # --- Complete Code Starts Here -----
  10. cmd edit rmitem 1 # Remove Specific Item v2 | Nuxeel | MadCommands v2.1.4 build 1027
  11. cmd edit rmitem 2 # /rmitem <player> <item id> <quantity>
  12. cmd edit rmitem 3 # -- Add this if only certain players are allowed to run the command --
  13. cmd edit rmitem 4 %p-name% = lowercase(%p%)
  14. cmd edit rmitem 5 %allowed% = array(\"rcon\",\"console\", <PUT HERE THE NAMES(in lowercase) OF THOSE WHO ARE ALLOWED TO RUN THE COMMAND (e.g. \"john\")>)
  15. cmd edit rmitem 6 if %p-name% in %allowed% then goto 20
  16. cmd edit rmitem 7 message %p% §cYou are not allowed to run this command.
  17. cmd edit rmitem 8 exit
  18. cmd edit rmitem 9 # -- End --
  19. cmd edit rmitem 20 # Code starts here.
  20. cmd edit rmitem 21 if varset(%args%[1]) then goto 40
  21. cmd edit rmitem 22 message %p% §aUsage: /rmitem <player> <item id> <quantity>
  22. cmd edit rmitem 23 exit
  23. cmd edit rmitem 40 # Check if player is online.
  24. cmd edit rmitem 41 %player% = %args%[1]
  25. cmd edit rmitem 42 if %player% in onlineplayers() then goto 60
  26. cmd edit rmitem 43 message %p% §cPlayer must be online.
  27. cmd edit rmitem 44 exit
  28. cmd edit rmitem 60 # Check if item id is valid.
  29. cmd edit rmitem 61 if varset(%args%[2]) = 0 then goto 22
  30. cmd edit rmitem 62 %item% = \"\" + %args%[2] + \"\"
  31. cmd edit rmitem 63 %item% = split(%item%, \":\")
  32. cmd edit rmitem 64 %item-id% = %item%[0]
  33. cmd edit rmitem 80 # Check if item variant/meta id is valid.
  34. cmd edit rmitem 81 if (varset(%item%[1]) = 0) or (%item%[1] = \"\") then goto 86
  35. cmd edit rmitem 82 %item-variant% = %item%[1]
  36. cmd edit rmitem 83 if %item-variant% >= 0 then goto 87
  37. cmd edit rmitem 84 message %p% §cInvalid meta id.
  38. cmd edit rmitem 85 exit
  39. cmd edit rmitem 86 %item-variant% = 0
  40. cmd edit rmitem 87 if %item-id% > 0 then goto 100
  41. cmd edit rmitem 88 message %p% §cInvalid item id.
  42. cmd edit rmitem 89 exit
  43. cmd edit rmitem 100 # Check whether a quantity is specified.
  44. cmd edit rmitem 101 %cond% = \"ALL\"
  45. cmd edit rmitem 102 if varset(%args%[3]) = 0 then goto 120
  46. cmd edit rmitem 103 if %args%[3] = \"\" then goto 120
  47. cmd edit rmitem 104 %cond% = \"LIM\"
  48. cmd edit rmitem 105 %quantity% = %args%[3]
  49. cmd edit rmitem 106 if %quantity% > 0 then goto 120
  50. cmd edit rmitem 107 message %p% §cInvalid quantity.
  51. cmd edit rmitem 108 exit
  52. cmd edit rmitem 120 # Check quantity and remove item starts here.
  53. cmd edit rmitem 121 %inv% = playerinventory(%player%)
  54. cmd edit rmitem 122 async
  55. cmd edit rmitem 123 %index% = size(%inv%) - 1
  56. cmd edit rmitem 124 %get-slot% = %inv%[%index%]
  57. cmd edit rmitem 125 %check-id% = %get-slot%[\"id\"]
  58. cmd edit rmitem 126 %check-variant% = %get-slot%[\"variant\"]
  59. cmd edit rmitem 127 if %check-id% != %item-id% then goto 143
  60. cmd edit rmitem 128 if %check-variant% != %item-variant% then goto 143
  61. cmd edit rmitem 129 if %cond% = \"ALL\" then goto 141
  62. cmd edit rmitem 130 %count% = %get-slot%[\"count\"]
  63. cmd edit rmitem 131 if %quantity% >= %count% then goto 140
  64. cmd edit rmitem 132 %new-count% = %count% - %quantity%
  65. cmd edit rmitem 133 if %new-count% = 0 then goto 140
  66. cmd edit rmitem 134 %new-item%[\"id\"] = %item-id%
  67. cmd edit rmitem 135 %new-item%[\"variant\"] = %item-variant%
  68. cmd edit rmitem 136 %new-item%[\"count\"] = %new-count%
  69. cmd edit rmitem 137 %new-item%[\"tags\"] = \"\"
  70. cmd edit rmitem 138 %inv%[%index%] = %new-item%
  71. cmd edit rmitem 139 goto 160
  72. cmd edit rmitem 140 %quantity% = %quantity% - %count%
  73. cmd edit rmitem 141 # Condition: ALL
  74. cmd edit rmitem 142 %inv%[%index%] =
  75. cmd edit rmitem 143 # Update index
  76. cmd edit rmitem 144 %index% = %index% - 1
  77. cmd edit rmitem 145 if %cond% = \"ALL\" then goto 147
  78. cmd edit rmitem 146 if %quantity% <= 0 then goto 160
  79. cmd edit rmitem 147 if %index% > -1 then goto 124
  80. cmd edit rmitem 160 # Update player's inventory.
  81. cmd edit rmitem 161 sync
  82. cmd edit rmitem 162 carry %player% %inv%
  83. cmd edit rmitem 163 %check% = substring(%player%, -1, 1)
  84. cmd edit rmitem 164 if %check% = \"s\" then message %p% §aPlayer §6%player%§a' inventory updated!
  85. cmd edit rmitem 165 if %check% != \"s\" then message %p% §aPlayer §6%player%§a's inventory updated!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement