Add an argument to swapteams command (#739)

* 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>
This commit is contained in:
Adrian Cirstea 2022-09-15 19:52:54 +03:00 committed by GitHub
parent e83eeaed39
commit 98b387bb68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -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. |

View File

@ -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