Author
Message
Member
05-19-2014
, 11:50
automating the task instead of cmd!
#1
Hey,
I want to automate the command every x rounds that I specify without using command here's the code i don't really know how to do that so please fix the code or just tell the way to do that !
Spoiler
PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < fun >
new const VERSION [ ] = "0.1.0" ;
enum _ : PlayerScore
{
SCORE_FRAGS ,
SCORE_DEATHS
};
new g_pScore [ 33 ][ PlayerScore ];
new g_iMaxPlayers ;
new g_iMsgID_ScoreInfo ;
public plugin_init ( )
{
register_plugin ( "AMXX Swap Teams" , VERSION , "Xellath" );
register_concmd ( "amx_swapteams" , "ConsoleCommand_SwapTeams" , ADMIN_KICK );
g_iMaxPlayers = get_maxplayers ( );
g_iMsgID_ScoreInfo = get_user_msgid ( "ScoreInfo" );
}
public client_disconnect ( iClient )
{
remove_task ( iClient );
for ( new i = 0 ; i < PlayerScore ; i ++ )
g_pScore [ iClient ][ i ] = 0 ;
}
public ConsoleCommand_SwapTeams ( iClient , iLevel , iCid )
{
if( ! cmd_access ( iClient , iLevel , iCid , 1 ) )
return PLUGIN_HANDLED ;
for ( new iPlayer = 1 ; iPlayer <= g_iMaxPlayers ; iPlayer ++ )
{
if ( is_user_connected ( iPlayer ) )
{
g_pScore [ iPlayer ][ SCORE_FRAGS ] = get_user_frags ( iPlayer );
g_pScore [ iPlayer ][ SCORE_DEATHS ] = cs_get_user_deaths ( iPlayer );
switch ( cs_get_user_team ( iPlayer ) )
{
case CS_TEAM_T : cs_set_user_team ( iPlayer , CS_TEAM_CT );
case CS_TEAM_CT : cs_set_user_team ( iPlayer , CS_TEAM_T );
}
set_task ( 5.0 , "TaskDelayedScore" , iPlayer );
}
}
server_cmd ( "sv_restart 1" );
new szAdminName [ 32 ];
get_user_name ( iClient , szAdminName , 31 );
log_amx ( "ADMIN '%s': Used command [ amx_swap ]" , szAdminName );
client_print ( 0 , print_chat , "ADMIN '%s': Swapped the teams [ amx_swap ]" , szAdminName );
return PLUGIN_HANDLED ;
}
public TaskDelayedScore ( iClient )
{
set_user_frags ( iClient , g_pScore [ iClient ][ SCORE_FRAGS ] );
cs_set_user_deaths ( iClient , g_pScore [ iClient ][ SCORE_DEATHS ] );
message_begin ( MSG_BROADCAST , g_iMsgID_ScoreInfo );
write_byte ( iClient );
write_short ( g_pScore [ iClient ][ SCORE_FRAGS ] );
write_short ( g_pScore [ iClient ][ SCORE_DEATHS ] );
write_short ( 0 );
write_short ( get_user_team ( iClient ) );
message_end ( );
}