AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Swap (https://forums.alliedmods.net/showthread.php?t=82209)

LostSkill 12-19-2008 06:19

[Help] Swap
 
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)



ConnorMcLeod 12-19-2008 06:27

Re: [Help] Swap
 
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 !!")
    }



LostSkill 12-19-2008 07:14

Re: [Help] Swap
 
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 


ConnorMcLeod 12-19-2008 08:08

Re: [Help] Swap
 
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 !!")
    }




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

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