1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00

Fixed chat mentions for MP

This commit is contained in:
SimonFlapse 2018-11-16 21:32:38 +01:00
parent 7437b9b835
commit 98d8a1ae6f

View File

@ -125,39 +125,43 @@ local function hodor(event)
if global.mention_enabled then
local missing_player_string
local not_found = 0
local admin_call = false
local cannot_mention = {}
for word in event.message:gmatch('#%S+') do
local lower_word = word:lower()
local success = false
local admin_call = false
if lower_word == '#admin' or lower_word == '#moderator' then
admin_call = true
end
local cannot_mention = {}
for _, p in ipairs(game.connected_players) do
if admin_call and p.admin then
p.print(prefix..Game.get_player_by_index(event.player_index).name..' mentioned #admin!', {r = 1, g = 1, b = 0, a = 1})
p.print(prefix..Game.get_player_by_index(event.player_index).name..' mentioned '..word..'!', {r = 1, g = 1, b = 0, a = 1})
p.play_sound{path='utility/new_objective', volume_modifier = 1 }
success = true
end
if not admin_call and '#'..p.name == word then
if p.name == player.name then
player.print(prefix..'Can\'t mention yourself!', {r = 1, g = 0, b = 0, a = 1})
success = true
break;
end
p.print(prefix..Game.get_player_by_index(event.player_index).name..' mentioned you!', {r = 1, g = 1, b = 0, a = 1})
p.play_sound{path='utility/new_objective', volume_modifier = 1 }
success = true
if _DEBUG then
player.print(prefix..'Successful mentioned '..p.name, {r = 0, g = 1, b = 0, a = 1})
end
elseif not admin_call then
not_found = not_found + 1
table.insert(cannot_mention, (word .. ', '))
end
end
for _, pname in ipairs(cannot_mention) do
missing_player_string = missing_player_string~=nil and missing_player_string .. pname or pname
if not success then
not_found = not_found + 1
table.insert(cannot_mention, (word .. ', '))
end
admin_call = false
end
for _, pname in ipairs(cannot_mention) do
missing_player_string = missing_player_string~=nil and missing_player_string .. pname or pname
end
if missing_player_string ~= nil then
missing_player_string = string.sub(missing_player_string, 1, (string.len(missing_player_string)-2))