Advertisement
Nuxeel

Remove a Specific Item v2.1.1 | Nuxeel

Jun 8th, 2018
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. # What's new:
  2. 1. You may now specify the [tags].
  3.  
  4. # Usage: /rmitem <player> <id:meta> <quantity> [tags]
  5. - e.g.: /rmitem Nuxeel 5:1 20 [input tag here]
  6. - the [tags] is optional, which means that you may or may not specify it.
  7. - if you encounter any errors or bugs, please do report it at LEET discord.
  8.  
  9. # Note:
  10. - if you specified a tag, make sure it is the correct tag. Otherwise, the item will not get removed.
  11.  
  12. # --- Complete Code Starts Here -----
  13. cmd edit rmitem 1 # Remove Specific Item v2.1.1 | Nuxeel | MadCommands v2.1.4 build 1027
  14. cmd edit rmitem 2 # /rmitem <player> <id:meta> <quantity> [tags]
  15. cmd edit rmitem 3 # -- Add this if only OPs are allowed to run the command --
  16. cmd edit rmitem 4 %p-name% = %p%
  17. cmd edit rmitem 5 %console% = array(\"Rcon\",\"CONSOLE\")
  18. cmd edit rmitem 6 if %p-name% in %console% then goto 20
  19. cmd edit rmitem 7 %is-op% = playerstatus(%p%)
  20. cmd edit rmitem 8 if %is-op%[\"op\"] = %true% then goto 20
  21. cmd edit rmitem 9 message %p% §cYou are not allowed to run this command.
  22. cmd edit rmitem 10 exit
  23. cmd edit rmitem 11 # -- End --
  24. cmd edit rmitem 20 # Validation process starts here.
  25. cmd edit rmitem 21 if varset(%args%[1]) = %true% then goto 40
  26. cmd edit rmitem 22 message %p% §aUsage: /rmitem <player> <id:meta> <quantity> [tags]
  27. cmd edit rmitem 23 exit
  28. cmd edit rmitem 40 # Check if player is online.
  29. cmd edit rmitem 41 %player% = %args%[1]
  30. cmd edit rmitem 42 if %player% in onlineplayers() then goto 60
  31. cmd edit rmitem 43 message %p% §cPlayer must be online.
  32. cmd edit rmitem 44 exit
  33. cmd edit rmitem 60 # Check if item id is valid.
  34. cmd edit rmitem 61 if varset(%args%[2]) = %false% then goto 22
  35. cmd edit rmitem 62 %item% = \"\" + %args%[2] + \"\"
  36. cmd edit rmitem 63 %item% = split(%item%, \":\")
  37. cmd edit rmitem 64 %item-id% = %item%[0]
  38. cmd edit rmitem 80 # Check if item variant/meta id is valid.
  39. cmd edit rmitem 81 if (varset(%item%[1]) = %false%) or (%item%[1] = \"\") then goto 86
  40. cmd edit rmitem 82 %item-variant% = %item%[1]
  41. cmd edit rmitem 83 if %item-variant% >= 0 then goto 87
  42. cmd edit rmitem 84 message %p% §cInvalid meta id.
  43. cmd edit rmitem 85 exit
  44. cmd edit rmitem 86 %item-variant% = 0
  45. cmd edit rmitem 87 if %item-id% > 0 then goto 100
  46. cmd edit rmitem 88 message %p% §cInvalid item id.
  47. cmd edit rmitem 89 exit
  48. cmd edit rmitem 100 # Check whether a quantity is specified.
  49. cmd edit rmitem 101 %cond% = %false%
  50. cmd edit rmitem 102 if varset(%args%[3]) = %false% then goto 120
  51. cmd edit rmitem 103 if %args%[3] = \"\" then goto 120
  52. cmd edit rmitem 104 %cond% = %true%
  53. cmd edit rmitem 105 %quantity% = %args%[3]
  54. cmd edit rmitem 106 if %quantity% > 0 then goto 120
  55. cmd edit rmitem 107 message %p% §cInvalid quantity.
  56. cmd edit rmitem 108 exit
  57. cmd edit rmitem 120 # Check whether tags is specified.
  58. cmd edit rmitem 121 %tag% = \"\"
  59. cmd edit rmitem 122 if varset(%args%[4]) = %false% then goto 140
  60. cmd edit rmitem 123 if %args%[4] = \"\" then goto 140
  61. cmd edit rmitem 124 %tag% = %args%[4]
  62. cmd edit rmitem 125 goto 140
  63. cmd edit rmitem 140 # Check quantity and remove item starts here.
  64. cmd edit rmitem 141 %inv% = playerinventory(%player%)
  65. cmd edit rmitem 142 async
  66. cmd edit rmitem 143 %index% = size(%inv%) - 1
  67. cmd edit rmitem 144 %get-slot% = %inv%[%index%]
  68. cmd edit rmitem 145 %check-id% = %get-slot%[\"id\"]
  69. cmd edit rmitem 146 %check-variant% = %get-slot%[\"variant\"]
  70. cmd edit rmitem 147 %check-tag% = %get-slot%[\"tags\"]
  71. cmd edit rmitem 148 if %check-id% != %item-id% then goto 165
  72. cmd edit rmitem 149 if %check-variant% != %item-variant% then goto 165
  73. cmd edit rmitem 150 if %check-tag% != %tag% then goto 165
  74. cmd edit rmitem 151 if %cond% = %false% then goto 163
  75. cmd edit rmitem 152 %count% = %get-slot%[\"count\"]
  76. cmd edit rmitem 153 if %quantity% >= %count% then goto 162
  77. cmd edit rmitem 154 %new-count% = %count% - %quantity%
  78. cmd edit rmitem 155 if %new-count% = 0 then goto 162
  79. cmd edit rmitem 156 %new-item%[\"id\"] = %item-id%
  80. cmd edit rmitem 157 %new-item%[\"variant\"] = %item-variant%
  81. cmd edit rmitem 158 %new-item%[\"count\"] = %new-count%
  82. cmd edit rmitem 159 %new-item%[\"tags\"] = %tag%
  83. cmd edit rmitem 160 %inv%[%index%] = %new-item%
  84. cmd edit rmitem 161 goto 180
  85. cmd edit rmitem 162 %quantity% = %quantity% - %count%
  86. cmd edit rmitem 163 # Condition: ALL
  87. cmd edit rmitem 164 %inv%[%index%] =
  88. cmd edit rmitem 165 # Update index
  89. cmd edit rmitem 166 %index% = %index% - 1
  90. cmd edit rmitem 167 if %cond% = %false% then goto 169
  91. cmd edit rmitem 168 if %quantity% <= 0 then goto 180
  92. cmd edit rmitem 169 if %index% > -1 then goto 144
  93. cmd edit rmitem 180 # Update player's inventory.
  94. cmd edit rmitem 181 sync
  95. cmd edit rmitem 182 carry %player% %inv%
  96. cmd edit rmitem 183 %check% = substring(%player%, -1, 1)
  97. cmd edit rmitem 184 if %check% = \"s\" then message %p% §aPlayer §6%player%§a' inventory updated!
  98. cmd edit rmitem 185 if %check% != \"s\" then message %p% §aPlayer §6%player%§a's inventory updated!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement