mirror of
https://github.com/mt-mods/playerfactions.git
synced 2024-11-29 18:53:49 +01:00
join: cleanup
- don't call get_player_factions() unless needed - use get_player_factions() instead of depricated get_player_faction() - truth check of password in valid_password() for easier understanding of code - remove explicit nil check where not needed
This commit is contained in:
parent
86ba332441
commit
d0520d2221
6
init.lua
6
init.lua
@ -149,7 +149,7 @@ function factions.hash_password(password)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function factions.valid_password(fname, password)
|
function factions.valid_password(fname, password)
|
||||||
if not facts[fname] then
|
if not facts[fname] or not password then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return factions.hash_password(password) == facts[fname].password256
|
return factions.hash_password(password) == facts[fname].password256
|
||||||
@ -328,11 +328,11 @@ local function handle_command(name, param)
|
|||||||
elseif action == "join" then
|
elseif action == "join" then
|
||||||
local faction_name = params[2]
|
local faction_name = params[2]
|
||||||
local password = params[3]
|
local password = params[3]
|
||||||
if factions.get_player_faction(name) ~= nil and factions.mode_unique_faction then
|
if factions.mode_unique_faction and factions.get_player_factions(name) then
|
||||||
return false, S("You are already in a faction.")
|
return false, S("You are already in a faction.")
|
||||||
elseif not faction_name then
|
elseif not faction_name then
|
||||||
return false, S("Missing faction name.")
|
return false, S("Missing faction name.")
|
||||||
elseif facts[faction_name] == nil then
|
elseif not facts[faction_name] then
|
||||||
return false, S("Faction @1 doesn't exist.", faction_name)
|
return false, S("Faction @1 doesn't exist.", faction_name)
|
||||||
elseif not factions.valid_password(faction_name, password) then
|
elseif not factions.valid_password(faction_name, password) then
|
||||||
return false, S("Permission denied: Wrong password.")
|
return false, S("Permission denied: Wrong password.")
|
||||||
|
Loading…
Reference in New Issue
Block a user