Skip to content

Commit

Permalink
Add an argument to swapteams command (#739)
Browse files Browse the repository at this point in the history
* Added an argument to `swapteams` command

* Updated `README.md` `swapteams` description

* Fixed check arguments count

* better arg usage

* better notations for readme

* better desc

Co-authored-by: Sergey Shorokhov <sergeyshorokhov@csgo.com>
  • Loading branch information
ShadowsAdi and Sergey Shorokhov authored Sep 15, 2022
1 parent e83eeae commit 98b387b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| :---------------------------------- | :---------------------------------------------- |
| game version | Will show GameDLL build version, date & URL. |
| endround | Args:<br/>`T` force round end with Terrorists win. <br/>`CT` force round end with Counter-Terrorists win. <br/> or terminate round draw when called without arguments. |
| swapteams | Swap the teams and restart the game. |
| swapteams | Swap the teams and restart the game (1 sec delay to restart by default).<br/> Args: <br/>`0` - swap teams without restart. <br/> `>0.001` - time delay in seconds to restart the round after swap. |
| give | Give weapon command.<br/> Args:<br/><weapon_name><br/>Usage:<br/>`give weapon_ak47`<br/>`give weapon_usp`<br/><br/>NOTE: `sv_cheats 1` required. |
| impulse 255 | Give all weapons.<br/><br/>NOTE: `sv_cheats 1` required. |

Expand Down
12 changes: 11 additions & 1 deletion regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,17 @@ void GameDLL_EndRound_f()
void GameDLL_SwapTeams_f()
{
CSGameRules()->SwapAllPlayers();
CVAR_SET_FLOAT("sv_restartround", 1.0);

float value = 1.0f;
if(CMD_ARGC() >= 2)
{
value = Q_atof(CMD_ARGV(1));
}

if (value > 0.0f)
{
CVAR_SET_FLOAT("sv_restartround", value);
}
}

#endif // REGAMEDLL_ADD
Expand Down

0 comments on commit 98b387b

Please sign in to comment.