Raised This Month: $51 Target: $400
 12% 

[HELP] My plugin requires new features.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
debr1s
Junior Member
Join Date: Jun 2021
Old 06-25-2021 , 18:21   [HELP] My plugin requires new features.
Reply With Quote #1

I have such a plugin, it forbids changing teams. I want players to be able to switch back to their old teams after switching to the spectator team. But they cannot move to another team.

Example: I Switched From T Team to Audience Team I Can't Switch To CT Team. I have to go back to T-Team.

Plugin won't allow me to Switch to Spec Team while in a Team. Let him. It would be great if it could be added in immunity for admins.

I'm sorry for my bad english.


Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>

public OnPluginStart()
{
	RegAdminCmd("sm_spectate", command_switchSpec, ADMFLAG_CUSTOM6, "Switch to specatate");
	RegAdminCmd("sm_spec", command_switchSpec, ADMFLAG_CUSTOM6, "Switch to specatate");
	AddCommandListener(altJoin, "jointeam");
}

public Action:command_switchSpec(client, args)
{
	switch(GetClientTeam(client))
	{
		case CS_TEAM_CT, CS_TEAM_T:
		{
			ChangeClientTeam(client, CS_TEAM_SPECTATOR);
			return Plugin_Handled;
		}

		case CS_TEAM_SPECTATOR:
		{
			ChangeClientTeam(client, CS_TEAM_T);
			return Plugin_Handled;
		}
	}

	return Plugin_Handled;
}

public Action:altJoin(Client, const String:command[], argc)
{
	if(!IsClientInGame(Client) || argc < 1) 
	{
		return Plugin_Handled;
	}
 
	decl String:arg[8];
	GetCmdArg(1, arg, sizeof(arg));
	new teamJoin = StringToInt(arg);
	new teamLeave = GetClientTeam(Client);
 
	if(teamLeave == teamJoin || IsFakeClient(Client))
	{
		return Plugin_Continue;
	} 
	else 
	{
		// ignore switches between T/CT team
		if((teamLeave == CS_TEAM_CT && teamJoin == CS_TEAM_T)
		|| (teamLeave == CS_TEAM_T  && teamJoin == CS_TEAM_CT))
		{
			return Plugin_Handled;
		}
	}
	return Plugin_Handled;
}
debr1s is offline
debr1s
Junior Member
Join Date: Jun 2021
Old 07-09-2021 , 16:37   Re: [HELP] My plugin requires new features.
Reply With Quote #2

I still need help with this.
debr1s is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-09-2021 , 17:02   Re: [HELP] My plugin requires new features.
Reply With Quote #3

cs:s or cs:go ?
Bacardi is offline
debr1s
Junior Member
Join Date: Jun 2021
Old 07-10-2021 , 16:30   Re: [HELP] My plugin requires new features.
Reply With Quote #4

Quote:
Originally Posted by Bacardi View Post
cs:s or cs:go ?
CS:GO
debr1s is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-10-2021 , 19:24   Re: [HELP] My plugin requires new features.
Reply With Quote #5

Example 1
- Admin with flag "t" have immunity
Can be change admin flag/override this access from admin_overrides.cfg, using word "sm_bypass_jointeam"
or "allow" this access without admin flag from admin_group.cfg
- Plugin remember player old team as long as player not reconnect.
- Plugin not move player in old team.
Not sure should you increase team limit little ? I don't know your autoteambalance etc. etc.
mp_limitteams 3 or 4


PHP Code:
public void OnPluginStart()
{
    
AddCommandListener(listen"jointeam");
    
HookEventEx("player_team"player_team);
}

int oldteam[MAXPLAYERS+1];

public 
Action listen(int client, const char[] commandint argc)
{
    
// human player only
    
if(client || !IsClientInGame(client) || IsFakeClient(client)) return Plugin_Continue;

    
int team GetClientTeam(client);

    
// if in team unknow or no old team recorded - skip
    
if(team || oldteam[client] < 2) return Plugin_Continue;

    
// immunity
    
if(CheckCommandAccess(client"sm_bypass_jointeam"ADMFLAG_CUSTOM6)) return Plugin_Continue;

    
// not enough arguments
    
if(argc 1) return Plugin_Handled;


    
char arg[3];
    
GetCmdArg(1argsizeof(arg));
    
    
int newteam StringToInt(arg);

    
// bad team index
    
if(newteam || newteam 3) return Plugin_Handled;

    switch(
newteam)
    {
        case 
0:    // random choose
        
{
            return 
Plugin_Handled;
        }
        case 
1// spectator
        
{
            return 
Plugin_Continue;
        }
        default: 
// T or CT
        
{
            if(
oldteam[client] != newteam)
                return 
Plugin_Handled;
        }
    }

    
    
// player need pick old team

    
return Plugin_Continue;
}

public 
void player_team(Event event, const char[] namebool dontBroadcast)
{
/*
Server event "player_team", Tick 15475:
- "userid" = "13"
- "team" = "3"
- "oldteam" = "2"
- "disconnect" = "0"
- "autoteam" = "0"
- "silent" = "0"
- "isbot" = "0"
Server event "switch_team", Tick 15475:
- "numPlayers" = "1"
- "numSpectators" = "0"
- "avg_rank" = "0"
- "numTSlotsFree" = "10"
- "numCTSlotsFree" = "9"
*/

    
int team event.GetInt("team");
    
    
// skip moving to spectator
    
if(team == 1) return;

    
int client GetClientOfUserId(event.GetInt("userid"));

    
// clear record when player disconnect or bot
    
if(event.GetBool("disconnect") || event.GetBool("isbot"))
    {
        
oldteam[client] = 0;
        return;
    }
    
    
// record
    
oldteam[client] = event.GetInt("team");

__________________
Do not Private Message @me
Bacardi is offline
debr1s
Junior Member
Join Date: Jun 2021
Old 07-17-2021 , 12:20   Re: [HELP] My plugin requires new features.
Reply With Quote #6

tested but it doesn't work
debr1s is offline
debr1s
Junior Member
Join Date: Jun 2021
Old 07-17-2021 , 12:21   Re: [HELP] My plugin requires new features.
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
Example 1
- Admin with flag "t" have immunity
Can be change admin flag/override this access from admin_overrides.cfg, using word "sm_bypass_jointeam"
or "allow" this access without admin flag from admin_group.cfg
- Plugin remember player old team as long as player not reconnect.
- Plugin not move player in old team.
Not sure should you increase team limit little ? I don't know your autoteambalance etc. etc.
mp_limitteams 3 or 4


PHP Code:
public void OnPluginStart()
{
    
AddCommandListener(listen"jointeam");
    
HookEventEx("player_team"player_team);
}

int oldteam[MAXPLAYERS+1];

public 
Action listen(int client, const char[] commandint argc)
{
    
// human player only
    
if(client || !IsClientInGame(client) || IsFakeClient(client)) return Plugin_Continue;

    
int team GetClientTeam(client);

    
// if in team unknow or no old team recorded - skip
    
if(team || oldteam[client] < 2) return Plugin_Continue;

    
// immunity
    
if(CheckCommandAccess(client"sm_bypass_jointeam"ADMFLAG_CUSTOM6)) return Plugin_Continue;

    
// not enough arguments
    
if(argc 1) return Plugin_Handled;


    
char arg[3];
    
GetCmdArg(1argsizeof(arg));
    
    
int newteam StringToInt(arg);

    
// bad team index
    
if(newteam || newteam 3) return Plugin_Handled;

    switch(
newteam)
    {
        case 
0:    // random choose
        
{
            return 
Plugin_Handled;
        }
        case 
1// spectator
        
{
            return 
Plugin_Continue;
        }
        default: 
// T or CT
        
{
            if(
oldteam[client] != newteam)
                return 
Plugin_Handled;
        }
    }

    
    
// player need pick old team

    
return Plugin_Continue;
}

public 
void player_team(Event event, const char[] namebool dontBroadcast)
{
/*
Server event "player_team", Tick 15475:
- "userid" = "13"
- "team" = "3"
- "oldteam" = "2"
- "disconnect" = "0"
- "autoteam" = "0"
- "silent" = "0"
- "isbot" = "0"
Server event "switch_team", Tick 15475:
- "numPlayers" = "1"
- "numSpectators" = "0"
- "avg_rank" = "0"
- "numTSlotsFree" = "10"
- "numCTSlotsFree" = "9"
*/

    
int team event.GetInt("team");
    
    
// skip moving to spectator
    
if(team == 1) return;

    
int client GetClientOfUserId(event.GetInt("userid"));

    
// clear record when player disconnect or bot
    
if(event.GetBool("disconnect") || event.GetBool("isbot"))
    {
        
oldteam[client] = 0;
        return;
    }
    
    
// record
    
oldteam[client] = event.GetInt("team");

You can still switch to different teams.
debr1s is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-17-2021 , 13:23   Re: [HELP] My plugin requires new features.
Reply With Quote #8

yes, if they re-connect to server (or map change.)
yes, if they have admin flag custom... t ?

Or if player wait on "choose team" after connect, game put it in team automatically.

I don't know, what is your team limit and do you have auto team balance in use.
Are you running Jail-mod or something where players need to lock in team ?
Bacardi is offline
debr1s
Junior Member
Join Date: Jun 2021
Old 07-17-2021 , 20:22   Re: [HELP] My plugin requires new features.
Reply With Quote #9

Quote:
Originally Posted by Bacardi View Post
yes, if they re-connect to server (or map change.)
yes, if they have admin flag custom... t ?

Or if player wait on "choose team" after connect, game put it in team automatically.

I don't know, what is your team limit and do you have auto team balance in use.
Are you running Jail-mod or something where players need to lock in team ?
A Classic Competitive Server for 52 Players.

I installed the plugin. However, it did not work, still players can switch to the team they want. No external plugin available.

Our setting : mp_limitteams 1
debr1s is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-18-2021 , 07:12   Re: [HELP] My plugin requires new features.
Reply With Quote #10

Example 2
- Player need choose random team, when connected into server or map change.
- After this player can choose between spectator and old team.
- If player reconnect or map change -> start read this post again above.

- Admins immunity is now removed, so you can test without thinking admin rights/overrides.
You can enable it back by erase double slash (//) line 16.

- You may counter problems with team limit.
You need either increase mp_limitteams example 5 or 0 = disable check.

- optional: you can force player in team when they connect to server automatically with
mp_force_assign_teams 1

PHP Code:
public void OnPluginStart()
{
    
AddCommandListener(listen"jointeam");
    
HookEventEx("player_spawn"player_spawn);
    
HookEventEx("player_team"player_team);
}

int oldteam[MAXPLAYERS+1];

public 
Action listen(int client, const char[] commandint argc)
{
    
// human player only
    
if(client || !IsClientInGame(client) || IsFakeClient(client)) return Plugin_Continue;

    
// immunity - disabled for now
    //if(CheckCommandAccess(client, "sm_bypass_jointeam", ADMFLAG_CUSTOM6)) return Plugin_Continue;

    // not enough arguments
    
if(argc 1) return Plugin_Handled;


    
char arg[3];
    
GetCmdArg(1argsizeof(arg));
    
    
int newteam StringToInt(arg);

    
// bad team index
    
if(newteam || newteam 3) return Plugin_Handled;

    switch(
newteam)
    {
        case 
0:    // random choose
        
{
            if(
oldteam[client] == 0)
            {
                return 
Plugin_Continue;
            }

            return 
Plugin_Handled;
        }
        case 
1// spectator
        
{
            return 
Plugin_Continue;
        }
        default: 
// T or CT
        
{
            if(
oldteam[client] != newteam)
                return 
Plugin_Handled;
        }
    }

    
    
// player need pick old team

    
return Plugin_Continue;
}

public 
void player_spawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));

    
oldteam[client] = event.GetInt("teamnum");
}

public 
void player_team(Event event, const char[] namebool dontBroadcast)
{
    
int team event.GetInt("team");
    
    
// skip moving to spectator
    
if(team == 1) return;

    
int client GetClientOfUserId(event.GetInt("userid"));

    
// clear record when player disconnect or bot
    
if(event.GetBool("disconnect") || event.GetBool("isbot"))
    {
        
oldteam[client] = 0;
        return;
    }
    
    
// record
    
oldteam[client] = event.GetInt("team");


Last edited by Bacardi; 07-18-2021 at 07:15.
Bacardi 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:38.


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