How to use the minetest.set_player_privs

Mr_A_ASAP
New member
 
Posts: 1
Joined: Fri Dec 02, 2016 10:35
In-game: Ade

How to use the minetest.set_player_privs

by Mr_A_ASAP » Fri Dec 02, 2016 10:48

Hi all,

This is my first time creating a mod and I am attempting to create a jail mod that teleports the user to a set location and removing the "home" premission from them so they cannot get out of jail.

So far I have them teleporting to the location that I would like but it crashes out on the privs part.

which is producing this error state and bugging out the server.

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
2016-12-02 10:32:46: ERROR[Main]: ServerError: Lua: Runtime error from mod 'asap_jail' in callback on_chat_message(): E:\minetest-0.4.14\bin\..\builtin\game\auth.lua:146: assertion failed!
2016-12-02 10:32:46: ERROR[Main]: stack traceback:
2016-12-02 10:32:46: ERROR[Main]:       [C]: in function 'assert'
2016-12-02 10:32:46: ERROR[Main]:       E:\minetest-0.4.14\bin\..\builtin\game\auth.lua:146: in function 'set_player_privs'
2016-12-02 10:32:46: ERROR[Main]:       E:\minetest-0.4.14\bin\..\mods\asap_jail\init.lua:23: in function 'func'
2016-12-02 10:32:46: ERROR[Main]:       E:\minetest-0.4.14\bin\..\builtin\game\chatcommands.lua:42: in function <E:\minetest-0.4.14\bin\..\builtin\game\chatcommands.lua:30>
2016-12-02 10:32:46: ERROR[Main]:       E:\minetest-0.4.14\bin\..\builtin\game\register.lua:369: in function <E:\minetest-0.4.14\bin\..\builtin\game\register.lua:349>


The code that I am using is:

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("j1", {
   params = "<player>",
   description = "Send a player to jail and remove home",
   privs = {jail = true},
   func = function (name, params)
      local player = minetest.get_player_by_name(params)
      if (player) then
         player:setpos(jailpos1)
         minetest.set_player_privs(player, {interact = true, shout = true})
      end
   end,
})


Any help will be more than appreciated on this.

Thanks

Ade

[EDIT]
I have solved this! set_privs needed a string instead of the Hex which was returned by get_player_by_name. So I used the params and tested it if they were a player and then used the string.
 

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 68 guests

cron