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

jointeam hook


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Veteran Member
Join Date: Nov 2020
Old 04-11-2021 , 16:50   jointeam hook
Reply With Quote #1

hello guys. i have this code:
PHP Code:
{
        
    new 
iPlayers[MAX_PLAYERS], iPlayeriNumiName[MAX_PLAYERS 1][MAX_NAME_LENGTH], iCount_CTiCount_TiTeam
    
    iTeam 
read_argv_int(1)
    
    
get_user_name(idiName[id], charsmax(iName[]))
    
    
get_players(iPlayersiNum)
    
    for (new 
0iNumi++)
    {
        
iPlayer iPlayers[i]
        
        if(
cs_get_user_team(iPlayer) == CS_TEAM_CT
        {
            ++
iCount_CT
        
}
        else if (
cs_get_user_team(iPlayer) == CS_TEAM_T)
        {
            ++
iCount_T
        
}
    }
            
    if (
iTeam)
    {
        switch(
iTeam)
        {
            
            case 
1
            {
                if (
iCount_T >= TEAM_LIMIT && iStarted)
                {
                    if(
cs_get_user_team(id) != CS_TEAM_SPECTATOR)
                        
cs_set_user_team(idCS_TEAM_SPECTATOR)
                        
                    
client_print_color(idprint_team_default"%s Nu poti intra la^4 Terrorist^1 pentru ca sunt^4 %i^1 jucatori."iTagTEAM_LIMIT)
                    
                    return 
PLUGIN_HANDLED
                
}
                else
                {
                    
client_print_color(0print_team_default"%s Jucatorul^4 %s^1 a intrat la echipa^4 Terrorist^1!"iTagiName[id])
                    
                    if(
iWarmUp)
                        
player_respawn(id)
                }
            }
            
            case 
2:
            {
                if (
iCount_CT >= TEAM_LIMIT && iStarted)
                {
                    if(
cs_get_user_team(id) != CS_TEAM_SPECTATOR)
                        
cs_set_user_team(idCS_TEAM_SPECTATOR)
                    
                    
client_print_color(idprint_team_default"%s Nu poti intra la^4 Counter-Terrorist^1 pentru ca sunt^4 %i^1 jucatori."iTagTEAM_LIMIT)
                    return 
PLUGIN_HANDLED
                
}
                else
                {
                    
client_print_color(0print_team_default"%s Jucatorul^4 %s^1 a intrat la echipa^4 Counter-Terrorist^1!"iTagiName[id])
                    
                    if(
iWarmUp)
                        
player_respawn(id)
                }    
            }
            
            case 
5
            {
                
client_print_color(idprint_team_default"%s Nu poti folosi^4 Auto Assign^1."iTag)
                return 
PLUGIN_HANDLED
            
}
        
        }
    }
    
    return 
PLUGIN_CONTINUE
}

public 
player_respawn(id)
{    
    if(!
is_user_alive(id) && cs_get_user_team(id) != CS_TEAM_SPECTATOR && cs_get_user_team(id) != CS_TEAM_UNASSIGNED)
        
cs_user_spawn(id)
        

i hook jointeam command. sometimes, when iStarted is false, i can t choose a team and when i choose a team, player_respawn don't work.

some ideas ?

Last edited by lexzor; 04-11-2021 at 16:52.
lexzor is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 04-11-2021 , 22:12   Re: jointeam hook
Reply With Quote #2

Does it print the message?
PHP Code:
client_print_color(0print_team_default"%s Jucatorul^4 %s^1 a intrat la echipa^4 Counter-Terrorist^1!"iTagiName[id]) 
If yes, maybe your iWarmUp haven't set to true yet
__________________
My plugin:
Celena Luna is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 04-12-2021 , 12:29   Re: jointeam hook
Reply With Quote #3

no

if i choose a team (ct or t) i can t select the type of the skin, it s getting me back in that menu

Last edited by lexzor; 04-12-2021 at 12:30.
lexzor is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 04-12-2021 , 22:34   Re: jointeam hook
Reply With Quote #4

ahh I am an idiot...
I didn't notice this at first

PHP Code:
public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event"TeamInfo""join_team""a")
}


public 
join_team()
{    
    new 
id read_data(1)
    static 
user_team[32]
    
    
read_data(2user_team31)    
    
    if(!
is_user_connected(id))
        return 
PLUGIN_CONTINUE    
    
    
switch(user_team[0])
    {
        case 
'C':  
        {
            
// player join to ct's        
        
}
            
        case 
'T'
        {
            
// player join to terrorist
        
}
        
        
        case 
'S':  
        {
            
// player join to spectators
        
}
        
        
    }
    return 
PLUGIN_CONTINUE
    

The team info was in param 2, not 1
so your iTeam is user id

use the code above, edit it according to what you need
__________________
My plugin:

Last edited by Celena Luna; 04-12-2021 at 22:34.
Celena Luna is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 04-13-2021 , 07:21   Re: jointeam hook
Reply With Quote #5

if i m using code above, the plugin will show this message
PHP Code:
client_print_color(0print_team_default"%s Jucatorul^4 %s^1 a intrat la echipa^4 Terrorist^1!"iTagiName[id]) 
when:
- round start (will show it for every player).
- every time i press a button in chooseteam.
lexzor is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 04-13-2021 , 21:38   Re: jointeam hook
Reply With Quote #6

Quote:
Originally Posted by lexzor View Post
if i m using code above, the plugin will show this message
PHP Code:
client_print_color(0print_team_default"%s Jucatorul^4 %s^1 a intrat la echipa^4 Terrorist^1!"iTagiName[id]) 
when:
- round start (will show it for every player).
- every time i press a button in chooseteam.
Please post full of that public join_team() so I can help
__________________
My plugin:
Celena Luna is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 04-14-2021 , 09:05   Re: jointeam hook
Reply With Quote #7

PHP Code:
public ijointeam(id)
{
        
    new 
iPlayers[MAX_PLAYERS], iPlayeriNumiName[MAX_PLAYERS 1][MAX_NAME_LENGTH], iCount_CTiCount_TiTeam
    
    iTeam 
read_argv_int(1)
    
    
get_user_name(idiName[id], charsmax(iName[]))
    
    
get_players(iPlayersiNum)
    
    for (new 
0iNumi++)
    {
        
iPlayer iPlayers[i]
        
        if(
cs_get_user_team(iPlayer) == CS_TEAM_CT
        {
            ++
iCount_CT
        
}
        else if (
cs_get_user_team(iPlayer) == CS_TEAM_T)
        {
            ++
iCount_T
        
}
    }
            
    if (
iTeam)
    {
        switch(
iTeam)
        {
            
            case 
1
            {
                if (
iCount_T >= TEAM_LIMIT && iStarted)
                {
                    if(
cs_get_user_team(id) != CS_TEAM_SPECTATOR)
                        
cs_set_user_team(idCS_TEAM_SPECTATOR)
                        
                    
client_print_color(idprint_team_default"%s Nu poti intra la^4 Terrorist^1 pentru ca sunt^4 %i^1 jucatori."iTagTEAM_LIMIT)
                    
                    return 
PLUGIN_HANDLED
                
}
                else
                {
                    
client_print_color(0print_team_default"%s Jucatorul^4 %s^1 a intrat la echipa^4 Terrorist^1!"iTagiName[id])
                    
                    if(
iWarmUp)
                        
player_respawn(id)
                }
            }
            
            case 
2:
            {
                if (
iCount_CT >= TEAM_LIMIT && iStarted)
                {
                    if(
cs_get_user_team(id) != CS_TEAM_SPECTATOR)
                        
cs_set_user_team(idCS_TEAM_SPECTATOR)
                    
                    
client_print_color(idprint_team_default"%s Nu poti intra la^4 Counter-Terrorist^1 pentru ca sunt^4 %i^1 jucatori."iTagTEAM_LIMIT)
                    return 
PLUGIN_HANDLED
                
}
                else
                {
                    
client_print_color(0print_team_default"%s Jucatorul^4 %s^1 a intrat la echipa^4 Counter-Terrorist^1!"iTagiName[id])
                    
                    if(
iWarmUp)
                        
player_respawn(id)
                }    
            }
            
            case 
5
            {
                
client_print_color(idprint_team_default"%s Nu poti folosi^4 Auto Assign^1."iTag)
                return 
PLUGIN_HANDLED
            
}
        
        }
    }
    
    return 
PLUGIN_CONTINUE
}

public 
player_respawn(id)
{    
    if(!
is_user_alive(id) && cs_get_user_team(id) != CS_TEAM_SPECTATOR && cs_get_user_team(id) != CS_TEAM_UNASSIGNED)
        
cs_user_spawn(id)
        

this is the code. iStarted represent if players started a game. In problem situation, iStarted is false.

Also, when message
PHP Code:
client_print_color(0print_team_default"%s Jucatorul^4 %s^1 a intrat la echipa^4 Terrorist^1!"iTagiName[id
is shown, the below function "player_Respawn" is not working properly. I don't know why. Maybe i should use set_task ?

Anyway, the main problem is that players can t join when iStarted is off.

You said that
PHP Code:
iTeam read_argv_int(1
should be
PHP Code:
iTeam read_argv_int(2
?

(i haven't tried i don't know what parameter is the team choosed by player, but i have a feeling that you are right and i should use the second one)
lexzor is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 04-19-2021 , 12:53   Re: jointeam hook
Reply With Quote #8

some ideas?
lexzor is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 04-19-2021 , 18:54   Re: jointeam hook
Reply With Quote #9

Quote:
Originally Posted by lexzor View Post
this is the code. iStarted represent if players started a game. In problem situation, iStarted is false.

Also, when message
PHP Code:
client_print_color(0print_team_default"%s Jucatorul^4 %s^1 a intrat la echipa^4 Terrorist^1!"iTagiName[id
is shown, the below function "player_Respawn" is not working properly. I don't know why. Maybe i should use set_task ?
try Ham_CS_RoundRespawn instead of cs_user_spawn()



Quote:
Originally Posted by lexzor View Post
You said that
PHP Code:
iTeam read_argv_int(1
should be
PHP Code:
iTeam read_argv_int(2
?

(i haven't tried i don't know what parameter is the team choosed by player, but i have a feeling that you are right and i should use the second one)
second parameter of teaminfo message is string https://wiki.alliedmods.net/Half-lif...vents#TeamInfo

TeamInfo message is sent to update client scoreboard, to filter out only team changes you'll have to cache the previous team and compare those

Last edited by jimaway; 04-19-2021 at 19:23.
jimaway is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-19-2021 , 20:23   Re: jointeam hook
Reply With Quote #10

This has been covered many times, a few times by me. Try searching, there's a ton of info on basic topics like this
__________________
Bugsy 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 03:25.


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