Oz-Lin / cs2-rockthevote

General purpose cs2 map voting plugin, made with love from scratch
11 stars 2 forks source link

End of Map vote does not show up after extending a map #2

Open alnoisegit opened 2 months ago

alnoisegit commented 2 months ago

After extending a map, the end of map vote does not show up when it hits the specified time left. Instead the map changes to a random one from the map list when time runs out.

Oz-Lin commented 2 months ago

I'll try to investigate after work. I have something on the dev branch, but the new release is not available yet. So far the ExtendRoundStep is bugged, and the first ExtendTimeStep is bugged for the first mp_timelimit extension. What game mode or mods are you running on your server?

alnoisegit commented 2 months ago

I tried the version on the dev branch and on that one the !nominate menu doesn't work at all for me. Nominating a specific map works but when you do !nominate it doesn't bring up the menu. I also get the same issue with the end of map vote after extending a map.

I'm using custom gamemode with mp_timelimit 30, using SharpTimer which controls the server settings. ST executes the server cfg every time a map is loaded.

I'm not sure if you want me to create another issue on git but I also noticed on map change the server changes to a seemingly random map from the list before it changes to the map that was voted on. This causes players that don't have the map from workshop to be disconnected because it starts the download for the wrong map and doesn't reconnect when it finishes.

Here's the cfg I'm using to test

`// Round Settings mp_roundtime 30 mp_roundtime_defuse 30 mp_roundtime_hostage 30 mp_timelimit 30 mp_maxrounds 0
mp_freezetime 0 mp_halftime false
mp_overtime_enable false mp_round_restart_delay 0
mp_team_intro_time 0 mp_team_timeout_max 0
mp_technical_timeout_per_team 0 sv_warmup_to_freezetime_delay 0
mp_buytime 0 mp_ignore_round_win_conditions false
mp_respawn_immunitytime -1 mp_respawn_on_death_ct true mp_respawn_on_death_t true mp_warmuptime 0 mp_warmup_end

// Movement sv_airaccelerate 150 sv_enablebunnyhopping 1 sv_autobunnyhopping 1 sv_falldamage_scale 0 sv_staminajumpcost 0 sv_staminalandcost 0 sv_timebetweenducks 0.400000 sv_staminarecoveryrate 60.0 sv_staminamax 80.0 sv_ladder_scale_speed 0.780000 sv_jump_impulse 301.993378 sv_friction 5.2 sv_accelerate_use_weapon_speed false sv_clamp_unsafe_velocities 0 sv_accelerate 6.5 sv_maxvelocity 9876.0 sv_air_max_wishspeed 30.000000 sv_gravity 800.0 sv_ledge_mantle_helper 0.0 sv_standable_normal 0.7 sv_wateraccelerate 10.0 sv_water_movespeed_multiplier 0.8 sv_water_swim_mode 0.0 sv_weapon_encumbrance_per_item 0 sv_weapon_encumbrance_scale 0.0

// Team & Map Settings ff_damage_reduction_bullets 0 ff_damage_reduction_grenade 0 ff_damage_reduction_grenade_self 0 ff_damage_reduction_other 0 mp_damage_headshot_only 1 mp_damage_scale_ct_head 0.0 mp_damage_scale_t_head 0.0 mp_damage_scale_ct_body 0.0 mp_damage_scale_t_body 0.0 mp_autokick 0 mp_autoteambalance 0 mp_forcecamera 0
mp_force_pick_time 60 mp_friendlyfire 0 mp_limitteams 0
mp_randomspawn 0 mp_randomspawn_los 0 mp_solid_teammates 1
mp_spectators_max 64 mp_suicide_penalty false mp_team_timeout_max 0
mp_teamname_1 "SHARPTIMER"
mp_teamname2 "X.COM/DEAFPS"
sv_falldamage_scale 0 sv_show_teammate_death_notification 0 sv_disable_radar 1

// Money & Weapon Stuff mp_afterroundmoney 0 mp_free_armor 0
mp_maxmoney 0 mp_startmoney 0
mp_teamcashawards false mp_playercashawards false mp_weapons_allow_map_placed false mp_weapons_allow_zeus 0 mp_weapons_glow_on_ground 0 sv_infinite_ammo 2 mp_ct_default_secondary weapon_usp_silencer mp_t_default_secondary weapon_usp_silencer mp_drop_knife_enable 1 mp_weapons_allow_map_placed 0 mp_death_drop_gun 0

// Voting Settings sv_workshop_allow_other_maps true mp_endmatch_votenextmap true
mp_endmatch_votenextmap_keepcurrent false
mp_match_end_changelevel true
mp_match_end_restart false
mp_match_restart_delay 0
sv_allow_votes true
//sv_vote_kick_ban_duration 1 //sv_vote_failure_timer 500 //sv_vote_creation_timer 500 //sv_vote_quorum_ratio 0.801 //sv_vote_count_spectator_votes false

// Voice Settings sv_auto_full_alltalk_during_warmup_half_end true sv_deadtalk true
sv_full_alltalk true sv_ignoregrenaderadio true sv_talk_enemy_dead true
sv_talk_enemy_living true

// Misc CS_WarnFriendlyDamageInterval 99999
sv_gameinstructor_enable 0 mp_disconnect_kills_players true

// Bot Settings bot_controllable 0 bot_quota_mode fill bot_quota 1 `

Oz-Lin commented 2 months ago

Nominating a specific map works but when you do !nominate it doesn't bring up the menu.

It happened once on my server as well, but typing maplist <number> on the game console lists the maps. Until I manually do css_plugins reload RockTheVote. Maybe there are teething issues when I merged code from razpberry's fork to use the ExtendMap config variables

Oz-Lin commented 2 months ago

https://github.com/Oz-Lin/cs2-rockthevote/commit/088537fc2b299d64a8fee98ea2fa937f9052b0d4 Hopefully the empty !nominate problem is solved. Will look at mp_timelimit extend map time bug this weekend

alnoisegit commented 2 months ago

!nominate still doesn't seem to be working for me on the dev branch. Doing !maplist in game gives the exception You provided wrong argument, was executed with 0 by default.. Doing !maplist (#) in game doesn't do anything at all. It doesn't do anything when I run the command in console either.

Here's the contents of my maplist.txt in case it helps. I'm also using the default generated config (only edited extend time amount to test).

//Put your map list here surf_cuboid surf_inspire surf_mesa_mine surf_void surf_botanica surf_prelude_ksf surf_grassland surf_enlightened surf_666 surf_1win

Oz-Lin commented 2 months ago

I finally found the issue. A null reference exception occurs when the server starts and the plugin loads for the first time. This bugs out both !nominate and !votemap.

As from the Discord chat https://discord.com/channels/1160907911501991946/1176224458751627514/1285859354108755989

17:02:55 [EROR] (cssharp:Core) Error invoking callback
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at cs2_rockthevote.ExtendRoundTimeManager.OnMapStart(String map) in C:\Users\OP9020\Documents\cs2-ze\cs2-rockthevote\Core\ExtendRoundTimeManager.cs:line 49
   at cs2_rockthevote.DependencyManager`2.OnMapStart(String mapName) in C:\Users\OP9020\Documents\cs2-ze\cs2-rockthevote\CrossCutting\DependencyManager.cs:line 46
   at InvokeStub_OnMapStart.Invoke(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at CounterStrikeSharp.API.Core.BasePlugin.<>c__DisplayClass51_0`1.<RegisterListener>b__2(ScriptContext context) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/BasePlugin.cs:line 298
   at InvokeStub_Action`1.Invoke(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at CounterStrikeSharp.API.Core.FunctionReference.<CreateWrappedCallback>b__18_0(fxScriptContext* context)

Until razpbery replies to me on Discord to fix the ExtendRoundTimeManager.cs code, I added an exception handling to reload the plugin itself.

https://github.com/Oz-Lin/cs2-rockthevote/commit/79fb1c1cd2f9770201d989bb4fe5233e9122cae2 I've also bumped the config version from 12 to 13, so ensure you update that.

Oz-Lin commented 1 month ago

ec2b2e4ad424aa31d19e87f5032a143e5197255c Could you try this commit? I'm using ExtendMapTimeLimit instead of ExtendRoundTime in ExtendRoundTimeManager.cs, so the extend only changes mp_timelimit now. It no longer messes with the current round time. You need to find another way to handle when the current round time reaches zero.

alnoisegit commented 1 month ago

The nomination menu seems to work now, but extend stopped working for me. When the time reaches 0 it just restarts the round instead of adding the desired extend time. I have extend set to 5 minutes in config but after extending and time running out it restarts the round using the time I have set for mp_timelimit so its adding 3 minutes. The end of map vote still isn't showing up at the end of that either and switches to a random map from the list when time runs out.