Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # What's new:
- 1. You may now specify the [tags].
- # Usage: /rmitem <player> <id:meta> <quantity> [tags]
- - e.g.: /rmitem Nuxeel 5:1 20 [input tag here]
- - the [tags] is optional, which means that you may or may not specify it.
- - if you encounter any errors or bugs, please do report it at LEET discord.
- # Note:
- - if you specified a tag, make sure it is the correct tag. Otherwise, the item will not get removed.
- # --- Complete Code Starts Here -----
- cmd edit rmitem 1 # Remove Specific Item v2.1.1 | Nuxeel | MadCommands v2.1.4 build 1027
- cmd edit rmitem 2 # /rmitem <player> <id:meta> <quantity> [tags]
- cmd edit rmitem 3 # -- Add this if only OPs are allowed to run the command --
- cmd edit rmitem 4 %p-name% = %p%
- cmd edit rmitem 5 %console% = array(\"Rcon\",\"CONSOLE\")
- cmd edit rmitem 6 if %p-name% in %console% then goto 20
- cmd edit rmitem 7 %is-op% = playerstatus(%p%)
- cmd edit rmitem 8 if %is-op%[\"op\"] = %true% then goto 20
- cmd edit rmitem 9 message %p% §cYou are not allowed to run this command.
- cmd edit rmitem 10 exit
- cmd edit rmitem 11 # -- End --
- cmd edit rmitem 20 # Validation process starts here.
- cmd edit rmitem 21 if varset(%args%[1]) = %true% then goto 40
- cmd edit rmitem 22 message %p% §aUsage: /rmitem <player> <id:meta> <quantity> [tags]
- cmd edit rmitem 23 exit
- cmd edit rmitem 40 # Check if player is online.
- cmd edit rmitem 41 %player% = %args%[1]
- cmd edit rmitem 42 if %player% in onlineplayers() then goto 60
- cmd edit rmitem 43 message %p% §cPlayer must be online.
- cmd edit rmitem 44 exit
- cmd edit rmitem 60 # Check if item id is valid.
- cmd edit rmitem 61 if varset(%args%[2]) = %false% then goto 22
- cmd edit rmitem 62 %item% = \"\" + %args%[2] + \"\"
- cmd edit rmitem 63 %item% = split(%item%, \":\")
- cmd edit rmitem 64 %item-id% = %item%[0]
- cmd edit rmitem 80 # Check if item variant/meta id is valid.
- cmd edit rmitem 81 if (varset(%item%[1]) = %false%) or (%item%[1] = \"\") then goto 86
- cmd edit rmitem 82 %item-variant% = %item%[1]
- cmd edit rmitem 83 if %item-variant% >= 0 then goto 87
- cmd edit rmitem 84 message %p% §cInvalid meta id.
- cmd edit rmitem 85 exit
- cmd edit rmitem 86 %item-variant% = 0
- cmd edit rmitem 87 if %item-id% > 0 then goto 100
- cmd edit rmitem 88 message %p% §cInvalid item id.
- cmd edit rmitem 89 exit
- cmd edit rmitem 100 # Check whether a quantity is specified.
- cmd edit rmitem 101 %cond% = %false%
- cmd edit rmitem 102 if varset(%args%[3]) = %false% then goto 120
- cmd edit rmitem 103 if %args%[3] = \"\" then goto 120
- cmd edit rmitem 104 %cond% = %true%
- cmd edit rmitem 105 %quantity% = %args%[3]
- cmd edit rmitem 106 if %quantity% > 0 then goto 120
- cmd edit rmitem 107 message %p% §cInvalid quantity.
- cmd edit rmitem 108 exit
- cmd edit rmitem 120 # Check whether tags is specified.
- cmd edit rmitem 121 %tag% = \"\"
- cmd edit rmitem 122 if varset(%args%[4]) = %false% then goto 140
- cmd edit rmitem 123 if %args%[4] = \"\" then goto 140
- cmd edit rmitem 124 %tag% = %args%[4]
- cmd edit rmitem 125 goto 140
- cmd edit rmitem 140 # Check quantity and remove item starts here.
- cmd edit rmitem 141 %inv% = playerinventory(%player%)
- cmd edit rmitem 142 async
- cmd edit rmitem 143 %index% = size(%inv%) - 1
- cmd edit rmitem 144 %get-slot% = %inv%[%index%]
- cmd edit rmitem 145 %check-id% = %get-slot%[\"id\"]
- cmd edit rmitem 146 %check-variant% = %get-slot%[\"variant\"]
- cmd edit rmitem 147 %check-tag% = %get-slot%[\"tags\"]
- cmd edit rmitem 148 if %check-id% != %item-id% then goto 165
- cmd edit rmitem 149 if %check-variant% != %item-variant% then goto 165
- cmd edit rmitem 150 if %check-tag% != %tag% then goto 165
- cmd edit rmitem 151 if %cond% = %false% then goto 163
- cmd edit rmitem 152 %count% = %get-slot%[\"count\"]
- cmd edit rmitem 153 if %quantity% >= %count% then goto 162
- cmd edit rmitem 154 %new-count% = %count% - %quantity%
- cmd edit rmitem 155 if %new-count% = 0 then goto 162
- cmd edit rmitem 156 %new-item%[\"id\"] = %item-id%
- cmd edit rmitem 157 %new-item%[\"variant\"] = %item-variant%
- cmd edit rmitem 158 %new-item%[\"count\"] = %new-count%
- cmd edit rmitem 159 %new-item%[\"tags\"] = %tag%
- cmd edit rmitem 160 %inv%[%index%] = %new-item%
- cmd edit rmitem 161 goto 180
- cmd edit rmitem 162 %quantity% = %quantity% - %count%
- cmd edit rmitem 163 # Condition: ALL
- cmd edit rmitem 164 %inv%[%index%] =
- cmd edit rmitem 165 # Update index
- cmd edit rmitem 166 %index% = %index% - 1
- cmd edit rmitem 167 if %cond% = %false% then goto 169
- cmd edit rmitem 168 if %quantity% <= 0 then goto 180
- cmd edit rmitem 169 if %index% > -1 then goto 144
- cmd edit rmitem 180 # Update player's inventory.
- cmd edit rmitem 181 sync
- cmd edit rmitem 182 carry %player% %inv%
- cmd edit rmitem 183 %check% = substring(%player%, -1, 1)
- cmd edit rmitem 184 if %check% = \"s\" then message %p% §aPlayer §6%player%§a' inventory updated!
- 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