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

Request "Reconnect in the same team"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BrainDead
Junior Member
Join Date: Dec 2020
Location: Anywhere
Old 12-03-2020 , 08:25   Request "Reconnect in the same team"
Reply With Quote #1

Hello, new here. Hope i'm writing in a right section.
I need plugin who save SteamIDs of teams and when any player reconnect to the server, he join in the same team he was.
To working for spectators too.
BrainDead is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 12-06-2020 , 12:15   Re: Request "Reconnect in the same team"
Reply With Quote #2

Quote:
Originally Posted by BrainDead View Post
Hello, new here. Hope i'm writing in a right section.
I need plugin who save SteamIDs of teams and when any player reconnect to the server, he join in the same team he was.
To working for spectators too.
For how long and why? What if somebody joins a team they did not want by mistake?

PHP Code:
#include amxmodx

#define MAX_PLAYERS                32
#define MAX_AUTHID_LENGTH          64

new authid[MAX_AUTHID_LENGTH]
new 
team16 ], HashedTaskman[34], Taskmang_team[MAX_PLAYERS], g_timeframe;
new 
Float:timerg_debugging;

public 
plugin_init()

{
    
register_plugin("Reconnect to same team","A",".sρiηX҉.");
    
register_event("Money","CS_Event_handler","bf");
    
g_timeframe register_cvar("mp_teamtime","120");
    
g_debugging register_cvar("mp_teamtime_debug""0");
}

public 
client_putinserver(id)

if(
is_user_connected(id) && !is_user_bot(id))
{
    
get_user_authid(id,authid,charsmax(authid));
    
replace(authidcharsmax(authid), "STEAM_""");
    
replace_all(authidcharsmax(authid), ":""");

    
#if AMXX_VERSION_NUM == 182;
    
md5(authidHashedTaskman);
    
#else
    
hash_stringauthidHash_Md5HashedTaskmancharsmax(HashedTaskman) );
    
#endif

    
if(get_pcvar_num(g_debugging) > 1)
        
server_print("Md5 hash of %s is %s^n",authid,HashedTaskman);

    
#if AMXX_VERSION_NUM == 182;

    
Taskman str_to_num(HashedTaskman);

    
#else

    
Taskman strtol(HashedTaskman);

    
#endif
    
    
if (Taskman 1000)
        
Taskman str_to_num(authid);


    if(
get_pcvar_num(g_debugging))
        
server_print("String to number of hash %s is %i^n",HashedTaskman,Taskman);

    
    if(
task_exists(Taskman) && index_by_authid(authid) == id )

        {
           
server_print("We have a reconnection tasked.^n");
           if(
Taskman == 0)
               
remove_task(Taskman) && server_print("^n^nBad task. Deleted.^n^n")
           else
           {
               
change_task(Taskman0.1);
               
set_msg_blockget_user_msgid"MOTD" ), BLOCK_SET );
               
set_msg_blockget_user_msgid"ShowMenu" ), BLOCK_SET );
               
set_msg_blockget_user_msgid"VGUIMenu" ), BLOCK_SET );
               
set_task(0.2,"retain_team",id);
           }

        }

}

public 
retain_team(id)

{
    new 
name[MAX_PLAYERS];

    
get_user_name(id,name,charsmax(name));

    if (
id 0)
        
server_print("%s is back!"name);

    if(
is_user_connected(id) && !is_user_bot(id))

    {

        if(
get_pcvar_num(g_debugging))
            
client_print(0,print_chat"%s is back!"name);


        if(
containi(g_team"CT") )
            {
            
set_msg_blockget_user_msgid"MOTD" ), BLOCK_SET );
            
client_cmd(id"jointeam 1");
            
client_cmd(id"joinclass 6");
            
set_msg_blockget_user_msgid"ShowMenu" ), BLOCK_SET );
            
set_msg_blockget_user_msgid"VGUIMenu" ), BLOCK_ONCE );
            }

        if(
containi(g_team"TERRORIST") )
            {
            
set_msg_blockget_user_msgid"MOTD" ), BLOCK_SET );
            
client_cmd(id"jointeam 2");
            
client_cmd(id"joinclass 5")
            
set_msg_blockget_user_msgid"ShowMenu" ), BLOCK_SET );
            
set_msg_blockget_user_msgid"VGUIMenu" ), BLOCK_ONCE );
            }

        if(!
equal(g_team"TERRORIST") && !equal(g_team"CT") )
            {
            
set_msg_blockget_user_msgid"MOTD" ), BLOCK_SET );
            
set_msg_blockget_user_msgid"ShowMenu" ), BLOCK_SET );
            
set_msg_blockget_user_msgid"VGUIMenu" ), BLOCK_ONCE );
            
client_cmd(id"jointeam 6");

            }

      }

}

public 
CS_Event_handler(id)

if(
is_user_alive(id) && !is_user_bot(id))

{
    
timer get_pcvar_num(g_timeframe)*1.0;

    
get_user_team(idteamcharsmax(team));

    if(
get_pcvar_num(g_debugging))
        
server_print("%s",team);


    
get_user_authid(id,authid,charsmax(authid));
    
replace(authidcharsmax(authid), "STEAM_""");
    
replace_all(authidcharsmax(authid), ":""");

    
#if AMXX_VERSION_NUM == 182;
    
md5(authidHashedTaskman);
    
#else
    
hash_stringauthidHash_Md5HashedTaskmancharsmax(HashedTaskman) );
    
#endif

    #if AMXX_VERSION_NUM == 182;
    
Taskman str_to_num(authid)
    
#else
    
Taskman strtol(HashedTaskman)
    
#endif

    
if(!task_exists(Taskman) && !equal(team"UNASSIGNED") && Taskman != 0)

        {

        if(
containi(team"CT") )
            {
                
set_task(timer,"set_team"Taskmanteamcharsmax(team));
            }
        if(
containi(team"TERRORIST") )
            {
                
set_task(timer,"set_team"Taskmanteamcharsmax(team));
            }
        if(
containi(team"SPECTATOR") )
            {
                
set_task(timer,"set_team"Taskmanteamcharsmax(team));
            }


        }



}

public 
set_team(TaskID)
    
g_team team

stock index_by_authid
(authid[64])
{
    new 
players[MAX_PLAYERS], playercountscan[MAX_PLAYERS];
    
server_print("^nChecking index_by_authid...");
    
get_players(players,playercount"c");

    for (new 
indexauthid=0indexauthid<playercountindexauthid++)
    {
        
get_user_authid(players[indexauthid], scancharsmax(scan))
        
replace(scancharsmax(scan), "STEAM_""");
        
replace_all(scancharsmax(scan), ":""");


        if(
get_pcvar_num(g_debugging) > 2)
        {
            
server_print("^nAuth is %s.^n"authid);
            
server_print("Scan is %s.^n^n"scan);
        }
        if(
strcmp(scan,authid0) == 0)
            return 
players[indexauthid];
    }

    return 
0;

__________________

Last edited by DJEarthQuake; 12-21-2020 at 17:24. Reason: Bugfix. Str_to_num on Amxx182 is consistently inconsistent.
DJEarthQuake is offline
BrainDead
Junior Member
Join Date: Dec 2020
Location: Anywhere
Old 12-07-2020 , 03:13   Re: Request "Reconnect in the same team"
Reply With Quote #3

Quote:
Originally Posted by DJEarthQuake View Post
For how long and why? What if somebody joins a team they did not want by mistake?

PHP Code:
#include amxmodx

#define MAX_PLAYERS                32
#define MAX_AUTHID_LENGTH          64

new g_authid[MAX_AUTHID_LENGTH]
new 
team16 ], g_Taskmang_team[MAX_PLAYERS], g_timeframe;
new 
Float:timer;

public 
plugin_init()

{
    
register_plugin("Reconnect to same team","A",".sρiηX҉.");
    
register_event("Money","CS_Event_handler","bf");

    
g_Taskman str_to_num(g_authid);
    
g_timeframe register_cvar("mp_teamtime","120");
}

public 
client_putinserver(id)

if(
is_user_connected(id) && !is_user_bot(id))
{

    
get_user_authid(id,g_authid,charsmax(g_authid));

    if(
task_exists(g_Taskman))

        {
           
server_print("We have a reconnection tasked.");
           
change_task(g_Taskman0.1);
           
set_msg_blockget_user_msgid"MOTD" ), BLOCK_SET );
           
set_msg_blockget_user_msgid"ShowMenu" ), BLOCK_SET );
           
set_msg_blockget_user_msgid"VGUIMenu" ), BLOCK_SET );
           
set_task(0.2,"retain_team",id);

        }

}

public 
retain_team(id)

{
    new 
name[MAX_PLAYERS];

    
get_user_name(id,name,charsmax(name));

    if (
id 0)
        
server_print("%s is back!"name);

    if(
is_user_connected(id) && !is_user_bot(id))

    {
        
client_print(0,print_console"%s is back!"name);

        if(
containi(g_team"CT") )
            {
            
set_msg_blockget_user_msgid"MOTD" ), BLOCK_SET );
            
client_cmd(id"jointeam 1");
            
client_cmd(id"joinclass 6");
            
set_msg_blockget_user_msgid"ShowMenu" ), BLOCK_SET );
            
set_msg_blockget_user_msgid"VGUIMenu" ), BLOCK_ONCE );
            }

        if(
containi(g_team"TERRORIST") )
            {
            
set_msg_blockget_user_msgid"MOTD" ), BLOCK_SET );
            
client_cmd(id"jointeam 2");
            
client_cmd(id"joinclass 5")
            
set_msg_blockget_user_msgid"ShowMenu" ), BLOCK_SET );
            
set_msg_blockget_user_msgid"VGUIMenu" ), BLOCK_ONCE );
            }
            
        if(!
equal(g_team"TERRORIST") && !equal(g_team"CT") )
            {
            
set_msg_blockget_user_msgid"MOTD" ), BLOCK_SET );
            
set_msg_blockget_user_msgid"ShowMenu" ), BLOCK_SET );
            
set_msg_blockget_user_msgid"VGUIMenu" ), BLOCK_ONCE );
            
client_cmd(id"jointeam 6");

            }

      }

}

public 
CS_Event_handler(id)

if(
is_user_alive(id) && !is_user_bot(id))

{
    
timer get_pcvar_num(g_timeframe)*1.0;

    
get_user_team(idteamcharsmax(team));
    
server_print("%s",team);
    
get_user_authid(id,g_authid,charsmax(g_authid));

    if(!
task_exists(g_Taskman) && !equal(team"UNASSIGNED"))

        {

        if(
containi(team"CT") )
            {
                
set_task(timer,"set_team"g_Taskmanteamcharsmax(team));
            }
        if(
containi(team"TERRORIST") )
            {
                
set_task(timer,"set_team"g_Taskmanteamcharsmax(team));
            }
        if(
containi(team"SPECTATOR") )
            {
                
set_task(timer,"set_team"g_Taskmanteamcharsmax(team));
            }


        }



}

public 
set_team(TaskID)
    
g_team team 
Yep, it works perfect. The team are like PUG mode so they are perfectly match.
Time: Admin easily can change the cvar or pause the plugin.
Thank you very much.
BrainDead is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 12-07-2020 , 09:23   Re: Request "Reconnect in the same team"
Reply With Quote #4

You are welcome. It needs tested on a busy server to know how well it works.
__________________
DJEarthQuake is offline
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 12-12-2020 , 03:50   Re: Request "Reconnect in the same team"
Reply With Quote #5

DJEarthQuake i am using ur plugin


Code:
Invalid voice data

Can't "say", not connected

disconnected.
It happens when i try to use /spec

Whats the Problem???? How to fix this?

This is the Spec Plugin by Oxicrom.

PHP Code:
#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <hamsandwich>

#define PLUGIN_VERSION "1.2"

enum _:Cvars
{
    
gospec_spec_flag,
    
gospec_change_flag,
    
gospec_respawn
}

new 
g_eCvars[Cvars]

new 
CsTeams:g_iOldTeam[33],
    
g_iSpecFlag,
    
g_iChangeFlag

public plugin_init()
{
    
register_plugin("GoSpec"PLUGIN_VERSION"OciXCrom")
    
register_cvar("@CRXGoSpec"PLUGIN_VERSIONFCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
    
register_dictionary("GoSpec.txt")
    
    
register_clcmd("say /spec""GoSpec")
    
register_clcmd("say /back""GoBack")
    
register_clcmd("say /change""SwitchTeam")
    
    
g_eCvars[gospec_spec_flag] = register_cvar("gospec_spec_flag""e")
    
g_eCvars[gospec_change_flag] = register_cvar("gospec_change_flag""e")
    
g_eCvars[gospec_respawn] = register_cvar("gospec_respawn""0")
    
CC_SetPrefix("[&x03GoSpec&x01]")
}

public 
plugin_cfg()
{
    new 
szFlag[2]
    
get_pcvar_string(g_eCvars[gospec_spec_flag], szFlagcharsmax(szFlag))
    
g_iSpecFlag szFlag[0] == EOS ADMIN_ALL read_flags(szFlag)
    
get_pcvar_string(g_eCvars[gospec_change_flag], szFlagcharsmax(szFlag))
    
g_iChangeFlag szFlag[0] == EOS ADMIN_ALL read_flags(szFlag)
}

public 
GoSpec(id)
{
    if(!
HasAccess(idg_iSpecFlag))
        return 
PLUGIN_HANDLED
    
    
new CsTeams:iTeam cs_get_user_team(id)
        
    if(
iTeam == CS_TEAM_SPECTATOR)
        
CC_SendMessage(id"%L"id"GOSPEC_ALREADY_SPECTATOR")
    else
    {
        
g_iOldTeam[id] = iTeam
        cs_set_user_team
(idCS_TEAM_SPECTATOR)
        
CC_SendMessage(id"%L"id"GOSPEC_NOW_SPECTATOR")
        
        if(
is_user_alive(id))
            
user_silentkill(id)
    }
    
    return 
PLUGIN_HANDLED
}

public 
GoBack(id)
{
    if(!
HasAccess(idg_iSpecFlag))
        return 
PLUGIN_HANDLED
        
    
if(cs_get_user_team(id) != CS_TEAM_SPECTATOR)
        
CC_SendMessage(id"%L"id"GOSPEC_NOT_SPECTATOR")
    else
    {
        new 
iPlayers[32], iCTiT
        get_players
(iPlayersiCT"e""CT")
        
get_players(iPlayersiT"e""TERRORIST")
        
        if(
iCT == iT)
        {
            
cs_set_user_team(idg_iOldTeam[id])
            
CC_SendMessage(id"%L"id"GOSPEC_TRANSFERED_TO_PREVIOUS")
        }
        else
        {
            
cs_set_user_team(idiCT iT CS_TEAM_T CS_TEAM_CT)
            
CC_SendMessage(id"%L"id"GOSPEC_TRANSFERED_TO_LESS")
        }
        
        if(
get_pcvar_num(g_eCvars[gospec_respawn]))
            
ExecuteHamB(Ham_CS_RoundRespawnid)
    }        
    
    return 
PLUGIN_HANDLED
}

public 
SwitchTeam(id)
{
    if(!
HasAccess(idg_iChangeFlag))
        return 
PLUGIN_HANDLED
        
    
new CsTeams:iTeam cs_get_user_team(id)
        
        
    if(
iTeam == CS_TEAM_SPECTATOR)
        
CC_SendMessage(id"%L"id"GOSPEC_CANT_USE")
    else
    {
        
cs_set_user_team(idcs_get_user_team(id) == CS_TEAM_CT CS_TEAM_T CS_TEAM_CT)
        
CC_SendMessage(id"%L"id"GOSPEC_TRANSFERED_TO_OPPOSITE")
        
        if(
is_user_alive(id))
        {
            
user_silentkill(id)
            
            if(
get_pcvar_num(g_eCvars[gospec_respawn]))
                
ExecuteHamB(Ham_CS_RoundRespawnid)
        }            
    }
    
    return 
PLUGIN_HANDLED
}

bool:HasAccess(idiFlag)
{
    if(
iFlag == ADMIN_ALL || get_user_flags(id) & iFlag)
        return 
true
    
else
    {
        
CC_SendMessage(id"%L"id"GOSPEC_NO_ACCESS")
        return 
false
    
}
    
    
#if AMXX_VERSION_NUM < 183
    
return false
    
#endif


Last edited by Godofwar; 12-12-2020 at 03:57.
Godofwar is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 12-12-2020 , 06:50   Re: Request "Reconnect in the same team"
Reply With Quote #6

Pretty sure that's a Valve thing.
__________________
DJEarthQuake is offline
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 12-12-2020 , 06:52   Re: Request "Reconnect in the same team"
Reply With Quote #7

But i never had this problem. it comes as i added your plugin ^^
Godofwar is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 12-12-2020 , 19:03   Re: Request "Reconnect in the same team"
Reply With Quote #8

Does it do it with just those 2 plugins? Will need lang file and inc to help test please.
__________________
DJEarthQuake is offline
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 12-13-2020 , 09:32   Re: Request "Reconnect in the same team"
Reply With Quote #9

correct.

https://github.com/OciXCrom/GoSpec

And your Plugin:

PHP Code:
#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <hamsandwich>

#define PLUGIN_VERSION "1.2"

enum _:Cvars
{
    
gospec_spec_flag,
    
gospec_change_flag,
    
gospec_respawn
}

new 
g_eCvars[Cvars]

new 
CsTeams:g_iOldTeam[33],
    
g_iSpecFlag,
    
g_iChangeFlag

public plugin_init()
{
    
register_plugin("GoSpec"PLUGIN_VERSION"OciXCrom")
    
register_cvar("@CRXGoSpec"PLUGIN_VERSIONFCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
    
register_dictionary("GoSpec.txt")
    
    
register_clcmd("say /spec""GoSpec")
    
register_clcmd("say /back""GoBack")
    
register_clcmd("say /change""SwitchTeam")
    
    
g_eCvars[gospec_spec_flag] = register_cvar("gospec_spec_flag""e")
    
g_eCvars[gospec_change_flag] = register_cvar("gospec_change_flag""e")
    
g_eCvars[gospec_respawn] = register_cvar("gospec_respawn""0")
    
CC_SetPrefix("[&x03GoSpec&x01]")
}

public 
plugin_cfg()
{
    new 
szFlag[2]
    
get_pcvar_string(g_eCvars[gospec_spec_flag], szFlagcharsmax(szFlag))
    
g_iSpecFlag szFlag[0] == EOS ADMIN_ALL read_flags(szFlag)
    
get_pcvar_string(g_eCvars[gospec_change_flag], szFlagcharsmax(szFlag))
    
g_iChangeFlag szFlag[0] == EOS ADMIN_ALL read_flags(szFlag)
}

public 
GoSpec(id)
{
    if(!
HasAccess(idg_iSpecFlag))
        return 
PLUGIN_HANDLED
    
    
new CsTeams:iTeam cs_get_user_team(id)
        
    if(
iTeam == CS_TEAM_SPECTATOR)
        
CC_SendMessage(id"%L"id"GOSPEC_ALREADY_SPECTATOR")
    else
    {
        
g_iOldTeam[id] = iTeam
        cs_set_user_team
(idCS_TEAM_SPECTATOR)
        
CC_SendMessage(id"%L"id"GOSPEC_NOW_SPECTATOR")
        
        if(
is_user_alive(id))
            
user_silentkill(id)
    }
    
    return 
PLUGIN_HANDLED
}

public 
GoBack(id)
{
    if(!
HasAccess(idg_iSpecFlag))
        return 
PLUGIN_HANDLED
        
    
if(cs_get_user_team(id) != CS_TEAM_SPECTATOR)
        
CC_SendMessage(id"%L"id"GOSPEC_NOT_SPECTATOR")
    else
    {
        new 
iPlayers[32], iCTiT
        get_players
(iPlayersiCT"e""CT")
        
get_players(iPlayersiT"e""TERRORIST")
        
        if(
iCT == iT)
        {
            
cs_set_user_team(idg_iOldTeam[id])
            
CC_SendMessage(id"%L"id"GOSPEC_TRANSFERED_TO_PREVIOUS")
        }
        else
        {
            
cs_set_user_team(idiCT iT CS_TEAM_T CS_TEAM_CT)
            
CC_SendMessage(id"%L"id"GOSPEC_TRANSFERED_TO_LESS")
        }
        
        if(
get_pcvar_num(g_eCvars[gospec_respawn]))
            
ExecuteHamB(Ham_CS_RoundRespawnid)
    }        
    
    return 
PLUGIN_HANDLED
}

public 
SwitchTeam(id)
{
    if(!
HasAccess(idg_iChangeFlag))
        return 
PLUGIN_HANDLED
        
    
new CsTeams:iTeam cs_get_user_team(id)
        
        
    if(
iTeam == CS_TEAM_SPECTATOR)
        
CC_SendMessage(id"%L"id"GOSPEC_CANT_USE")
    else
    {
        
cs_set_user_team(idcs_get_user_team(id) == CS_TEAM_CT CS_TEAM_T CS_TEAM_CT)
        
CC_SendMessage(id"%L"id"GOSPEC_TRANSFERED_TO_OPPOSITE")
        
        if(
is_user_alive(id))
        {
            
user_silentkill(id)
            
            if(
get_pcvar_num(g_eCvars[gospec_respawn]))
                
ExecuteHamB(Ham_CS_RoundRespawnid)
        }            
    }
    
    return 
PLUGIN_HANDLED
}

bool:HasAccess(idiFlag)
{
    if(
iFlag == ADMIN_ALL || get_user_flags(id) & iFlag)
        return 
true
    
else
    {
        
CC_SendMessage(id"%L"id"GOSPEC_NO_ACCESS")
        return 
false
    
}
    
    
#if AMXX_VERSION_NUM < 183
    
return false
    
#endif

When i disable your Plugin, Spec works without Problems.. But when both Plugins are active then the problem comes.
Godofwar is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 12-13-2020 , 11:13   Re: Request "Reconnect in the same team"
Reply With Quote #10

I just tested GoSpec and 'Reconnect to same team' without issue going to SPEC and all my other plugins running. It's something else on your end. That's why I asked for you to test only those 2 plugins. I do not use rehlds. GoSpec is last plugin on my list.
__________________

Last edited by DJEarthQuake; 12-13-2020 at 11:18.
DJEarthQuake 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 22:35.


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