Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include < amxmodx >
  2. #include < engine >
  3. #include < fakemeta_util >
  4. #include < cstrike >
  5. #include < hamsandwich >
  6.  
  7. #pragma semicolon 1
  8.  
  9. #define TASK_BOX 1234
  10. #define HIT_SOUND "debris/metal6.wav"
  11.  
  12. /* Constants & Others */
  13.  
  14. new Info[ 3 ][ ] ={
  15.  
  16. "Galaxy Box",
  17. "1.0",
  18. "Avio"
  19. };
  20.  
  21. native get_user_cash(client);
  22. native set_user_cash(client, cash);
  23.  
  24. new szModel[] = "models/w_GalaxyBox.mdl";
  25.  
  26. new Float:Uglovi[3];
  27.  
  28. public plugin_init() {
  29.  
  30. register_plugin( Info[ 0 ], Info[ 1 ], Info[ 2 ] );
  31.  
  32. register_event("DeathMsg", "event_death", "a");
  33. register_event("HLTV", "Event_Roundstart", "a", "1=0", "2=0");
  34.  
  35.  
  36. register_touch("SupplyBox", "player", "touchbox");
  37.  
  38. register_clcmd("create_box", "gBox" );
  39. }
  40.  
  41. public plugin_precache(){
  42.  
  43. precache_model( szModel );
  44. precache_sound( HIT_SOUND );
  45. }
  46.  
  47. public Event_Roundstart( )
  48. {
  49. remove_task();
  50.  
  51. new iEnt = -1;
  52. while( ( iEnt = find_ent_by_class( iEnt, "SupplyBox" ) ) != 0 )
  53. {
  54. remove_entity( iEnt );
  55. }
  56. }
  57.  
  58. public event_death()
  59. {
  60. new szVictim = read_data( 2 );
  61. setbox( szVictim );
  62. return 1;
  63. }
  64.  
  65. public gBox( client )
  66. {
  67. if ( !( get_user_flags( client ) & ADMIN_IMMUNITY) )
  68. return ColorChat( client, "You have no^x04 access^x01 to this command." );
  69.  
  70. setbox( client );
  71.  
  72. return 1;
  73. }
  74.  
  75.  
  76. public setbox( client )
  77. {
  78. static Float:fOrigin[3];
  79. pev( client, pev_origin, fOrigin );
  80. pev( client, pev_angles, Uglovi );
  81. Uglovi[0] = 0.0;
  82. fOrigin[1] += 35.0;
  83. create_SupplyBox(fOrigin);
  84. return 1;
  85. }
  86.  
  87. public create_SupplyBox(Float:origin[3])
  88. {
  89. static Float:fMinSize[ 3 ];
  90. static Float:fMaxSize[ 3 ];
  91.  
  92. new iEnt = create_entity("info_target");
  93.  
  94. entity_set_origin( iEnt, origin);
  95. entity_set_vector( iEnt, EV_VEC_angles, Uglovi);
  96. entity_set_string( iEnt, EV_SZ_classname, "SupplyBox" );
  97. entity_set_model( iEnt, szModel );
  98.  
  99. emit_sound( iEnt, CHAN_AUTO, "items/9mmclip1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
  100.  
  101. entity_set_int( iEnt, EV_INT_solid, SOLID_BBOX );
  102. entity_set_int( iEnt, EV_INT_movetype, MOVETYPE_BOUNCE );
  103.  
  104. if( !fMinSize[ 0 ] )
  105. {
  106. fMinSize = Float:{ -10.299999, -8.970000, 0.000000 };
  107.  
  108. fMaxSize = Float:{ 10.299999, 8.970000, 12.760000 };
  109. }
  110.  
  111. entity_set_size( iEnt, fMinSize, fMaxSize );
  112.  
  113. entity_set_float( iEnt, EV_FL_gravity, 0.85 );
  114.  
  115. /* Colors Glow */
  116.  
  117. new g_flGlowColor[ 3 ];
  118.  
  119. g_flGlowColor[ 0 ] = 50;
  120. g_flGlowColor[ 1 ] = 250;
  121. g_flGlowColor[ 2 ] = 50;
  122.  
  123. set_rendering ( iEnt, kRenderFxGlowShell, g_flGlowColor[ 0 ], g_flGlowColor[ 1 ], g_flGlowColor[ 2 ], kRenderFxNone, 16 );
  124.  
  125. /* Drop to Floor */
  126.  
  127. drop_to_floor( iEnt );
  128.  
  129. RegisterHamFromEntity( Ham_TraceAttack, iEnt, "OnTraceAttack" );
  130.  
  131. return 1;
  132. }
  133.  
  134. public OnTraceAttack( ent )
  135. {
  136. engfunc( EngFunc_EmitSound, ent, CHAN_ITEM, HIT_SOUND, 0.5, ATTN_STATIC, 0, PITCH_NORM );
  137. }
  138.  
  139. public touchbox( iEnt, client )
  140. {
  141. if ( !is_user_alive( client ) || !pev_valid( iEnt ) )
  142. return FMRES_IGNORED;
  143.  
  144. if( fm_get_user_button( client ) & IN_USE )
  145. {
  146. new classname[ 32 ];
  147. pev( iEnt, pev_classname, classname, 31);
  148. if (!equal( classname, "SupplyBox"))
  149. return FMRES_IGNORED;
  150.  
  151. gSupplyBoxSub( client );
  152.  
  153. set_pev( iEnt, pev_effects, EF_NODRAW);
  154. set_pev( iEnt, pev_solid, SOLID_NOT);
  155. remove_ent( iEnt );
  156. }
  157.  
  158. return FMRES_IGNORED;
  159. }
  160.  
  161. public gSupplyBoxSub( client )
  162. {
  163. new szRandomCash[ 33 ], g_iMin, g_iMax;
  164.  
  165. g_iMin = 100;
  166.  
  167. g_iMax = 500;
  168.  
  169. szRandomCash[ client ] = random_num( g_iMin, g_iMax );
  170.  
  171. set_user_cash(client,get_user_cash(client) + szRandomCash[ client ]);
  172.  
  173. ColorChat(0, "^x03%s^x01 picked up the box received^x04 %i^x01 Cash", szName( client ), szRandomCash[ client ] );
  174. emit_sound( client, CHAN_ITEM, "items/weapondrop1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
  175. }
  176.  
  177. public remove_ent( iEnt )
  178. {
  179. if (pev_valid( iEnt ) )
  180. engfunc( EngFunc_RemoveEntity, iEnt );
  181. }
  182.  
  183.  
  184. /* Stocks */
  185.  
  186. stock szName( index )
  187. {
  188. static name[ 32 ];
  189.  
  190. get_user_name( index, name, charsmax( name ) );
  191.  
  192. return name;
  193. }
  194.  
  195. stock ColorChat( const index, const string[], any:... )
  196. {
  197. new szMsg[ 191 ], Players[ 32 ], PNum = 1;
  198.  
  199. static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "^x04[AMXX]^x01 " );
  200.  
  201. vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
  202.  
  203. if ( index )
  204. Players[ 0 ] = index;
  205.  
  206. else
  207. get_players( Players, PNum, "ch" );
  208.  
  209. for ( new i; i < PNum; i++ )
  210. {
  211.  
  212.  
  213. if( is_user_connected( Players[ i ] ) )
  214. {
  215. message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );
  216.  
  217. write_byte( Players[ i ] );
  218.  
  219. write_string( szMsg );
  220.  
  221. message_end( );
  222. }
  223. }
  224.  
  225. return 1;
  226. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement