Mutators: changed method for retrieving cookies
This commit is contained in:
parent
5946b0dac1
commit
59ca071b0f
1 changed files with 17 additions and 14 deletions
|
@ -5,6 +5,10 @@ local vmf = get_mod("VMF")
|
||||||
|
|
||||||
local _WERE_ENABLED_BEFORE = false
|
local _WERE_ENABLED_BEFORE = false
|
||||||
|
|
||||||
|
-- ####################################################################################################################
|
||||||
|
-- ##### Local functions ##############################################################################################
|
||||||
|
-- ####################################################################################################################
|
||||||
|
|
||||||
-- Assembles a list of enabled mutators
|
-- Assembles a list of enabled mutators
|
||||||
local function add_enabled_mutators_titles_to_string(separator, is_short)
|
local function add_enabled_mutators_titles_to_string(separator, is_short)
|
||||||
local enabled_mutators = {}
|
local enabled_mutators = {}
|
||||||
|
@ -16,6 +20,7 @@ local function add_enabled_mutators_titles_to_string(separator, is_short)
|
||||||
return vmf.add_mutator_titles_to_string(enabled_mutators, separator, is_short)
|
return vmf.add_mutator_titles_to_string(enabled_mutators, separator, is_short)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Sets the lobby name
|
-- Sets the lobby name
|
||||||
local function set_lobby_data()
|
local function set_lobby_data()
|
||||||
|
|
||||||
|
@ -42,23 +47,15 @@ local function set_lobby_data()
|
||||||
Managers.matchmaking.lobby:set_lobby_data(lobby_data)
|
Managers.matchmaking.lobby:set_lobby_data(lobby_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
--@TODO: maybe rewrite?
|
|
||||||
local function get_peer_id_from_cookie(client_cookie)
|
local function get_peer_id_from_cookie(client_cookie)
|
||||||
local peer_id = tostring(client_cookie)
|
return string.match(client_cookie, "%[(.-)%]")
|
||||||
for _ = 1, 3 do
|
|
||||||
peer_id = string.sub(peer_id, 1 + tonumber(tostring(string.find(peer_id, "-"))))
|
|
||||||
end
|
|
||||||
peer_id = string.sub(peer_id, 2)
|
|
||||||
peer_id = string.reverse(peer_id)
|
|
||||||
peer_id = string.sub(peer_id, 2)
|
|
||||||
peer_id = string.reverse(peer_id)
|
|
||||||
|
|
||||||
vmf:echo("PEER ID FROM COOKIE #1: [" .. tostring(peer_id) .. "]")
|
|
||||||
vmf:echo("PEER ID FROM COOKIE #2: [" .. tostring(string.match(client_cookie, "%[(%a+)%]")) .. "]")
|
|
||||||
|
|
||||||
return peer_id
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- ####################################################################################################################
|
||||||
|
-- ##### Hooks ########################################################################################################
|
||||||
|
-- ####################################################################################################################
|
||||||
|
|
||||||
-- Append difficulty name with enabled mutators' titles
|
-- Append difficulty name with enabled mutators' titles
|
||||||
vmf:hook("IngamePlayerListUI.update_difficulty", function(func_, self)
|
vmf:hook("IngamePlayerListUI.update_difficulty", function(func_, self)
|
||||||
local difficulty_settings = Managers.state.difficulty:get_difficulty_settings()
|
local difficulty_settings = Managers.state.difficulty:get_difficulty_settings()
|
||||||
|
@ -77,6 +74,7 @@ vmf:hook("IngamePlayerListUI.update_difficulty", function(func_, self)
|
||||||
self.current_difficulty_name = difficulty_name
|
self.current_difficulty_name = difficulty_name
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
-- Notify everybody about enabled/disabled mutators when Play button is pressed on the map screen
|
-- Notify everybody about enabled/disabled mutators when Play button is pressed on the map screen
|
||||||
vmf:hook("MatchmakingStateHostGame.host_game", function(func, ...)
|
vmf:hook("MatchmakingStateHostGame.host_game", function(func, ...)
|
||||||
func(...)
|
func(...)
|
||||||
|
@ -91,6 +89,7 @@ vmf:hook("MatchmakingStateHostGame.host_game", function(func, ...)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
-- Send special messages with enabled mutators list to players just joining the lobby
|
-- Send special messages with enabled mutators list to players just joining the lobby
|
||||||
vmf:hook("MatchmakingManager.rpc_matchmaking_request_join_lobby", function(func, self, sender, client_cookie, ...)
|
vmf:hook("MatchmakingManager.rpc_matchmaking_request_join_lobby", function(func, self, sender, client_cookie, ...)
|
||||||
local name = add_enabled_mutators_titles_to_string(", ")
|
local name = add_enabled_mutators_titles_to_string(", ")
|
||||||
|
@ -101,4 +100,8 @@ vmf:hook("MatchmakingManager.rpc_matchmaking_request_join_lobby", function(func,
|
||||||
func(self, sender, client_cookie, ...)
|
func(self, sender, client_cookie, ...)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- ####################################################################################################################
|
||||||
|
-- ##### Return #######################################################################################################
|
||||||
|
-- ####################################################################################################################
|
||||||
|
|
||||||
return set_lobby_data
|
return set_lobby_data
|
Loading…
Add table
Reference in a new issue