Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Newer version: https://pastebin.com/gc3uUnq5
- # What's new:
- 1. You can now specify the quantity. (Usage: /rmitem <player> <item id> <quantity>)
- 2. If you don't specify the quantity, it will assume that you want to remove all of the item specified.
- 3. The meta id or variant will now work. For exmaple, `/rmitem Nuxeel 35:4 32`.
- 4. Remember to specify the persons allowed to run the command at line 5, %allowed% variable.
- # --- Complete Code Starts Here -----
- cmd edit rmitem 1 # Remove Specific Item v2 | Nuxeel | MadCommands v2.1.4 build 1027
- cmd edit rmitem 2 # /rmitem <player> <item id> <quantity>
- cmd edit rmitem 3 # -- Add this if only certain players are allowed to run the command --
- cmd edit rmitem 4 %p-name% = lowercase(%p%)
- 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\")>)
- cmd edit rmitem 6 if %p-name% in %allowed% then goto 20
- cmd edit rmitem 7 message %p% §cYou are not allowed to run this command.
- cmd edit rmitem 8 exit
- cmd edit rmitem 9 # -- End --
- cmd edit rmitem 20 # Code starts here.
- cmd edit rmitem 21 if varset(%args%[1]) then goto 40
- cmd edit rmitem 22 message %p% §aUsage: /rmitem <player> <item id> <quantity>
- 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]) = 0 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]) = 0) 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% = \"ALL\"
- cmd edit rmitem 102 if varset(%args%[3]) = 0 then goto 120
- cmd edit rmitem 103 if %args%[3] = \"\" then goto 120
- cmd edit rmitem 104 %cond% = \"LIM\"
- 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 quantity and remove item starts here.
- cmd edit rmitem 121 %inv% = playerinventory(%player%)
- cmd edit rmitem 122 async
- cmd edit rmitem 123 %index% = size(%inv%) - 1
- cmd edit rmitem 124 %get-slot% = %inv%[%index%]
- cmd edit rmitem 125 %check-id% = %get-slot%[\"id\"]
- cmd edit rmitem 126 %check-variant% = %get-slot%[\"variant\"]
- cmd edit rmitem 127 if %check-id% != %item-id% then goto 143
- cmd edit rmitem 128 if %check-variant% != %item-variant% then goto 143
- cmd edit rmitem 129 if %cond% = \"ALL\" then goto 141
- cmd edit rmitem 130 %count% = %get-slot%[\"count\"]
- cmd edit rmitem 131 if %quantity% >= %count% then goto 140
- cmd edit rmitem 132 %new-count% = %count% - %quantity%
- cmd edit rmitem 133 if %new-count% = 0 then goto 140
- cmd edit rmitem 134 %new-item%[\"id\"] = %item-id%
- cmd edit rmitem 135 %new-item%[\"variant\"] = %item-variant%
- cmd edit rmitem 136 %new-item%[\"count\"] = %new-count%
- cmd edit rmitem 137 %new-item%[\"tags\"] = \"\"
- cmd edit rmitem 138 %inv%[%index%] = %new-item%
- cmd edit rmitem 139 goto 160
- cmd edit rmitem 140 %quantity% = %quantity% - %count%
- cmd edit rmitem 141 # Condition: ALL
- cmd edit rmitem 142 %inv%[%index%] =
- cmd edit rmitem 143 # Update index
- cmd edit rmitem 144 %index% = %index% - 1
- cmd edit rmitem 145 if %cond% = \"ALL\" then goto 147
- cmd edit rmitem 146 if %quantity% <= 0 then goto 160
- cmd edit rmitem 147 if %index% > -1 then goto 124
- cmd edit rmitem 160 # Update player's inventory.
- cmd edit rmitem 161 sync
- cmd edit rmitem 162 carry %player% %inv%
- cmd edit rmitem 163 %check% = substring(%player%, -1, 1)
- cmd edit rmitem 164 if %check% = \"s\" then message %p% §aPlayer §6%player%§a' inventory updated!
- 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