Re: Not an array or to many subscripts
Here's the full code
PHP Code:
#include < amxmodx > #include < cstrike > #include < colorchat > #include < hamsandwich > #include < engine > #include < fakemeta > #include < fun >
new g_iSimon;
new const g_szPrefix[ ] = "^04[Jailbreak]^01";
new gsCommanderMdlPrec[] = "models/player/scandic-gamers/commander.mdl"; new gsCommanderMdl[] = "Commander"; new gsCtMdl[] = "gign";
public plugin_init() { register_plugin( "Commander & Decommander", "1.0", "MokeN" ); register_event( "DeathMsg", "Event_DeathMsg", "a" ); register_event( "RoundStart", "evRoundStart", "a", "1=0", "2=0" ) register_clcmd( "say /commander", "CmdSimon" ); register_clcmd( "say /change", "CmdChange" ); register_clcmd( "say /decommander", "CmdDeSimon" ); register_logevent( "Event_RoundEvent", 3, "1=Round_Start", "2=Round_End" ); set_task( 1.0, "HudSimon", .flags="b" ); }
public evRoundStart() { new players[ 32 ], player, num; get_players( players, num ); for( new i ; i < num ; i ++ ) { player = players[ i ]; if( g_iSimon == player ) cs_set_user_model( player, gsCtMdl ); }
g_iSimon = 0; server_cmd( "mp_friendlyfire 0" ); }
public Event_RoundEvent() { g_iSimon = 0; }
public plugin_precache() { precache_model( gsCommanderMdlPrec ); }
public CmdChange( id ) { if( id != g_iSimon ) { ColorChat( id, NORMAL, "%s Only the ^03Commander ^01can use this command.", g_szPrefix ); return PLUGIN_HANDLED; } new hMenu = menu_create( "New Commander:", "ChangeMenu_Handler" ); new szName[ 32 ], szData[ 6 ]; new iPlayers[ 32 ], iNum; get_players( iPlayers, iNum, "ae", "CT" ); for( new i = 0, iPlayer; i < iNum; i++ ) { iPlayer = iPlayers[ i ]; get_user_name( iPlayer, szName, charsmax( szName ) ); num_to_str( iPlayer, szData, charsmax( szData ) ); menu_additem( hMenu, szName, szData ); } menu_display( id, hMenu, 0 ); return PLUGIN_HANDLED; }
public ChangeMenu_Handler( id, hMenu, iItem ) { if( iItem == MENU_EXIT ) { menu_destroy( hMenu ); return PLUGIN_HANDLED; } new iAccess, hCallback, szData[ 6 ], szName[ 32 ]; menu_item_getinfo( hMenu, iItem, iAccess, szData, charsmax( szData ), szName, charsmax( szName ), hCallback ); new iPlayer = str_to_num( szData ); if( !is_user_alive( iPlayer ) ) { ColorChat( id, NORMAL, "%s That player is no longer available to be ^03Commander^01.", g_szPrefix ); return PLUGIN_HANDLED; } g_iSimon = iPlayer; ColorChat( 0, NORMAL, "%s ^03%s ^01is the new ^03Commander^01.", g_szPrefix, szName ); return PLUGIN_HANDLED; }
public plugin_natives() { register_library("jb_simon"); register_native("jb_is_user_simon", "_is_user_simon"); } public _is_user_simon(iPlugin, iParams) { return g_iSimon[get_param(1)]; }
public CmdSimon( id ) { if( cs_get_user_team( id ) != CS_TEAM_CT ) { ColorChat( id, NORMAL, "%s ^01You must be a ^03Counter-Terrorist ^01to use this command.", g_szPrefix ); return PLUGIN_HANDLED; } else if( g_iSimon == id ) { ColorChat( id, NORMAL, "%s ^01You are already the ^04Commander^01!", g_szPrefix ); return PLUGIN_HANDLED; } else if( is_user_alive( g_iSimon ) ) { ColorChat( id, NORMAL, "%s ^01Somebody else is currently Commander.", g_szPrefix ); return PLUGIN_HANDLED; } g_iSimon = id; new name[32]; get_user_name( id, name, 31 ); ColorChat( 0, NORMAL, "%s ^03%s ^01 is now the Commander.", g_szPrefix, name ); cs_set_user_model( id, gsCommanderMdl ); return PLUGIN_CONTINUE; }
public cmdDeSimon( Victim, shouldgib ) { new victim = read_data( 2 ); if( !is_user_connected( victim ) ) return PLUGIN_HANDLED; if( victim == g_iSimon ) { g_iSimon = 0; ColorChat( 0, NORMAL, "%s ^01Due /decommander vote, somebody else has to take the commander spot.", g_szPrefix ); cs_set_user_model( Victim, gsCtMdl ); return PLUGIN_HANDLED; } return PLUGIN_HANDLED; } public HudSimon() { set_hudmessage( 0, 255, 0, -1.0, 0.05, 0, 0.1, 1.0, 0.1, 0.1, 4 ); if( !is_user_alive( g_iSimon ) ) { g_iSimon = 0; show_hudmessage( 0, "There is currently nobody commanding." ); return PLUGIN_HANDLED; } new name[32]; get_user_name( g_iSimon, name, 31 ); show_hudmessage( 0, "%s is the current Commander.", name ); return PLUGIN_HANDLED; }
public client_disconnect( id ) { if( g_iSimon == 0 ); { g_iSimon = 0; ColorChat( 0, NORMAL, "%s ^01The current Commander has left the game.", g_szPrefix ); return PLUGIN_HANDLED; } return PLUGIN_HANDLED; }
public Event_DeathMsg(victim) { new victim = read_data( 2 ); if( !is_user_connected( victim ) ) return PLUGIN_HANDLED; if( victim == g_iSimon ) { ColorChat( 0, NORMAL, "%s ^01The current Commander has died.", g_szPrefix ); g_iSimon = 0; cs_set_user_model( victim, gsCtMdl ); return PLUGIN_HANDLED; } return PLUGIN_HANDLED; }
|