Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clearinventory(name, param)
- if param == nil or param == "" then
- local playername = minetest.env:get_player_by_name(name)
- local inventory = {}
- playername:get_inventory():set_list("main", inventory)
- print(name.." has cleared his inventory.")
- minetest.chat_send_player(name, 'Inventory Cleared!')
- return
- elseif minetest.check_player_privs(name, {clearinventory_admin=true}) then
- local playername = minetest.env:get_player_by_name(param)
- local inventory = {}
- playername:get_inventory():set_list("main", inventory)
- print(name.." has cleared " ..param.."'s inventory.")
- minetest.chat_send_player(name, 'Inventory Cleared!')
- return
- else
- minetest.chat_send_player(name, 'You do not have the priveleges necessary to clear another\'s inventory')
- return false;
- end
- end
- minetest.register_chatcommand('clearinv',{
- description = 'Clear your inventory.',
- params = "<playername> | name of player (optional)",
- privs = {clearinventory=true},
- func = clearinventory
- })
- minetest.register_privilege("clearinventory", "Permission to use /clearinventory to clear your inventory.")
- minetest.register_privilege("clearinventory_admin", "Permission to use /clearinventory to clear your inventory.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement