AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Two get_user_msgid("TeamInfo") (https://forums.alliedmods.net/showthread.php?t=83119)

xbatista 01-04-2009 12:59

Two get_user_msgid("TeamInfo")
 
OK I have this.
In plugin init.

PHP Code:

new g_maxplayers
new p_On
new bool:g_bSwitch33 

PHP Code:

register_message(get_user_msgid("TeamInfo"), "message_teaminfo")

        
p_On register_cvar"amx_stbk""1" // 1 = switching teams.
        
g_maxplayers get_maxplayers()
        
register_event"HLTV""ev_newRound""a""1=0""2=0" )
        
register_event"DeathMsg""ev_Death""a" )
        
register_messageget_user_msgid"TeamInfo" ), "msg_TeamInfo" )

///Here is the in the ct team can be max 4 ct's///
public message_teaminfo(msg_idmsg_dest){
     if (
msg_dest != MSG_ALL && msg_dest != MSG_BROADCAST) return;
     new 
id get_msg_arg_int(1)
     static 
team[2]
     
get_msg_arg_string(2teamsizeof team 1)
     if(
team[0] == 'U' || team[0] == 'S') return;
     new 
cts ckrun_get_ct_num()
     if(
cts >= 4){
     
cs_set_user_team(idCS_TEAM_TCS_DONTCHANGE)
     
set_msg_arg_string(2"TERRORIST")
     }
}
stock ckrun_get_ct_num(){
      new 
num i
      
for (1<= g_maxplayersi++){
      if (
is_user_connected(i) && get_user_team(i) == 2)
      
num ++
      }
      return 
num
}
///Switching teams, If terrorist killed ct switch their teams///
public client_disconnect(id)
{
       
g_bSwitchid ] = false
}
public 
ev_Death()
{
    if( !
get_pcvar_nump_On ) )
    {
        return 
PLUGIN_CONTINUE;
    }
    
    static 
iAtt iAtt read_data);
    if( !( 
<= iAtt <= g_maxplayers ) )
    {
        return 
PLUGIN_CONTINUE;
    }
    
    static 
iVic iVic read_data);
    if( !( 
<= iVic <= g_maxplayers ) )
    {
        return 
PLUGIN_CONTINUE;
    }
    
    if( 
cs_get_user_teamiAtt ) == CS_TEAM_T && cs_get_user_teamiVic ) == CS_TEAM_CT )
    {
        if( !
g_bSwitchiAtt ] )
        {
            
g_bSwitchiAtt ] = true;
            
            if( !
g_bSwitchiVic ] )
            {
                
g_bSwitchiVic ] = true;
            }
        }
    }
    
    return 
PLUGIN_CONTINUE;
}
public 
msg_TeamInfomidDestid )
{
    if( 
Dest != MSG_ALL && Dest != MSG_BROADCAST )
    {
        return 
PLUGIN_CONTINUE;
    }
    
    if( !
get_pcvar_nump_On ) )
    {
        return 
PLUGIN_CONTINUE;
    }
    
    if( 
g_bSwitchid ] )
    {
        
g_bSwitchid ] = false;
    }
    
    return 
PLUGIN_CONTINUE;
}
public 
ev_newRound()
{
    if( !
get_pcvar_nump_On ) )
    {
        return;
    }
    
    static 
iCsTeams:team;
    for( 
<= g_maxplayers i++ )
    {
        if( !
is_user_connected) || !g_bSwitch]
        || !( 
CS_TEAM_UNASSIGNED < ( team cs_get_user_team) ) < CS_TEAM_SPECTATOR ) )
            continue;
        
        
cs_set_user_teami, ( team CS_TEAM_CT ) + CS_TEAM_T );
        
g_bSwitch] = false;
    }


This is good if I'm using 2 Team info?
And this codes together worst working,maybe someone can configure it?

Dores 01-04-2009 16:46

Re: Two get_user_msgid("TeamInfo")
 
So my code didn't work for you eh?
I really don't understand, as it works fine for me.
Put my code at the top of the list at plugins.ini and try then.
If it doesn't work, I hope someone will find a solution for you.

And if you want your function to work instead of mine:
Code:
register_message( get_user_msgid( "TeamInfo" ), "msg_TeamInfo" ) ---> register_message( get_user_msgid( "TeamInfo" ), "message_teaminfo" ) // and remove my function
But what you're trying to do is pointless, as the rest of the plugin will switch their teams anyways...
Why didn't you ask me...

xbatista 01-05-2009 08:47

Re: Two get_user_msgid("TeamInfo")
 
Dores I just thing that 2 codes worst working.
P.S.Your code working ,but buggy,I don't know how but sometimes terrorist's spawns in ct's spawn when switching,I don't say always ,but sometimes :/
And thanks for trying help,suggest ;)
And yes your code works but buggy :/
Dores I'm asking you and other people :}

And this code may cause those bugs for switching?
PHP Code:

///Here is the in the ct team can be max 4 ct's/// 
public message_teaminfo(msg_idmsg_dest){ 
     if (
msg_dest != MSG_ALL && msg_dest != MSG_BROADCAST) return; 
     new 
id get_msg_arg_int(1
     static 
team[2
     
get_msg_arg_string(2teamsizeof team 1
     if(
team[0] == 'U' || team[0] == 'S') return; 
     new 
cts ckrun_get_ct_num() 
     if(
cts >= 4){ 
     
cs_set_user_team(idCS_TEAM_TCS_DONTCHANGE
     
set_msg_arg_string(2"TERRORIST"
     } 
}
stock ckrun_get_ct_num(){ 
      new 
num 
      
for (1<= g_maxplayersi++){ 
      if (
is_user_connected(i) && get_user_team(i) == 2
      
num ++ 
      } 
      return 
num 



xPaw 01-05-2009 08:57

Re: Two get_user_msgid("TeamInfo")
 
huh check his sig o.O'

xbatista 01-05-2009 09:06

Re: Two get_user_msgid("TeamInfo")
 
???
EDIT: Ahh yes
:(((

SnoW 01-05-2009 10:04

Re: Two get_user_msgid("TeamInfo")
 
Quote:

Originally Posted by xbatista (Post 738666)
???
EDIT: Ahh yes :D
:(((

What was that ":D"? Mah, like "You did this to him!"... Anyway...

xbatista 01-06-2009 08:46

Re: Two get_user_msgid("TeamInfo")
 
No... I've asking not only him about the problem,but to all.

Dores 01-07-2009 07:49

Re: Two get_user_msgid("TeamInfo")
 
i wasn't angry at you, xbatista, i was angry because my codes never work.
ignore what i said...

xPaw 01-07-2009 08:47

Re: Two get_user_msgid("TeamInfo")
 
ah always have same problem :D my codes never work clean -.-` if its more than 100 lines like DRM

xbatista 01-07-2009 08:54

Re: Two get_user_msgid("TeamInfo")
 
No Dores,your code works,but little buggy ;)

So how about the team info?That 1-st code of max in CT team can be 4 players good coded?


All times are GMT -4. The time now is 09:11.

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