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

Autojoin blocks the buy menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
szogun
Senior Member
Join Date: Apr 2016
Old 04-05-2018 , 12:27   Autojoin blocks the buy menu
Reply With Quote #1

I have a problem with the plugin that blocks the change of teams and automatically adds players.
the problem is that the player can not buy a weapon

PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#pragma newdecls required
#pragma semicolon 1

ConVar cvTeamchangelimit;
ConVar cvExcludespec;
Handle hTeam;
int iTeamchangecount[MAXPLAYERS+1];

public 
Plugin myinfo =
{
    
name "Team Change Regulator",
    
author "allienmods ",
    
description "Regulates team change.",
    
version "1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=306013"
};

public 
void OnPluginStart()
{
    
hTeam CreateConVar("sm_join_team""1""Do not edit this");
    
cvTeamchangelimit CreateConVar("sm_teamchange_limit""1""Sets how many times a player may switch between teams. Default = 1");
    
cvExcludespec CreateConVar("sm_teamchange_excludespec""1""Should we exclude counting team changes to spectators? 0 = Disable");
    
AddCommandListener(cmdListener_Changeteam"jointeam");
    
HookEvent("player_connect_full"vEvent_OnFullConnectEventHookMode_Post);
}

public 
void vEvent_OnFullConnect(Event event, const char[] namebool dontBroadcast)

    
int client GetClientOfUserId(event.GetInt("userid"));
    if (
client != && IsClientInGame(client) && !IsFakeClient(client) && !bIsAdminRoot(client))
    {
        
CreateTimer(0.5tAssignTeamclient);
    }
}

public 
void OnClientPutInServer(int client)
{
    if (!
IsFakeClient(client) && IsClientInGame(client))
    {
        
iTeamchangecount[client] = 0;
    }
}

public 
Action tAssignTeam(Handle timerany client)

    if (
IsClientInGame(client))
    { 
        
int iCvar GetConVarInt(hTeam);
        switch (
iCvar)
        { 
            case 
0:
            {
                return 
Plugin_Handled;
            }

            case 
1:
            {
                
int iRed;
                
int iBlue;
                for (
int i 1<= MaxClientsi++)
                {
                    if (!
IsClientInGame(i))
                    {
                        continue;
                    }

                    
int iTeam GetClientTeam(i);
                    if (
iTeam == CS_TEAM_T)
                    {
                        
iRed++;
                    }

                    else if (
iTeam == CS_TEAM_CT)
                    {
                        
iBlue++;
                    }
                }

                if (
iRed iBlue)
                {
                    
ChangeClientTeam(client3);
                }

                else if (
iRed iBlue || iRed == iBlue
                {
                    
ChangeClientTeam(client2);
                }
            }

            case 
2:
            {
                
ChangeClientTeam(client2);
            }

            case 
3:
            {
                
ChangeClientTeam(client3);
            }
        }
    }

    return 
Plugin_Continue;
}

public 
Action cmdListener_Changeteam(int client, const char[] commandint args)
{
    if (
bIsAdminRoot(client))
    {
        return 
Plugin_Continue;
    }

    if (
iTeamchangecount[client] == cvTeamchangelimit.IntValue)
    {
        
PrintToChat(client"[TeamManager] Nie mozesz ponownie zmienic teamu!!!");
        
PrintCenterText(client"<font color='#FF0000'><b>[TeamManager]</font> <font color='#FFFFFF'>Nie mozesz ponownie zmienic teamu!!!</font>");
        return 
Plugin_Handled;
    }

    
char arg1[3];
    
GetCmdArg(1arg1sizeof(arg1));
    
int target_team StringToInt(arg1);
    
int current_team GetClientTeam(client);
    if (
target_team == current_team)
    {
        return 
Plugin_Handled;
    }

    else if ((
target_team && cvExcludespec.IntValue >= 1) || cvExcludespec.IntValue 1)
    {
        
iTeamchangecount[client]++;
    }

    return 
Plugin_Handled;
}

bool bIsAdminRoot(int client)
{
    return (
CheckCommandAccess(client"team_change_admin"ADMFLAG_ROOTfalse));


Last edited by szogun; 04-05-2018 at 12:32.
szogun is offline
pride95
Senior Member
Join Date: Aug 2015
Old 04-05-2018 , 13:13   Re: Autojoin blocks the buy menu
Reply With Quote #2

PHP Code:
mp_force_assign_teams 0
mp_force_pick_time 0 
pride95 is offline
szogun
Senior Member
Join Date: Apr 2016
Old 04-05-2018 , 13:28   Re: Autojoin blocks the buy menu
Reply With Quote #3

Unfortunately, this does not give you the solution you need. Lack of immunity and does not allow a one-off team change.

I am more interested in why this code blocks the purchase of weapons.
szogun is offline
pride95
Senior Member
Join Date: Aug 2015
Old 04-05-2018 , 18:12   Re: Autojoin blocks the buy menu
Reply With Quote #4

Quote:
Originally Posted by szogun View Post
Unfortunately, this does not give you the solution you need. Lack of immunity and does not allow a one-off team change.

I am more interested in why this code blocks the purchase of weapons.
Have you tested? Players can't buy weapons because you assign them a team before the hud with menu selection appears. So the cvar with time on 0 disables the menu on connect, but it works fine while pressing M.

Another solution: hook vguimenu with arg team. You can find the code in Snippets and Tutorials category.
pride95 is offline
szogun
Senior Member
Join Date: Apr 2016
Old 04-06-2018 , 13:59   Re: Autojoin blocks the buy menu
Reply With Quote #5

Could you adjust the plugin under the vgui menu hookah?
Unfortunately, I still do not have the skills to modify it
szogun is offline
szogun
Senior Member
Join Date: Apr 2016
Old 04-07-2018 , 07:17   Re: Autojoin blocks the buy menu
Reply With Quote #6

PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#pragma newdecls required
#pragma semicolon 1

ConVar cvTeamchangelimit;
ConVar cvExcludespec;
Handle hTeam;
int iTeamchangecount[MAXPLAYERS+1];

public 
Plugin myinfo =
{
    
name "Team Change Regulator",
    
author "",
    
description "Regulates team change.",
    
version "1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=306013"
};

public 
void OnPluginStart()
{
    
hTeam CreateConVar("sm_join_team""1""Do not edit this");
    
cvTeamchangelimit CreateConVar("sm_teamchange_limit""1""Sets how many times a player may switch between teams. Default = 1");
    
cvExcludespec CreateConVar("sm_teamchange_excludespec""1""Should we exclude counting team changes to spectators? 0 = Disable");
    
AddCommandListener(cmdListener_Changeteam"jointeam");
    
HookEvent("player_connect_full"vEvent_OnFullConnectEventHookMode_Post);
    
HookUserMessage(GetUserMessageId("VGUIMenu"),TeamMenuHook,true);
}

public 
void vEvent_OnFullConnect(Event event, const char[] namebool dontBroadcast)

    
int client GetClientOfUserId(event.GetInt("userid"));
    if (
client != && IsClientInGame(client) && !IsFakeClient(client) && !bIsAdminRoot(client))
    {
       
// CreateTimer(0.5, tAssignTeam, client);
       
CreateTimer(0.5TeamMenuHookclient);
    }
}

public 
void OnClientPutInServer(int client)
{
    if (!
IsFakeClient(client) && IsClientInGame(client))
    {
        
iTeamchangecount[client] = 0;
    }
}

//public Action tAssignTeam(Handle timer, any client)
public Action TeamMenuHook(UserMsg msg_idProtobuf msg, const int[] playersint playersNumbool reliablebool init)

    if (
IsClientInGame(client))
    { 
        
int iCvar GetConVarInt(hTeam);
        switch (
iCvar)
        { 
            case 
0:
            {
                return 
Plugin_Handled;
            }

            case 
1:
            {
                
int iRed;
                
int iBlue;
                for (
int i 1<= MaxClientsi++)
                {
                    if (!
IsClientInGame(i))
                    {
                        continue;
                    }

                    
int iTeam GetClientTeam(i);
                    if (
iTeam == CS_TEAM_T)
                    {
                        
iRed++;
                    }

                    else if (
iTeam == CS_TEAM_CT)
                    {
                        
iBlue++;
                    }
                }

                if (
iRed iBlue)
                {
                    
ChangeClientTeam(client3);
                }

                else if (
iRed iBlue || iRed == iBlue
                {
                    
ChangeClientTeam(client2);
                }
            }

            case 
2:
            {
                
ChangeClientTeam(client2);
            }

            case 
3:
            {
                
ChangeClientTeam(client3);
            }
        }
    }

    return 
Plugin_Continue;
}

public 
Action cmdListener_Changeteam(int client, const char[] commandint args)
{
    if (
bIsAdminRoot(client))
    {
        return 
Plugin_Continue;
    }

    if (
iTeamchangecount[client] == cvTeamchangelimit.IntValue)
    {
        
PrintToChat(client"[TeamManager] Nie mozesz ponownie zmienic teamu!!!");
        
PrintCenterText(client"<font color='#FF0000'><b>[TeamManager]</font> <font color='#FFFFFF'>Nie mozesz ponownie zmienic teamu!!!</font>");
        return 
Plugin_Handled;
    }

    
char arg1[3];
    
GetCmdArg(1arg1sizeof(arg1));
    
int target_team StringToInt(arg1);
    
int current_team GetClientTeam(client);
    if (
target_team == current_team)
    {
        return 
Plugin_Handled;
    }

    else if ((
target_team && cvExcludespec.IntValue >= 1) || cvExcludespec.IntValue 1)
    {
        
iTeamchangecount[client]++;
    }

    return 
Plugin_Handled;
}

bool bIsAdminRoot(int client)
{
    return (
CheckCommandAccess(client"team_change_admin"ADMFLAG_GENERICfalse));

Quote:
//// autojoin_v2.sp
//
// autojoin_v2.sp(2 : warning 217: loose indentation
// autojoin_v2.sp(37) : error 100: function prototypes do not match
// autojoin_v2.sp(52) : error 017: undefined symbol "client"
// autojoin_v2.sp(87) : error 017: undefined symbol "client"
// autojoin_v2.sp(92) : error 017: undefined symbol "client"
// autojoin_v2.sp(9 : error 017: undefined symbol "client"
// autojoin_v2.sp(103) : error 017: undefined symbol "client"
//
// 6 Errors.
//
// Compilation Time: 0,25 sec
szogun 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 09:11.


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