Page 1 of 1

How to create a privilege?

PostPosted: Mon Sep 23, 2013 16:49
by BrunoMine
I have this mod and can not find the creator of it.
I want to set a privilege to give command to spawn.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_chatcommand("spawn", {
    params = "",
    description = "Go to spawn",
    privs = {},
    func = function(name, param)
            local player = minetest.env:get_player_by_name(name)
            minetest.chat_send_player(name, "Teletransporte to spawn...")
            player:setpos({x=0, y=0, z=0})
            return true
    end,
})

PostPosted: Mon Sep 23, 2013 16:59
by PilzAdam
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_privilege("spawn", "Can use /spawn")

minetest.register_chatcommand("spawn", {
    params = "",
    description = "Go to spawn",
    privs = {spawn=true},
    func = function(name, param)
            local player = minetest.env:get_player_by_name(name)
            minetest.chat_send_player(name, "Teletransporte to spawn...")
            player:setpos({x=0, y=0, z=0})
            return true
    end,
})

PostPosted: Mon Sep 23, 2013 18:49
by BrunoMine
Good
If I want to repeat? example spawn2
and spawn3
and spawn4
would look like?