#include < amxmodx > #include < amxmisc > #include < cstrike > #include < dhudmessage > #include < engine > #include < fakemeta > #include < fakemeta_util > #include < fun > #include < hamsandwich > #include < xs > #include < zp50_core > #include < zp50_class_nemesis > #include < zp50_class_survivor > //============================================== // [Customization] //============================================== // Max level #define MAX_LEVEL_ZOMBIE 10 // XP const g_iXPForInfect = 10 // XP for infect human const g_iXPForKill = 10 // XP for killing normal human const g_iXPForKillSurvivor = 25 // XP for killing survivor const g_iXPForWinZombie = 15 // XP for winning the round as zombie(for all zombie team) // Zombie XP table new const g_iZombieXPTable[ MAX_LEVEL_ZOMBIE ] = { 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200 } // Zombie race names(multilingual) new const g_szZombieRaceName[ ][ ] = { "RACE_MUTANT", "RACE_BOOM", "RACE_THUNDER", "RACE_SPY", "RACE_CHEATER", "RACE_DESTROYER", "RACE_MENTAL", "RACE_TOXIC", "RACE_EVIL" }; // Chat message prefix new const g_szChatPrefix = "[ZP]" // Levelup sound new const g_szSoundLevelUp[ ] = "zp_xp/levelup.wav" //============================================== // [Customization end] //============================================== new g_iCurrentZombieRace[ 33 ][ 2 ]; // 0 - current race, 1 - next race new g_iZombieXP[ 33 ]; // zombie xp new g_iZombieLevel[ 33 ][ 9 ]; // zombie level new g_iZombieSkillLevel[ 33 ]; // zombie skill level new bool:g_bShowMenuOnSpawn[ 33 ][ 2 ] // 0 human manu, 1 zombie menu new g_bitIsAlive; new g_bitIsConnected; new g_iMaxPlayers; new gmsgSayText; const MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0; enum ( += 32 ) { TASK_XP } #define FBitSet(%0,%1) ( %0 & ( 1 << %1 ) ) #define SetBits(%0,%1) ( %0 |= ( 1 << %1 ) ) #define ClearBits(%0,%1) ( %0 &= ~( 1 << %1 ) ) #define IsPlayer(%0) ( 1 <= %0 <= g_iMaxPlayers ) #define ID_XP ( taskid - TASK_XP ) public plugin_precache( ) { precache_sound( g_szSoundLevelUp ); } public plugin_init( ) { register_plugin( "[ZP] XP System", "1.0", "NiHiLaNTh" ); register_dictionary( "zp_xp.txt" ); register_clcmd( "say /zclass", "COMMAND_ZCLASS" ); register_event( "DeathMsg", "EV_DeathMsg", "a" ); RegisterHam( Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1 ); register_menu( "Zombie Race Menu", MENU_KEYS, "MENU_ZombieHandler" ); gmsgSayText = get_user_msgid( "SayText" ); g_iMaxPlayers = get_maxplayers( ); } public client_connect( Player ) { SetBits( g_bitIsConnected, Player ); ClearBits( g_bitIsAlive, Player ); g_iCurrentZombieRace[ Player ][ 0 ] = g_iCurrentZombieRace[ Player ][ 1 ] = 0; g_iZombieXP[ Player ] = 0; g_iZombieSkillLevel[ Player ] = 0; g_bShowMenuOnSpawn[ Player ][ 0 ] = g_bShowMenuOnSpawn[ Player ][ 1 ] = true; new i; for( i = 0; i < 9; i++ ) g_iZombieLevel[ Player ][ i ] = 0; } public client_disconnect( Player ) { ClearBits( g_bitIsConnected, Player ); ClearBits( g_bitIsAlive, Player ); remove_task( Player + TASK_XP ); } public zp_fw_core_infect_post( iVictim, pevAttacker ) { g_iCurrentZombieRace[ iVictim ][ 0 ] = g_iCurrentZombieRace[ iVictim ][ 1 ]; if( g_bShowMenuOnSpawn[ iVictim ][ 1 ] ) set_task( 0.1, "UTIL_ShowZombieMenu", iVictim ); if( IsPlayer( pevAttacker ) ) { g_iZombieXP[ pevAttacker ] += g_iXPForInfect; UTIL_VarArgs( pevAttacker, "/g%s /y%L", g_szChatPrefix, pevAttacker, "MSG_XP_FOR_INFECT", g_iXPForInfect ); UTIL_CheckLevel( pevAttacker, true, true ); } set_task( 0.1, "TASK_InitHUD", iVictim + TASK_XP, _, _, "b" ); } public COMMAND_ZCLASS( Player ) { UTIL_ShowZombieMenu( Player ); } public EV_DeathMsg( ) { static iVictim; iVictim = read_data( 2 ); if( !FBitSet( iVictim, g_bitIsConnected ) ) return; ClearBits( g_bitIsAlive, iVictim ); static iKiller; iKiller = read_data( 1 ); if( IsPlayer( iKiller ) && iKiller != iVictim ) { new bool:fSurv; fSurv = zp_class_survivor_get( iVictim ) ? true : false; g_iZombieXP[ iKiller ] += fSurv ? g_iXPForKillSurvivor : g_iXPForKill; UTIL_VarArgs( iKiller, "/g%s /y%L", g_szChatPrefix, iKiller, fSurv ? "MSG_XP_FOR_KILL_SURV" : "MSG_XP_FOR_KILL", fSurv ? g_iXPForKillSurvivor : g_iXPForKill ); UTIL_CheckLevel( iKiller, true, true ); } remove_task( iVictim + TASK_XP ); } public fw_PlayerSpawn_Post( Player ) { if( !is_user_alive( Player ) ) return; SetBits( g_bitIsAlive, Player ); } public MENU_ZombieHandler( Player, iKey ) { switch( iKey ) { case 0..8: { if( g_iZombieLevel[ Player ][ iKey ] >= 10 ) { UTIL_VarArgs( Player, "/g%s /y%L", g_szChatPrefix, Player, "MSG_LAST_LEVEL" ); UTIL_ShowZombieMenu( Player ); } else { g_bShowMenuOnSpawn[ Player ][ 1 ] = false; g_iCurrentZombieRace[ Player ][ 1 ] = iKey; UTIL_VarArgs( Player, "/g%s /y%L /g%L", g_szChatPrefix, Player, "MSG_NEXTZRACE", Player, g_szZombieRaceName[ iKey ] ); } } case 9: { return PLUGIN_HANDLED; } } return PLUGIN_HANDLED; } public TASK_InitHUD( taskid ) { if( !FBitSet( g_bitIsAlive, ID_XP ) ) return; static iColor[ 3 ]; if( zp_core_is_zombie( ID_XP ) ) iColor[ 0 ] = 255, iColor[ 1 ] = 0, iColor[ 2 ] = 0; set_dhudmessage( iColor[ 0 ], iColor[ 1 ], iColor[ 2 ], 0.0, 0.14, 0, 6.0, 12.0 ); show_dhudmessage( ID_XP, "[%L: %L]^n[%L: %d/%d]^n[XP: %d/%d]", ID_XP, "HUD_RACE", ID_XP, g_szZombieRaceName[ g_iCurrentZombieRace[ ID_XP ][ 0 ] ], ID_XP, "MENU_LEVEL", g_iZombieLevel[ ID_XP ][ g_iCurrentZombieRace[ ID_XP ][ 0 ] ], MAX_LEVEL_ZOMBIE, g_iZombieXP[ ID_XP ], g_iZombieXPTable[ g_iZombieLevel[ ID_XP ][ g_iCurrentZombieRace[ ID_XP ][ 0 ] ] ] ); } UTIL_CheckLevel( Player, bool:fNoticePlayer, bool:fZombie ) { if( fZombie ) { if( g_iZombieLevel[ Player ][ g_iCurrentZombieRace[ Player ][ 0 ] ] < MAX_LEVEL_ZOMBIE - 1 ) { while( g_iZombieXP[ Player ] >= g_iZombieXPTable[ g_iZombieLevel[ Player ][ g_iCurrentZombieRace[ Player ][ 0 ] ] ] ) { g_iZombieLevel[ Player ][ g_iCurrentZombieRace[ Player ][ 0 ] ]++; g_bShowMenuOnSpawn[ Player ][ 1 ] = true; if( g_iZombieSkillLevel[ Player ] < 3 ) g_iZombieSkillLevel[ Player ]++ if( fNoticePlayer ) { set_dhudmessage( 160, 0, 0, 0.37, 0.27, _, 3.0, 3.0, 0.01, _, _ ); show_dhudmessage( Player, "%L", Player, "MSG_LEVEL", g_iZombieLevel[ Player ][ g_iCurrentZombieRace[ Player ][ 0 ] ] ); emit_sound( Player, CHAN_BODY, g_szSoundLevelUp, VOL_NORM, ATTN_NORM, 0, PITCH_NORM ); } } } } } UTIL_VarArgs( Player, const szMessage[ ], any:...) { static iPlayersNum[ 32 ], iCount; iCount = 1; static szMsg[ 191 ]; vformat( szMsg, charsmax( szMsg ), szMessage, 3 ); replace_all( szMsg, 190, "/g", "^4" ); // green txt replace_all( szMsg, 190, "/y", "^1" ); // orange txt replace_all( szMsg, 190, "/ctr", "^3" ); // team txt replace_all( szMsg, 190, "/w", "^0" ); // team txt if( Player ) iPlayersNum[ 0 ] = Player; else get_players( iPlayersNum, iCount, "ch" ); for( new i = 0; i < iCount; i++ ) { if( FBitSet( g_bitIsConnected, iPlayersNum[ i ] ) ) { message_begin( MSG_ONE_UNRELIABLE, gmsgSayText, _, iPlayersNum[ i ] ); write_byte( iPlayersNum[ i ] ); write_string( szMsg ); message_end( ); } } } public UTIL_ShowZombieMenu( Player ) { if( !zp_core_is_zombie( Player ) ) return; new iMenu[ 500 ], iLen, i; iLen = 0; iLen += formatex( iMenu[ iLen ], charsmax( iMenu ) - iLen, "\y%L^n^n", Player, "MENU_ZRACE" ); for( i = 0; i < 9; i++ ) { if( g_iCurrentZombieRace[ Player ][ 1 ] == i || g_iZombieLevel[ Player ][ i ] >= 10 ) iLen += formatex( iMenu[ iLen ], charsmax( iMenu ) - iLen, "\d%d.%L \y%L[%d]^n", i + 1, Player, g_szZombieRaceName[ i ], Player, "MENU_LEVEL", g_iZombieLevel[ Player ][ i ] ); else iLen += formatex( iMenu[ iLen ], charsmax( iMenu ) - iLen, "\r%d.\w%L \y%L[%d]^n", i + 1, Player, g_szZombieRaceName[ i ], Player, "MENU_LEVEL", g_iZombieLevel[ Player ][ i ] ); } iLen += formatex( iMenu[ iLen ], charsmax( iMenu ) - iLen, "^n\r0.\w%L", Player, "MENU_EXIT" ); show_menu( Player, MENU_KEYS, iMenu, -1, "Zombie Race Menu" ); } /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par } */