hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.03.28. 13:13



Jelenlévő felhasználók

Jelenleg 250 felhasználó van jelen :: 2 regisztrált, 0 rejtett és 248 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot], Google [Bot] az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 5 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Labda
HozzászólásElküldve: 2017.01.04. 20:38 
Offline
GFX-Designer
Avatar

Csatlakozott: 2015.03.12. 15:06
Hozzászólások: 624
Megköszönt másnak: 199 alkalommal
Megköszönték neki: 78 alkalommal
Sziasztok!
Valaki átírná úgy, hogy csak a labda pattogás hallatszodjon, és a "NÁLLAD A LABDA!" hud üzenetet kellene még ki szedni belőlle.

Köszi előre!

  1. // Version 1.0 : Menu + Orginal Bounc / kicking
  2. // Version 2.0 : Added Real soccerjamsounds / Got ball msg / Freezetimebug
  3. // Version 3.0 : Fixed Ball spawns every round
  4.  
  5. #include <amxmodx>
  6. #include <engine>
  7. #include <fakemeta>
  8. #include <hamsandwich>
  9. #include <fun>
  10.  
  11. static const BALL_BOUNCE_GROUND[ ] = "kickball/bounce.wav";
  12. static const g_szBallModel[ ]     = "models/basebuilder/ball.mdl";
  13. static const g_szBallName[ ]      = "ball";
  14.  
  15. new g_iBall, g_szFile[ 128 ], g_szMapname[ 32 ], g_iButtonsMenu;
  16. new bool:g_bNeedBall
  17. new Float:g_vOrigin[ 3 ];
  18. new beamspr
  19.  
  20. new ballcolor[3] = { 255,200,100 }
  21. new ballbeam[3] = { 20,50,255 }
  22. new kicked[] = "kickball/kicked.wav"
  23. new gotball[] = "kickball/gotball.wav"
  24.  
  25. public plugin_init( ) {
  26.     register_plugin( "JailMod-Ball", "3.0", "ButterZ`" );
  27.      
  28.      
  29.     /* Register Forward */
  30.     register_forward(FM_PlayerPreThink, "PlayerPreThink", 0)
  31.      
  32.     /* Current Weapon */
  33.     register_event("CurWeapon", "CurWeapon", "be");
  34.      
  35.     RegisterHam( Ham_ObjectCaps, "player", "FwdHamObjectCaps", 1 );
  36.     register_logevent( "EventRoundStart", 2, "1=Round_Start" );
  37.      
  38.     register_think( g_szBallName, "FwdThinkBall" );
  39.     register_touch( g_szBallName, "player", "FwdTouchPlayer" );
  40.      
  41.     new const szEntity[ ][ ] = {
  42.         "worldspawn", "func_wall", "func_door",  "func_door_rotating",
  43.         "func_wall_toggle", "func_breakable", "func_pushable", "func_train",
  44.         "func_illusionary", "func_button", "func_rot_button", "func_rotating"
  45.     }
  46.      
  47.     for( new i; i < sizeof szEntity; i++ )
  48.         register_touch( g_szBallName, szEntity[ i ], "FwdTouchWorld" );
  49.      
  50.     g_iButtonsMenu = menu_create( "BallMaker Menu", "HandleButtonsMenu" );
  51.      
  52.     menu_additem( g_iButtonsMenu, "Create Ball", "1" );
  53.     menu_additem( g_iButtonsMenu, "Load Ball", "2" );
  54.     menu_additem( g_iButtonsMenu, "Delete all Ball", "3" );
  55.     menu_additem( g_iButtonsMenu, "Save", "4" );
  56.      
  57.     register_clcmd( "say /ball", "CmdButtonsMenu", ADMIN_RCON );
  58.     register_clcmd( "say /reset", "UpdateBall" );
  59. }    
  60. public PlayerPreThink(id) {
  61.     if(!is_user_alive(id))
  62.         return PLUGIN_CONTINUE;
  63.          
  64.     if( is_valid_ent( g_iBall  ) ) {
  65.         static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  66.         if( iOwner != id && get_user_maxspeed(id) != 1.0 )  
  67.             set_user_maxspeed(id, 230.0)
  68.     }
  69.     return PLUGIN_HANDLED;
  70. }
  71. public CurWeapon(id) {
  72.     if(!is_user_alive(id))
  73.         return PLUGIN_CONTINUE;
  74.     if( is_valid_ent(g_iBall ) ) {
  75.         static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  76.         if( iOwner == id )
  77.             set_user_maxspeed(id, 230.0)
  78.     }    
  79.     return PLUGIN_HANDLED;
  80. }
  81. public UpdateBall( id ) {
  82.     if( !id || get_user_flags( id ) & ADMIN_KICK ) {
  83.         if( is_valid_ent( g_iBall ) ) {
  84.             entity_set_vector(g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  85.             entity_set_origin( g_iBall , g_vOrigin );
  86.              
  87.             entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  88.             entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  89.             entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  90.         }
  91.     }
  92.      
  93.     return PLUGIN_HANDLED;
  94. }
  95.  
  96. public plugin_precache( ) {
  97.     precache_model( g_szBallModel );
  98.     precache_sound( BALL_BOUNCE_GROUND );
  99.      
  100.     beamspr = precache_model( "sprites/laserbeam.spr" );
  101.     precache_sound(kicked)
  102.     precache_sound(gotball)
  103.      
  104.     get_mapname( g_szMapname, 31 );
  105.     strtolower( g_szMapname );
  106.      
  107.     // File
  108.     new szDatadir[ 64 ];
  109.     get_localinfo( "amxx_datadir", szDatadir, charsmax( szDatadir ) );
  110.      
  111.     formatex( szDatadir, charsmax( szDatadir ), "%s", szDatadir );
  112.      
  113.     if( !dir_exists( szDatadir ) )
  114.         mkdir( szDatadir );
  115.      
  116.     formatex( g_szFile, charsmax( g_szFile ), "%s/ball.ini", szDatadir );
  117.      
  118.     if( !file_exists( g_szFile ) ) {
  119.         write_file( g_szFile, "// Ball Spawn Editor", -1 );
  120.         write_file( g_szFile, " ", -1 );
  121.          
  122.         return; // We dont need to load file
  123.     }
  124.      
  125.     new szData[ 256 ], szMap[ 32 ], szOrigin[ 3 ][ 16 ];
  126.     new iFile = fopen( g_szFile, "rt" );
  127.      
  128.     while( !feof( iFile ) ) {
  129.         fgets( iFile, szData, charsmax( szData ) );
  130.          
  131.         if( !szData[ 0 ] || szData[ 0 ] == ';' || szData[ 0 ] == ' ' || ( szData[ 0 ] == '/' && szData[ 1 ] == '/' ) )
  132.             continue;
  133.          
  134.         parse( szData, szMap, 31, szOrigin[ 0 ], 15, szOrigin[ 1 ], 15, szOrigin[ 2 ], 15 );
  135.          
  136.         if( equal( szMap, g_szMapname ) ) {
  137.             new Float:vOrigin[ 3 ];
  138.              
  139.             vOrigin[ 0 ] = str_to_float( szOrigin[ 0 ] );
  140.             vOrigin[ 1 ] = str_to_float( szOrigin[ 1 ] );
  141.             vOrigin[ 2 ] = str_to_float( szOrigin[ 2 ] );
  142.              
  143.             CreateBall( 0, vOrigin );
  144.              
  145.             g_vOrigin = vOrigin;
  146.              
  147.             break;
  148.         }
  149.     }
  150.      
  151.     fclose( iFile );
  152. }
  153.  
  154. public CmdButtonsMenu( id ) {
  155.     if( get_user_flags( id ) & ADMIN_RCON )
  156.         menu_display( id, g_iButtonsMenu, 0 );
  157.      
  158.     return PLUGIN_HANDLED;
  159. }
  160.  
  161. public HandleButtonsMenu( id, iMenu, iItem ) {
  162.     if( iItem == MENU_EXIT )
  163.         return PLUGIN_HANDLED;
  164.      
  165.     new szKey[ 2 ], _Access, _Callback;
  166.     menu_item_getinfo( iMenu, iItem, _Access, szKey, 1, "", 0, _Callback );
  167.      
  168.     new iKey = str_to_num( szKey );
  169.      
  170.     switch( iKey ) {
  171.         case 1:    {
  172.             if( pev_valid( g_iBall  ) )
  173.                 return PLUGIN_CONTINUE;
  174.                  
  175.             CreateBall( id );
  176.         }
  177.         case 2: {
  178.             if( is_valid_ent( g_iBall  ) ) {
  179.                 entity_set_vector( g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  180.                 entity_set_origin( g_iBall , g_vOrigin );
  181.                  
  182.                 entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  183.                 entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  184.                 entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  185.                 client_print( id, print_chat, "*** Loading Ball ***" );
  186.             }
  187.         }
  188.         case 3: {
  189.             new iEntity;
  190.              
  191.             while( ( iEntity = find_ent_by_class( iEntity, g_szBallName ) ) > 0 )
  192.                 remove_entity( iEntity );
  193.             client_print( id, print_chat, "*** Ball Deleted ! ***" );
  194.         }
  195.         case 4: {
  196.             new iBall, iEntity, Float:vOrigin[ 3 ];
  197.              
  198.             while( ( iEntity = find_ent_by_class( iEntity, g_szBallName ) ) > 0 )
  199.                 iBall = iEntity;
  200.              
  201.             if( iBall > 0 )
  202.                 entity_get_vector( iBall, EV_VEC_origin, vOrigin );
  203.             else
  204.                 return PLUGIN_HANDLED;
  205.              
  206.             new bool:bFound, iPos, szData[ 32 ], iFile = fopen( g_szFile, "r+" );
  207.              
  208.             if( !iFile )
  209.                 return PLUGIN_HANDLED;
  210.              
  211.             while( !feof( iFile ) ) {
  212.                 fgets( iFile, szData, 31 );
  213.                 parse( szData, szData, 31 );
  214.                  
  215.                 iPos++;
  216.                  
  217.                 if( equal( szData, g_szMapname ) ) {
  218.                     bFound = true;
  219.                      
  220.                     new szString[ 256 ];
  221.                     formatex( szString, 255, "%s %f %f %f", g_szMapname, vOrigin[ 0 ], vOrigin[ 1 ], vOrigin[ 2 ] );
  222.                      
  223.                     write_file( g_szFile, szString, iPos - 1 );
  224.                      
  225.                     break;
  226.                 }
  227.             }
  228.              
  229.             if( !bFound )
  230.                 fprintf( iFile, "%s %f %f %f^n", g_szMapname, vOrigin[ 0 ], vOrigin[ 1 ], vOrigin[ 2 ] );
  231.              
  232.             fclose( iFile );
  233.              
  234.             client_print( id, print_chat, "*** Ball Saved ! ***" );
  235.         }
  236.         default: return PLUGIN_HANDLED;
  237.     }
  238.      
  239.     menu_display( id, g_iButtonsMenu, 0 );
  240.      
  241.     return PLUGIN_HANDLED;
  242. }
  243.  
  244. public EventRoundStart(id) {
  245.     if( !g_bNeedBall )
  246.         return;
  247.      
  248.     if( !is_valid_ent( g_iBall  ) )
  249.         CreateBall( 0, g_vOrigin );
  250.     else {
  251.         entity_set_vector( g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  252.         entity_set_origin( g_iBall , g_vOrigin );
  253.          
  254.         entity_set_int( g_iBall , EV_INT_solid, SOLID_BBOX );
  255.         entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  256.         entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  257.         entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  258.     }
  259. }
  260.  
  261. public FwdHamObjectCaps( id ) {
  262.     if( pev_valid( g_iBall  ) && is_user_alive( id ) ) {
  263.         static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  264.          
  265.         if( iOwner == id )
  266.             KickBall( id );
  267.     }
  268. }
  269.  
  270. // BALL BRAIN :)
  271. ////////////////////////////////////////////////////////////
  272. public FwdThinkBall( iEntity ) {
  273.     if( !is_valid_ent( g_iBall   ) )
  274.         return PLUGIN_HANDLED;
  275.      
  276.     entity_set_float( iEntity, EV_FL_nextthink, halflife_time( ) + 0.05 );
  277.      
  278.     static Float:vOrigin[ 3 ], Float:vBallVelocity[ 3 ];
  279.     entity_get_vector( iEntity, EV_VEC_origin, vOrigin );
  280.     entity_get_vector( iEntity, EV_VEC_velocity, vBallVelocity );
  281.      
  282.     static iOwner; iOwner = pev( iEntity, pev_iuser1 );
  283.     static iSolid; iSolid = pev( iEntity, pev_solid );
  284.      
  285.      
  286.     if( iOwner > 0 ) {
  287.         static Float:vOwnerOrigin[ 3 ];
  288.         entity_get_vector( iOwner, EV_VEC_origin, vOwnerOrigin );
  289.          
  290.         static const Float:vVelocity[ 3 ] = { 1.0, 1.0, 0.0 };
  291.          
  292.         if( !is_user_alive( iOwner ) ) {
  293.             entity_set_int( iEntity, EV_INT_iuser1, 0 );
  294.              
  295.             vOwnerOrigin[ 2 ] += 5.0;
  296.              
  297.             entity_set_origin( iEntity, vOwnerOrigin );
  298.             entity_set_vector( iEntity, EV_VEC_velocity, vVelocity );
  299.              
  300.             return PLUGIN_CONTINUE;
  301.         }
  302.          
  303.         if( iSolid != SOLID_NOT )
  304.             set_pev( iEntity, pev_solid, SOLID_NOT );
  305.          
  306.         static Float:vAngles[ 3 ], Float:vReturn[ 3 ];
  307.         entity_get_vector( iOwner, EV_VEC_v_angle, vAngles );
  308.          
  309.         vReturn[ 0 ] = ( floatcos( vAngles[ 1 ], degrees ) * 55.0 ) + vOwnerOrigin[ 0 ];
  310.         vReturn[ 1 ] = ( floatsin( vAngles[ 1 ], degrees ) * 55.0 ) + vOwnerOrigin[ 1 ];
  311.         vReturn[ 2 ] = vOwnerOrigin[ 2 ];
  312.         vReturn[ 2 ] -= ( entity_get_int( iOwner, EV_INT_flags ) & FL_DUCKING ) ? 10 : 30;
  313.          
  314.         entity_set_vector( iEntity, EV_VEC_velocity, vVelocity );
  315.         entity_set_origin( iEntity, vReturn );
  316.     } else {
  317.         if( iSolid != SOLID_BBOX )
  318.             set_pev( iEntity, pev_solid, SOLID_BBOX );
  319.          
  320.         static Float:flLastVerticalOrigin;
  321.          
  322.         if( vBallVelocity[ 2 ] == 0.0 ) {
  323.             static iCounts;
  324.              
  325.             if( flLastVerticalOrigin > vOrigin[ 2 ] ) {
  326.                 iCounts++;
  327.                  
  328.                 if( iCounts > 10 ) {
  329.                     iCounts = 0;
  330.                      
  331.                     UpdateBall( 0 );
  332.                 }
  333.             } else {
  334.                 iCounts = 0;
  335.                  
  336.                 if( PointContents( vOrigin ) != CONTENTS_EMPTY )
  337.                     UpdateBall( 0 );
  338.             }
  339.              
  340.             flLastVerticalOrigin = vOrigin[ 2 ];
  341.         }
  342.     }
  343.      
  344.     return PLUGIN_CONTINUE;
  345. }
  346.  
  347. KickBall( id ) {
  348.     set_user_maxspeed(id, 230.0)
  349.     static Float:vOrigin[ 3 ];
  350.     entity_get_vector( g_iBall , EV_VEC_origin, vOrigin );
  351.      
  352.     vOrigin[2] += 35;
  353.      
  354.     if( PointContents( vOrigin ) != CONTENTS_EMPTY )
  355.         return PLUGIN_HANDLED;
  356.  
  357.     new Float:vVelocity[ 3 ];
  358.     velocity_by_aim( id, 650, vVelocity );
  359.      
  360.     beam(10)
  361.     emit_sound(g_iBall, CHAN_ITEM, kicked, 1.0, ATTN_NORM, 0, PITCH_NORM)
  362.      
  363.     set_pev( g_iBall , pev_solid, SOLID_BBOX );
  364.     entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  365.     entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  366.     entity_set_origin(g_iBall,vOrigin)
  367.     entity_set_vector( g_iBall , EV_VEC_velocity, vVelocity );
  368.          
  369.     return PLUGIN_CONTINUE;
  370. }
  371.  
  372. // BALL TOUCHES
  373. ////////////////////////////////////////////////////////////
  374. public FwdTouchPlayer( Ball, id ) {
  375.     if( is_user_bot( id ) )
  376.         return PLUGIN_CONTINUE;
  377.      
  378.     static iOwner; iOwner = pev( Ball, pev_iuser1 );
  379.      
  380.     if( iOwner == 0 ) {
  381.         entity_set_int( Ball, EV_INT_iuser1, id );
  382.         beam(10)
  383.         emit_sound(Ball, CHAN_ITEM, gotball, 1.0, ATTN_NORM, 0, PITCH_NORM);
  384.         set_hudmessage(255, 20, 20, -1.0, 0.4, 1, 1.0, 1.5, 0.1, 0.1, 2)
  385.         show_hudmessage(id,"*** NÁLLAD A LABDA! ***")
  386.         set_user_maxspeed(id, 230.0)
  387.     }
  388.     return PLUGIN_CONTINUE;
  389. }
  390.  
  391. public FwdTouchWorld( Ball, World ) {
  392.     static Float:vVelocity[ 3 ];
  393.     entity_get_vector( Ball, EV_VEC_velocity, vVelocity );
  394.      
  395.     if( floatround( vector_length( vVelocity ) ) > 10 ) {
  396.         vVelocity[ 0 ] *= 0.85;
  397.         vVelocity[ 1 ] *= 0.85;
  398.         vVelocity[ 2 ] *= 0.85;
  399.          
  400.         entity_set_vector( Ball, EV_VEC_velocity, vVelocity );
  401.          
  402.         emit_sound( Ball, CHAN_ITEM, BALL_BOUNCE_GROUND, 1.0, ATTN_NORM, 0, PITCH_NORM );
  403.     }
  404.  
  405.     return PLUGIN_CONTINUE;
  406. }
  407.  
  408.  
  409. // ENTITIES CREATING
  410. ////////////////////////////////////////////////////////////
  411. CreateBall( id, Float:vOrigin[ 3 ] = { 0.0, 0.0, 0.0 } ) {
  412.     if( !id && vOrigin[ 0 ] == 0.0 && vOrigin[ 1 ] == 0.0 && vOrigin[ 2 ] == 0.0 )
  413.         return 0;
  414.      
  415.     g_bNeedBall = true;
  416.      
  417.     g_iBall = create_entity( "info_target" );
  418.      
  419.     if( is_valid_ent( g_iBall ) ) {
  420.         entity_set_string( g_iBall , EV_SZ_classname, g_szBallName );
  421.         entity_set_int( g_iBall , EV_INT_solid, SOLID_BBOX );
  422.         entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  423.         entity_set_model( g_iBall , g_szBallModel );
  424.         entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  425.          
  426.         entity_set_float( g_iBall , EV_FL_framerate, 0.0 );
  427.         entity_set_int( g_iBall , EV_INT_sequence, 0 );
  428.          
  429.         entity_set_float(g_iBall , EV_FL_nextthink, get_gametime( ) + 0.05 );
  430.      
  431.         glow(g_iBall,ballcolor[0],ballcolor[1],ballcolor[2],10)
  432.          
  433.         //client_print( id, print_chat, "*** Ball Spawned! ***" );
  434.          
  435.         if( id > 0 ) {
  436.             new iOrigin[ 3 ];
  437.             get_user_origin( id, iOrigin, 3 );
  438.             IVecFVec( iOrigin, vOrigin );
  439.              
  440.             vOrigin[ 2 ] += 5.0;
  441.              
  442.             entity_set_origin( g_iBall , vOrigin );
  443.         } else
  444.             entity_set_origin( g_iBall , vOrigin );
  445.          
  446.         g_vOrigin = vOrigin;
  447.          
  448.         return g_iBall ;
  449.     }
  450.      
  451.     return -1;
  452. }
  453.  
  454. beam(life) {
  455.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  456.     write_byte(22); // TE_BEAMFOLLOW
  457.     write_short(g_iBall); // ball
  458.     write_short(beamspr); // laserbeam
  459.     write_byte(life); // life
  460.     write_byte(5); // width
  461.     write_byte(ballbeam[0]); // R
  462.     write_byte(ballbeam[1]); // G
  463.     write_byte(ballbeam[2]); // B
  464.     write_byte(175); // brightness
  465.     message_end();    
  466. }
  467. glow(id, r, g, b, on) {
  468.     if(on == 1) {
  469.         set_rendering(id, kRenderFxGlowShell, r, g, b, kRenderNormal, 255)
  470.         entity_set_float(id, EV_FL_renderamt, 1.0)
  471.     }
  472.     else if(!on) {
  473.         set_rendering(id, kRenderFxNone, r, g, b,  kRenderNormal, 255)
  474.         entity_set_float(id, EV_FL_renderamt, 1.0)
  475.     }
  476.     else if(on == 10) {
  477.         set_rendering(id, kRenderFxGlowShell, r, g, b, kRenderNormal, 255)
  478.         entity_set_float(id, EV_FL_renderamt, 1.0)
  479.     }
  480. }

_________________
„Nem azért felejtünk el játszani, mert megöregszünk, hanem attól öregszünk meg, hogy elfelejtünk játszani.”

-MAXHACKED Website-
-HERViD Website-
► Spoiler mutatása


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Labda
HozzászólásElküldve: 2017.01.05. 21:30 
Offline
Beavatott

Csatlakozott: 2015.11.10. 14:34
Hozzászólások: 81
Megköszönt másnak: 27 alkalommal
Megköszönték neki: 20 alkalommal
  1. // Version 1.0 : Menu + Orginal Bounc / kicking
  2.     // Version 2.0 : Added Real soccerjamsounds / Got ball msg / Freezetimebug
  3.     // Version 3.0 : Fixed Ball spawns every round
  4.      
  5.     #include <amxmodx>
  6.     #include <engine>
  7.     #include <fakemeta>
  8.     #include <hamsandwich>
  9.     #include <fun>
  10.      
  11.     static const BALL_BOUNCE_GROUND[ ] = "kickball/bounce.wav";
  12.     static const g_szBallModel[ ]     = "models/basebuilder/ball.mdl";
  13.     static const g_szBallName[ ]      = "ball";
  14.      
  15.     new g_iBall, g_szFile[ 128 ], g_szMapname[ 32 ], g_iButtonsMenu;
  16.     new bool:g_bNeedBall
  17.     new Float:g_vOrigin[ 3 ];
  18.     new beamspr
  19.      
  20.     new ballcolor[3] = { 255,200,100 }
  21.     new ballbeam[3] = { 20,50,255 }
  22.     new kicked[] = "kickball/kicked.wav"
  23.      
  24.     public plugin_init( ) {
  25.         register_plugin( "JailMod-Ball", "3.0", "ButterZ`" );
  26.          
  27.          
  28.         /* Register Forward */
  29.         register_forward(FM_PlayerPreThink, "PlayerPreThink", 0)
  30.          
  31.         /* Current Weapon */
  32.         register_event("CurWeapon", "CurWeapon", "be");
  33.          
  34.         RegisterHam( Ham_ObjectCaps, "player", "FwdHamObjectCaps", 1 );
  35.         register_logevent( "EventRoundStart", 2, "1=Round_Start" );
  36.          
  37.         register_think( g_szBallName, "FwdThinkBall" );
  38.         register_touch( g_szBallName, "player", "FwdTouchPlayer" );
  39.          
  40.         new const szEntity[ ][ ] = {
  41.             "worldspawn", "func_wall", "func_door",  "funac_door_rotating",
  42.             "func_wall_toggle", "func_breakable", "func_pushable", "func_train",
  43.             "func_illusionary", "func_button", "func_rot_button", "func_rotating"
  44.         }
  45.          
  46.         for( new i; i < sizeof szEntity; i++ )
  47.             register_touch( g_szBallName, szEntity[ i ], "FwdTouchWorld" );
  48.          
  49.         g_iButtonsMenu = menu_create( "BallMaker Menu", "HandleButtonsMenu" );
  50.          
  51.         menu_additem( g_iButtonsMenu, "Create Ball", "1" );
  52.         menu_additem( g_iButtonsMenu, "Load Ball", "2" );
  53.         menu_additem( g_iButtonsMenu, "Delete all Ball", "3" );
  54.         menu_additem( g_iButtonsMenu, "Save", "4" );
  55.          
  56.         register_clcmd( "say /ball", "CmdButtonsMenu", ADMIN_RCON );
  57.         register_clcmd( "say /reset", "UpdateBall" );
  58.     }    
  59.     public PlayerPreThink(id) {
  60.         if(!is_user_alive(id))
  61.             return PLUGIN_CONTINUE;
  62.              
  63.         if( is_valid_ent( g_iBall  ) ) {
  64.             static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  65.             if( iOwner != id && get_user_maxspeed(id) != 1.0 )  
  66.                 set_user_maxspeed(id, 230.0)
  67.         }
  68.         return PLUGIN_HANDLED;
  69.     }
  70.     public CurWeapon(id) {
  71.         if(!is_user_alive(id))
  72.             return PLUGIN_CONTINUE;
  73.         if( is_valid_ent(g_iBall ) ) {
  74.             static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  75.             if( iOwner == id )
  76.                 set_user_maxspeed(id, 230.0)
  77.         }    
  78.         return PLUGIN_HANDLED;
  79.     }
  80.     public UpdateBall( id ) {
  81.         if( !id || get_user_flags( id ) & ADMIN_KICK ) {
  82.             if( is_valid_ent( g_iBall ) ) {
  83.                 entity_set_vector(g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  84.                 entity_set_origin( g_iBall , g_vOrigin );
  85.                  
  86.                 entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  87.                 entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  88.                 entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  89.             }
  90.         }
  91.          
  92.         return PLUGIN_HANDLED;
  93.     }
  94.      
  95.     public plugin_precache( ) {
  96.         precache_model( g_szBallModel );
  97.         precache_sound( BALL_BOUNCE_GROUND );
  98.          
  99.         beamspr = precache_model( "sprites/laserbeam.spr" );
  100.         precache_sound(kicked)
  101.          
  102.         get_mapname( g_szMapname, 31 );
  103.         strtolower( g_szMapname );
  104.          
  105.         // File
  106.         new szDatadir[ 64 ];
  107.         get_localinfo( "amxx_datadir", szDatadir, charsmax( szDatadir ) );
  108.          
  109.         formatex( szDatadir, charsmax( szDatadir ), "%s", szDatadir );
  110.          
  111.         if( !dir_exists( szDatadir ) )
  112.             mkdir( szDatadir );
  113.          
  114.         formatex( g_szFile, charsmax( g_szFile ), "%s/ball.ini", szDatadir );
  115.          
  116.         if( !file_exists( g_szFile ) ) {
  117.             write_file( g_szFile, "// Ball Spawn Editor", -1 );
  118.             write_file( g_szFile, " ", -1 );
  119.              
  120.             return; // We dont need to load file
  121.         }
  122.          
  123.         new szData[ 256 ], szMap[ 32 ], szOrigin[ 3 ][ 16 ];
  124.         new iFile = fopen( g_szFile, "rt" );
  125.          
  126.         while( !feof( iFile ) ) {
  127.             fgets( iFile, szData, charsmax( szData ) );
  128.              
  129.             if( !szData[ 0 ] || szData[ 0 ] == ';' || szData[ 0 ] == ' ' || ( szData[ 0 ] == '/' && szData[ 1 ] == '/' ) )
  130.                 continue;
  131.              
  132.             parse( szData, szMap, 31, szOrigin[ 0 ], 15, szOrigin[ 1 ], 15, szOrigin[ 2 ], 15 );
  133.              
  134.             if( equal( szMap, g_szMapname ) ) {
  135.                 new Float:vOrigin[ 3 ];
  136.                  
  137.                 vOrigin[ 0 ] = str_to_float( szOrigin[ 0 ] );
  138.                 vOrigin[ 1 ] = str_to_float( szOrigin[ 1 ] );
  139.                 vOrigin[ 2 ] = str_to_float( szOrigin[ 2 ] );
  140.                  
  141.                 CreateBall( 0, vOrigin );
  142.                  
  143.                 g_vOrigin = vOrigin;
  144.                  
  145.                 break;
  146.             }
  147.         }
  148.          
  149.         fclose( iFile );
  150.     }
  151.      
  152.     public CmdButtonsMenu( id ) {
  153.         if( get_user_flags( id ) & ADMIN_RCON )
  154.             menu_display( id, g_iButtonsMenu, 0 );
  155.          
  156.         return PLUGIN_HANDLED;
  157.     }
  158.      
  159.     public HandleButtonsMenu( id, iMenu, iItem ) {
  160.         if( iItem == MENU_EXIT )
  161.             return PLUGIN_HANDLED;
  162.          
  163.         new szKey[ 2 ], _Access, _Callback;
  164.         menu_item_getinfo( iMenu, iItem, _Access, szKey, 1, "", 0, _Callback );
  165.          
  166.         new iKey = str_to_num( szKey );
  167.          
  168.         switch( iKey ) {
  169.             case 1:    {
  170.                 if( pev_valid( g_iBall  ) )
  171.                     return PLUGIN_CONTINUE;
  172.                      
  173.                 CreateBall( id );
  174.             }
  175.             case 2: {
  176.                 if( is_valid_ent( g_iBall  ) ) {
  177.                     entity_set_vector( g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  178.                     entity_set_origin( g_iBall , g_vOrigin );
  179.                      
  180.                     entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  181.                     entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  182.                     entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  183.                     client_print( id, print_chat, "*** Loading Ball ***" );
  184.                 }
  185.             }
  186.             case 3: {
  187.                 new iEntity;
  188.                  
  189.                 while( ( iEntity = find_ent_by_class( iEntity, g_szBallName ) ) > 0 )
  190.                     remove_entity( iEntity );
  191.                 client_print( id, print_chat, "*** Ball Deleted ! ***" );
  192.             }
  193.             case 4: {
  194.                 new iBall, iEntity, Float:vOrigin[ 3 ];
  195.                  
  196.                 while( ( iEntity = find_ent_by_class( iEntity, g_szBallName ) ) > 0 )
  197.                     iBall = iEntity;
  198.                  
  199.                 if( iBall > 0 )
  200.                     entity_get_vector( iBall, EV_VEC_origin, vOrigin );
  201.                 else
  202.                     return PLUGIN_HANDLED;
  203.                  
  204.                 new bool:bFound, iPos, szData[ 32 ], iFile = fopen( g_szFile, "r+" );
  205.                  
  206.                 if( !iFile )
  207.                     return PLUGIN_HANDLED;
  208.                  
  209.                 while( !feof( iFile ) ) {
  210.                     fgets( iFile, szData, 31 );
  211.                     parse( szData, szData, 31 );
  212.                      
  213.                     iPos++;
  214.                      
  215.                     if( equal( szData, g_szMapname ) ) {
  216.                         bFound = true;
  217.                          
  218.                         new szString[ 256 ];
  219.                         formatex( szString, 255, "%s %f %f %f", g_szMapname, vOrigin[ 0 ], vOrigin[ 1 ], vOrigin[ 2 ] );
  220.                          
  221.                         write_file( g_szFile, szString, iPos - 1 );
  222.                          
  223.                         break;
  224.                     }
  225.                 }
  226.                  
  227.                 if( !bFound )
  228.                     fprintf( iFile, "%s %f %f %f^n", g_szMapname, vOrigin[ 0 ], vOrigin[ 1 ], vOrigin[ 2 ] );
  229.                  
  230.                 fclose( iFile );
  231.                  
  232.                 client_print( id, print_chat, "*** Ball Saved ! ***" );
  233.             }
  234.             default: return PLUGIN_HANDLED;
  235.         }
  236.          
  237.         menu_display( id, g_iButtonsMenu, 0 );
  238.          
  239.         return PLUGIN_HANDLED;
  240.     }
  241.      
  242.     public EventRoundStart(id) {
  243.         if( !g_bNeedBall )
  244.             return;
  245.          
  246.         if( !is_valid_ent( g_iBall  ) )
  247.             CreateBall( 0, g_vOrigin );
  248.         else {
  249.             entity_set_vector( g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  250.             entity_set_origin( g_iBall , g_vOrigin );
  251.              
  252.             entity_set_int( g_iBall , EV_INT_solid, SOLID_BBOX );
  253.             entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  254.             entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  255.             entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  256.         }
  257.     }
  258.      
  259.     public FwdHamObjectCaps( id ) {
  260.         if( pev_valid( g_iBall  ) && is_user_alive( id ) ) {
  261.             static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  262.              
  263.             if( iOwner == id )
  264.                 KickBall( id );
  265.         }
  266.     }
  267.      
  268.     // BALL BRAIN :)
  269.     ////////////////////////////////////////////////////////////
  270.     public FwdThinkBall( iEntity ) {
  271.         if( !is_valid_ent( g_iBall   ) )
  272.             return PLUGIN_HANDLED;
  273.          
  274.         entity_set_float( iEntity, EV_FL_nextthink, halflife_time( ) + 0.05 );
  275.          
  276.         static Float:vOrigin[ 3 ], Float:vBallVelocity[ 3 ];
  277.         entity_get_vector( iEntity, EV_VEC_origin, vOrigin );
  278.         entity_get_vector( iEntity, EV_VEC_velocity, vBallVelocity );
  279.          
  280.         static iOwner; iOwner = pev( iEntity, pev_iuser1 );
  281.         static iSolid; iSolid = pev( iEntity, pev_solid );
  282.          
  283.          
  284.         if( iOwner > 0 ) {
  285.             static Float:vOwnerOrigin[ 3 ];
  286.             entity_get_vector( iOwner, EV_VEC_origin, vOwnerOrigin );
  287.              
  288.             static const Float:vVelocity[ 3 ] = { 1.0, 1.0, 0.0 };
  289.              
  290.             if( !is_user_alive( iOwner ) ) {
  291.                 entity_set_int( iEntity, EV_INT_iuser1, 0 );
  292.                  
  293.                 vOwnerOrigin[ 2 ] += 5.0;
  294.                  
  295.                 entity_set_origin( iEntity, vOwnerOrigin );
  296.                 entity_set_vector( iEntity, EV_VEC_velocity, vVelocity );
  297.                  
  298.                 return PLUGIN_CONTINUE;
  299.             }
  300.              
  301.             if( iSolid != SOLID_NOT )
  302.                 set_pev( iEntity, pev_solid, SOLID_NOT );
  303.              
  304.             static Float:vAngles[ 3 ], Float:vReturn[ 3 ];
  305.             entity_get_vector( iOwner, EV_VEC_v_angle, vAngles );
  306.              
  307.             vReturn[ 0 ] = ( floatcos( vAngles[ 1 ], degrees ) * 55.0 ) + vOwnerOrigin[ 0 ];
  308.             vReturn[ 1 ] = ( floatsin( vAngles[ 1 ], degrees ) * 55.0 ) + vOwnerOrigin[ 1 ];
  309.             vReturn[ 2 ] = vOwnerOrigin[ 2 ];
  310.             vReturn[ 2 ] -= ( entity_get_int( iOwner, EV_INT_flags ) & FL_DUCKING ) ? 10 : 30;
  311.              
  312.             entity_set_vector( iEntity, EV_VEC_velocity, vVelocity );
  313.             entity_set_origin( iEntity, vReturn );
  314.         } else {
  315.             if( iSolid != SOLID_BBOX )
  316.                 set_pev( iEntity, pev_solid, SOLID_BBOX );
  317.              
  318.             static Float:flLastVerticalOrigin;
  319.              
  320.             if( vBallVelocity[ 2 ] == 0.0 ) {
  321.                 static iCounts;
  322.                  
  323.                 if( flLastVerticalOrigin > vOrigin[ 2 ] ) {
  324.                     iCounts++;
  325.                      
  326.                     if( iCounts > 10 ) {
  327.                         iCounts = 0;
  328.                          
  329.                         UpdateBall( 0 );
  330.                     }
  331.                 } else {
  332.                     iCounts = 0;
  333.                      
  334.                     if( PointContents( vOrigin ) != CONTENTS_EMPTY )
  335.                         UpdateBall( 0 );
  336.                 }
  337.                  
  338.                 flLastVerticalOrigin = vOrigin[ 2 ];
  339.             }
  340.         }
  341.          
  342.         return PLUGIN_CONTINUE;
  343.     }
  344.      
  345.     KickBall( id ) {
  346.         set_user_maxspeed(id, 230.0)
  347.         static Float:vOrigin[ 3 ];
  348.         entity_get_vector( g_iBall , EV_VEC_origin, vOrigin );
  349.          
  350.         vOrigin[2] += 35;
  351.          
  352.         if( PointContents( vOrigin ) != CONTENTS_EMPTY )
  353.             return PLUGIN_HANDLED;
  354.      
  355.         new Float:vVelocity[ 3 ];
  356.         velocity_by_aim( id, 650, vVelocity );
  357.          
  358.         beam(10)
  359.         emit_sound(g_iBall, CHAN_ITEM, kicked, 1.0, ATTN_NORM, 0, PITCH_NORM)
  360.          
  361.         set_pev( g_iBall , pev_solid, SOLID_BBOX );
  362.         entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  363.         entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  364.         entity_set_origin(g_iBall,vOrigin)
  365.         entity_set_vector( g_iBall , EV_VEC_velocity, vVelocity );
  366.              
  367.         return PLUGIN_CONTINUE;
  368.     }
  369.      
  370.     // BALL TOUCHES
  371.     ////////////////////////////////////////////////////////////
  372.     public FwdTouchPlayer( Ball, id ) {
  373.         if( is_user_bot( id ) )
  374.             return PLUGIN_CONTINUE;
  375.          
  376.         static iOwner; iOwner = pev( Ball, pev_iuser1 );
  377.          
  378.         if( iOwner == 0 ) {
  379.             entity_set_int( Ball, EV_INT_iuser1, id );
  380.             beam(10)
  381.             set_user_maxspeed(id, 230.0)
  382.         }
  383.         return PLUGIN_CONTINUE;
  384.     }
  385.      
  386.     public FwdTouchWorld( Ball, World ) {
  387.         static Float:vVelocity[ 3 ];
  388.         entity_get_vector( Ball, EV_VEC_velocity, vVelocity );
  389.          
  390.         if( floatround( vector_length( vVelocity ) ) > 10 ) {
  391.             vVelocity[ 0 ] *= 0.85;
  392.             vVelocity[ 1 ] *= 0.85;
  393.             vVelocity[ 2 ] *= 0.85;
  394.              
  395.             entity_set_vector( Ball, EV_VEC_velocity, vVelocity );
  396.              
  397.             emit_sound( Ball, CHAN_ITEM, BALL_BOUNCE_GROUND, 1.0, ATTN_NORM, 0, PITCH_NORM );
  398.         }
  399.      
  400.         return PLUGIN_CONTINUE;
  401.     }
  402.      
  403.      
  404.     // ENTITIES CREATING
  405.     ////////////////////////////////////////////////////////////
  406.     CreateBall( id, Float:vOrigin[ 3 ] = { 0.0, 0.0, 0.0 } ) {
  407.         if( !id && vOrigin[ 0 ] == 0.0 && vOrigin[ 1 ] == 0.0 && vOrigin[ 2 ] == 0.0 )
  408.             return 0;
  409.          
  410.         g_bNeedBall = true;
  411.          
  412.         g_iBall = create_entity( "info_target" );
  413.          
  414.         if( is_valid_ent( g_iBall ) ) {
  415.             entity_set_string( g_iBall , EV_SZ_classname, g_szBallName );
  416.             entity_set_int( g_iBall , EV_INT_solid, SOLID_BBOX );
  417.             entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  418.             entity_set_model( g_iBall , g_szBallModel );
  419.             entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  420.              
  421.             entity_set_float( g_iBall , EV_FL_framerate, 0.0 );
  422.             entity_set_int( g_iBall , EV_INT_sequence, 0 );
  423.              
  424.             entity_set_float(g_iBall , EV_FL_nextthink, get_gametime( ) + 0.05 );
  425.          
  426.             glow(g_iBall,ballcolor[0],ballcolor[1],ballcolor[2],10)
  427.              
  428.             //client_print( id, print_chat, "*** Ball Spawned! ***" );
  429.              
  430.             if( id > 0 ) {
  431.                 new iOrigin[ 3 ];
  432.                 get_user_origin( id, iOrigin, 3 );
  433.                 IVecFVec( iOrigin, vOrigin );
  434.                  
  435.                 vOrigin[ 2 ] += 5.0;
  436.                  
  437.                 entity_set_origin( g_iBall , vOrigin );
  438.             } else
  439.                 entity_set_origin( g_iBall , vOrigin );
  440.              
  441.             g_vOrigin = vOrigin;
  442.              
  443.             return g_iBall ;
  444.         }
  445.          
  446.         return -1;
  447.     }
  448.      
  449.     beam(life) {
  450.         message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  451.         write_byte(22); // TE_BEAMFOLLOW
  452.         write_short(g_iBall); // ball
  453.         write_short(beamspr); // laserbeam
  454.         write_byte(life); // life
  455.         write_byte(5); // width
  456.         write_byte(ballbeam[0]); // R
  457.         write_byte(ballbeam[1]); // G
  458.         write_byte(ballbeam[2]); // B
  459.         write_byte(175); // brightness
  460.         message_end();    
  461.     }
  462.     glow(id, r, g, b, on) {
  463.         if(on == 1) {
  464.             set_rendering(id, kRenderFxGlowShell, r, g, b, kRenderNormal, 255)
  465.             entity_set_float(id, EV_FL_renderamt, 1.0)
  466.         }
  467.         else if(!on) {
  468.             set_rendering(id, kRenderFxNone, r, g, b,  kRenderNormal, 255)
  469.             entity_set_float(id, EV_FL_renderamt, 1.0)
  470.         }
  471.         else if(on == 10) {
  472.             set_rendering(id, kRenderFxGlowShell, r, g, b, kRenderNormal, 255)
  473.             entity_set_float(id, EV_FL_renderamt, 1.0)
  474.         }
  475.     }

Ők köszönték meg ReDSTAR nek ezt a hozzászólást: *GrafitY* (2017.01.06. 18:11)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Labda
HozzászólásElküldve: 2017.01.06. 18:11 
Offline
GFX-Designer
Avatar

Csatlakozott: 2015.03.12. 15:06
Hozzászólások: 624
Megköszönt másnak: 199 alkalommal
Megköszönték neki: 78 alkalommal
ReDSTAR írta:
  1. // Version 1.0 : Menu + Orginal Bounc / kicking
  2.     // Version 2.0 : Added Real soccerjamsounds / Got ball msg / Freezetimebug
  3.     // Version 3.0 : Fixed Ball spawns every round
  4.      
  5.     #include <amxmodx>
  6.     #include <engine>
  7.     #include <fakemeta>
  8.     #include <hamsandwich>
  9.     #include <fun>
  10.      
  11.     static const BALL_BOUNCE_GROUND[ ] = "kickball/bounce.wav";
  12.     static const g_szBallModel[ ]     = "models/basebuilder/ball.mdl";
  13.     static const g_szBallName[ ]      = "ball";
  14.      
  15.     new g_iBall, g_szFile[ 128 ], g_szMapname[ 32 ], g_iButtonsMenu;
  16.     new bool:g_bNeedBall
  17.     new Float:g_vOrigin[ 3 ];
  18.     new beamspr
  19.      
  20.     new ballcolor[3] = { 255,200,100 }
  21.     new ballbeam[3] = { 20,50,255 }
  22.     new kicked[] = "kickball/kicked.wav"
  23.      
  24.     public plugin_init( ) {
  25.         register_plugin( "JailMod-Ball", "3.0", "ButterZ`" );
  26.          
  27.          
  28.         /* Register Forward */
  29.         register_forward(FM_PlayerPreThink, "PlayerPreThink", 0)
  30.          
  31.         /* Current Weapon */
  32.         register_event("CurWeapon", "CurWeapon", "be");
  33.          
  34.         RegisterHam( Ham_ObjectCaps, "player", "FwdHamObjectCaps", 1 );
  35.         register_logevent( "EventRoundStart", 2, "1=Round_Start" );
  36.          
  37.         register_think( g_szBallName, "FwdThinkBall" );
  38.         register_touch( g_szBallName, "player", "FwdTouchPlayer" );
  39.          
  40.         new const szEntity[ ][ ] = {
  41.             "worldspawn", "func_wall", "func_door",  "funac_door_rotating",
  42.             "func_wall_toggle", "func_breakable", "func_pushable", "func_train",
  43.             "func_illusionary", "func_button", "func_rot_button", "func_rotating"
  44.         }
  45.          
  46.         for( new i; i < sizeof szEntity; i++ )
  47.             register_touch( g_szBallName, szEntity[ i ], "FwdTouchWorld" );
  48.          
  49.         g_iButtonsMenu = menu_create( "BallMaker Menu", "HandleButtonsMenu" );
  50.          
  51.         menu_additem( g_iButtonsMenu, "Create Ball", "1" );
  52.         menu_additem( g_iButtonsMenu, "Load Ball", "2" );
  53.         menu_additem( g_iButtonsMenu, "Delete all Ball", "3" );
  54.         menu_additem( g_iButtonsMenu, "Save", "4" );
  55.          
  56.         register_clcmd( "say /ball", "CmdButtonsMenu", ADMIN_RCON );
  57.         register_clcmd( "say /reset", "UpdateBall" );
  58.     }    
  59.     public PlayerPreThink(id) {
  60.         if(!is_user_alive(id))
  61.             return PLUGIN_CONTINUE;
  62.              
  63.         if( is_valid_ent( g_iBall  ) ) {
  64.             static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  65.             if( iOwner != id && get_user_maxspeed(id) != 1.0 )  
  66.                 set_user_maxspeed(id, 230.0)
  67.         }
  68.         return PLUGIN_HANDLED;
  69.     }
  70.     public CurWeapon(id) {
  71.         if(!is_user_alive(id))
  72.             return PLUGIN_CONTINUE;
  73.         if( is_valid_ent(g_iBall ) ) {
  74.             static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  75.             if( iOwner == id )
  76.                 set_user_maxspeed(id, 230.0)
  77.         }    
  78.         return PLUGIN_HANDLED;
  79.     }
  80.     public UpdateBall( id ) {
  81.         if( !id || get_user_flags( id ) & ADMIN_KICK ) {
  82.             if( is_valid_ent( g_iBall ) ) {
  83.                 entity_set_vector(g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  84.                 entity_set_origin( g_iBall , g_vOrigin );
  85.                  
  86.                 entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  87.                 entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  88.                 entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  89.             }
  90.         }
  91.          
  92.         return PLUGIN_HANDLED;
  93.     }
  94.      
  95.     public plugin_precache( ) {
  96.         precache_model( g_szBallModel );
  97.         precache_sound( BALL_BOUNCE_GROUND );
  98.          
  99.         beamspr = precache_model( "sprites/laserbeam.spr" );
  100.         precache_sound(kicked)
  101.          
  102.         get_mapname( g_szMapname, 31 );
  103.         strtolower( g_szMapname );
  104.          
  105.         // File
  106.         new szDatadir[ 64 ];
  107.         get_localinfo( "amxx_datadir", szDatadir, charsmax( szDatadir ) );
  108.          
  109.         formatex( szDatadir, charsmax( szDatadir ), "%s", szDatadir );
  110.          
  111.         if( !dir_exists( szDatadir ) )
  112.             mkdir( szDatadir );
  113.          
  114.         formatex( g_szFile, charsmax( g_szFile ), "%s/ball.ini", szDatadir );
  115.          
  116.         if( !file_exists( g_szFile ) ) {
  117.             write_file( g_szFile, "// Ball Spawn Editor", -1 );
  118.             write_file( g_szFile, " ", -1 );
  119.              
  120.             return; // We dont need to load file
  121.         }
  122.          
  123.         new szData[ 256 ], szMap[ 32 ], szOrigin[ 3 ][ 16 ];
  124.         new iFile = fopen( g_szFile, "rt" );
  125.          
  126.         while( !feof( iFile ) ) {
  127.             fgets( iFile, szData, charsmax( szData ) );
  128.              
  129.             if( !szData[ 0 ] || szData[ 0 ] == ';' || szData[ 0 ] == ' ' || ( szData[ 0 ] == '/' && szData[ 1 ] == '/' ) )
  130.                 continue;
  131.              
  132.             parse( szData, szMap, 31, szOrigin[ 0 ], 15, szOrigin[ 1 ], 15, szOrigin[ 2 ], 15 );
  133.              
  134.             if( equal( szMap, g_szMapname ) ) {
  135.                 new Float:vOrigin[ 3 ];
  136.                  
  137.                 vOrigin[ 0 ] = str_to_float( szOrigin[ 0 ] );
  138.                 vOrigin[ 1 ] = str_to_float( szOrigin[ 1 ] );
  139.                 vOrigin[ 2 ] = str_to_float( szOrigin[ 2 ] );
  140.                  
  141.                 CreateBall( 0, vOrigin );
  142.                  
  143.                 g_vOrigin = vOrigin;
  144.                  
  145.                 break;
  146.             }
  147.         }
  148.          
  149.         fclose( iFile );
  150.     }
  151.      
  152.     public CmdButtonsMenu( id ) {
  153.         if( get_user_flags( id ) & ADMIN_RCON )
  154.             menu_display( id, g_iButtonsMenu, 0 );
  155.          
  156.         return PLUGIN_HANDLED;
  157.     }
  158.      
  159.     public HandleButtonsMenu( id, iMenu, iItem ) {
  160.         if( iItem == MENU_EXIT )
  161.             return PLUGIN_HANDLED;
  162.          
  163.         new szKey[ 2 ], _Access, _Callback;
  164.         menu_item_getinfo( iMenu, iItem, _Access, szKey, 1, "", 0, _Callback );
  165.          
  166.         new iKey = str_to_num( szKey );
  167.          
  168.         switch( iKey ) {
  169.             case 1:    {
  170.                 if( pev_valid( g_iBall  ) )
  171.                     return PLUGIN_CONTINUE;
  172.                      
  173.                 CreateBall( id );
  174.             }
  175.             case 2: {
  176.                 if( is_valid_ent( g_iBall  ) ) {
  177.                     entity_set_vector( g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  178.                     entity_set_origin( g_iBall , g_vOrigin );
  179.                      
  180.                     entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  181.                     entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  182.                     entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  183.                     client_print( id, print_chat, "*** Loading Ball ***" );
  184.                 }
  185.             }
  186.             case 3: {
  187.                 new iEntity;
  188.                  
  189.                 while( ( iEntity = find_ent_by_class( iEntity, g_szBallName ) ) > 0 )
  190.                     remove_entity( iEntity );
  191.                 client_print( id, print_chat, "*** Ball Deleted ! ***" );
  192.             }
  193.             case 4: {
  194.                 new iBall, iEntity, Float:vOrigin[ 3 ];
  195.                  
  196.                 while( ( iEntity = find_ent_by_class( iEntity, g_szBallName ) ) > 0 )
  197.                     iBall = iEntity;
  198.                  
  199.                 if( iBall > 0 )
  200.                     entity_get_vector( iBall, EV_VEC_origin, vOrigin );
  201.                 else
  202.                     return PLUGIN_HANDLED;
  203.                  
  204.                 new bool:bFound, iPos, szData[ 32 ], iFile = fopen( g_szFile, "r+" );
  205.                  
  206.                 if( !iFile )
  207.                     return PLUGIN_HANDLED;
  208.                  
  209.                 while( !feof( iFile ) ) {
  210.                     fgets( iFile, szData, 31 );
  211.                     parse( szData, szData, 31 );
  212.                      
  213.                     iPos++;
  214.                      
  215.                     if( equal( szData, g_szMapname ) ) {
  216.                         bFound = true;
  217.                          
  218.                         new szString[ 256 ];
  219.                         formatex( szString, 255, "%s %f %f %f", g_szMapname, vOrigin[ 0 ], vOrigin[ 1 ], vOrigin[ 2 ] );
  220.                          
  221.                         write_file( g_szFile, szString, iPos - 1 );
  222.                          
  223.                         break;
  224.                     }
  225.                 }
  226.                  
  227.                 if( !bFound )
  228.                     fprintf( iFile, "%s %f %f %f^n", g_szMapname, vOrigin[ 0 ], vOrigin[ 1 ], vOrigin[ 2 ] );
  229.                  
  230.                 fclose( iFile );
  231.                  
  232.                 client_print( id, print_chat, "*** Ball Saved ! ***" );
  233.             }
  234.             default: return PLUGIN_HANDLED;
  235.         }
  236.          
  237.         menu_display( id, g_iButtonsMenu, 0 );
  238.          
  239.         return PLUGIN_HANDLED;
  240.     }
  241.      
  242.     public EventRoundStart(id) {
  243.         if( !g_bNeedBall )
  244.             return;
  245.          
  246.         if( !is_valid_ent( g_iBall  ) )
  247.             CreateBall( 0, g_vOrigin );
  248.         else {
  249.             entity_set_vector( g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  250.             entity_set_origin( g_iBall , g_vOrigin );
  251.              
  252.             entity_set_int( g_iBall , EV_INT_solid, SOLID_BBOX );
  253.             entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  254.             entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  255.             entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  256.         }
  257.     }
  258.      
  259.     public FwdHamObjectCaps( id ) {
  260.         if( pev_valid( g_iBall  ) && is_user_alive( id ) ) {
  261.             static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  262.              
  263.             if( iOwner == id )
  264.                 KickBall( id );
  265.         }
  266.     }
  267.      
  268.     // BALL BRAIN :)
  269.     ////////////////////////////////////////////////////////////
  270.     public FwdThinkBall( iEntity ) {
  271.         if( !is_valid_ent( g_iBall   ) )
  272.             return PLUGIN_HANDLED;
  273.          
  274.         entity_set_float( iEntity, EV_FL_nextthink, halflife_time( ) + 0.05 );
  275.          
  276.         static Float:vOrigin[ 3 ], Float:vBallVelocity[ 3 ];
  277.         entity_get_vector( iEntity, EV_VEC_origin, vOrigin );
  278.         entity_get_vector( iEntity, EV_VEC_velocity, vBallVelocity );
  279.          
  280.         static iOwner; iOwner = pev( iEntity, pev_iuser1 );
  281.         static iSolid; iSolid = pev( iEntity, pev_solid );
  282.          
  283.          
  284.         if( iOwner > 0 ) {
  285.             static Float:vOwnerOrigin[ 3 ];
  286.             entity_get_vector( iOwner, EV_VEC_origin, vOwnerOrigin );
  287.              
  288.             static const Float:vVelocity[ 3 ] = { 1.0, 1.0, 0.0 };
  289.              
  290.             if( !is_user_alive( iOwner ) ) {
  291.                 entity_set_int( iEntity, EV_INT_iuser1, 0 );
  292.                  
  293.                 vOwnerOrigin[ 2 ] += 5.0;
  294.                  
  295.                 entity_set_origin( iEntity, vOwnerOrigin );
  296.                 entity_set_vector( iEntity, EV_VEC_velocity, vVelocity );
  297.                  
  298.                 return PLUGIN_CONTINUE;
  299.             }
  300.              
  301.             if( iSolid != SOLID_NOT )
  302.                 set_pev( iEntity, pev_solid, SOLID_NOT );
  303.              
  304.             static Float:vAngles[ 3 ], Float:vReturn[ 3 ];
  305.             entity_get_vector( iOwner, EV_VEC_v_angle, vAngles );
  306.              
  307.             vReturn[ 0 ] = ( floatcos( vAngles[ 1 ], degrees ) * 55.0 ) + vOwnerOrigin[ 0 ];
  308.             vReturn[ 1 ] = ( floatsin( vAngles[ 1 ], degrees ) * 55.0 ) + vOwnerOrigin[ 1 ];
  309.             vReturn[ 2 ] = vOwnerOrigin[ 2 ];
  310.             vReturn[ 2 ] -= ( entity_get_int( iOwner, EV_INT_flags ) & FL_DUCKING ) ? 10 : 30;
  311.              
  312.             entity_set_vector( iEntity, EV_VEC_velocity, vVelocity );
  313.             entity_set_origin( iEntity, vReturn );
  314.         } else {
  315.             if( iSolid != SOLID_BBOX )
  316.                 set_pev( iEntity, pev_solid, SOLID_BBOX );
  317.              
  318.             static Float:flLastVerticalOrigin;
  319.              
  320.             if( vBallVelocity[ 2 ] == 0.0 ) {
  321.                 static iCounts;
  322.                  
  323.                 if( flLastVerticalOrigin > vOrigin[ 2 ] ) {
  324.                     iCounts++;
  325.                      
  326.                     if( iCounts > 10 ) {
  327.                         iCounts = 0;
  328.                          
  329.                         UpdateBall( 0 );
  330.                     }
  331.                 } else {
  332.                     iCounts = 0;
  333.                      
  334.                     if( PointContents( vOrigin ) != CONTENTS_EMPTY )
  335.                         UpdateBall( 0 );
  336.                 }
  337.                  
  338.                 flLastVerticalOrigin = vOrigin[ 2 ];
  339.             }
  340.         }
  341.          
  342.         return PLUGIN_CONTINUE;
  343.     }
  344.      
  345.     KickBall( id ) {
  346.         set_user_maxspeed(id, 230.0)
  347.         static Float:vOrigin[ 3 ];
  348.         entity_get_vector( g_iBall , EV_VEC_origin, vOrigin );
  349.          
  350.         vOrigin[2] += 35;
  351.          
  352.         if( PointContents( vOrigin ) != CONTENTS_EMPTY )
  353.             return PLUGIN_HANDLED;
  354.      
  355.         new Float:vVelocity[ 3 ];
  356.         velocity_by_aim( id, 650, vVelocity );
  357.          
  358.         beam(10)
  359.         emit_sound(g_iBall, CHAN_ITEM, kicked, 1.0, ATTN_NORM, 0, PITCH_NORM)
  360.          
  361.         set_pev( g_iBall , pev_solid, SOLID_BBOX );
  362.         entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  363.         entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  364.         entity_set_origin(g_iBall,vOrigin)
  365.         entity_set_vector( g_iBall , EV_VEC_velocity, vVelocity );
  366.              
  367.         return PLUGIN_CONTINUE;
  368.     }
  369.      
  370.     // BALL TOUCHES
  371.     ////////////////////////////////////////////////////////////
  372.     public FwdTouchPlayer( Ball, id ) {
  373.         if( is_user_bot( id ) )
  374.             return PLUGIN_CONTINUE;
  375.          
  376.         static iOwner; iOwner = pev( Ball, pev_iuser1 );
  377.          
  378.         if( iOwner == 0 ) {
  379.             entity_set_int( Ball, EV_INT_iuser1, id );
  380.             beam(10)
  381.             set_user_maxspeed(id, 230.0)
  382.         }
  383.         return PLUGIN_CONTINUE;
  384.     }
  385.      
  386.     public FwdTouchWorld( Ball, World ) {
  387.         static Float:vVelocity[ 3 ];
  388.         entity_get_vector( Ball, EV_VEC_velocity, vVelocity );
  389.          
  390.         if( floatround( vector_length( vVelocity ) ) > 10 ) {
  391.             vVelocity[ 0 ] *= 0.85;
  392.             vVelocity[ 1 ] *= 0.85;
  393.             vVelocity[ 2 ] *= 0.85;
  394.              
  395.             entity_set_vector( Ball, EV_VEC_velocity, vVelocity );
  396.              
  397.             emit_sound( Ball, CHAN_ITEM, BALL_BOUNCE_GROUND, 1.0, ATTN_NORM, 0, PITCH_NORM );
  398.         }
  399.      
  400.         return PLUGIN_CONTINUE;
  401.     }
  402.      
  403.      
  404.     // ENTITIES CREATING
  405.     ////////////////////////////////////////////////////////////
  406.     CreateBall( id, Float:vOrigin[ 3 ] = { 0.0, 0.0, 0.0 } ) {
  407.         if( !id && vOrigin[ 0 ] == 0.0 && vOrigin[ 1 ] == 0.0 && vOrigin[ 2 ] == 0.0 )
  408.             return 0;
  409.          
  410.         g_bNeedBall = true;
  411.          
  412.         g_iBall = create_entity( "info_target" );
  413.          
  414.         if( is_valid_ent( g_iBall ) ) {
  415.             entity_set_string( g_iBall , EV_SZ_classname, g_szBallName );
  416.             entity_set_int( g_iBall , EV_INT_solid, SOLID_BBOX );
  417.             entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  418.             entity_set_model( g_iBall , g_szBallModel );
  419.             entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  420.              
  421.             entity_set_float( g_iBall , EV_FL_framerate, 0.0 );
  422.             entity_set_int( g_iBall , EV_INT_sequence, 0 );
  423.              
  424.             entity_set_float(g_iBall , EV_FL_nextthink, get_gametime( ) + 0.05 );
  425.          
  426.             glow(g_iBall,ballcolor[0],ballcolor[1],ballcolor[2],10)
  427.              
  428.             //client_print( id, print_chat, "*** Ball Spawned! ***" );
  429.              
  430.             if( id > 0 ) {
  431.                 new iOrigin[ 3 ];
  432.                 get_user_origin( id, iOrigin, 3 );
  433.                 IVecFVec( iOrigin, vOrigin );
  434.                  
  435.                 vOrigin[ 2 ] += 5.0;
  436.                  
  437.                 entity_set_origin( g_iBall , vOrigin );
  438.             } else
  439.                 entity_set_origin( g_iBall , vOrigin );
  440.              
  441.             g_vOrigin = vOrigin;
  442.              
  443.             return g_iBall ;
  444.         }
  445.          
  446.         return -1;
  447.     }
  448.      
  449.     beam(life) {
  450.         message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  451.         write_byte(22); // TE_BEAMFOLLOW
  452.         write_short(g_iBall); // ball
  453.         write_short(beamspr); // laserbeam
  454.         write_byte(life); // life
  455.         write_byte(5); // width
  456.         write_byte(ballbeam[0]); // R
  457.         write_byte(ballbeam[1]); // G
  458.         write_byte(ballbeam[2]); // B
  459.         write_byte(175); // brightness
  460.         message_end();    
  461.     }
  462.     glow(id, r, g, b, on) {
  463.         if(on == 1) {
  464.             set_rendering(id, kRenderFxGlowShell, r, g, b, kRenderNormal, 255)
  465.             entity_set_float(id, EV_FL_renderamt, 1.0)
  466.         }
  467.         else if(!on) {
  468.             set_rendering(id, kRenderFxNone, r, g, b,  kRenderNormal, 255)
  469.             entity_set_float(id, EV_FL_renderamt, 1.0)
  470.         }
  471.         else if(on == 10) {
  472.             set_rendering(id, kRenderFxGlowShell, r, g, b, kRenderNormal, 255)
  473.             entity_set_float(id, EV_FL_renderamt, 1.0)
  474.         }
  475.     }


A el dobási hangot még mindig lejátsza..

_________________
„Nem azért felejtünk el játszani, mert megöregszünk, hanem attól öregszünk meg, hogy elfelejtünk játszani.”

-MAXHACKED Website-
-HERViD Website-
► Spoiler mutatása


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Labda
HozzászólásElküldve: 2017.01.06. 22:27 
Offline
Beavatott

Csatlakozott: 2015.11.10. 14:34
Hozzászólások: 81
Megköszönt másnak: 27 alkalommal
Megköszönték neki: 20 alkalommal
  1. // Version 1.0 : Menu + Orginal Bounc / kicking
  2.     // Version 2.0 : Added Real soccerjamsounds / Got ball msg / Freezetimebug
  3.     // Version 3.0 : Fixed Ball spawns every round
  4.      
  5.     #include <amxmodx>
  6.     #include <engine>
  7.     #include <fakemeta>
  8.     #include <hamsandwich>
  9.     #include <fun>
  10.      
  11.     static const BALL_BOUNCE_GROUND[ ] = "kickball/bounce.wav";
  12.     static const g_szBallModel[ ]     = "models/basebuilder/ball.mdl";
  13.     static const g_szBallName[ ]      = "ball";
  14.      
  15.     new g_iBall, g_szFile[ 128 ], g_szMapname[ 32 ], g_iButtonsMenu;
  16.     new bool:g_bNeedBall
  17.     new Float:g_vOrigin[ 3 ];
  18.     new beamspr
  19.      
  20.     new ballcolor[3] = { 255,200,100 }
  21.     new ballbeam[3] = { 20,50,255 }
  22.      
  23.     public plugin_init( ) {
  24.         register_plugin( "JailMod-Ball", "3.0", "ButterZ`" );
  25.          
  26.          
  27.         /* Register Forward */
  28.         register_forward(FM_PlayerPreThink, "PlayerPreThink", 0)
  29.          
  30.         /* Current Weapon */
  31.         register_event("CurWeapon", "CurWeapon", "be");
  32.          
  33.         RegisterHam( Ham_ObjectCaps, "player", "FwdHamObjectCaps", 1 );
  34.         register_logevent( "EventRoundStart", 2, "1=Round_Start" );
  35.          
  36.         register_think( g_szBallName, "FwdThinkBall" );
  37.         register_touch( g_szBallName, "player", "FwdTouchPlayer" );
  38.          
  39.         new const szEntity[ ][ ] = {
  40.             "worldspawn", "func_wall", "func_door",  "func_door_rotating",
  41.             "func_wall_toggle", "func_breakable", "func_pushable", "func_train",
  42.             "func_illusionary", "func_button", "func_rot_button", "func_rotating"
  43.         }
  44.          
  45.         for( new i; i < sizeof szEntity; i++ )
  46.             register_touch( g_szBallName, szEntity[ i ], "FwdTouchWorld" );
  47.          
  48.         g_iButtonsMenu = menu_create( "BallMaker Menu", "HandleButtonsMenu" );
  49.          
  50.         menu_additem( g_iButtonsMenu, "Create Ball", "1" );
  51.         menu_additem( g_iButtonsMenu, "Load Ball", "2" );
  52.         menu_additem( g_iButtonsMenu, "Delete all Ball", "3" );
  53.         menu_additem( g_iButtonsMenu, "Save", "4" );
  54.          
  55.         register_clcmd( "say /ball", "CmdButtonsMenu", ADMIN_RCON );
  56.         register_clcmd( "say /reset", "UpdateBall" );
  57.     }    
  58.     public PlayerPreThink(id) {
  59.         if(!is_user_alive(id))
  60.             return PLUGIN_CONTINUE;
  61.              
  62.         if( is_valid_ent( g_iBall  ) ) {
  63.             static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  64.             if( iOwner != id && get_user_maxspeed(id) != 1.0 )  
  65.                 set_user_maxspeed(id, 230.0)
  66.         }
  67.         return PLUGIN_HANDLED;
  68.     }
  69.     public CurWeapon(id) {
  70.         if(!is_user_alive(id))
  71.             return PLUGIN_CONTINUE;
  72.         if( is_valid_ent(g_iBall ) ) {
  73.             static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  74.             if( iOwner == id )
  75.                 set_user_maxspeed(id, 230.0)
  76.         }    
  77.         return PLUGIN_HANDLED;
  78.     }
  79.     public UpdateBall( id ) {
  80.         if( !id || get_user_flags( id ) & ADMIN_KICK ) {
  81.             if( is_valid_ent( g_iBall ) ) {
  82.                 entity_set_vector(g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  83.                 entity_set_origin( g_iBall , g_vOrigin );
  84.                  
  85.                 entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  86.                 entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  87.                 entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  88.             }
  89.         }
  90.          
  91.         return PLUGIN_HANDLED;
  92.     }
  93.      
  94.     public plugin_precache( ) {
  95.         precache_model( g_szBallModel );
  96.         precache_sound( BALL_BOUNCE_GROUND );
  97.          
  98.         beamspr = precache_model( "sprites/laserbeam.spr" );
  99.          
  100.         get_mapname( g_szMapname, 31 );
  101.         strtolower( g_szMapname );
  102.          
  103.         // File
  104.         new szDatadir[ 64 ];
  105.         get_localinfo( "amxx_datadir", szDatadir, charsmax( szDatadir ) );
  106.          
  107.         formatex( szDatadir, charsmax( szDatadir ), "%s", szDatadir );
  108.          
  109.         if( !dir_exists( szDatadir ) )
  110.             mkdir( szDatadir );
  111.          
  112.         formatex( g_szFile, charsmax( g_szFile ), "%s/ball.ini", szDatadir );
  113.          
  114.         if( !file_exists( g_szFile ) ) {
  115.             write_file( g_szFile, "// Ball Spawn Editor", -1 );
  116.             write_file( g_szFile, " ", -1 );
  117.              
  118.             return; // We dont need to load file
  119.         }
  120.          
  121.         new szData[ 256 ], szMap[ 32 ], szOrigin[ 3 ][ 16 ];
  122.         new iFile = fopen( g_szFile, "rt" );
  123.          
  124.         while( !feof( iFile ) ) {
  125.             fgets( iFile, szData, charsmax( szData ) );
  126.              
  127.             if( !szData[ 0 ] || szData[ 0 ] == ';' || szData[ 0 ] == ' ' || ( szData[ 0 ] == '/' && szData[ 1 ] == '/' ) )
  128.                 continue;
  129.              
  130.             parse( szData, szMap, 31, szOrigin[ 0 ], 15, szOrigin[ 1 ], 15, szOrigin[ 2 ], 15 );
  131.              
  132.             if( equal( szMap, g_szMapname ) ) {
  133.                 new Float:vOrigin[ 3 ];
  134.                  
  135.                 vOrigin[ 0 ] = str_to_float( szOrigin[ 0 ] );
  136.                 vOrigin[ 1 ] = str_to_float( szOrigin[ 1 ] );
  137.                 vOrigin[ 2 ] = str_to_float( szOrigin[ 2 ] );
  138.                  
  139.                 CreateBall( 0, vOrigin );
  140.                  
  141.                 g_vOrigin = vOrigin;
  142.                  
  143.                 break;
  144.             }
  145.         }
  146.          
  147.         fclose( iFile );
  148.     }
  149.      
  150.     public CmdButtonsMenu( id ) {
  151.         if( get_user_flags( id ) & ADMIN_RCON )
  152.             menu_display( id, g_iButtonsMenu, 0 );
  153.          
  154.         return PLUGIN_HANDLED;
  155.     }
  156.      
  157.     public HandleButtonsMenu( id, iMenu, iItem ) {
  158.         if( iItem == MENU_EXIT )
  159.             return PLUGIN_HANDLED;
  160.          
  161.         new szKey[ 2 ], _Access, _Callback;
  162.         menu_item_getinfo( iMenu, iItem, _Access, szKey, 1, "", 0, _Callback );
  163.          
  164.         new iKey = str_to_num( szKey );
  165.          
  166.         switch( iKey ) {
  167.             case 1:    {
  168.                 if( pev_valid( g_iBall  ) )
  169.                     return PLUGIN_CONTINUE;
  170.                      
  171.                 CreateBall( id );
  172.             }
  173.             case 2: {
  174.                 if( is_valid_ent( g_iBall  ) ) {
  175.                     entity_set_vector( g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  176.                     entity_set_origin( g_iBall , g_vOrigin );
  177.                      
  178.                     entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  179.                     entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  180.                     entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  181.                     client_print( id, print_chat, "*** Loading Ball ***" );
  182.                 }
  183.             }
  184.             case 3: {
  185.                 new iEntity;
  186.                  
  187.                 while( ( iEntity = find_ent_by_class( iEntity, g_szBallName ) ) > 0 )
  188.                     remove_entity( iEntity );
  189.                 client_print( id, print_chat, "*** Ball Deleted ! ***" );
  190.             }
  191.             case 4: {
  192.                 new iBall, iEntity, Float:vOrigin[ 3 ];
  193.                  
  194.                 while( ( iEntity = find_ent_by_class( iEntity, g_szBallName ) ) > 0 )
  195.                     iBall = iEntity;
  196.                  
  197.                 if( iBall > 0 )
  198.                     entity_get_vector( iBall, EV_VEC_origin, vOrigin );
  199.                 else
  200.                     return PLUGIN_HANDLED;
  201.                  
  202.                 new bool:bFound, iPos, szData[ 32 ], iFile = fopen( g_szFile, "r+" );
  203.                  
  204.                 if( !iFile )
  205.                     return PLUGIN_HANDLED;
  206.                  
  207.                 while( !feof( iFile ) ) {
  208.                     fgets( iFile, szData, 31 );
  209.                     parse( szData, szData, 31 );
  210.                      
  211.                     iPos++;
  212.                      
  213.                     if( equal( szData, g_szMapname ) ) {
  214.                         bFound = true;
  215.                          
  216.                         new szString[ 256 ];
  217.                         formatex( szString, 255, "%s %f %f %f", g_szMapname, vOrigin[ 0 ], vOrigin[ 1 ], vOrigin[ 2 ] );
  218.                          
  219.                         write_file( g_szFile, szString, iPos - 1 );
  220.                          
  221.                         break;
  222.                     }
  223.                 }
  224.                  
  225.                 if( !bFound )
  226.                     fprintf( iFile, "%s %f %f %f^n", g_szMapname, vOrigin[ 0 ], vOrigin[ 1 ], vOrigin[ 2 ] );
  227.                  
  228.                 fclose( iFile );
  229.                  
  230.                 client_print( id, print_chat, "*** Ball Saved ! ***" );
  231.             }
  232.             default: return PLUGIN_HANDLED;
  233.         }
  234.          
  235.         menu_display( id, g_iButtonsMenu, 0 );
  236.          
  237.         return PLUGIN_HANDLED;
  238.     }
  239.      
  240.     public EventRoundStart(id) {
  241.         if( !g_bNeedBall )
  242.             return;
  243.          
  244.         if( !is_valid_ent( g_iBall  ) )
  245.             CreateBall( 0, g_vOrigin );
  246.         else {
  247.             entity_set_vector( g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  248.             entity_set_origin( g_iBall , g_vOrigin );
  249.              
  250.             entity_set_int( g_iBall , EV_INT_solid, SOLID_BBOX );
  251.             entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  252.             entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  253.             entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  254.         }
  255.     }
  256.      
  257.     public FwdHamObjectCaps( id ) {
  258.         if( pev_valid( g_iBall  ) && is_user_alive( id ) ) {
  259.             static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  260.              
  261.             if( iOwner == id )
  262.                 KickBall( id );
  263.         }
  264.     }
  265.      
  266.     // BALL BRAIN :)
  267.     ////////////////////////////////////////////////////////////
  268.     public FwdThinkBall( iEntity ) {
  269.         if( !is_valid_ent( g_iBall   ) )
  270.             return PLUGIN_HANDLED;
  271.          
  272.         entity_set_float( iEntity, EV_FL_nextthink, halflife_time( ) + 0.05 );
  273.          
  274.         static Float:vOrigin[ 3 ], Float:vBallVelocity[ 3 ];
  275.         entity_get_vector( iEntity, EV_VEC_origin, vOrigin );
  276.         entity_get_vector( iEntity, EV_VEC_velocity, vBallVelocity );
  277.          
  278.         static iOwner; iOwner = pev( iEntity, pev_iuser1 );
  279.         static iSolid; iSolid = pev( iEntity, pev_solid );
  280.          
  281.          
  282.         if( iOwner > 0 ) {
  283.             static Float:vOwnerOrigin[ 3 ];
  284.             entity_get_vector( iOwner, EV_VEC_origin, vOwnerOrigin );
  285.              
  286.             static const Float:vVelocity[ 3 ] = { 1.0, 1.0, 0.0 };
  287.              
  288.             if( !is_user_alive( iOwner ) ) {
  289.                 entity_set_int( iEntity, EV_INT_iuser1, 0 );
  290.                  
  291.                 vOwnerOrigin[ 2 ] += 5.0;
  292.                  
  293.                 entity_set_origin( iEntity, vOwnerOrigin );
  294.                 entity_set_vector( iEntity, EV_VEC_velocity, vVelocity );
  295.                  
  296.                 return PLUGIN_CONTINUE;
  297.             }
  298.              
  299.             if( iSolid != SOLID_NOT )
  300.                 set_pev( iEntity, pev_solid, SOLID_NOT );
  301.              
  302.             static Float:vAngles[ 3 ], Float:vReturn[ 3 ];
  303.             entity_get_vector( iOwner, EV_VEC_v_angle, vAngles );
  304.              
  305.             vReturn[ 0 ] = ( floatcos( vAngles[ 1 ], degrees ) * 55.0 ) + vOwnerOrigin[ 0 ];
  306.             vReturn[ 1 ] = ( floatsin( vAngles[ 1 ], degrees ) * 55.0 ) + vOwnerOrigin[ 1 ];
  307.             vReturn[ 2 ] = vOwnerOrigin[ 2 ];
  308.             vReturn[ 2 ] -= ( entity_get_int( iOwner, EV_INT_flags ) & FL_DUCKING ) ? 10 : 30;
  309.              
  310.             entity_set_vector( iEntity, EV_VEC_velocity, vVelocity );
  311.             entity_set_origin( iEntity, vReturn );
  312.         } else {
  313.             if( iSolid != SOLID_BBOX )
  314.                 set_pev( iEntity, pev_solid, SOLID_BBOX );
  315.              
  316.             static Float:flLastVerticalOrigin;
  317.              
  318.             if( vBallVelocity[ 2 ] == 0.0 ) {
  319.                 static iCounts;
  320.                  
  321.                 if( flLastVerticalOrigin > vOrigin[ 2 ] ) {
  322.                     iCounts++;
  323.                      
  324.                     if( iCounts > 10 ) {
  325.                         iCounts = 0;
  326.                          
  327.                         UpdateBall( 0 );
  328.                     }
  329.                 } else {
  330.                     iCounts = 0;
  331.                      
  332.                     if( PointContents( vOrigin ) != CONTENTS_EMPTY )
  333.                         UpdateBall( 0 );
  334.                 }
  335.                  
  336.                 flLastVerticalOrigin = vOrigin[ 2 ];
  337.             }
  338.         }
  339.          
  340.         return PLUGIN_CONTINUE;
  341.     }
  342.      
  343.     KickBall( id ) {
  344.         set_user_maxspeed(id, 230.0)
  345.         static Float:vOrigin[ 3 ];
  346.         entity_get_vector( g_iBall , EV_VEC_origin, vOrigin );
  347.          
  348.         vOrigin[2] += 35;
  349.          
  350.         if( PointContents( vOrigin ) != CONTENTS_EMPTY )
  351.             return PLUGIN_HANDLED;
  352.      
  353.         new Float:vVelocity[ 3 ];
  354.         velocity_by_aim( id, 650, vVelocity );
  355.          
  356.         beam(10)
  357.          
  358.         set_pev( g_iBall , pev_solid, SOLID_BBOX );
  359.         entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  360.         entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  361.         entity_set_origin(g_iBall,vOrigin)
  362.         entity_set_vector( g_iBall , EV_VEC_velocity, vVelocity );
  363.              
  364.         return PLUGIN_CONTINUE;
  365.     }
  366.      
  367.     // BALL TOUCHES
  368.     ////////////////////////////////////////////////////////////
  369.     public FwdTouchPlayer( Ball, id ) {
  370.         if( is_user_bot( id ) )
  371.             return PLUGIN_CONTINUE;
  372.          
  373.         static iOwner; iOwner = pev( Ball, pev_iuser1 );
  374.          
  375.         if( iOwner == 0 ) {
  376.             entity_set_int( Ball, EV_INT_iuser1, id );
  377.             beam(10)
  378.             set_user_maxspeed(id, 230.0)
  379.         }
  380.         return PLUGIN_CONTINUE;
  381.     }
  382.      
  383.     public FwdTouchWorld( Ball, World ) {
  384.         static Float:vVelocity[ 3 ];
  385.         entity_get_vector( Ball, EV_VEC_velocity, vVelocity );
  386.          
  387.         if( floatround( vector_length( vVelocity ) ) > 10 ) {
  388.             vVelocity[ 0 ] *= 0.85;
  389.             vVelocity[ 1 ] *= 0.85;
  390.             vVelocity[ 2 ] *= 0.85;
  391.              
  392.             entity_set_vector( Ball, EV_VEC_velocity, vVelocity );
  393.              
  394.             emit_sound( Ball, CHAN_ITEM, BALL_BOUNCE_GROUND, 1.0, ATTN_NORM, 0, PITCH_NORM );
  395.         }
  396.      
  397.         return PLUGIN_CONTINUE;
  398.     }
  399.      
  400.      
  401.     // ENTITIES CREATING
  402.     ////////////////////////////////////////////////////////////
  403.     CreateBall( id, Float:vOrigin[ 3 ] = { 0.0, 0.0, 0.0 } ) {
  404.         if( !id && vOrigin[ 0 ] == 0.0 && vOrigin[ 1 ] == 0.0 && vOrigin[ 2 ] == 0.0 )
  405.             return 0;
  406.          
  407.         g_bNeedBall = true;
  408.          
  409.         g_iBall = create_entity( "info_target" );
  410.          
  411.         if( is_valid_ent( g_iBall ) ) {
  412.             entity_set_string( g_iBall , EV_SZ_classname, g_szBallName );
  413.             entity_set_int( g_iBall , EV_INT_solid, SOLID_BBOX );
  414.             entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  415.             entity_set_model( g_iBall , g_szBallModel );
  416.             entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  417.              
  418.             entity_set_float( g_iBall , EV_FL_framerate, 0.0 );
  419.             entity_set_int( g_iBall , EV_INT_sequence, 0 );
  420.              
  421.             entity_set_float(g_iBall , EV_FL_nextthink, get_gametime( ) + 0.05 );
  422.          
  423.             glow(g_iBall,ballcolor[0],ballcolor[1],ballcolor[2],10)
  424.              
  425.             //client_print( id, print_chat, "*** Ball Spawned! ***" );
  426.              
  427.             if( id > 0 ) {
  428.                 new iOrigin[ 3 ];
  429.                 get_user_origin( id, iOrigin, 3 );
  430.                 IVecFVec( iOrigin, vOrigin );
  431.                  
  432.                 vOrigin[ 2 ] += 5.0;
  433.                  
  434.                 entity_set_origin( g_iBall , vOrigin );
  435.             } else
  436.                 entity_set_origin( g_iBall , vOrigin );
  437.              
  438.             g_vOrigin = vOrigin;
  439.              
  440.             return g_iBall ;
  441.         }
  442.          
  443.         return -1;
  444.     }
  445.      
  446.     beam(life) {
  447.         message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  448.         write_byte(22); // TE_BEAMFOLLOW
  449.         write_short(g_iBall); // ball
  450.         write_short(beamspr); // laserbeam
  451.         write_byte(life); // life
  452.         write_byte(5); // width
  453.         write_byte(ballbeam[0]); // R
  454.         write_byte(ballbeam[1]); // G
  455.         write_byte(ballbeam[2]); // B
  456.         write_byte(175); // brightness
  457.         message_end();    
  458.     }
  459.     glow(id, r, g, b, on) {
  460.         if(on == 1) {
  461.             set_rendering(id, kRenderFxGlowShell, r, g, b, kRenderNormal, 255)
  462.             entity_set_float(id, EV_FL_renderamt, 1.0)
  463.         }
  464.         else if(!on) {
  465.             set_rendering(id, kRenderFxNone, r, g, b,  kRenderNormal, 255)
  466.             entity_set_float(id, EV_FL_renderamt, 1.0)
  467.         }
  468.         else if(on == 10) {
  469.             set_rendering(id, kRenderFxGlowShell, r, g, b, kRenderNormal, 255)
  470.             entity_set_float(id, EV_FL_renderamt, 1.0)
  471.         }
  472.     }

Ők köszönték meg ReDSTAR nek ezt a hozzászólást: *GrafitY* (2017.01.07. 01:41)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Labda
HozzászólásElküldve: 2017.01.07. 01:41 
Offline
GFX-Designer
Avatar

Csatlakozott: 2015.03.12. 15:06
Hozzászólások: 624
Megköszönt másnak: 199 alkalommal
Megköszönték neki: 78 alkalommal
ReDSTAR írta:
  1. // Version 1.0 : Menu + Orginal Bounc / kicking
  2.     // Version 2.0 : Added Real soccerjamsounds / Got ball msg / Freezetimebug
  3.     // Version 3.0 : Fixed Ball spawns every round
  4.      
  5.     #include <amxmodx>
  6.     #include <engine>
  7.     #include <fakemeta>
  8.     #include <hamsandwich>
  9.     #include <fun>
  10.      
  11.     static const BALL_BOUNCE_GROUND[ ] = "kickball/bounce.wav";
  12.     static const g_szBallModel[ ]     = "models/basebuilder/ball.mdl";
  13.     static const g_szBallName[ ]      = "ball";
  14.      
  15.     new g_iBall, g_szFile[ 128 ], g_szMapname[ 32 ], g_iButtonsMenu;
  16.     new bool:g_bNeedBall
  17.     new Float:g_vOrigin[ 3 ];
  18.     new beamspr
  19.      
  20.     new ballcolor[3] = { 255,200,100 }
  21.     new ballbeam[3] = { 20,50,255 }
  22.      
  23.     public plugin_init( ) {
  24.         register_plugin( "JailMod-Ball", "3.0", "ButterZ`" );
  25.          
  26.          
  27.         /* Register Forward */
  28.         register_forward(FM_PlayerPreThink, "PlayerPreThink", 0)
  29.          
  30.         /* Current Weapon */
  31.         register_event("CurWeapon", "CurWeapon", "be");
  32.          
  33.         RegisterHam( Ham_ObjectCaps, "player", "FwdHamObjectCaps", 1 );
  34.         register_logevent( "EventRoundStart", 2, "1=Round_Start" );
  35.          
  36.         register_think( g_szBallName, "FwdThinkBall" );
  37.         register_touch( g_szBallName, "player", "FwdTouchPlayer" );
  38.          
  39.         new const szEntity[ ][ ] = {
  40.             "worldspawn", "func_wall", "func_door",  "func_door_rotating",
  41.             "func_wall_toggle", "func_breakable", "func_pushable", "func_train",
  42.             "func_illusionary", "func_button", "func_rot_button", "func_rotating"
  43.         }
  44.          
  45.         for( new i; i < sizeof szEntity; i++ )
  46.             register_touch( g_szBallName, szEntity[ i ], "FwdTouchWorld" );
  47.          
  48.         g_iButtonsMenu = menu_create( "BallMaker Menu", "HandleButtonsMenu" );
  49.          
  50.         menu_additem( g_iButtonsMenu, "Create Ball", "1" );
  51.         menu_additem( g_iButtonsMenu, "Load Ball", "2" );
  52.         menu_additem( g_iButtonsMenu, "Delete all Ball", "3" );
  53.         menu_additem( g_iButtonsMenu, "Save", "4" );
  54.          
  55.         register_clcmd( "say /ball", "CmdButtonsMenu", ADMIN_RCON );
  56.         register_clcmd( "say /reset", "UpdateBall" );
  57.     }    
  58.     public PlayerPreThink(id) {
  59.         if(!is_user_alive(id))
  60.             return PLUGIN_CONTINUE;
  61.              
  62.         if( is_valid_ent( g_iBall  ) ) {
  63.             static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  64.             if( iOwner != id && get_user_maxspeed(id) != 1.0 )  
  65.                 set_user_maxspeed(id, 230.0)
  66.         }
  67.         return PLUGIN_HANDLED;
  68.     }
  69.     public CurWeapon(id) {
  70.         if(!is_user_alive(id))
  71.             return PLUGIN_CONTINUE;
  72.         if( is_valid_ent(g_iBall ) ) {
  73.             static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  74.             if( iOwner == id )
  75.                 set_user_maxspeed(id, 230.0)
  76.         }    
  77.         return PLUGIN_HANDLED;
  78.     }
  79.     public UpdateBall( id ) {
  80.         if( !id || get_user_flags( id ) & ADMIN_KICK ) {
  81.             if( is_valid_ent( g_iBall ) ) {
  82.                 entity_set_vector(g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  83.                 entity_set_origin( g_iBall , g_vOrigin );
  84.                  
  85.                 entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  86.                 entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  87.                 entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  88.             }
  89.         }
  90.          
  91.         return PLUGIN_HANDLED;
  92.     }
  93.      
  94.     public plugin_precache( ) {
  95.         precache_model( g_szBallModel );
  96.         precache_sound( BALL_BOUNCE_GROUND );
  97.          
  98.         beamspr = precache_model( "sprites/laserbeam.spr" );
  99.          
  100.         get_mapname( g_szMapname, 31 );
  101.         strtolower( g_szMapname );
  102.          
  103.         // File
  104.         new szDatadir[ 64 ];
  105.         get_localinfo( "amxx_datadir", szDatadir, charsmax( szDatadir ) );
  106.          
  107.         formatex( szDatadir, charsmax( szDatadir ), "%s", szDatadir );
  108.          
  109.         if( !dir_exists( szDatadir ) )
  110.             mkdir( szDatadir );
  111.          
  112.         formatex( g_szFile, charsmax( g_szFile ), "%s/ball.ini", szDatadir );
  113.          
  114.         if( !file_exists( g_szFile ) ) {
  115.             write_file( g_szFile, "// Ball Spawn Editor", -1 );
  116.             write_file( g_szFile, " ", -1 );
  117.              
  118.             return; // We dont need to load file
  119.         }
  120.          
  121.         new szData[ 256 ], szMap[ 32 ], szOrigin[ 3 ][ 16 ];
  122.         new iFile = fopen( g_szFile, "rt" );
  123.          
  124.         while( !feof( iFile ) ) {
  125.             fgets( iFile, szData, charsmax( szData ) );
  126.              
  127.             if( !szData[ 0 ] || szData[ 0 ] == ';' || szData[ 0 ] == ' ' || ( szData[ 0 ] == '/' && szData[ 1 ] == '/' ) )
  128.                 continue;
  129.              
  130.             parse( szData, szMap, 31, szOrigin[ 0 ], 15, szOrigin[ 1 ], 15, szOrigin[ 2 ], 15 );
  131.              
  132.             if( equal( szMap, g_szMapname ) ) {
  133.                 new Float:vOrigin[ 3 ];
  134.                  
  135.                 vOrigin[ 0 ] = str_to_float( szOrigin[ 0 ] );
  136.                 vOrigin[ 1 ] = str_to_float( szOrigin[ 1 ] );
  137.                 vOrigin[ 2 ] = str_to_float( szOrigin[ 2 ] );
  138.                  
  139.                 CreateBall( 0, vOrigin );
  140.                  
  141.                 g_vOrigin = vOrigin;
  142.                  
  143.                 break;
  144.             }
  145.         }
  146.          
  147.         fclose( iFile );
  148.     }
  149.      
  150.     public CmdButtonsMenu( id ) {
  151.         if( get_user_flags( id ) & ADMIN_RCON )
  152.             menu_display( id, g_iButtonsMenu, 0 );
  153.          
  154.         return PLUGIN_HANDLED;
  155.     }
  156.      
  157.     public HandleButtonsMenu( id, iMenu, iItem ) {
  158.         if( iItem == MENU_EXIT )
  159.             return PLUGIN_HANDLED;
  160.          
  161.         new szKey[ 2 ], _Access, _Callback;
  162.         menu_item_getinfo( iMenu, iItem, _Access, szKey, 1, "", 0, _Callback );
  163.          
  164.         new iKey = str_to_num( szKey );
  165.          
  166.         switch( iKey ) {
  167.             case 1:    {
  168.                 if( pev_valid( g_iBall  ) )
  169.                     return PLUGIN_CONTINUE;
  170.                      
  171.                 CreateBall( id );
  172.             }
  173.             case 2: {
  174.                 if( is_valid_ent( g_iBall  ) ) {
  175.                     entity_set_vector( g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  176.                     entity_set_origin( g_iBall , g_vOrigin );
  177.                      
  178.                     entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  179.                     entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  180.                     entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  181.                     client_print( id, print_chat, "*** Loading Ball ***" );
  182.                 }
  183.             }
  184.             case 3: {
  185.                 new iEntity;
  186.                  
  187.                 while( ( iEntity = find_ent_by_class( iEntity, g_szBallName ) ) > 0 )
  188.                     remove_entity( iEntity );
  189.                 client_print( id, print_chat, "*** Ball Deleted ! ***" );
  190.             }
  191.             case 4: {
  192.                 new iBall, iEntity, Float:vOrigin[ 3 ];
  193.                  
  194.                 while( ( iEntity = find_ent_by_class( iEntity, g_szBallName ) ) > 0 )
  195.                     iBall = iEntity;
  196.                  
  197.                 if( iBall > 0 )
  198.                     entity_get_vector( iBall, EV_VEC_origin, vOrigin );
  199.                 else
  200.                     return PLUGIN_HANDLED;
  201.                  
  202.                 new bool:bFound, iPos, szData[ 32 ], iFile = fopen( g_szFile, "r+" );
  203.                  
  204.                 if( !iFile )
  205.                     return PLUGIN_HANDLED;
  206.                  
  207.                 while( !feof( iFile ) ) {
  208.                     fgets( iFile, szData, 31 );
  209.                     parse( szData, szData, 31 );
  210.                      
  211.                     iPos++;
  212.                      
  213.                     if( equal( szData, g_szMapname ) ) {
  214.                         bFound = true;
  215.                          
  216.                         new szString[ 256 ];
  217.                         formatex( szString, 255, "%s %f %f %f", g_szMapname, vOrigin[ 0 ], vOrigin[ 1 ], vOrigin[ 2 ] );
  218.                          
  219.                         write_file( g_szFile, szString, iPos - 1 );
  220.                          
  221.                         break;
  222.                     }
  223.                 }
  224.                  
  225.                 if( !bFound )
  226.                     fprintf( iFile, "%s %f %f %f^n", g_szMapname, vOrigin[ 0 ], vOrigin[ 1 ], vOrigin[ 2 ] );
  227.                  
  228.                 fclose( iFile );
  229.                  
  230.                 client_print( id, print_chat, "*** Ball Saved ! ***" );
  231.             }
  232.             default: return PLUGIN_HANDLED;
  233.         }
  234.          
  235.         menu_display( id, g_iButtonsMenu, 0 );
  236.          
  237.         return PLUGIN_HANDLED;
  238.     }
  239.      
  240.     public EventRoundStart(id) {
  241.         if( !g_bNeedBall )
  242.             return;
  243.          
  244.         if( !is_valid_ent( g_iBall  ) )
  245.             CreateBall( 0, g_vOrigin );
  246.         else {
  247.             entity_set_vector( g_iBall , EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } ); // To be sure ?
  248.             entity_set_origin( g_iBall , g_vOrigin );
  249.              
  250.             entity_set_int( g_iBall , EV_INT_solid, SOLID_BBOX );
  251.             entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  252.             entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  253.             entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  254.         }
  255.     }
  256.      
  257.     public FwdHamObjectCaps( id ) {
  258.         if( pev_valid( g_iBall  ) && is_user_alive( id ) ) {
  259.             static iOwner; iOwner = pev( g_iBall , pev_iuser1 );
  260.              
  261.             if( iOwner == id )
  262.                 KickBall( id );
  263.         }
  264.     }
  265.      
  266.     // BALL BRAIN :)
  267.     ////////////////////////////////////////////////////////////
  268.     public FwdThinkBall( iEntity ) {
  269.         if( !is_valid_ent( g_iBall   ) )
  270.             return PLUGIN_HANDLED;
  271.          
  272.         entity_set_float( iEntity, EV_FL_nextthink, halflife_time( ) + 0.05 );
  273.          
  274.         static Float:vOrigin[ 3 ], Float:vBallVelocity[ 3 ];
  275.         entity_get_vector( iEntity, EV_VEC_origin, vOrigin );
  276.         entity_get_vector( iEntity, EV_VEC_velocity, vBallVelocity );
  277.          
  278.         static iOwner; iOwner = pev( iEntity, pev_iuser1 );
  279.         static iSolid; iSolid = pev( iEntity, pev_solid );
  280.          
  281.          
  282.         if( iOwner > 0 ) {
  283.             static Float:vOwnerOrigin[ 3 ];
  284.             entity_get_vector( iOwner, EV_VEC_origin, vOwnerOrigin );
  285.              
  286.             static const Float:vVelocity[ 3 ] = { 1.0, 1.0, 0.0 };
  287.              
  288.             if( !is_user_alive( iOwner ) ) {
  289.                 entity_set_int( iEntity, EV_INT_iuser1, 0 );
  290.                  
  291.                 vOwnerOrigin[ 2 ] += 5.0;
  292.                  
  293.                 entity_set_origin( iEntity, vOwnerOrigin );
  294.                 entity_set_vector( iEntity, EV_VEC_velocity, vVelocity );
  295.                  
  296.                 return PLUGIN_CONTINUE;
  297.             }
  298.              
  299.             if( iSolid != SOLID_NOT )
  300.                 set_pev( iEntity, pev_solid, SOLID_NOT );
  301.              
  302.             static Float:vAngles[ 3 ], Float:vReturn[ 3 ];
  303.             entity_get_vector( iOwner, EV_VEC_v_angle, vAngles );
  304.              
  305.             vReturn[ 0 ] = ( floatcos( vAngles[ 1 ], degrees ) * 55.0 ) + vOwnerOrigin[ 0 ];
  306.             vReturn[ 1 ] = ( floatsin( vAngles[ 1 ], degrees ) * 55.0 ) + vOwnerOrigin[ 1 ];
  307.             vReturn[ 2 ] = vOwnerOrigin[ 2 ];
  308.             vReturn[ 2 ] -= ( entity_get_int( iOwner, EV_INT_flags ) & FL_DUCKING ) ? 10 : 30;
  309.              
  310.             entity_set_vector( iEntity, EV_VEC_velocity, vVelocity );
  311.             entity_set_origin( iEntity, vReturn );
  312.         } else {
  313.             if( iSolid != SOLID_BBOX )
  314.                 set_pev( iEntity, pev_solid, SOLID_BBOX );
  315.              
  316.             static Float:flLastVerticalOrigin;
  317.              
  318.             if( vBallVelocity[ 2 ] == 0.0 ) {
  319.                 static iCounts;
  320.                  
  321.                 if( flLastVerticalOrigin > vOrigin[ 2 ] ) {
  322.                     iCounts++;
  323.                      
  324.                     if( iCounts > 10 ) {
  325.                         iCounts = 0;
  326.                          
  327.                         UpdateBall( 0 );
  328.                     }
  329.                 } else {
  330.                     iCounts = 0;
  331.                      
  332.                     if( PointContents( vOrigin ) != CONTENTS_EMPTY )
  333.                         UpdateBall( 0 );
  334.                 }
  335.                  
  336.                 flLastVerticalOrigin = vOrigin[ 2 ];
  337.             }
  338.         }
  339.          
  340.         return PLUGIN_CONTINUE;
  341.     }
  342.      
  343.     KickBall( id ) {
  344.         set_user_maxspeed(id, 230.0)
  345.         static Float:vOrigin[ 3 ];
  346.         entity_get_vector( g_iBall , EV_VEC_origin, vOrigin );
  347.          
  348.         vOrigin[2] += 35;
  349.          
  350.         if( PointContents( vOrigin ) != CONTENTS_EMPTY )
  351.             return PLUGIN_HANDLED;
  352.      
  353.         new Float:vVelocity[ 3 ];
  354.         velocity_by_aim( id, 650, vVelocity );
  355.          
  356.         beam(10)
  357.          
  358.         set_pev( g_iBall , pev_solid, SOLID_BBOX );
  359.         entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  360.         entity_set_int( g_iBall , EV_INT_iuser1, 0 );
  361.         entity_set_origin(g_iBall,vOrigin)
  362.         entity_set_vector( g_iBall , EV_VEC_velocity, vVelocity );
  363.              
  364.         return PLUGIN_CONTINUE;
  365.     }
  366.      
  367.     // BALL TOUCHES
  368.     ////////////////////////////////////////////////////////////
  369.     public FwdTouchPlayer( Ball, id ) {
  370.         if( is_user_bot( id ) )
  371.             return PLUGIN_CONTINUE;
  372.          
  373.         static iOwner; iOwner = pev( Ball, pev_iuser1 );
  374.          
  375.         if( iOwner == 0 ) {
  376.             entity_set_int( Ball, EV_INT_iuser1, id );
  377.             beam(10)
  378.             set_user_maxspeed(id, 230.0)
  379.         }
  380.         return PLUGIN_CONTINUE;
  381.     }
  382.      
  383.     public FwdTouchWorld( Ball, World ) {
  384.         static Float:vVelocity[ 3 ];
  385.         entity_get_vector( Ball, EV_VEC_velocity, vVelocity );
  386.          
  387.         if( floatround( vector_length( vVelocity ) ) > 10 ) {
  388.             vVelocity[ 0 ] *= 0.85;
  389.             vVelocity[ 1 ] *= 0.85;
  390.             vVelocity[ 2 ] *= 0.85;
  391.              
  392.             entity_set_vector( Ball, EV_VEC_velocity, vVelocity );
  393.              
  394.             emit_sound( Ball, CHAN_ITEM, BALL_BOUNCE_GROUND, 1.0, ATTN_NORM, 0, PITCH_NORM );
  395.         }
  396.      
  397.         return PLUGIN_CONTINUE;
  398.     }
  399.      
  400.      
  401.     // ENTITIES CREATING
  402.     ////////////////////////////////////////////////////////////
  403.     CreateBall( id, Float:vOrigin[ 3 ] = { 0.0, 0.0, 0.0 } ) {
  404.         if( !id && vOrigin[ 0 ] == 0.0 && vOrigin[ 1 ] == 0.0 && vOrigin[ 2 ] == 0.0 )
  405.             return 0;
  406.          
  407.         g_bNeedBall = true;
  408.          
  409.         g_iBall = create_entity( "info_target" );
  410.          
  411.         if( is_valid_ent( g_iBall ) ) {
  412.             entity_set_string( g_iBall , EV_SZ_classname, g_szBallName );
  413.             entity_set_int( g_iBall , EV_INT_solid, SOLID_BBOX );
  414.             entity_set_int( g_iBall , EV_INT_movetype, MOVETYPE_BOUNCE );
  415.             entity_set_model( g_iBall , g_szBallModel );
  416.             entity_set_size( g_iBall , Float:{ -15.0, -15.0, 0.0 }, Float:{ 15.0, 15.0, 12.0 } );
  417.              
  418.             entity_set_float( g_iBall , EV_FL_framerate, 0.0 );
  419.             entity_set_int( g_iBall , EV_INT_sequence, 0 );
  420.              
  421.             entity_set_float(g_iBall , EV_FL_nextthink, get_gametime( ) + 0.05 );
  422.          
  423.             glow(g_iBall,ballcolor[0],ballcolor[1],ballcolor[2],10)
  424.              
  425.             //client_print( id, print_chat, "*** Ball Spawned! ***" );
  426.              
  427.             if( id > 0 ) {
  428.                 new iOrigin[ 3 ];
  429.                 get_user_origin( id, iOrigin, 3 );
  430.                 IVecFVec( iOrigin, vOrigin );
  431.                  
  432.                 vOrigin[ 2 ] += 5.0;
  433.                  
  434.                 entity_set_origin( g_iBall , vOrigin );
  435.             } else
  436.                 entity_set_origin( g_iBall , vOrigin );
  437.              
  438.             g_vOrigin = vOrigin;
  439.              
  440.             return g_iBall ;
  441.         }
  442.          
  443.         return -1;
  444.     }
  445.      
  446.     beam(life) {
  447.         message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  448.         write_byte(22); // TE_BEAMFOLLOW
  449.         write_short(g_iBall); // ball
  450.         write_short(beamspr); // laserbeam
  451.         write_byte(life); // life
  452.         write_byte(5); // width
  453.         write_byte(ballbeam[0]); // R
  454.         write_byte(ballbeam[1]); // G
  455.         write_byte(ballbeam[2]); // B
  456.         write_byte(175); // brightness
  457.         message_end();    
  458.     }
  459.     glow(id, r, g, b, on) {
  460.         if(on == 1) {
  461.             set_rendering(id, kRenderFxGlowShell, r, g, b, kRenderNormal, 255)
  462.             entity_set_float(id, EV_FL_renderamt, 1.0)
  463.         }
  464.         else if(!on) {
  465.             set_rendering(id, kRenderFxNone, r, g, b,  kRenderNormal, 255)
  466.             entity_set_float(id, EV_FL_renderamt, 1.0)
  467.         }
  468.         else if(on == 10) {
  469.             set_rendering(id, kRenderFxGlowShell, r, g, b, kRenderNormal, 255)
  470.             entity_set_float(id, EV_FL_renderamt, 1.0)
  471.         }
  472.     }



Sikerült, köszönöm!

_________________
„Nem azért felejtünk el játszani, mert megöregszünk, hanem attól öregszünk meg, hogy elfelejtünk játszani.”

-MAXHACKED Website-
-HERViD Website-
► Spoiler mutatása


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 5 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 5 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole