Raised This Month: $32 Target: $400
 8% 

Restarting the Round?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MyWarthog
Senior Member
Join Date: Feb 2013
Old 08-17-2015 , 00:56   Restarting the Round?
Reply With Quote #1

How wold I go about restarting the round?

This:

Code:
SetConVarInt(FindConVar(mp_restartgame, 1));
returns this:

Code:
017: undefined symbol mp_restartgame

Alternatively, is there maybe a way to respawn all players directly (instantly) through the code through like a function or something like that? This is for a TF2 plugin.
MyWarthog is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 08-17-2015 , 01:27   Re: Restarting the Round?
Reply With Quote #2

Code:
SetConVarInt(FindConVar("mp_restartgame"), 1, false, false);
Maxximou5 is offline
versatile_bfg
Veteran Member
Join Date: Feb 2012
Old 08-17-2015 , 02:17   Re: Restarting the Round?
Reply With Quote #3

could just send the server command:

https://sm.alliedmods.net/new-api/console/ServerCommand
PHP Code:
ServerCommand("mp_restartgame 1"); 
__________________

Last edited by versatile_bfg; 08-17-2015 at 02:18.
versatile_bfg is offline
MyWarthog
Senior Member
Join Date: Feb 2013
Old 08-17-2015 , 02:30   Re: Restarting the Round?
Reply With Quote #4

^ I've read some things about security issues with using ServerCommand, though, which is kind of why I'm trying to stay away from it.

And I'll try that, Maxx. Thanks!
MyWarthog is offline
versatile_bfg
Veteran Member
Join Date: Feb 2012
Old 08-17-2015 , 04:39   Re: Restarting the Round?
Reply With Quote #5

Quote:
Originally Posted by MyWarthog View Post
^ I've read some things about security issues with using ServerCommand, though, which is kind of why I'm trying to stay away from it.

And I'll try that, Maxx. Thanks!
https://forums.alliedmods.net/showthread.php?t=254865

Is that what you mean? If so you are hard coding the command so it wont be able to do that.
__________________
versatile_bfg is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 08-17-2015 , 06:39   Re: Restarting the Round?
Reply With Quote #6

The issue, if you want to know why it wasn't working, was because you were asking for:
FindConVar(mp_restartgame, 1)
It should actually be:
FindConVar("mp_restartgame")
That's because you are looking for the convar, not the value, you want to set the value with the next command SetConVarInt.
Maxximou5 is offline
TheUnderTaker
Senior Member
Join Date: Dec 2013
Location: Israel
Old 08-17-2015 , 06:59   Re: Restarting the Round?
Reply With Quote #7

PHP Code:
Handle RG;

public 
OnPluginStart()
{
RG FindConVar("mp_restartgame");
}

public 
Action:X(clientargs)
{
SetConVarInt(RG1);

__________________
SourcePawn, C# and C++ Programmer.

My plugin list
TheUnderTaker is offline
ESK0
BANNED
Join Date: May 2014
Location: Czech Republic
Old 08-17-2015 , 13:07   Re: Restarting the Round?
Reply With Quote #8

CS_TerminateRound(1.0, CSRoundEnd_GameStart);
ESK0 is offline
MyWarthog
Senior Member
Join Date: Feb 2013
Old 08-19-2015 , 18:57   Re: Restarting the Round?
Reply With Quote #9

Maxx's code worked. And thanks for the info about that ServerCommand command/function, I'll keep that in mind. I also figured out respawning all players.....

Code:
				for (new i = 1; i <= MaxClients; i++)
				{
					if (IsClientInGame(i) && GetClientTeam(i) != 1  && GetClientTeam(i) != 0)
					{
						TF2_RespawnPlayer(i);
					}
				}
This is all for an update to an old/out-of-date/abandoned plugin that I'm doing. Release sometime within the next couple of days or so.

Thanks again, guys.

Last edited by MyWarthog; 08-19-2015 at 18:58.
MyWarthog is offline
foxhound27
AlliedModders Donor
Join Date: Sep 2019
Location: Argentina
Old 02-15-2020 , 21:59   Re: Restarting the Round?
Reply With Quote #10

i know this is old but this is to help more users here 2 ways.

PHP Code:
        ServerCommand("sm_cvar \"%s\" \"%i\"""mp_restartgame"1);
        
FindConVar("mp_restartgame").IntValue 
foxhound27 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:54.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode