Raised This Month: $ Target: $400
 0% 

[TF2] Autorestartgame


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MON@H Rasta
Junior Member
Join Date: Dec 2010
Location: Kyiv, Ukraine
Old 09-29-2012 , 14:05   [TF2] Autorestartgame
Reply With Quote #1

Hi everyone & Sorry for my bad english! =)
Trying to create my first plugin. It's really simple plugin. Trying to do something like this - https://forums.alliedmods.net/showthread.php?t=182698, but without advertising my server & with some automatisation + want to add command to adminmenu in the future. But first of all, I want to compile it to run on my server as "autoroundrestarter".

Readed:
But without your help can't finish =)
Thank you for understanding & help!

PHP Code:
#include <sourcemod>

new Handle:cvarAutoRestartEnabled INVALID_HANDLE;    // Auto restartgame Enabled?;
new Handle:cvarAutoRestartTime INVALID_HANDLE;    // Time in seconds before Auto restartgame (round).
new Handle:AutoRestartGameTimer;
new 
Counter;

public 
Plugin:myinfo =
{
    
name "[TF2] Autorestartgame",
    
author "MON@H Rasta",
    
description "Automaticly restarting game (round)",
    
version "1.0.0.0",
    
url ""
};

public 
OnPluginStart()
{
    
cvarAutoRestartEnabled CreateConVar("sm_autorestartgame""0""Enable/Disable Auto restartgame"FCVAR_PLUGINtrue0.0true1.0);
    
cvarAutoRestartTime CreateConVar("sm_autorestartgame_time""3600.0""Time in seconds before Auto restartgame."FCVAR_PLUGINtrue60.0);
    
RegAdminCmd ("sm_restartgame"RestartGameADMFLAG_GENERIC"Restarts the round and resets the round time");
}

public 
OnMapStart()
{
    
Counter 0;

    If(
GetConVarInt(cvarAutoRestartEnabled) == 1)
    {
        
AutoRestartGameTimer CreateTimer(1.0Count_TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
OnMapEnd()
{
    
KillTimer(AutoRestartGameTimer);
    
Counter 0;
}

RestartGame()
{
    
PrintToChatAll ("Autorestarting game in 1 second");
    
ServerCommand ("mp_restartgame 1");
    
Counter 0;
}

Count()
{
    If 
Counter GetConVarInt(cvarAutoRestartTime)
        
Counter++;
    Else
        
RestartGame();

Cpompilation result:
Code:
//// TF2_Autorestartgame.sp
// TF2_Autorestartgame.sp(21) : error 100: function prototypes do not match
// TF2_Autorestartgame.sp(28) : error 017: undefined symbol "If"
// TF2_Autorestartgame.sp(30) : error 100: function prototypes do not match
// TF2_Autorestartgame.sp(49) : error 017: undefined symbol "If"
// TF2_Autorestartgame.sp(50) : warning 217: loose indentation
// TF2_Autorestartgame.sp(51) : warning 217: loose indentation
// TF2_Autorestartgame.sp(51) : error 017: undefined symbol "Else"
// TF2_Autorestartgame.sp(52) : warning 217: loose indentation
//
// 5 Errors.
//
// Compilation Time: 0,31 sec:oops:
// ----------------------------------------

Last edited by MON@H Rasta; 09-29-2012 at 14:07.
MON@H Rasta is offline
Send a message via ICQ to MON@H Rasta Send a message via Skype™ to MON@H Rasta
Hunter S. Thompson
Senior Member
Join Date: Jun 2012
Old 09-29-2012 , 15:22   Re: [TF2] Autorestartgame
Reply With Quote #2

PHP Code:
#include <sourcemod>

new Handle:cvarAutoRestartEnabled INVALID_HANDLE;    // Auto restartgame Enabled?;
new Handle:cvarAutoRestartTime INVALID_HANDLE;    // Time in seconds before Auto restartgame (round).
new Handle:AutoRestartGameTimer INVALID_HANDLE;
new 
Counter;

public 
Plugin:myinfo =
{
    
name "[TF2] Autorestartgame",
    
author "MON@H Rasta",
    
description "Automaticly restarting game (round)",
    
version "1.0.0.0",
    
url ""
};

public 
OnPluginStart()
{
    
cvarAutoRestartEnabled CreateConVar("sm_autorestartgame""0""Enable/Disable Auto restartgame"FCVAR_PLUGINtrue0.0true1.0);
    
cvarAutoRestartTime CreateConVar("sm_autorestartgame_time""3600.0""Time in seconds before Auto restartgame."FCVAR_PLUGINtrue60.0);
    
RegAdminCmd ("sm_restartgame"RestartGameADMFLAG_GENERIC"Restarts the round and resets the round time");
}

public 
OnMapStart()
{
    
Counter 0;

    if(
GetConVarInt(cvarAutoRestartEnabled) == 1)
    {
        
AutoRestartGameTimer CreateTimer(1.0Timer_Count_TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
OnMapEnd()
{
    
KillTimer(AutoRestartGameTimer);
    
Counter 0;
}

public 
Action:RestartGame(clientargs)
{
    
PrintToChatAll ("Autorestarting game in 1 second");
    
ServerCommand ("mp_restartgame 1");
    
Counter 0;
}

stock ForceRestartGame()
{
    
PrintToChatAll ("Autorestarting game in 1 second");
    
ServerCommand ("mp_restartgame 1");
    
Counter 0;
}

public 
Action:Timer_Count(Handle:timerany:client)
{
    if (
Counter GetConVarInt(cvarAutoRestartTime))
    {
        
Counter++;
        return 
Plugin_Continue;
    }
    else
    {
        
ForceRestartGame();
        return 
Plugin_Stop;
    }

All of your errors were simple errors, such as capitalization, or missing INVALID_HANDLE, etc.

Read the error log, and you could have fixed 3 of your errors with replace capitals with lower case letters.

Last edited by Hunter S. Thompson; 09-29-2012 at 15:29.
Hunter S. Thompson is offline
MON@H Rasta
Junior Member
Join Date: Dec 2010
Location: Kyiv, Ukraine
Old 09-29-2012 , 16:10   Re: [TF2] Autorestartgame
Reply With Quote #3

PHP Code:
#include <sourcemod>

new Handle:cvarAutoRestartEnabled INVALID_HANDLE;    // Auto restartgame Enabled?;
new Handle:cvarAutoRestartTime INVALID_HANDLE;    // Time in seconds before Auto restartgame (round).
new Handle:AutoRestartGameTimer INVALID_HANDLE;
new 
Counter;

public 
Plugin:myinfo =
{
    
name "[TF2] Autorestartgame",
    
author "MON@H Rasta",
    
description "Automaticly restarting game (round)",
    
version "1.0.0.0",
    
url ""
};

public 
OnPluginStart()
{
    
cvarAutoRestartEnabled CreateConVar("sm_autorestartgame""0""Enable/Disable Auto restartgame"FCVAR_PLUGINtrue0.0true1.0);
    
cvarAutoRestartTime CreateConVar("sm_autorestartgame_time""3600.0""Time in seconds before Auto restartgame."FCVAR_PLUGINtrue60.0);
    
RegAdminCmd ("sm_restartgame"RestartGameADMFLAG_GENERIC"Restarts the round and resets the round time");
}

public 
Action:RestartGame(clientargs)
{
    
PrintToChatAll ("Autorestarting game in 1 second");
    
ServerCommand ("mp_restartgame 1");
    
Counter 0;
}

public 
OnMapStart()
{
    
Counter 0;

    if(
GetConVarInt(cvarAutoRestartEnabled) == 1)
    {
        
AutoRestartGameTimer CreateTimer(1.0Count_TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);//error 100: function prototypes do not match
    
}
}

public 
OnMapEnd()
{
    
KillTimer(AutoRestartGameTimer);
    
Counter 0;
}

stock Count()
{
    if 
Counter GetConVarInt(cvarAutoRestartTime)
        
Counter++; //error 001: expected token: "*then", but found "-identifier-"
    
else
        
RestartGame();//error 092: number of arguments does not match definition

Code:
//// TF2_Autorestartgame.sp
// TF2_Autorestartgame.sp(37) : error 100: function prototypes do not match
// TF2_Autorestartgame.sp(50) : error 001: expected token: "*then", but found "-identifier-"
// TF2_Autorestartgame.sp(52) : error 092: number of arguments does not match definition
//
// 3 Errors.
//
// Compilation Time: 0,2 sec
// ----------------------------------------
MON@H Rasta is offline
Send a message via ICQ to MON@H Rasta Send a message via Skype™ to MON@H Rasta
Hunter S. Thompson
Senior Member
Join Date: Jun 2012
Old 09-29-2012 , 16:14   Re: [TF2] Autorestartgame
Reply With Quote #4

Quote:
Originally Posted by MON@H Rasta View Post
PHP Code:
#include <sourcemod>

new Handle:cvarAutoRestartEnabled INVALID_HANDLE;    // Auto restartgame Enabled?;
new Handle:cvarAutoRestartTime INVALID_HANDLE;    // Time in seconds before Auto restartgame (round).
new Handle:AutoRestartGameTimer INVALID_HANDLE;
new 
Counter;

public 
Plugin:myinfo =
{
    
name "[TF2] Autorestartgame",
    
author "MON@H Rasta",
    
description "Automaticly restarting game (round)",
    
version "1.0.0.0",
    
url ""
};

public 
OnPluginStart()
{
    
cvarAutoRestartEnabled CreateConVar("sm_autorestartgame""0""Enable/Disable Auto restartgame"FCVAR_PLUGINtrue0.0true1.0);
    
cvarAutoRestartTime CreateConVar("sm_autorestartgame_time""3600.0""Time in seconds before Auto restartgame."FCVAR_PLUGINtrue60.0);
    
RegAdminCmd ("sm_restartgame"RestartGameADMFLAG_GENERIC"Restarts the round and resets the round time");
}

public 
Action:RestartGame(clientargs)
{
    
PrintToChatAll ("Autorestarting game in 1 second");
    
ServerCommand ("mp_restartgame 1");
    
Counter 0;
}

public 
OnMapStart()
{
    
Counter 0;

    if(
GetConVarInt(cvarAutoRestartEnabled) == 1)
    {
        
AutoRestartGameTimer CreateTimer(1.0Count_TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);//error 100: function prototypes do not match
    
}
}

public 
OnMapEnd()
{
    
KillTimer(AutoRestartGameTimer);
    
Counter 0;
}

stock Count()
{
    if 
Counter GetConVarInt(cvarAutoRestartTime)
        
Counter++; //error 001: expected token: "*then", but found "-identifier-"
    
else
        
RestartGame();//error 092: number of arguments does not match definition

Code:
//// TF2_Autorestartgame.sp
// TF2_Autorestartgame.sp(37) : error 100: function prototypes do not match
// TF2_Autorestartgame.sp(50) : error 001: expected token: "*then", but found "-identifier-"
// TF2_Autorestartgame.sp(52) : error 092: number of arguments does not match definition
//
// 3 Errors.
//
// Compilation Time: 0,2 sec
// ----------------------------------------
Use the example I gave you.

Your timer isn't matching, and your ResetGame will never match.
Hunter S. Thompson is offline
MON@H Rasta
Junior Member
Join Date: Dec 2010
Location: Kyiv, Ukraine
Old 09-29-2012 , 16:41   Re: [TF2] Autorestartgame
Reply With Quote #5

Hunter S. Thompson, sorrry, was trying to fix mine )
Yours works fine! Thanks!
MON@H Rasta is offline
Send a message via ICQ to MON@H Rasta Send a message via Skype™ to MON@H Rasta
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 09-29-2012 , 17:11   Re: [TF2] Autorestartgame
Reply With Quote #6

Quote:
Originally Posted by MON@H Rasta View Post
Hunter S. Thompson, sorrry, was trying to fix mine )
Yours works fine! Thanks!
Your if statement just needed parentheses for that final error:

Code:
if (expression)
{

}
__________________
11530 is offline
MON@H Rasta
Junior Member
Join Date: Dec 2010
Location: Kyiv, Ukraine
Old 09-29-2012 , 17:30   Re: [TF2] Autorestartgame
Reply With Quote #7

11530, thanks!

Started new thread: https://forums.alliedmods.net/showthread.php?p=1809170
MON@H Rasta is offline
Send a message via ICQ to MON@H Rasta Send a message via Skype™ to MON@H Rasta
Hunter S. Thompson
Senior Member
Join Date: Jun 2012
Old 09-29-2012 , 17:35   Re: [TF2] Autorestartgame
Reply With Quote #8

Quote:
Originally Posted by 11530 View Post
Your if statement just needed parentheses for that final error:

Code:
if (expression)
{

}
There was more than just the if statement, he couldn't pass back ResetRound without having client, and arguments. Plus, he never had a timer, instead had a stock.
Hunter S. Thompson is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 09-29-2012 , 19:08   Re: [TF2] Autorestartgame
Reply With Quote #9

Quote:
Originally Posted by Hunter S. Thompson View Post
There was more than just the if statement, he couldn't pass back ResetRound without having client, and arguments. Plus, he never had a timer, instead had a stock.
I'm well aware of that, but you already said/fixed all that in your second post. It didn't bear repeating again. Although, if you want to nitpick, instead of copying the same three lines twice, passing RestartGame(0, 0) would have sufficed fine, since the parameters aren't used. I only stated the parentheses since Rasta was trying to compile his own version after your post.
__________________

Last edited by 11530; 09-29-2012 at 19:11.
11530 is offline
MON@H Rasta
Junior Member
Join Date: Dec 2010
Location: Kyiv, Ukraine
Old 09-30-2012 , 03:56   Re: [TF2] Autorestartgame
Reply With Quote #10

I'm wondering if plugin still be autorestarting game after "return Plugin_Stop" in timer, that made Hunter S. Thompson?
MON@H Rasta is offline
Send a message via ICQ to MON@H Rasta Send a message via Skype™ to MON@H Rasta
Reply



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:45.


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