Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protector mod calls deprecated factions.get_player_faction #10

Open
dennisjenkins75 opened this issue Jan 26, 2022 · 2 comments
Open

protector mod calls deprecated factions.get_player_faction #10

dennisjenkins75 opened this issue Jan 26, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@dennisjenkins75
Copy link

The protector mod calls deprecated factions.get_player_faction (returns one faction name). This is logged to the server logs repeatedly. The replacement, factions.get_player_factions, returns all factions (players can be members of more than 1).

@wsor4035
Copy link

relevant section https://github.com/mt-mods/playerfactions/blob/77fe095ac839908b71ea0d9b1a58a3a6c171c465/init.lua#L60-L72. additionally the readme should probably to updated to denote its depreciated status

@wsor4035
Copy link

wsor4035 commented Jan 26, 2022

current:

protector/init.lua

Lines 60 to 80 in 3a3b225

-- check for member name
local is_member = function (meta, name)
if factions_available
and meta:get_int("faction_members") == 1
and factions.get_player_faction(name) ~= nil
and factions.get_player_faction(meta:get_string("owner")) ==
factions.get_player_faction(name) then
return true
end
for _, n in pairs(get_member_list(meta)) do
if n == name then
return true
end
end
return false
end

not tested but should work

local is_member = function (meta, name)

	if factions_available and meta:get_int("faction_members") == 1 then
        local p_factions = factions.get_player_factions(name)
        local o_factions = factions.get_player_factions(meta:get_string("owner"))
        for _, o_faction in pairs(o_factions) do
            for _, p_faction in pairs(p_factions) do
                if o_faction == p_faction then return true end
            end
        end
	end

	for _, n in pairs(get_member_list(meta)) do

		if n == name then
			return true
		end
	end

	return false
end

@BuckarooBanzay BuckarooBanzay added the bug Something isn't working label Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants