forked from mtcontrib/factions
Fixing bullshit
This commit is contained in:
parent
dba04e2e5a
commit
97a3bab635
@ -146,8 +146,7 @@ function factions_chat.cmdhandler(playername,parameter)
|
||||
if params[3] ~= nil then
|
||||
local toremove = minetest.env:get_player_by_name(params[3])
|
||||
--allowed if faction_admin, admin of faction or player itself
|
||||
if minetest.check_player_privs(playername,{ faction_admin=true }) or
|
||||
factions.is_admin(params[2],playername) and
|
||||
if factions.is_admin(params[2],playername) and
|
||||
toremove ~= nil then
|
||||
|
||||
factions.member_remove(params[2],toremove)
|
||||
@ -190,29 +189,9 @@ function factions_chat.cmdhandler(playername,parameter)
|
||||
end
|
||||
end
|
||||
--end
|
||||
|
||||
if cmd == "
|
||||
if cmd == "join" then
|
||||
if params[2] ~= nil then
|
||||
if params[3] ~= nil and
|
||||
minetest.check_player_privs(playername,{ faction_admin=true }) then
|
||||
|
||||
local toadd = minetest.env:get_player_by_name(params[3])
|
||||
|
||||
if toadd ~= nil then
|
||||
if factions.member_add(params[2],toadd) then
|
||||
minetest.chat_send_player(playername,
|
||||
"Factions: " .. params[3] .. " joined faction " ..
|
||||
params[2],
|
||||
false)
|
||||
return
|
||||
end
|
||||
end
|
||||
minetest.chat_send_player(playername,
|
||||
"Factions: " .. params[3] .. " FAILED to join faction " ..
|
||||
params[2],
|
||||
false)
|
||||
return
|
||||
else
|
||||
--check for invitation
|
||||
if factions.is_invited(params[2],playername) then
|
||||
if factions.member_add(params[2],player) then
|
||||
@ -234,7 +213,6 @@ function factions_chat.cmdhandler(playername,parameter)
|
||||
false)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
13
factions.lua
13
factions.lua
@ -53,6 +53,7 @@ function factions.add_faction(name)
|
||||
factions.data.factions[name].base_reputation = {}
|
||||
factions.data.factions[name].adminlist = {}
|
||||
factions.data.factions[name].invitations = {}
|
||||
factions.data.factions[name].owner = ""
|
||||
|
||||
factions.dynamic_data.membertable[name] = {}
|
||||
|
||||
@ -262,6 +263,10 @@ function factions.member_add(name, object)
|
||||
factions.data.objects[new_entry.name].factions[name] = true
|
||||
factions.dynamic_data.membertable[name][new_entry.name] = true
|
||||
factions.data.factions[name].invitations[new_entry.name] = nil
|
||||
if factions.data.factions[name].owner == ""
|
||||
factions.data.factions[name].owner = object.get_player_name()
|
||||
factions.set_admin(name,object.get_player_name(), true)
|
||||
end
|
||||
factions.save()
|
||||
return true
|
||||
end
|
||||
@ -329,6 +334,10 @@ function factions.member_remove(name,object)
|
||||
factions.save()
|
||||
return true
|
||||
end
|
||||
if factions.data.objects[id].factions[name].owner == object.get_player_name()
|
||||
factions.delete_faction(name)
|
||||
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
@ -766,13 +775,13 @@ function factions.load()
|
||||
end
|
||||
|
||||
--create special faction players
|
||||
factions.add_faction("players")
|
||||
--factions.add_faction("players")
|
||||
|
||||
--autojoin players to faction players
|
||||
minetest.register_on_joinplayer(
|
||||
function(player)
|
||||
if player:is_player() then
|
||||
factions.member_add("players",player)
|
||||
--factions.member_add("players",player)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user