Advertisement
macquid123560

Top Jailbreak | Clown Event

Mar 23rd, 2016
1,032
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.68 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta_util>
  4. #include <hamsandwich>
  5.  
  6. #define SNOW_MAN "models/bonus_mon021.mdl"
  7. #define SNOW_MAN_HP 5000.0
  8. #define SNOW_MAN_HIT 300
  9. #define SNOW_MAN_CLASS_NAME "show_man"
  10.  
  11. #define SNOW_MAN_SOUND_IDLE     "snow_idle.wav"
  12. #define SNOW_MAN_SOUND_DIE      "snow_die.wav"
  13.  
  14. native get_user_cash( const index );
  15. native set_user_cash( const index, cash );
  16.  
  17. new spr_blood_drop, spr_blood_spray
  18. new g_NpcDead
  19. new Float:g_vecSnowManSpawnPos[3]
  20. new g_iRound
  21.  
  22. new maxplayers;
  23.  
  24. native szDropBox( ent );
  25.  
  26. public plugin_init()
  27. {
  28.     register_plugin("Clown Event", "v1.0", "@,TheBomB`");
  29.    
  30.     register_event("HLTV", "Event_RoundStart", "a", "1=0", "2=0")
  31.  
  32.     register_logevent("Event_NewRoundStarted", 2, "1=Round_Start")
  33.     register_logevent("Event_NewRoundEnd", 2, "1=Round_End")
  34.  
  35.     register_clcmd("set_clown", "clcmd_coord_snowman", ADMIN_IMMUNITY)
  36.  
  37.     register_clcmd("clown", "clcmd_show", ADMIN_IMMUNITY)
  38.  
  39.     RegisterHam(Ham_Think, "info_target", "Entity_Think")
  40.     RegisterHam(Ham_TakeDamage, "info_target", "Entity_TakeDamage_Post", 1)
  41.     RegisterHam(Ham_Killed, "info_target", "Entity_Killed")
  42.     RegisterHam(Ham_TraceAttack, "info_target", "Entity_TraceAttack")
  43.    
  44.     maxplayers = get_maxplayers( );
  45.     set_task( 0.5, "checkPlayers", .flags = "b" );
  46. }
  47.  
  48. public plugin_precache()
  49. {
  50.     spr_blood_drop = precache_model("sprites/blood.spr")
  51.     spr_blood_spray = precache_model("sprites/bloodspray.spr")
  52.  
  53.     precache_model(SNOW_MAN)
  54.  
  55.     precache_sound(SNOW_MAN_SOUND_IDLE)
  56.     precache_sound(SNOW_MAN_SOUND_DIE)
  57.     load_spawn()
  58. }
  59.  
  60. public checkPlayers( )
  61. {
  62.     static ent, body;
  63.     static szClassName[32]
  64.    
  65.     for( new i = 1; i <= maxplayers; i++ )
  66.     {
  67.         if( !is_user_connected( i ) )
  68.             continue;
  69.            
  70.         get_user_aiming( i, ent, body );
  71.        
  72.         if( ent <= maxplayers )
  73.             continue;
  74.        
  75.         entity_get_string( ent, EV_SZ_classname, szClassName, charsmax(szClassName) )
  76.        
  77.         if(!equali(szClassName, SNOW_MAN_CLASS_NAME))
  78.             continue;
  79.        
  80.         client_print( i, print_center, "Health: %d", pev( ent, pev_health ) );
  81.     }
  82. }
  83.  
  84. public Event_NewRoundStarted()
  85. {
  86. }
  87.  
  88. public clcmd_coord_snowman(id, access)
  89. {
  90.     if ( !( get_user_flags( id ) & ADMIN_KICK ) )
  91.         return PLUGIN_CONTINUE
  92.  
  93.     new Float:vecOrigin[3], szOrigin[39]
  94.  
  95.     pev(id, pev_origin, vecOrigin)
  96.     formatex(szOrigin, charsmax(szOrigin), "%f %f %f", vecOrigin[0], vecOrigin[1], vecOrigin[2])
  97.  
  98.     new szFile[32]
  99.  
  100.     get_mapname(szFile, charsmax(szFile))
  101.  
  102.     format(szFile, charsmax(szFile), "maps/%s.snowman", szFile)
  103.     client_print( id, print_chat, "HALF 1");
  104.  
  105.     write_file(szFile, szOrigin, 0)
  106.  
  107.     return PLUGIN_HANDLED
  108. }
  109.  
  110. public Event_RoundStart()
  111. {
  112.     g_iRound--
  113.  
  114.     if(g_iRound < 0)
  115.         g_iRound = 4
  116.  
  117.     static entity; entity = -1
  118.     while((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", SNOW_MAN_CLASS_NAME)))
  119.     {
  120.         engfunc(EngFunc_RemoveEntity, entity)
  121.     }
  122. }
  123.  
  124. public Event_NewRoundEnd()
  125. {
  126.     remove_task()
  127. }
  128.  
  129. public Entity_Think(ent)
  130. {
  131.     if(!is_valid_ent(ent))
  132.         return
  133.  
  134.     static szClassName[32]
  135.     new Float:a[3]
  136.     entity_get_string(ent, EV_SZ_classname, szClassName, charsmax(szClassName))
  137.      
  138.     if(!equali(szClassName, SNOW_MAN_CLASS_NAME))
  139.         return
  140.  
  141.     if(g_NpcDead)
  142.         return
  143.  
  144.     drop_to_floor(ent)
  145.     pev(ent, pev_velocity, a)
  146.     if(vector_length(a)  < 150.0 ) {
  147.         pev(ent, pev_v_angle, a)
  148.         a[1]+=random_float(-180.0,180.0)
  149.         set_pev(ent, pev_v_angle, a)
  150.         set_pev(ent, pev_angles, a)
  151.     }
  152.     entity_set_float(ent, EV_FL_framerate, 1.0)
  153.     if( pev(ent, pev_sequence) != 2 ) set_pev( ent, pev_sequence, 2 )
  154.     velocity_by_aim(ent, 300, a)
  155.     set_pev(ent, pev_velocity, a)
  156.     pev(ent, pev_origin, a)
  157.     a[2]+=5.0
  158.     set_pev(ent, pev_origin, a)
  159.     entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.01)
  160.    
  161.     set_task( 3.0, "szDropBox", ent)
  162. }
  163.  
  164. public Entity_TakeDamage_Post(victim, inflicator, attacker, Float:damage, damage_type)
  165. {
  166.     if(!is_user_connected(attacker))
  167.         return
  168.  
  169.     new szClassName[32]
  170.     entity_get_string(victim, EV_SZ_classname, szClassName, charsmax(szClassName))
  171.  
  172.     if(equal(szClassName, SNOW_MAN_CLASS_NAME))
  173.     {
  174.         new iRandomAmount;
  175.    
  176.         if( get_user_flags( attacker ) & ADMIN_LEVEL_C )
  177.             iRandomAmount = random_num( 30, 300 );
  178.         else
  179.             iRandomAmount = random_num( 10, 250 );
  180.    
  181.         emit_sound(victim, CHAN_VOICE, SNOW_MAN_SOUND_IDLE, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  182.         ColorChat( attacker, "You got^3 %i^1 cash for hitting the clown !",iRandomAmount);
  183.         set_user_cash( attacker, get_user_cash( attacker ) + iRandomAmount );
  184.     }
  185. }
  186.  
  187. public Entity_Killed(victim, attacker, shouldgin)
  188. {
  189.     new szClassName[32]
  190.     entity_get_string(victim, EV_SZ_classname, szClassName, charsmax(szClassName))
  191.  
  192.     if(!equal(szClassName, SNOW_MAN_CLASS_NAME))
  193.         return HAM_IGNORED
  194.  
  195.     entity_set_float(victim, EV_FL_animtime, get_gametime())
  196.     entity_set_float(victim, EV_FL_framerate, 1.0)
  197.     entity_set_int(victim, EV_INT_sequence, 7)
  198.  
  199.     entity_set_int(victim, EV_INT_solid, SOLID_NOT)
  200.  
  201.     emit_sound(victim, CHAN_VOICE, SNOW_MAN_SOUND_DIE, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  202.  
  203.     g_NpcDead = true
  204.  
  205.     return HAM_SUPERCEDE
  206. }
  207.  
  208. public Entity_TraceAttack(ent, attacker, Float:damage, Float:direction[3], trace, damage_type)
  209. {
  210.     if(!is_valid_ent(ent))
  211.         return
  212.      
  213.     new szClassName[32]
  214.     entity_get_string(ent, EV_SZ_classname, szClassName, charsmax(szClassName))
  215.      
  216.     if(!equali(szClassName, SNOW_MAN_CLASS_NAME))
  217.         return
  218.          
  219.     new Float:end[3]
  220.     get_tr2(trace, TR_vecEndPos, end)
  221.      
  222.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  223.     write_byte(TE_BLOODSPRITE)
  224.     engfunc(EngFunc_WriteCoord, end[0])
  225.     engfunc(EngFunc_WriteCoord, end[1])
  226.     engfunc(EngFunc_WriteCoord, end[2])
  227.     write_short(spr_blood_spray)
  228.     write_short(spr_blood_drop)
  229.     write_byte(247)
  230.     write_byte(random_num(5, 10))
  231.     message_end()
  232. }
  233.  
  234. public clcmd_show(id)
  235. {
  236.     if( get_user_flags( id ) & ADMIN_IMMUNITY    )
  237.     {
  238.         ColorChat(id, "You^3 spawned^1 a clown")
  239.        
  240.         new ent = create_entity("info_target")
  241.        
  242.         if(!is_valid_ent(ent))
  243.             return
  244.        
  245.         entity_set_string(ent, EV_SZ_classname, SNOW_MAN_CLASS_NAME)
  246.         entity_set_model(ent, SNOW_MAN)
  247.         entity_set_size(ent, Float:{ -16.0, -16.0, -36.0 }, Float:{ 16.0, 16.0, 36.0 })
  248.         entity_set_float(ent, EV_FL_health, SNOW_MAN_HP)
  249.         entity_set_float(ent, EV_FL_takedamage, DAMAGE_AIM)
  250.         entity_set_int(ent, EV_INT_solid, SOLID_BBOX)
  251.         set_pev( ent, pev_movetype, MOVETYPE_PUSHSTEP )
  252.         entity_set_int(ent, EV_INT_sequence, 2)
  253.         set_pev( ent, pev_gravity, 11.0 )
  254.         entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.01)
  255.         g_vecSnowManSpawnPos[2]+= 10.0
  256.         entity_set_origin(ent, g_vecSnowManSpawnPos)
  257.         drop_to_floor(ent)
  258.         g_NpcDead = false
  259.     }
  260. }
  261.  
  262. load_spawn()
  263. {
  264.     new szFile[32], szSpawn[39], szSpawns[3][13]
  265.  
  266.     get_mapname(szFile, charsmax(szFile))
  267.  
  268.     format(szFile, charsmax(szFile), "maps/%s.snowman", szFile)
  269.  
  270.     if(!file_exists(szFile))
  271.         return
  272.  
  273.     new iLen
  274.  
  275.     read_file(szFile, 0, szSpawn, charsmax(szSpawn), iLen)
  276.  
  277.     parse(szSpawn, szSpawns[0], 12, szSpawns[1], 12, szSpawns[2], 12)
  278.  
  279.     g_vecSnowManSpawnPos[0] = floatstr(szSpawns[0])
  280.     g_vecSnowManSpawnPos[1] = floatstr(szSpawns[1])
  281.     g_vecSnowManSpawnPos[2] = floatstr(szSpawns[2])
  282. }
  283.  
  284. /* Stocks */
  285.  
  286. stock ColorChat( const index, const string[], any:... )
  287. {
  288.     new szMsg[ 191 ], Players[ 32 ], PNum = 1;
  289.    
  290.     static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "^3[^1 Cyber^3 ]^1 " );
  291.    
  292.     vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
  293.    
  294.     if ( index )
  295.         Players[ 0 ] = index;
  296.    
  297.     else
  298.         get_players( Players, PNum, "ch" );
  299.    
  300.     for ( new i; i < PNum; i++ )
  301.     {
  302.         if( is_user_connected( Players[ i ] ) )
  303.         {
  304.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );
  305.            
  306.             write_byte( Players[ i ] );
  307.            
  308.             write_string( szMsg );
  309.            
  310.             message_end( );
  311.         }
  312.     }
  313.    
  314.     return 1;
  315. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement