Raised This Month: $ Target: $400
 0% 

[Help] Swap


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LostSkill
Senior Member
Join Date: Jun 2008
Location: Monuhuelo Island
Old 12-19-2008 , 06:19   [Help] Swap
Reply With Quote #1

hi guy well i try do swap after 5 rounds, i dont get eny errors but in server it not works. so maybe u can look what wrong in it
PHP Code:
#include <amxmodx>
#include <cstrike>

#define PLUGIN "Auto Change Team"
#define VERSION "1.0"
#define AUTHOR "LostSkill"
#define START "sound/tmreverse.mp3"
#define END "sound/tmreversed.mp3"

new round 1
new g_iRoundCount 1


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_logevent("logevent_Round_Start"2"1=Round_Start")
    
register_logevent("eRoundEnd"2"1=Round_End")
}

public 
logevent_Round_Start() {
    
round++;
    
    new 
players[32], playerpnum;
    
get_players(playerspnum"a");
    for(new 
0pnumi++)
    {
        
player players[i];
        if(!
is_user_connected(player))
        {
            if(
round == 5
            {
                
client_cmd(0"mp3 play ^"%s^""START)
            }
            else if(
round == 6
            {
                
client_cmd(0"mp3 play ^"%s^""END)
            }
        }
    }
}

public 
eRoundEnd() 

    
g_iRoundCount++ 

    new 
players[32], playerpnum;
    
get_players(playerspnum"a");
    for(new 
0pnumi++)
    {
        
player players[i];
        if(!
is_user_connected(player))
        {
            if(
g_iRoundCount == 5
            {
                if(
cs_get_user_team(player) == CS_TEAM_T)
                
cs_set_user_team(playerCS_TEAM_CT);
                else if(
cs_get_user_team(player) == CS_TEAM_CT)
                
cs_set_user_team(playerCS_TEAM_T);
            }
        }
    }

}

public 
plugin_precache()
{
    
precache_generic(START)
    
precache_generic(END)

__________________
MY ENGLISH IS BAD.....
LostSkill is offline
Send a message via MSN to LostSkill
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-19-2008 , 06:27   Re: [Help] Swap
Reply With Quote #2

Remove flag "a" from get_players. Put "h" instead or nothing.
http://www.amxmodx.org/funcwiki.php?go=func&id=174

Also, you don't need to check if player is connected.


I would code it this way :
PHP Code:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Auto Change Team"
#define VERSION "1.0"
#define AUTHOR "LostSkill"

new const START[] = "sound/tmreverse.mp3"
new const END[] = "sound/tmreversed.mp3"

new g_iRoundCount 1
new g_iMaxPlayers

public plugin_precache()
{
    
precache_generic(START)
    
precache_generic(END)
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0")
    
register_logevent("Logevent_Round_End"2"1=Round_End")

    
register_event("TextMsg""Event_TextMsg_Restart""a""2&#Game_C""2&#Game_w")

    
register_event("DeathMsg""Event_DeathMsg""a")

    
g_iMaxPlayers get_maxplayers()
}

public 
Event_TextMsg_Restart()
{
    
g_iRoundCount 0
}

public 
Event_HLTV_New_Round()
{
    if( ++
g_iRoundCount == )
        
client_cmd(0"mp3 play %s"END)
}

public 
Logevent_Round_End() 

    if( 
g_iRoundCount != )
        return

    
client_print(0print_chat"** Don't change team !!")
    
client_cmd(0"mp3 play %s"START)

    for(new 
idid<=g_iMaxPlayersid++)
    {
        if( !
is_user_connected(id) || is_user_hltv(id) )
        {
            continue
        }

        switch( 
get_pdata_int(id114) )
        {
            case 
1:set_pdata_int(id1142)
            case 
2:set_pdata_int(id1141)
        }
    }
}

public 
Event_DeathMsg()
{
    if( 
g_iRoundCount == )
    {
        
client_print(read_data(2), print_chat"** Don't change team !!")
    }

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-19-2008 at 06:42.
ConnorMcLeod is offline
LostSkill
Senior Member
Join Date: Jun 2008
Location: Monuhuelo Island
Old 12-19-2008 , 07:14   Re: [Help] Swap
Reply With Quote #3

i did some edits on ur plugin but i get errors when i try compile maybe u can check it?

PHP Code:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Auto Change Team"
#define VERSION "1.0"
#define AUTHOR "LostSkill"

new const START[] = "sound/tmreverse.mp3"
new const END[] = "sound/tmreversed.mp3"

new g_iRoundCount 1
new g_iMaxPlayers

public plugin_precache()
{
    
precache_generic(START)
    
precache_generic(END)
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0")
    
register_logevent("Logevent_Round_End"2"1=Round_End")

    
register_event("TextMsg""Event_TextMsg_Restart""a""2&#Game_C""2&#Game_w")

    
g_iMaxPlayers get_maxplayers()
}

public 
Event_TextMsg_Restart()
{
    
g_iRoundCount 0
}

public 
Event_HLTV_New_Round()
{
    if( ++
g_iRoundCount == )
        
client_cmd(0"mp3 play %s"END)
    else if( ++
g_iRoundCount == 11 )
        
client_cmd(0"mp3 play %s"END)
    else if( ++
g_iRoundCount == 16 )
        
client_cmd(0"mp3 play %s"END)
    else if( ++
g_iRoundCount == 21 )
        
client_cmd(0"mp3 play %s"END)
    else if( ++
g_iRoundCount == 26 )
        
client_cmd(0"mp3 play %s"END)
    else if( ++
g_iRoundCount == 31 )
        
client_cmd(0"mp3 play %s"END)
    else if( ++
g_iRoundCount == 36 )
        
client_cmd(0"mp3 play %s"END)
    else if( ++
g_iRoundCount == 41 )
        
client_cmd(0"mp3 play %s"END)
    else if( ++
g_iRoundCount == 46 )
        
client_cmd(0"mp3 play %s"END)
    else if( ++
g_iRoundCount == 51 )
        
client_cmd(0"mp3 play %s"END)
}

public 
Logevent_Round_End() 

    if( 
g_iRoundCount != )
    return

    
client_print(0print_chat"** Don't change team !!")
    
client_cmd(0"mp3 play %s"START)

    for(new 
idid<=g_iMaxPlayersid++)
    {
        if( !
is_user_connected(id) || is_user_hltv(id) )
        {
            continue
        }

        switch( 
get_pdata_int(id114) )
        {
            case 
1:set_pdata_int(id1142)
            case 
2:set_pdata_int(id1141)
        }
    }
    else if( 
g_iRoundCount != 10 )
        return

    
client_print(0print_chat"** Don't change team !!")
    
client_cmd(0"mp3 play %s"START)

    for(new 
idid<=g_iMaxPlayersid++)
    {
        if( !
is_user_connected(id) || is_user_hltv(id) )
        {
            continue
        }

        switch( 
get_pdata_int(id114) )
        {
            case 
1:set_pdata_int(id1142)
            case 
2:set_pdata_int(id1141)
        }
    }
    else if( 
g_iRoundCount != 15 )
        return

    
client_print(0print_chat"** Don't change team !!")
    
client_cmd(0"mp3 play %s"START)

    for(new 
idid<=g_iMaxPlayersid++)
    {
        if( !
is_user_connected(id) || is_user_hltv(id) )
        {
            continue
        }

        switch( 
get_pdata_int(id114) )
        {
            case 
1:set_pdata_int(id1142)
            case 
2:set_pdata_int(id1141)
        }
    }
    else if( 
g_iRoundCount != 20 )
        return

    
client_print(0print_chat"** Don't change team !!")
    
client_cmd(0"mp3 play %s"START)

    for(new 
idid<=g_iMaxPlayersid++)
    {
        if( !
is_user_connected(id) || is_user_hltv(id) )
        {
            continue
        }

        switch( 
get_pdata_int(id114) )
        {
            case 
1:set_pdata_int(id1142)
            case 
2:set_pdata_int(id1141)
        }
    }
     else if( 
g_iRoundCount != 25 )
        return

    
client_print(0print_chat"** Don't change team !!")
    
client_cmd(0"mp3 play %s"START)

    for(new 
idid<=g_iMaxPlayersid++)
    {
        if( !
is_user_connected(id) || is_user_hltv(id) )
        {
            continue
        }

        switch( 
get_pdata_int(id114) )
        {
            case 
1:set_pdata_int(id1142)
            case 
2:set_pdata_int(id1141)
        }
    }
    else if( 
g_iRoundCount != 30 )
        return

    
client_print(0print_chat"** Don't change team !!")
    
client_cmd(0"mp3 play %s"START)

    for(new 
idid<=g_iMaxPlayersid++)
    {
        if( !
is_user_connected(id) || is_user_hltv(id) )
        {
            continue
        }

        switch( 
get_pdata_int(id114) )
        {
            case 
1:set_pdata_int(id1142)
            case 
2:set_pdata_int(id1141)
        }
    }
     else if( 
g_iRoundCount != 35 )
        return

    
client_print(0print_chat"** Don't change team !!")
    
client_cmd(0"mp3 play %s"START)

    for(new 
idid<=g_iMaxPlayersid++)
    {
        if( !
is_user_connected(id) || is_user_hltv(id) )
        {
            continue
        }

        switch( 
get_pdata_int(id114) )
        {
            case 
1:set_pdata_int(id1142)
            case 
2:set_pdata_int(id1141)
        }
    }
    else if( 
g_iRoundCount != 40 )
        return

    
client_print(0print_chat"** Don't change team !!")
    
client_cmd(0"mp3 play %s"START)

    for(new 
idid<=g_iMaxPlayersid++)
    {
        if( !
is_user_connected(id) || is_user_hltv(id) )
        {
            continue
        }

        switch( 
get_pdata_int(id114) )
        {
            case 
1:set_pdata_int(id1142)
            case 
2:set_pdata_int(id1141)
        }
    }
     else if( 
g_iRoundCount != 45 )
        return

    
client_print(0print_chat"** Don't change team !!")
    
client_cmd(0"mp3 play %s"START)

    for(new 
idid<=g_iMaxPlayersid++)
    {
        if( !
is_user_connected(id) || is_user_hltv(id) )
        {
            continue
        }

        switch( 
get_pdata_int(id114) )
        {
            case 
1:set_pdata_int(id1142)
            case 
2:set_pdata_int(id1141)
        }
    }
    else if( 
g_iRoundCount != 50 )
        return

    
client_print(0print_chat"** Don't change team !!")
    
client_cmd(0"mp3 play %s"START)

    for(new 
idid<=g_iMaxPlayersid++)
    {
        if( !
is_user_connected(id) || is_user_hltv(id) )
        {
            continue
        }

        switch( 
get_pdata_int(id114) )
        {
            case 
1:set_pdata_int(id1142)
            case 
2:set_pdata_int(id1141)
        }
    }

error in
PHP Code:
else if( g_iRoundCount != 10 
__________________
MY ENGLISH IS BAD.....

Last edited by LostSkill; 12-19-2008 at 07:59.
LostSkill is offline
Send a message via MSN to LostSkill
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-19-2008 , 08:08   Re: [Help] Swap
Reply With Quote #4

For execute the code every 5 rounds, you can use this :

PHP Code:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Auto Change Team"
#define VERSION "1.0"
#define AUTHOR "LostSkill"

new const START[] = "sound/tmreverse.mp3"
new const END[] = "sound/tmreversed.mp3"

new g_iRoundCount 1
new g_iMaxPlayers

public plugin_precache()
{
    
precache_generic(START)
    
precache_generic(END)
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0")
    
register_logevent("Logevent_Round_End"2"1=Round_End")

    
register_event("TextMsg""Event_TextMsg_Restart""a""2&#Game_C""2&#Game_w")

    
register_event("DeathMsg""Event_DeathMsg""a")

    
g_iMaxPlayers get_maxplayers()
}

public 
Event_TextMsg_Restart()
{
    
g_iRoundCount 0
}

public 
Event_HLTV_New_Round()
{
    ++
g_iRoundCount
    
if( g_iRoundCount == )
        
client_cmd(0"mp3 play %s"END)
}

public 
Logevent_Round_End() 

    if( 
g_iRoundCount )
        return

    
client_print(0print_chat"** Don't change team !!")
    
client_cmd(0"mp3 play %s"START)

    for(new 
idid<=g_iMaxPlayersid++)
    {
        if( !
is_user_connected(id) || is_user_hltv(id) )
        {
            continue
        }

        switch( 
get_pdata_int(id114) )
        {
            case 
1:set_pdata_int(id1142)
            case 
2:set_pdata_int(id1141)
        }
    }
}

public 
Event_DeathMsg()
{
    if( 
g_iRoundCount )
    {
        
client_print(read_data(2), print_chat"** Don't change team !!")
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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:07.


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