Raised This Month: $ Target: $400
 0% 

Winning Team Restriction


Post New Thread Reply   
 
Thread Tools Display Modes
ougogo
Member
Join Date: Jul 2010
Old 04-26-2011 , 10:11   Re: Winning Team Restriction
Reply With Quote #31

Could you help me please ?

Last edited by ougogo; 04-26-2011 at 10:11. Reason: Typo
ougogo is offline
ougogo
Member
Join Date: Jul 2010
Old 04-27-2011 , 15:28   Re: Winning Team Restriction
Reply With Quote #32

Up please :s
ougogo is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 04-27-2011 , 18:31   Re: Winning Team Restriction
Reply With Quote #33

Quote:
Originally Posted by ougogo View Post
Hello,

being French, I do not really understand the use of this plugin.


Could I use it to restrict all weapons except the knife to the team that lost the round? That is to say from the time they lose and when the next round begins.


Sincerely,

Hugo
Are you wanting to keep teams from attacking each other at the end of a round?
TnTSCS is offline
ougogo
Member
Join Date: Jul 2010
Old 04-28-2011 , 06:10   Re: Winning Team Restriction
Reply With Quote #34

In fact I hope that the loser of the round with only the knife as a weapon. But only losers, no winners.
ougogo is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 04-28-2011 , 09:49   Re: Winning Team Restriction
Reply With Quote #35

I don't think this is the plugin for that... but I could be wrong, maybe someone else knows a plugin that will do what he wants, which is the loser of the round has their weapons stripped
TnTSCS is offline
ougogo
Member
Join Date: Jul 2010
Old 04-29-2011 , 17:09   Re: Winning Team Restriction
Reply With Quote #36

Arf, no news? :s
ougogo is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 04-29-2011 , 17:45   Re: Winning Team Restriction
Reply With Quote #37

This isn't what you are asking for, but it still punishes the losing team

http://forums.alliedmods.net/showthread.php?p=1254308
TnTSCS is offline
ougogo
Member
Join Date: Jul 2010
Old 04-30-2011 , 14:40   Re: Winning Team Restriction
Reply With Quote #38

No no, I really want a script so when the team loses the round, she found only with the knife. But only for a few seconds to end of round, not for the next round.


Sincerely,

Hugo
ougogo is offline
Sagenth
Member
Join Date: Aug 2010
Old 07-06-2011 , 03:10   Re: Winning Team Restriction
Reply With Quote #39

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.0.4"




public Plugin:myinfo 
{
    
name "HANSE WT-Restrict",
    
author "red!",
    
description "Provides winning team restrictions",
    
version PLUGIN_VERSION,
    
url "http://www.hanse-clan.de"
};

/* Handles to convars used by plugin */
new Handle:sm_wt_restrict_enable;
new 
Handle:sm_restrict_cmd_t;
new 
Handle:sm_restrict_cmd_ct;
new 
Handle:sm_unrestrict_cmd_t;
new 
Handle:sm_unrestrict_cmd_ct;
new 
Handle:sm_restrict_cmd_unrestrict_all;
new 
Handle:sm_wt_offset;
new 
Handle:sm_wt_offset_only;
    
public 
OnPluginStart()
{
    
    
    
// connect to the setting convars
    
    
sm_wt_restrict_enable FindConVar("sm_wt_restrict_enable");
    if (
sm_wt_restrict_enable==INVALID_HANDLE) {
        
CreateConVar("sm_wt_restrict_enable""1");
        
sm_wt_restrict_enable FindConVar("sm_wt_restrict_enable");
    }
    
    
sm_wt_offset FindConVar("sm_wt_offset");
    if (
sm_wt_offset==INVALID_HANDLE) {
        
CreateConVar("sm_wt_offset""0");
        
sm_wt_offset FindConVar("sm_wt_offset");
    }
    
    
sm_wt_offset_only FindConVar("sm_wt_offset_only");
    if (
sm_wt_offset==INVALID_HANDLE) {
        
CreateConVar("sm_wt_offset_only""0");
        
sm_wt_offset FindConVar("sm_wt_offset_only");
    }
    
    
sm_restrict_cmd_t FindConVar("sm_restrict_cmd_t");
    if (
sm_restrict_cmd_t==INVALID_HANDLE) {
        
CreateConVar("sm_restrict_cmd_t""");
        
sm_restrict_cmd_t FindConVar("sm_restrict_cmd_t");
    }
    
sm_restrict_cmd_ct FindConVar("sm_restrict_cmd_ct");
    if (
sm_restrict_cmd_ct==INVALID_HANDLE) {
        
CreateConVar("sm_restrict_cmd_ct""");
        
sm_restrict_cmd_ct FindConVar("sm_restrict_cmd_ct");
    }
    
sm_unrestrict_cmd_t FindConVar("sm_unrestrict_cmd_t");
    if (
sm_unrestrict_cmd_t==INVALID_HANDLE) {
        
CreateConVar("sm_unrestrict_cmd_t""");
        
sm_unrestrict_cmd_t FindConVar("sm_unrestrict_cmd_t");
    }
    
sm_unrestrict_cmd_ct FindConVar("sm_unrestrict_cmd_ct");
    if (
sm_unrestrict_cmd_ct==INVALID_HANDLE) {
        
CreateConVar("sm_unrestrict_cmd_ct""");
        
sm_unrestrict_cmd_ct FindConVar("sm_unrestrict_cmd_ct");
    }

    
sm_restrict_cmd_unrestrict_all FindConVar("sm_restrict_cmd_unrestrict_all");
    if (
sm_restrict_cmd_unrestrict_all==INVALID_HANDLE) {
        
CreateConVar("sm_restrict_cmd_unrestrict_all""");
        
sm_restrict_cmd_unrestrict_all FindConVar("sm_restrict_cmd_unrestrict_all");
    }
    
    
CreateConVar("wt_restrict_version"PLUGIN_VERSION"Version of [HANSE] WT-Restrict"FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_SPONLY);

    
    
// hook round start & round end events
    //HookEvent("round_end",OnRoundEnd,EventHookMode_Post);
    
HookEvent("round_start",OnRoundStart);
    
    
RegConsoleCmd("sm_wtrestrict_status"debugPrint);
    
CreateTimer(5.0OnRoundEnd_TIMER_REPEAT);
}

new 
bool:restricted_T=false;
new 
bool:restricted_CT=false;
new 
bool:bdebug=false;

public 
Action:debugPrint(clientargs)
{
    
//PrintToConsole(client,"[wt_restrict] ct score %d, restriction %d, t score %d, restriction %d", GetTeamScore(TEAM_CT), restricted_CT, GetTeamScore(TEAM_T), restricted_T);
    
return Plugin_Handled;
}



set_T_restriction(bool:restrict)
{
    new 
String:cmd[256];
    if (
restricted_T!=restrict
    {
        
restricted_T=restrict;
        
        if (
restrict)
        {
            
// call sm_restrict_cmd_t
            
GetConVarString(sm_restrict_cmd_tcmd128);
            
//PrintToServer("[wt_restrict] exec: %s", cmd);
            //ServerCommand("%s", cmd);
        

        else 
        {
            
// call sm_unrestrict_cmd_t
            
GetConVarString(sm_unrestrict_cmd_tcmd128);
            
//PrintToServer("[wt_restrict] exec: %s", cmd);
            //ServerCommand("%s", cmd);
        
}
    }
}

set_CT_restriction(bool:restrict)
{
    new 
String:cmd[256];
    if (
restricted_CT!=restrict
    {
        
restricted_CT=restrict;
        
        if (
restrict)
        {
            
// call sm_restrict_cmd_ct
            
GetConVarString(sm_restrict_cmd_ctcmd256);
            
//PrintToServer("[wt_restrict] exec: %s", cmd);
            //ServerCommand("%s", cmd);
        

        else 
        {
            
// call sm_unrestrict_cmd_ct
            
GetConVarString(sm_unrestrict_cmd_ctcmd256);
            
//PrintToServer("[wt_restrict] exec: %s", cmd);
            //ServerCommand("%s", cmd);
        
}
    }
}

#define TEAM_T 2
#define TEAM_CT 3

public Action:OnRoundEnd(Handletimer)
{    
    
// break if plugin is disabled
    
if (GetConVarInt(sm_wt_restrict_enable)==0
    {
        
set_CT_restriction(false);
        
set_T_restriction(false);
        return;
    }
    
    
// evaluate teams to actiavte restrictions for
    
if(GetTeamScore(TEAM_T) > GetTeamScore(TEAM_CT))
    {
//Terrorists are in the lead
        
if((GetTeamScore(TEAM_T) - GetTeamScore(TEAM_CT)) >= GetConVarInt(sm_wt_offset))
        {
//Terrorirsts need to be restricted
            
set_CT_restriction(false);
            
set_T_restriction(true);
        }
        else if(
GetConVarInt(sm_wt_offset_only) != 0)
        {
//Terrorists no longer need restriction
            
set_T_restriction(false);
        }
    }
    else if(
GetTeamScore(TEAM_CT) > GetTeamScore(TEAM_T))
    {
//CT team is in the lead
        
if((GetTeamScore(TEAM_CT) - GetTeamScore(TEAM_T)) >= GetConVarInt(sm_wt_offset))
        {
//CT team needs to be restricted
            
set_CT_restriction(true);
            
set_T_restriction(false);
        }
        else if(
GetConVarInt(sm_wt_offset_only) != 0)
        {
//CT team no longer needs restriction
            
set_CT_restriction(false);
        }
    }
    else
//Even game
    
{
        
set_CT_restriction(false);
        
set_T_restriction(false);
    }
    if(
bdebug)
    
PrintToChatAll("exit");
}

public 
OnRoundStart(Handleevent , const Stringname[] , booldontBroadcast)
{    
    
// announcements
    
if(restricted_T)
    {
        
PrintToChatAll("\x04Terrorists: Awp/Auto Restriction = 0");
        
PrintToChatAll("\x04Counter-Terrorists: Awp/Auto Restriction = 2");
    }
    else if(
restricted_CT)
    {
        
PrintToChatAll("\x04Terrorists: Awp/Auto Restriction = 2");
        
PrintToChatAll("\x04Counter-Terrorists: Awp/Auto Restriction = 0");
    }
    else
    {
        
PrintToChatAll("\x04Terrorists: Awp/Auto Restriction = 2");
        
PrintToChatAll("\x04Counter-Terrorists: Awp/Auto Restriction = 2");
    }
}

public 
OnMapStart() 
{
    
set_CT_restriction(false);
    
set_T_restriction(false);
    
    
//new String:cmd[256];
    //GetConVarString(sm_restrict_cmd_unrestrict_all, cmd, 256);
    //ServerCommand("%s", cmd);

I don't fully understand why this mod was broken, but I've fixed it with a timer. I spent 5 hours and didn't fix anything, I ended up replacing the OnRoundEnd event hook with a timer of the same name.

For some strange reason it was rarely completing the call "onroundend" which resulted in one debug print actually being printed, but no others.
I was able to figure out it happened usually on a function call or during a "new" identifier

Anyways here is the code, and here is the .smx
It is hardcoded for every 5 seconds. If you don't want it to run its checks every 5 seconds just open up the source and find 5.0 change it and put it into the compiler on the sourcemod homepage.

Edit: Removed inconsistencies in colour formatting and removed some debugging information.

I forgot to mention earlier that I have also hardcoded the announcements to say awp and auto restricted to 2 or 0 depending on the winning team or if the teams are even. I just didn't care for the regular ones, they are still there but commented. "//ServerCommand("%s", cmd);" remove the //

My announcements are in OnRoundStart
Attached Files
File Type: smx wt_restrict.smx (4.0 KB, 82 views)

Last edited by Sagenth; 07-06-2011 at 03:22.
Sagenth is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 07-06-2011 , 10:11   Re: Winning Team Restriction
Reply With Quote #40

Sagenth: I think I'll try your OnRoundEnd sample - it looks a little cleaner at first glance

Also, you should change
GetConVarString(sm_restrict_cmd_t, cmd, 128); and GetConVarString(sm_unrestrict_cmd_t, cmd, 128);
to
GetConVarString(sm_restrict_cmd_t, cmd, 256); and GetConVarString(sm_unrestrict_cmd_t, cmd, 128);
because the two for cmd_ct are set to 256 and 128 wasn't enough for me since I wanted four lines of text to let everyone know weapons had been restricted and the loosing team was awarded cash.

And the hard coded AWP/Auto message is fine for you, but this plugin was meant to be a low level plugin and completely dependent on other plugins - it wasn't necessarily meant to restrict awps/autos (even though that's what I use it for ;)) If someone wanted to restrict awps/autos to 3 per team, I guess all they'd have to do is alter the hard coded message and change the 2 to a 3

Also, next time, just upload the .sp file and this forum will create the .smx for you :)

...:: TnT Edit ::...
The current OnRoundEnd on original plugin is kinda junky... thanks for your cleaner code (although the original code has worked for me flawlessly)
PHP Code:
public OnRoundEnd(Handleevent , const Stringname[] , booldontBroadcast)
{
    
// count scores
    
new winner GetEventInt(event"winner");
    
    if (
winner==TEAM_Tscore_t++;
    if (
winner==TEAM_CTscore_ct++;

    
    
// break if plugin is disabled
    
if (GetConVarInt(sm_wt_restrict_enable)==0
    {
        
set_CT_restriction(false);
        
set_T_restriction(false);
        return;
    }
    
    
    new 
offset GetConVarInt(sm_wt_offset);
    
    
// evaluate teams to actiavte restrictions for
    
if ((score_t+offset>=score_ct) && (score_ct+offset>=score_t)) {
        
set_CT_restriction(false);
        
set_T_restriction(false);
    } else if (
score_t>score_ct) {
        
set_CT_restriction(false);
        
set_T_restriction(true);
    } else if (
score_t<score_ct) {
        
set_CT_restriction(true);
        
set_T_restriction(false);
    }


Last edited by TnTSCS; 07-06-2011 at 10:21.
TnTSCS is offline
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:58.


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