Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <engine>
- #include <fakemeta_util>
- #include <hamsandwich>
- #define SNOW_MAN "models/bonus_mon021.mdl"
- #define SNOW_MAN_HP 5000.0
- #define SNOW_MAN_HIT 300
- #define SNOW_MAN_CLASS_NAME "show_man"
- #define SNOW_MAN_SOUND_IDLE "snow_idle.wav"
- #define SNOW_MAN_SOUND_DIE "snow_die.wav"
- native get_user_cash( const index );
- native set_user_cash( const index, cash );
- new spr_blood_drop, spr_blood_spray
- new g_NpcDead
- new Float:g_vecSnowManSpawnPos[3]
- new g_iRound
- new maxplayers;
- native szDropBox( ent );
- public plugin_init()
- {
- register_plugin("Clown Event", "v1.0", "@,TheBomB`");
- register_event("HLTV", "Event_RoundStart", "a", "1=0", "2=0")
- register_logevent("Event_NewRoundStarted", 2, "1=Round_Start")
- register_logevent("Event_NewRoundEnd", 2, "1=Round_End")
- register_clcmd("set_clown", "clcmd_coord_snowman", ADMIN_IMMUNITY)
- register_clcmd("clown", "clcmd_show", ADMIN_IMMUNITY)
- RegisterHam(Ham_Think, "info_target", "Entity_Think")
- RegisterHam(Ham_TakeDamage, "info_target", "Entity_TakeDamage_Post", 1)
- RegisterHam(Ham_Killed, "info_target", "Entity_Killed")
- RegisterHam(Ham_TraceAttack, "info_target", "Entity_TraceAttack")
- maxplayers = get_maxplayers( );
- set_task( 0.5, "checkPlayers", .flags = "b" );
- }
- public plugin_precache()
- {
- spr_blood_drop = precache_model("sprites/blood.spr")
- spr_blood_spray = precache_model("sprites/bloodspray.spr")
- precache_model(SNOW_MAN)
- precache_sound(SNOW_MAN_SOUND_IDLE)
- precache_sound(SNOW_MAN_SOUND_DIE)
- load_spawn()
- }
- public checkPlayers( )
- {
- static ent, body;
- static szClassName[32]
- for( new i = 1; i <= maxplayers; i++ )
- {
- if( !is_user_connected( i ) )
- continue;
- get_user_aiming( i, ent, body );
- if( ent <= maxplayers )
- continue;
- entity_get_string( ent, EV_SZ_classname, szClassName, charsmax(szClassName) )
- if(!equali(szClassName, SNOW_MAN_CLASS_NAME))
- continue;
- client_print( i, print_center, "Health: %d", pev( ent, pev_health ) );
- }
- }
- public Event_NewRoundStarted()
- {
- }
- public clcmd_coord_snowman(id, access)
- {
- if ( !( get_user_flags( id ) & ADMIN_KICK ) )
- return PLUGIN_CONTINUE
- new Float:vecOrigin[3], szOrigin[39]
- pev(id, pev_origin, vecOrigin)
- formatex(szOrigin, charsmax(szOrigin), "%f %f %f", vecOrigin[0], vecOrigin[1], vecOrigin[2])
- new szFile[32]
- get_mapname(szFile, charsmax(szFile))
- format(szFile, charsmax(szFile), "maps/%s.snowman", szFile)
- client_print( id, print_chat, "HALF 1");
- write_file(szFile, szOrigin, 0)
- return PLUGIN_HANDLED
- }
- public Event_RoundStart()
- {
- g_iRound--
- if(g_iRound < 0)
- g_iRound = 4
- static entity; entity = -1
- while((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", SNOW_MAN_CLASS_NAME)))
- {
- engfunc(EngFunc_RemoveEntity, entity)
- }
- }
- public Event_NewRoundEnd()
- {
- remove_task()
- }
- public Entity_Think(ent)
- {
- if(!is_valid_ent(ent))
- return
- static szClassName[32]
- new Float:a[3]
- entity_get_string(ent, EV_SZ_classname, szClassName, charsmax(szClassName))
- if(!equali(szClassName, SNOW_MAN_CLASS_NAME))
- return
- if(g_NpcDead)
- return
- drop_to_floor(ent)
- pev(ent, pev_velocity, a)
- if(vector_length(a) < 150.0 ) {
- pev(ent, pev_v_angle, a)
- a[1]+=random_float(-180.0,180.0)
- set_pev(ent, pev_v_angle, a)
- set_pev(ent, pev_angles, a)
- }
- entity_set_float(ent, EV_FL_framerate, 1.0)
- if( pev(ent, pev_sequence) != 2 ) set_pev( ent, pev_sequence, 2 )
- velocity_by_aim(ent, 300, a)
- set_pev(ent, pev_velocity, a)
- pev(ent, pev_origin, a)
- a[2]+=5.0
- set_pev(ent, pev_origin, a)
- entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.01)
- set_task( 3.0, "szDropBox", ent)
- }
- public Entity_TakeDamage_Post(victim, inflicator, attacker, Float:damage, damage_type)
- {
- if(!is_user_connected(attacker))
- return
- new szClassName[32]
- entity_get_string(victim, EV_SZ_classname, szClassName, charsmax(szClassName))
- if(equal(szClassName, SNOW_MAN_CLASS_NAME))
- {
- new iRandomAmount;
- if( get_user_flags( attacker ) & ADMIN_LEVEL_C )
- iRandomAmount = random_num( 30, 300 );
- else
- iRandomAmount = random_num( 10, 250 );
- emit_sound(victim, CHAN_VOICE, SNOW_MAN_SOUND_IDLE, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
- ColorChat( attacker, "You got^3 %i^1 cash for hitting the clown !",iRandomAmount);
- set_user_cash( attacker, get_user_cash( attacker ) + iRandomAmount );
- }
- }
- public Entity_Killed(victim, attacker, shouldgin)
- {
- new szClassName[32]
- entity_get_string(victim, EV_SZ_classname, szClassName, charsmax(szClassName))
- if(!equal(szClassName, SNOW_MAN_CLASS_NAME))
- return HAM_IGNORED
- entity_set_float(victim, EV_FL_animtime, get_gametime())
- entity_set_float(victim, EV_FL_framerate, 1.0)
- entity_set_int(victim, EV_INT_sequence, 7)
- entity_set_int(victim, EV_INT_solid, SOLID_NOT)
- emit_sound(victim, CHAN_VOICE, SNOW_MAN_SOUND_DIE, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
- g_NpcDead = true
- return HAM_SUPERCEDE
- }
- public Entity_TraceAttack(ent, attacker, Float:damage, Float:direction[3], trace, damage_type)
- {
- if(!is_valid_ent(ent))
- return
- new szClassName[32]
- entity_get_string(ent, EV_SZ_classname, szClassName, charsmax(szClassName))
- if(!equali(szClassName, SNOW_MAN_CLASS_NAME))
- return
- new Float:end[3]
- get_tr2(trace, TR_vecEndPos, end)
- message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
- write_byte(TE_BLOODSPRITE)
- engfunc(EngFunc_WriteCoord, end[0])
- engfunc(EngFunc_WriteCoord, end[1])
- engfunc(EngFunc_WriteCoord, end[2])
- write_short(spr_blood_spray)
- write_short(spr_blood_drop)
- write_byte(247)
- write_byte(random_num(5, 10))
- message_end()
- }
- public clcmd_show(id)
- {
- if( get_user_flags( id ) & ADMIN_IMMUNITY )
- {
- ColorChat(id, "You^3 spawned^1 a clown")
- new ent = create_entity("info_target")
- if(!is_valid_ent(ent))
- return
- entity_set_string(ent, EV_SZ_classname, SNOW_MAN_CLASS_NAME)
- entity_set_model(ent, SNOW_MAN)
- entity_set_size(ent, Float:{ -16.0, -16.0, -36.0 }, Float:{ 16.0, 16.0, 36.0 })
- entity_set_float(ent, EV_FL_health, SNOW_MAN_HP)
- entity_set_float(ent, EV_FL_takedamage, DAMAGE_AIM)
- entity_set_int(ent, EV_INT_solid, SOLID_BBOX)
- set_pev( ent, pev_movetype, MOVETYPE_PUSHSTEP )
- entity_set_int(ent, EV_INT_sequence, 2)
- set_pev( ent, pev_gravity, 11.0 )
- entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.01)
- g_vecSnowManSpawnPos[2]+= 10.0
- entity_set_origin(ent, g_vecSnowManSpawnPos)
- drop_to_floor(ent)
- g_NpcDead = false
- }
- }
- load_spawn()
- {
- new szFile[32], szSpawn[39], szSpawns[3][13]
- get_mapname(szFile, charsmax(szFile))
- format(szFile, charsmax(szFile), "maps/%s.snowman", szFile)
- if(!file_exists(szFile))
- return
- new iLen
- read_file(szFile, 0, szSpawn, charsmax(szSpawn), iLen)
- parse(szSpawn, szSpawns[0], 12, szSpawns[1], 12, szSpawns[2], 12)
- g_vecSnowManSpawnPos[0] = floatstr(szSpawns[0])
- g_vecSnowManSpawnPos[1] = floatstr(szSpawns[1])
- g_vecSnowManSpawnPos[2] = floatstr(szSpawns[2])
- }
- /* Stocks */
- stock ColorChat( const index, const string[], any:... )
- {
- new szMsg[ 191 ], Players[ 32 ], PNum = 1;
- static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "^3[^1 Cyber^3 ]^1 " );
- vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
- if ( index )
- Players[ 0 ] = index;
- else
- get_players( Players, PNum, "ch" );
- for ( new i; i < PNum; i++ )
- {
- if( is_user_connected( Players[ i ] ) )
- {
- message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );
- write_byte( Players[ i ] );
- write_string( szMsg );
- message_end( );
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement