Skip to content

Custom Map Voting

Vinzuerio edited this page Jan 19, 2024 · 1 revision

Prop Hunt: X2Z has Built In MapVote function to allow player choose to vote for a next map.

To Change this behaviour to use with your Custom/External Map Voting, There's different methods on how to use your Custom/External Map Voting addons.

⚠ Disclaimer: I never used or pay any paid Map Voting Addons, so this are only a demonstration just for sake of example.

Let's say you have "CoolMapVote". There is possible way to call the map vote by using Console Command, calling a function, or using a hook. In PH:X2Z however once the Game has Ended, A Hook to call Map Voting system will occured and MapVote will appear. This can be overriden by using multiple methods below. Alternatively or you could use Very Old way by using GAMEMODE.IsEndOfGame Hook.

⚠ Note: There is actually existing hook OnEndOfGame but this never seems being used since Original Classic Prop Hunt. Use this hook in case PH_OverrideMapVote hook doesn't get called.

1. Using Console Command (if supported)

To enable custom map voting that can be accessed via custom command, you can use this method. Be sure that ph_enable_mapvote is set to 1!

  • You Need to set ph_use_custom_mapvote_cmd to 1 in order to activate this. Make sure to set ph_use_custom_mapvote tp 0
  • Enter your Map Voting console command in ph_custom_mv_concmd <command>. For this Example it can be anything depends on how the addon was designed: ph_custom_mv_concmd start_coolmapvote
  • Wait until Game has ended, the custom map vote will get called instead of the built-in MapVote system.

2. Using Function Call (if supported)

To enable custom map voting that can be called by using Global Function call, you can use this method. Same as before, enable ph_enable_mapvote

  • You Need to set ph_use_custom_mapvote to 1 AND ph_use_custom_mapvote_cmd to 0
  • Enter your Map Voting Function command in ph_custom_mv_func <FunctionName()>. For Example it can be something like this: ph_custom_mv_func CoolMapVote:StartMap() - Argument may be needed
  • Wait until Game has ended, the custom map vote will get called instead of the built-in MapVote system.

3. Using Hook (PH_OverrideMapVote)

This one requires LUA coding skills in order to make this works. To make this demonstration simple, Here's how to do with lua code:

  • Be sure to set ph_enable_mapvote to 0, We will disable the mapvote and the Hook will be running.
  • Create a file /lua/autorun/server/sv_ph_mapvote.lua
  • Do the following:
hook.Add( "PH_OverrideMapVote", "Call CustomMapVote via Hook", function()
    -- Call your Map Voting function, Can be same as `ph_custom_mv_func` or anything else    
    CoolMapVote:Start() --Some addo may requires additional argument, you might have to look for it
    return true -- REQUIRED, it can be set to false in certain condition.
end )
  • Start New Game/Restart the map if you're hosting a server
  • Wait until Game has ended, the custom map vote will get called instead of the built-in MapVote system.

4. Alternative Method if none of these works (Fallback: Use OnEndOfGame)

If All of these none are working, the Map Voting system may have different style on how the game was designed. This section will teach you how to make this works by using alternative hook. ⚠ Addon Developer Note: Avoid modifying or Re-referencing GAMEMODE:EndOfGame() otherwise this will cease our Gamemode to work. Use PH_OverrideMapVote or use OnEndOfGame instead!

  • Same as method #3, the only way to do is that changing the first Argument from PH_OverrideMapVote to OnEndOfGame and remove the return true
  • Do the following:
hook.Add( "OnEndOfGame", "Call CustomMapVote via Hook", function()
    -- Call your Map Voting function, Can be same as `ph_custom_mv_func` or anything else    
    CoolMapVote:Start() --Some addo may requires additional argument, you might have to look for it
end )
  • Start New Game/Restart the map if you're hosting a server
  • Wait until Game has ended, the custom map vote will get called instead of the built-in MapVote system.

5. If Any of these don't work...

Contact the Addon Developer to fix their addons and use PH_OverrideMapVote instead for PH:X2Z.

⚠ Addon Developer Note: in PHX you just simply need a global check whether if Running Gamemode is PHX or Note. Here's example demonstration on how to do it:

hook.Add( "Initialize", "Check if PHX or Not", function()
    if (IS_PHX) or (GAMEMODE.IS_PHZ) then
        -- your Map Voting code that will use `PH_OverrideMapVote`
    else
        -- Re reference the `GAMEMODE:EndOfGame()` or Use `OnEndOfGame` hook instead.
    end
end)