AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   {REQ EDIT] (https://forums.alliedmods.net/showthread.php?t=118027)

Storas1337 02-07-2010 03:36

{REQ EDIT]
 
Hello i need to edit this plugin.
Things what should be done.
1.Text should be written every 5 rounds
2.After 15rounds Should be 1one RESTART(pls leave place for alias include :))
3.If possible CALCULATE CT AND T SCORE with player cvar .score
Code:

#include <amxmodx>
#include <fakemeta>

#define OFFSET_TEAM    114

enum
{
    TEAM_NULL, // LOL NULL
    TEAM_T,
    TEAM_CT,
    TEAM_SPECTATOR
}

new g_iCounter = 0;
new p_Rounds;
new g_Msg_TeamInfo;
new g_iMaxPlayers;

public plugin_init()
{
    register_plugin( "Team Switch", "1.5", "TBagT" );
   
    p_Rounds = register_cvar( "ats_rounds", "15" );
    register_event("TextMsg", "RoundRestart_Attempt", "a", "2&#Game_C", "2&Game_W");
    register_logevent("logevent_round_start2", 2, "1=Round_Start")
    register_logevent("logevent_round_end2", 2, "1=Round_End")
    g_iMaxPlayers = get_maxplayers();
    g_Msg_TeamInfo = get_user_msgid( "TeamInfo" );
}

public server_changelevel( map[] )
{
    g_iCounter = 0;
}

public plugin_pause()
{
    g_iCounter = 0;
}

public RoundRestart_Attempt()
{
    g_iCounter = 0;
}
public logevent_round_end2()
{
    if( get_playersnum() > 1 )
    {
        if ( g_iCounter >= get_pcvar_num( p_Rounds ) )
        {
            g_iCounter = 0;
           
            new team, oppTeam;
            for( new i = 1 ; i <= g_iMaxPlayers ; i++ )
            {
                if( !is_user_connected( i ) )    continue;
               
                team = get_user_team( i );
                if( team == TEAM_SPECTATOR )    continue;
       
                set_hudmessage( 200, 0, 0, -1.0, -1.0, 1, 6.0, 12.0 );
                show_hudmessage( 0, "Switching teams!" );
       
                oppTeam = team % 2 + 1;
                fm_set_user_team( i, oppTeam );
            }
        }
        else
        {
            set_hudmessage( 0, 100, 0, -1.0, -1.0, 1, 6.0, 12.0 );
            show_hudmessage( 0, "Teams will switch in: %d (rounds)", ( get_pcvar_num( p_Rounds ) - g_iCounter ) );
        }
    }
   
}
public logevent_round_start2()
{
    g_iCounter++;
}
fm_set_user_team( index, iTeam )
{
    static const Teams[][] =
    {
        "", // NULL
        "TERRORIST",
        "CT"
    }
   
    set_pdata_int( index, OFFSET_TEAM, iTeam );
    dllfunc( DLLFunc_ClientUserInfoChanged, index, engfunc( EngFunc_GetInfoKeyBuffer, index ) );
   
    message_begin( MSG_ONE_UNRELIABLE, g_Msg_TeamInfo, { 0, 0, 0 }, index );
    write_byte( index );
    write_string( Teams[ iTeam ] );
    message_end();
   
    return 1;
}


Mxnn 02-07-2010 14:16

Re: {REQ EDIT]
 
PHP Code:

#include <amxmodx>
#include <fakemeta>

#define OFFSET_TEAM    114

enum
{
TEAM_NULL// LOL NULL
TEAM_T,
TEAM_CT,
TEAM_SPECTATOR
}

new 
g_iCounter 0;
new 
p_Rounds;
new 
g_Msg_TeamInfo;
new 
g_iMaxPlayers;

// HERE HERE HERE HERE
new szText[ ] = "Text text text text"
new RoundRestartTime 1
// HERE HERE HERE HERE

public plugin_init()
{
register_plugin"Team Switch""1.5""TBagT" );

p_Rounds register_cvar"ats_rounds""15" );
register_event("TextMsg""RoundRestart_Attempt""a""2&#Game_C""2&Game_W");
register_logevent("logevent_round_start2"2"1=Round_Start")
register_logevent("logevent_round_end2"2"1=Round_End")
g_iMaxPlayers get_maxplayers();
g_Msg_TeamInfo get_user_msgid"TeamInfo" );
set_task(5.0"cmdText"0__"b")
}

public 
server_changelevelmap[] )
{
g_iCounter 0;
}

public 
plugin_pause()
{
g_iCounter 0;
}

public 
RoundRestart_Attempt()
{
g_iCounter 0;
}
public 
logevent_round_end2()
{
if( 
get_playersnum() > )
{
    if ( 
g_iCounter >= get_pcvar_nump_Rounds ) )
    {
        
g_iCounter 0;
        
        new 
teamoppTeam;
        for( new 
<= g_iMaxPlayers i++ )
        {
            if( !
is_user_connected) )    continue;
            
            
team get_user_team);
            if( 
team == TEAM_SPECTATOR )    continue;
            
            
set_hudmessage20000, -1.0, -1.016.012.0 );
            
show_hudmessage0"Switching teams!" );
            
            
oppTeam team 1;
            
fm_set_user_teamioppTeam );
        }
        
        
server_cmd("sv_restart %d"RoundRestartTime)
        
server_exec()
    }
    else
    {
        
set_hudmessage01000, -1.0, -1.016.012.0 );
        
show_hudmessage0"Teams will switch in: %d (rounds)", ( get_pcvar_nump_Rounds ) - g_iCounter ) );
    }
}

}
public 
logevent_round_start2()
{
g_iCounter++;
}
fm_set_user_teamindexiTeam )
{
static const 
Teams[][] =
{
""// NULL
"TERRORIST",
"CT"
}

set_pdata_intindexOFFSET_TEAMiTeam );
dllfuncDLLFunc_ClientUserInfoChangedindexengfuncEngFunc_GetInfoKeyBufferindex ) );

message_beginMSG_ONE_UNRELIABLEg_Msg_TeamInfo, { 00}, index );
write_byteindex );
write_stringTeamsiTeam ] );
message_end();

return 
1;
}

public 
cmdText() 
{
    
client_print(0print_chat"%s"szText)


To change the text change the var szText. The restart is on 1, you can change it in the var RoundRestartTime
That 2 vars are marked with comments
Points 1 & 2 are made. But with the 3 i have little trouble (i don't understand)
Quote:

Originally Posted by Storas1337 (Post 1081267)
3.If possible CALCULATE CT AND T SCORE with player cvar .score

You want to show the score when player write ".score" in chat?

Storas1337 02-07-2010 15:16

Re: {REQ EDIT]
 
Quate:
You want to show the score when player write ".score" in chat?

Yes you right.


you did text bad i needed this text
http://www.part.lt/img/9508ec0811fa5...b145c59907.JPG
every 5 rounds understood now?:))
And pls do .score cvar its all :)))

and please wrote how i can add ALIAS COMMAND FROM SERVER CFG(RESTARTS)
in plugin maybe more no needed one restart :))
Thnx for helping.

Mxnn 02-07-2010 19:41

Re: {REQ EDIT]
 
You want to execute a config when 15 rounds are over?
mhh, try this. I'm not sure totally that will work but we don't loss anything trying.
PHP Code:

#include <amxmodx>
#include <fakemeta>

#define OFFSET_TEAM    114

enum
{
TEAM_NULL// LOL NULL
TEAM_T,
TEAM_CT,
TEAM_SPECTATOR
}

new 
g_iCounter 0;
new 
ct_win
new tt_win
new p_Rounds;
new 
g_Msg_TeamInfo;
new 
g_iMaxPlayers;

// HERE HERE HERE HERE
new szConfig[ ] = "closed.cfg" /*Put directory and name of the cfg. Example: addons/amxmodx/configs/lala.cfg
cstrike folder is not needed to put it*/
new szText[ ] = "Text text text text";
// HERE HERE HERE HERE

public plugin_init()
{
register_plugin"Team Switch""1.5""TBagT" );
register_clcmd("say .score""sayResult");

p_Rounds register_cvar"ats_rounds""15" );
register_event("TextMsg""RoundRestart_Attempt""a""2&#Game_C""2&Game_W");
register_event("TeamScore""TeamScore""a")
register_logevent("logevent_round_start2"2"1=Round_Start")
register_logevent("logevent_round_end2"2"1=Round_End")
g_iMaxPlayers get_maxplayers();
g_Msg_TeamInfo get_user_msgid"TeamInfo" );
set_task(5.0"cmdText"0__"b")
}

public 
server_changelevelmap[] )
{
g_iCounter 0;
ct_win 0;
tt_win 0;
}

public 
plugin_pause()
{
g_iCounter 0;
ct_win 0;
tt_win 0;
}

public 
RoundRestart_Attempt()
{
g_iCounter 0;
ct_win 0;
tt_win 0;
}
public 
logevent_round_end2()
{
if( 
get_playersnum() > )
{
    if ( 
g_iCounter >= get_pcvar_nump_Rounds ) )
    {
        
g_iCounter 0;
        
        new 
teamoppTeam;
        for( new 
<= g_iMaxPlayers i++ )
        {
            if( !
is_user_connected) )    continue;
            
            
team get_user_team);
            if( 
team == TEAM_SPECTATOR )    continue;
            
            
set_hudmessage20000, -1.0, -1.016.012.0 );
            
show_hudmessage0"Switching teams!" );
            
            
oppTeam team 1;
            
fm_set_user_teamioppTeam );
        }
        
server_cmd("exec %s"szConfig)
    }
    else
    {
        
set_hudmessage01000, -1.0, -1.016.012.0 );
        
show_hudmessage0"Teams will switch in: %d (rounds)", ( get_pcvar_nump_Rounds ) - g_iCounter ) );
    }
}

}
public 
logevent_round_start2()
{
g_iCounter++;
}
fm_set_user_teamindexiTeam )
{
static const 
Teams[][] =
{
""// NULL
"TERRORIST",
"CT"
}

set_pdata_intindexOFFSET_TEAMiTeam );
dllfuncDLLFunc_ClientUserInfoChangedindexengfuncEngFunc_GetInfoKeyBufferindex ) );

message_beginMSG_ONE_UNRELIABLEg_Msg_TeamInfo, { 00}, index );
write_byteindex );
write_stringTeamsiTeam ] );
message_end();

return 
1;
}

public 
cmdText()
{
set_hudmessage01000, -1.0, -1.016.012.0 );
show_hudmessage(0"%s"szText);
}

public 
TeamScore() 
{
    new 
team[16],Float:score
    read_data
(1,team,15)
    
read_data(2,score)
     
    if(
equal(team,"CT"))
          
ct_win++
     
    if(
equal(team,"TERRORIST"))
          
tt_win++
}

public 
sayResult(id)
{
    
client_print(idprint_chat"Counter-Terrorist: %d | Terrorist: %d"ct_wintt_win);



Storas1337 02-08-2010 11:37

Re: {REQ EDIT]
 
Need to edit again
What you did bad:
.score Cvar is calculating CT And T REsult
on warmup and live THATS BAD:PHOTO
http://www.part.lt/img/dcb5118c43cf3...450851f837.JPG
and i think he calculating bad because WIN one of teams CT AND T`s GET 1 POINT
2.Maybe you can add Cvar to turn ON and turn OFF SWitching teams BECAUSE it works on warmup and the same make with .score(an repair calculating :) you should add after 30rounds new calculating(from 0) its such CM points calculating understand me?)

EDIT:
So i add few photos of calculting bug
and i wana tell you execing config dont work check it pls.

http://www.part.lt/img/ddd2b7a30f3f9...4b8039b488.JPG
You se t score 2-0(but ct have 2 too)
The photo when T won round:
http://www.part.lt/img/2939711691089...36c6ed9856.JPG

score 3-3(COOL :D)

4.When you done the TURN ON AND OFF CVARS OF .score and teamswitch maybe you can add autoshutdown(plugin) AFTER 30rounds?pls


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

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