Advertisement
Guest User

Untitled

a guest
Feb 5th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. function clearinventory(name, param)
  2.     if param == nil or param == "" then
  3.         local playername = minetest.env:get_player_by_name(name)
  4.         local inventory = {}
  5.         playername:get_inventory():set_list("main", inventory)
  6.         print(name.." has cleared his inventory.")
  7.         minetest.chat_send_player(name, 'Inventory Cleared!')
  8.     return
  9.     elseif minetest.check_player_privs(name, {clearinventory_admin=true}) then
  10.         local playername = minetest.env:get_player_by_name(param)
  11.         local inventory = {}
  12.         playername:get_inventory():set_list("main", inventory)
  13.         print(name.." has cleared " ..param.."'s inventory.")
  14.         minetest.chat_send_player(name, 'Inventory Cleared!')
  15.     return
  16.     else
  17.         minetest.chat_send_player(name, 'You do not have the priveleges necessary to clear another\'s inventory')
  18.         return false;
  19.     end
  20. end
  21. minetest.register_chatcommand('clearinv',{
  22.     description = 'Clear your inventory.',
  23.     params = "<playername> | name of player (optional)",
  24.     privs = {clearinventory=true},
  25.     func = clearinventory
  26. })
  27. minetest.register_privilege("clearinventory", "Permission to use /clearinventory to clear your inventory.")
  28.  
  29. minetest.register_privilege("clearinventory_admin", "Permission to use /clearinventory to clear your inventory.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement