Issue:
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
for _,i in ipairs(mem) do
if i.name == name then
mem[_].rank = newrank -- set new rank value
datalib.table.write(modpath.."/rank.db", mem) -- write updated table
servertools.log(name.."'s rank set to "..newrank..".")
end
end
Full set player rank function:
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
-- set rank
function servertools.set_player_rank(name, newrank)
-- check params
if not minetest.get_player_by_name(name) then
return "Invalid player: "..name
elseif not newrank then
return "New rank field required."
end
local rank_privs = servertools.get_rank_privs(newrank) -- get rank privileges
-- check that rank exists
if not rank_privs or type(rank_privs) ~= "table" then
return "Rank nonexistent."
end
-- update player privileges
if not minetest.set_player_privs(name, rank_privs) then return false end -- unsuccessful
-- TODO: fix setting table value
-- update database
for _,i in ipairs(mem) do
if i.name == name then
mem[_].rank = newrank -- set new rank value
datalib.table.write(modpath.."/rank.db", mem) -- write updated table
servertools.log(name.."'s rank set to "..newrank..".")
end
end
end
RankDB (example):
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
return {{["name"] = "singleplayer", ["rank"] = "player"}, {["name"] = "octacian", ["rank"] = "owner"}, {["name"] = "oct", ["rank"] = "player"}}
mem table (example):
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
mem = {
{ name = "singleplayer", rank = "player" },
{ name = "octacian", rank = "owner" },
{ name = "oct", rank = "player" },
}
I was thinking about removing the record, then inserting a new one, but that should definitely not be required.
Thanks.