Someone can help me please

Useless Stuffs, Spam ... etc
Locked
Stafie97
Member
Member
Romania
Posts: 1
Joined: 4 Months Ago
Has thanked: 0
Been thanked: 0
Contact:

Someone can help me please

#1

Post by Stafie97 » 4 Months Ago

Hello, so I have this weapon plugin "zp_wpn_at4cs" that has this weird bug, if you directly point your crosshair or you use the scope to shoot a Zombie the Rocket goes a totally different path then where you point/shoot at, only happenes when dirrectly pointing at a Zm, watch video below for more info. Could anyone take a look at the plugin file and help me please fix the bug?

[YouTube]https://www.youtube.com/watch?v=NkefUbhg6Ew[/YouTube]
  1. #include < amxmodx >
  2. #include < cstrike >
  3. #include < engine >
  4. #include < fakemeta >
  5. #include < hamsandwich >
  6. #include < zombieplague >
  7.  
  8. new const PLUGIN_VERSION[ ]    =  "0.0.1";
  9.  
  10. const OFFSET_WEAPONOWNER    =      41
  11. const OFFSET_LINUX    =    5
  12. const OFFSET_LINUX_WEAPONS     =      4
  13.  
  14. const WEAP_KEY   =  545464464
  15. const MAX_PLAYERS   =       32
  16.  
  17. const m_iClip           =       51
  18. const m_flNextAttack        =       83
  19. const m_flNextPrimaryAttack    =    46
  20.  
  21. enum _:Coord_e
  22. {
  23.     Float:x,
  24.     Float:y,
  25.     Float:z
  26. };
  27.  
  28. enum ( <<= 1 )
  29. {
  30.     angles = 1,
  31.     v_angle,
  32.     punchangle
  33. };
  34.  
  35. enum _:Angle_e
  36. {
  37.     Float:pitch,
  38.     Float:yaw,
  39.     Float:roll
  40. };
  41.  
  42. enum ( <<=1 )
  43. {
  44.     DROP_PRIMARY = 1,
  45.     DROP_SECONDARY
  46. };
  47.  
  48. enum _:OTHERS
  49. {
  50.     TRAIL = 1 ,
  51.     DECALINDEX ,
  52.     EXPLODESPR ,
  53.     PUFFSPR  
  54. }  
  55.  
  56. enum eState:
  57. {
  58.     State_Shown = 0,
  59.     State_Hidden
  60. };
  61.  
  62. const IDLE = 0
  63. const RELOAD = 3
  64. const DRAW = 4
  65. const SHOOT_1 = 1
  66. const SHOOT_2 = 2
  67.  
  68. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
  69. #define HoldCBaseWeapon(%0) ( get_user_weapon( %0 ) == g_iWeaponID  && g_pWeaponA[ %0 ] )
  70. #define IsValidPrivateData(%0)  ( pev_valid( %0 ) == 2 )
  71.  
  72. #define VectorScale(%1,%2,%3)    ( %3[ x ] = %2 * %1[ x ], %3[ y ] = %2 * %1[ y ], %3[ z ] = %2 * %1[ z ] )
  73. #define VectorAdd(%1,%2,%3)      ( %3[ x ] = %1[ x ] + %2[ x ], %3[ y ] = %1[ y ] + %2[ y ], %3[ z ] = %1[ z ] + %2[ z ] )
  74.  
  75. new const WEAPON_SOUND_FIRE[ ] = "weapons/at4-1.wav";
  76.  
  77. new const WEAPON_LIST[ ]   =   "weapon_at4cs_sh";
  78. new const WEAPON_BASE_NAME[ ]   =  "weapon_sg552";
  79.  
  80. const Float:RELOAD_TIME  =   4.0
  81.  
  82. const AMMO__WEAPON        =  10
  83. const CLIP__WEAPON  =  1
  84. const COST__GRENADE   =  200
  85.  
  86. const Float:ROCKET__DAMAGE   =   1000.0
  87. const Float:ROCKET__RADIUS = 300.0
  88. const Float:ROCKET__SPEED    = 1600.0
  89.  
  90. new const EXTRA_ITEM_NAME[ ]    =   "AT4CS";
  91.  
  92. new V_MODEL[ ] = "models/zm/v_at4ex.mdl";
  93. new P_MODEL[ ] = "models/zm/p_at4ex.mdl";
  94. new W_MODEL[ ] = "models/zm/w_weapons.mdl";
  95.  
  96. new R_MODEL[ ] = "models/zm/s_rocket.mdl"
  97.  
  98. new const BUYAMMO_SOUND[ ] = "items/9mmclip1.wav";
  99.  
  100. new const HUD_SPRITES[ ] [ ] =
  101. {
  102.     "sprites/zm/640hud7.spr" ,
  103.     "sprites/zm/640hud53.spr" ,
  104.     "sprites/zm/at4_scope.spr"
  105. }  
  106.  
  107. new g_iItem , g_iOriginEvent , g_iMaxPlayers , g_iForwardIndex;
  108.  
  109.  
  110. new g_iEffect[ OTHERS ];
  111.  
  112. new g_pWeaponA[ MAX_PLAYERS + 1 ] ,
  113.     bool:g_iPrimaryAttack;
  114.    
  115. new g_iClipAmmo[ MAX_PLAYERS + 1 ],
  116.     g_TmpClip[ MAX_PLAYERS + 1 ] ,
  117.     g_iWeaponID = 0;
  118.    
  119. const HIDE_CROSSHAIR = ( 1 << 6 )
  120.  
  121. new const ROCKET__CLASSNAME[ ]  =   "Rocket_at";   
  122.  
  123. const WEAPONS_PRIMARY_BITSUM    = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90);
  124. const WEAPONS_SECONDARY_BITSUM  = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE);
  125.  
  126. public plugin_precache()
  127. {
  128.     precache_model(V_MODEL);
  129.     precache_model(P_MODEL);
  130.     precache_model(W_MODEL);
  131.     precache_model(R_MODEL);
  132.    
  133.     PrecacheSoundsFromModel( V_MODEL );
  134.    
  135.     precache_sound(WEAPON_SOUND_FIRE);
  136.    
  137.     static iFile
  138.    
  139.     for( iFile = 0 ; iFile < sizeof HUD_SPRITES; iFile++ )
  140.     {
  141.         precache_generic( HUD_SPRITES[ iFile ] )
  142.     }  
  143.    
  144.     static szFile [ 64 ];
  145.    
  146.     formatex ( szFile , charsmax( szFile ) , "sprites/%s.txt" , WEAPON_LIST );
  147.     precache_generic( szFile );
  148.    
  149.     precache_sound( BUYAMMO_SOUND )
  150.    
  151.     g_iEffect[ EXPLODESPR ]  = precache_model( "sprites/zm/zerogxplode-big1.spr"  )
  152.     g_iEffect[ TRAIL ] = precache_model("sprites/xbeam3.spr")
  153.     g_iEffect[ PUFFSPR ]  = precache_model("sprites/effects/rainsplash.spr")
  154.    
  155.     g_iForwardIndex = register_forward( FM_PrecacheEvent, "Forward_PrecacheEventPost", true );
  156. }
  157.  
  158. public plugin_init()
  159. {
  160.     register_plugin( "[CSO] Extra Item Ethereal" , PLUGIN_VERSION , "Shurik07" );
  161.     register_clcmd( WEAPON_LIST, "weapon_hook_an" );
  162.    
  163.     unregister_forward( FM_PrecacheEvent, g_iForwardIndex, true );
  164.     register_forward(FM_SetModel, "Forward_SetModel" , false );
  165.     register_forward(FM_PlaybackEvent, "Forward_PlayBackEvent" , false )
  166.     register_forward(FM_UpdateClientData, "Forward_UpdateClientData" , true );
  167.    
  168.     RegisterHam( Ham_Item_AddToPlayer, WEAPON_BASE_NAME, "CBaseWeapon__AddToPlayer__Pre" , .Post = false );
  169.     RegisterHam( Ham_Item_Deploy, WEAPON_BASE_NAME , "CBaseWeapon__Deploy__Post", .Post = true );
  170.     RegisterHam( Ham_Item_Holster, WEAPON_BASE_NAME, "CBaseWeapon_Holster_Post", .Post = true );
  171.     RegisterHam( Ham_Weapon_PrimaryAttack, WEAPON_BASE_NAME, "CBaseWeapon__PrimaryAttack__Pre" , .Post = false );
  172.     RegisterHam( Ham_Weapon_PrimaryAttack, WEAPON_BASE_NAME, "CBaseWeapon_PrimaryAttack_Post", .Post = true );
  173.     RegisterHam( Ham_Item_PostFrame, WEAPON_BASE_NAME, "CBaseWeapon__PostFrame__Pre" , .Post = false );
  174.     RegisterHam( Ham_Weapon_Reload, WEAPON_BASE_NAME, "CBaseWeapon__Reload_Pre" , .Post = false );
  175.     RegisterHam( Ham_Weapon_Reload, WEAPON_BASE_NAME, "CBaseWeapon__Reload_Post", .Post = true );
  176.  
  177.  
  178.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 0)
  179.     RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack", 0)
  180.    
  181.     register_touch( ROCKET__CLASSNAME , "*", "CTouch_Rocket" )
  182.     register_think( ROCKET__CLASSNAME , "CThink_Rocket" )
  183.    
  184.    
  185.     g_iEffect[ DECALINDEX ]   = get_decal_index("{scorch3")
  186.  
  187.     g_iItem = zp_register_extra_item( EXTRA_ITEM_NAME, 150, ZP_TEAM_HUMAN );
  188.     g_iMaxPlayers = get_maxplayers();
  189.     g_iWeaponID = get_weaponid( WEAPON_BASE_NAME );
  190. }
  191.  
  192. public fw_TraceAttack(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
  193. {
  194.     if(!is_user_alive(Attacker))
  195.         return HAM_IGNORED 
  196.     if(get_user_weapon(Attacker) != CSW_G3SG1 || !g_pWeaponA[Attacker])
  197.         return HAM_IGNORED
  198.        
  199.     return HAM_SUPERCEDE
  200. }
  201.  
  202. public plugin_natives()
  203. {
  204.     register_native("zp_get_weapon_rocket", "native_weapon_rocket", 1)
  205. }
  206.  
  207. public native_weapon_rocket(id)
  208. {
  209.     return g_pWeaponA[id];
  210. }
  211.  
  212. public zp_extra_item_selected( pPlayer , pItem )
  213. {
  214.     if( pItem == g_iItem  )
  215.     {
  216.          UTIL__DropWeapons( pPlayer, DROP_PRIMARY )
  217.          
  218.          g_pWeaponA[ pPlayer ]  = true;
  219.          
  220.          static pEntity;
  221.          
  222.          pEntity = fm_give_item( pPlayer , WEAPON_BASE_NAME );
  223.          
  224.          if( pEntity > 0 )
  225.          {
  226.             cs_set_weapon_ammo( pEntity, CLIP__WEAPON );   
  227.          } 
  228.          
  229.          cs_set_user_bpammo( pPlayer , g_iWeaponID , AMMO__WEAPON );
  230.          
  231.          UTIL__WeaponList( pPlayer,  WEAPON_LIST , 4 , 90 , -1 , -1 , 0 , 10 , g_iWeaponID , 0 );
  232.     }  
  233. }
  234.  
  235. public weapon_hook_an( pPlayer  )
  236. {
  237.         engclient_cmd( pPlayer, WEAPON_BASE_NAME);
  238.         return PLUGIN_HANDLED;
  239. }
  240.  
  241. public zp_user_humanized_post( pPlayer )
  242. {
  243.     g_pWeaponA[ pPlayer ] = false;
  244. }
  245.  
  246. public client_disconnect( pPlayer )
  247. {
  248.     g_pWeaponA[ pPlayer ]  = false;
  249. }
  250.  
  251. public Forward_PrecacheEventPost(type, const pName[ ] )
  252. {
  253.     if ( equal ("events/sg552.sc", pName ) )
  254.     {
  255.         g_iOriginEvent = get_orig_retval( );
  256.         return FMRES_HANDLED;
  257.     }
  258.     return FMRES_IGNORED;
  259. }
  260.  
  261. public Forward_SetModel( pEntity, pModel[])
  262. {
  263.     if( !is_valid_ent( pEntity ) )
  264.     {
  265.         return FMRES_IGNORED;
  266.     }  
  267.    
  268.     static szClassName [ 33 ]
  269.     entity_get_string( pEntity, EV_SZ_classname, szClassName, charsmax ( szClassName ) )
  270.        
  271.     if( !equal ( szClassName, "weaponbox" ) )
  272.     {
  273.         return FMRES_IGNORED;
  274.     }  
  275.    
  276.     static pOwner , pModel
  277.    
  278.     pModel = find_ent_by_owner ( -1, WEAPON_BASE_NAME, pEntity );
  279.    
  280.     pOwner = entity_get_edict(pEntity, EV_ENT_owner)
  281.    
  282.     if ( g_pWeaponA [ pOwner ]  && is_valid_ent ( pModel ) )
  283.     {
  284.         entity_set_int( pModel, EV_INT_impulse, WEAP_KEY);
  285.        
  286.         entity_set_model( pEntity, W_MODEL );
  287.         set_pev(pEntity, pev_body, 22)
  288.  
  289.         g_pWeaponA [ pOwner ]   = false;
  290.        
  291.         return FMRES_SUPERCEDE;
  292.     }
  293.  
  294.     return FMRES_IGNORED;
  295. }
  296.  
  297. public Forward_UpdateClientData( pPlayer , SendWeapons, CD_Handle )
  298. {
  299.     if ( !HoldCBaseWeapon( pPlayer ) )
  300.     {
  301.         return HAM_IGNORED;
  302.     }
  303.  
  304.     static Float:fGametime;
  305.     fGametime = get_gametime();
  306.    
  307.     set_cd ( CD_Handle, CD_flNextAttack, fGametime + 0.001 );
  308.  
  309.     return FMRES_HANDLED;
  310. }
  311.  
  312. public Forward_PlayBackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:fvangles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  313. {
  314.     if ( ( eventid != g_iOriginEvent) || !g_iPrimaryAttack )
  315.     {
  316.         return FMRES_IGNORED;
  317.     }  
  318.        
  319.     if (!( 1 <= invoker <= g_iMaxPlayers ) )
  320.     {
  321.         return FMRES_IGNORED;
  322.     }  
  323.    
  324.     if( flags & FEV_GLOBAL )
  325.     {  
  326.         flags &= ~FEV_GLOBAL;
  327.     }
  328.  
  329.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, fvangles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  330.     return FMRES_SUPERCEDE
  331. }
  332.  
  333. public CBaseWeapon__AddToPlayer__Pre( pEnity , pPlayer )
  334. {
  335.     if( !pev_valid( pEnity ) && !is_user_connected( pPlayer ) )
  336.     {
  337.          return HAM_IGNORED;
  338.     }
  339.    
  340.     if( pev( pEnity, pev_impulse ) == WEAP_KEY || g_pWeaponA[ pPlayer ] )
  341.     {
  342.         g_pWeaponA[ pPlayer ]  = true;
  343.        
  344.         UTIL__WeaponList( pPlayer,  WEAPON_LIST , 4 , 90 , -1 , -1 , 0 , 10 , g_iWeaponID , 0 );
  345.  
  346.         return HAM_HANDLED;
  347.     }
  348.     else
  349.     {
  350.         UTIL__WeaponList( pPlayer,  WEAPON_BASE_NAME , 4 , 90 , -1 , -1 , 0 , 10 , g_iWeaponID , 0 );
  351.     }  
  352.  
  353.     return HAM_IGNORED;
  354. }
  355.  
  356. public CBaseWeapon__Deploy__Post( pEntity )
  357. {
  358.     if( !IsValidPrivateData( pEntity ) )
  359.     {
  360.                 return HAM_HANDLED;
  361.     }
  362.    
  363.     static pId
  364.     pId = get_pdata_cbase( pEntity , OFFSET_WEAPONOWNER , OFFSET_LINUX_WEAPONS );
  365.    
  366.     if (!g_pWeaponA[pId]  )
  367.     {
  368.         return HAM_IGNORED;
  369.     }  
  370.    
  371.     set_pev(pId, pev_viewmodel2, V_MODEL);
  372.     set_pev(pId, pev_weaponmodel2, P_MODEL);
  373.    
  374.     set_pdata_float( pId, m_flNextAttack, 1.0, OFFSET_LINUX);
  375.    
  376.     UTIL__SetCrosshairStatus( pId, State_Hidden  )
  377.     UTIL_SenwWeaponAnim( pId, DRAW );
  378.    
  379.     return HAM_IGNORED;
  380. }
  381.  
  382. public CBaseWeapon_Holster_Post( pEntity )
  383. {
  384.     if( !IsValidPrivateData( pEntity ) )
  385.     {
  386.                 return HAM_HANDLED;
  387.     }
  388.  
  389.     static pPlayer;
  390.  
  391.     pPlayer = get_pdata_cbase( pEntity , OFFSET_WEAPONOWNER , OFFSET_LINUX_WEAPONS );
  392.  
  393.     UTIL__SetCrosshairStatus( pPlayer, State_Shown );
  394.  
  395.     if ( !HoldCBaseWeapon( pPlayer ) )
  396.     {
  397.         return HAM_IGNORED;
  398.     }
  399.  
  400.     return HAM_IGNORED;
  401. }
  402.  
  403. public CBaseWeapon__PrimaryAttack__Pre(pEntity)
  404. {
  405.     if( !IsValidPrivateData( pEntity ) )
  406.     {
  407.         return HAM_IGNORED;
  408.     }
  409.  
  410.     static  pId;
  411.  
  412.     pId = get_pdata_cbase( pEntity , OFFSET_WEAPONOWNER , OFFSET_LINUX_WEAPONS );
  413.  
  414.     if ( !HoldCBaseWeapon( pId ) )
  415.     {
  416.         return HAM_IGNORED;
  417.     }
  418.  
  419.     g_iClipAmmo[pId] = cs_get_weapon_ammo(pEntity);
  420.  
  421.     g_iPrimaryAttack = true;
  422.    
  423.     return HAM_IGNORED;
  424. }
  425.  
  426. public CBaseWeapon_PrimaryAttack_Post( pEntity )
  427. {
  428.     if( !IsValidPrivateData( pEntity ) )
  429.     {
  430.         return HAM_IGNORED;
  431.     }
  432.     g_iPrimaryAttack = false;
  433.    
  434.     static pId ; pId = get_pdata_cbase( pEntity, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS );
  435.    
  436.     if ( !HoldCBaseWeapon( pId ) )
  437.     {
  438.         return HAM_IGNORED;
  439.     }
  440.  
  441.     if (!g_iClipAmmo[pId])
  442.     {
  443.             return HAM_IGNORED;
  444.     }  
  445.        
  446.        
  447.     client_cmd(pId, "spk %s", WEAPON_SOUND_FIRE)
  448.     UTIL_SenwWeaponAnim( pId, random_num( SHOOT_1 , SHOOT_2 ) );
  449.    
  450.     static Float:vf_Forward[ Coord_e ], Float:vf_vAngle[ Angle_e ];
  451.     static Float:vf_Source [ Coord_e ], Float:vf_Angles[ Coord_e ];
  452.    
  453.     engfunc( EngFunc_GetAttachment, pId, 0, vf_Source, vf_Angles )
  454.  
  455.     global_get ( glb_v_forward, vf_Forward );
  456.     pev ( pId, pev_v_angle, vf_vAngle );
  457.    
  458.     set_pev( pId , pev_punchangle , Float:{ 3.2 , 3.2 , 0.0 } );
  459.  
  460.     static Float:vf_VelocitySR[ Coord_e ]
  461.    
  462.     VectorScale ( vf_Forward, ROCKET__SPEED , vf_VelocitySR );
  463.     GLauncher_ShootRocket ( vf_Source, vf_VelocitySR, pId );
  464.    
  465.     return HAM_IGNORED;
  466. }
  467.  
  468. GLauncher_ShootRocket ( const Float:vf_Origin[], const Float:vf_Velocity[], const i_Owner )
  469. {
  470.     static i_Rocket;
  471.  
  472.     if ( ( i_Rocket = engfunc ( EngFunc_CreateNamedEntity, engfunc ( EngFunc_AllocString, "info_target" ) ) ) )
  473.     {
  474.         static vf_Temp[ Angle_e ]
  475.  
  476.         set_pev ( i_Rocket, pev_classname, ROCKET__CLASSNAME );
  477.         set_pev ( i_Rocket, pev_origin, vf_Origin );
  478.         set_pev ( i_Rocket, pev_owner, i_Owner );
  479.  
  480.         set_pev ( i_Rocket, pev_movetype, MOVETYPE_FLYMISSILE );
  481.         set_pev ( i_Rocket, pev_solid, SOLID_BBOX );
  482.         set_pev ( i_Rocket, pev_takedamage, DAMAGE_NO );
  483.         set_pev ( i_Rocket, pev_gravity, 0.5 );
  484.        
  485.         engfunc ( EngFunc_VecToAngles, vf_Velocity, vf_Temp );
  486.         set_pev ( i_Rocket, pev_angles, vf_Temp );
  487.        
  488.         engfunc ( EngFunc_ParticleEffect, vf_Origin, vf_Velocity, 8.0 , 25.0 )
  489.  
  490.         engfunc ( EngFunc_SetModel , i_Rocket, R_MODEL );
  491.         engfunc ( EngFunc_SetSize  , i_Rocket, Float:{ 0.0, 0.0, 0.0 }, Float:{ 0.0, 0.0, 0.0 } );
  492.         engfunc ( EngFunc_SetOrigin, i_Rocket, vf_Origin );
  493.  
  494.         set_pev ( i_Rocket, pev_velocity, vf_Velocity );
  495.        
  496.         FX_BeamFollow ( i_Rocket, g_iEffect[ TRAIL ] , 25, 7, 255, 0, 0, 200 );
  497.        
  498.         set_pev(i_Rocket, pev_nextthink, get_gametime( ) + 0.1)
  499.     }
  500. }
  501.  
  502. public CBaseWeapon__PostFrame__Pre( pEntity )
  503. {
  504.     if( !IsValidPrivateData( pEntity ) )
  505.     {
  506.                 return HAM_HANDLED;
  507.     }
  508.  
  509.     static pId;
  510.  
  511.     pId = get_pdata_cbase( pEntity , OFFSET_WEAPONOWNER , OFFSET_LINUX_WEAPONS );
  512.  
  513.     if ( !is_user_connected( pId ) && !HoldCBaseWeapon( pId ) && !g_iMaxPlayers )
  514.     {
  515.         return HAM_HANDLED;
  516.     }
  517.    
  518.     new fInReload = get_pdata_int( pEntity, 54, OFFSET_LINUX_WEAPONS );
  519.     new Float:flNextAttack = get_pdata_float( pId, m_flNextAttack, OFFSET_LINUX_WEAPONS );
  520.     new iClip  = get_pdata_int( pEntity, m_iClip, OFFSET_LINUX_WEAPONS );
  521.     new iAmmoType = 376 + get_pdata_int( pEntity, 49, OFFSET_LINUX_WEAPONS );
  522.     new iBpAmmo  = get_pdata_int( pId, iAmmoType, OFFSET_LINUX );
  523.    
  524.     if ( fInReload && flNextAttack <= 1.4 )
  525.     {
  526.         new j = min( CLIP__WEAPON  - iClip, iBpAmmo);
  527.    
  528.         set_pdata_int( pEntity, m_iClip, iClip + j, OFFSET_LINUX_WEAPONS );
  529.         set_pdata_int( pId, iAmmoType, iBpAmmo-j, OFFSET_LINUX );
  530.         set_pdata_int( pEntity, 54, 0, OFFSET_LINUX_WEAPONS );
  531.  
  532.         fInReload = 0;
  533.     }    
  534.    
  535.     return HAM_IGNORED;
  536. }
  537.  
  538. public CBaseWeapon__Reload_Pre(pEntity)
  539. {
  540.     if( !IsValidPrivateData( pEntity ) )
  541.     {
  542.         return HAM_HANDLED;
  543.     }
  544.  
  545.     static pId;
  546.  
  547.     pId = get_pdata_cbase( pEntity , OFFSET_WEAPONOWNER , OFFSET_LINUX_WEAPONS );
  548.  
  549.     if ( !is_user_connected( pId ) || !HoldCBaseWeapon( pId ) )
  550.     {
  551.         return HAM_IGNORED;
  552.     }
  553.    
  554.     static iClipExtra;
  555.     iClipExtra = CLIP__WEAPON ;
  556.    
  557.     g_TmpClip[pId] = -1;
  558.    
  559.     new iAmmoType = 376 + get_pdata_int( pEntity, 49, OFFSET_LINUX_WEAPONS );
  560.     new iBpAmmo = get_pdata_int( pId, iAmmoType, OFFSET_LINUX );
  561.     new iClip = get_pdata_int( pEntity, m_iClip, OFFSET_LINUX );
  562.    
  563.     if ( iBpAmmo <= 0 || iClip >= iClipExtra )
  564.     {
  565.        return HAM_SUPERCEDE;
  566.     }  
  567.    
  568.     g_TmpClip[pId] = iClip;
  569.    
  570.     return HAM_HANDLED;
  571. }
  572.  
  573. public CBaseWeapon__Reload_Post( pEntity )
  574. {
  575.     if( !IsValidPrivateData( pEntity ) )
  576.     {
  577.                 return HAM_HANDLED;
  578.     }
  579.  
  580.     static pId ; pId  = get_pdata_cbase( pEntity , OFFSET_WEAPONOWNER , OFFSET_LINUX_WEAPONS );
  581.    
  582.     if ( !HoldCBaseWeapon( pId ) )
  583.     {
  584.         return HAM_IGNORED;
  585.     }
  586.  
  587.     if (g_TmpClip[ pId ] == -1)
  588.     {
  589.         return HAM_IGNORED;
  590.     }
  591.    
  592.     set_pdata_float( pId, m_flNextAttack, RELOAD_TIME , OFFSET_LINUX);
  593.    
  594.     UTIL_SenwWeaponAnim(pId, RELOAD);
  595.  
  596.     return HAM_HANDLED;
  597. }
  598.  
  599. public CTouch_Rocket(pEntity, id)
  600. {
  601.     if( !pev_valid( pEntity ) )
  602.     {
  603.         return;
  604.     }
  605.  
  606.     static Float:flOrigin[ Coord_e ];
  607.     pev( pEntity, pev_origin, flOrigin );
  608.    
  609.     set_pev(pEntity, pev_movetype, MOVETYPE_NONE)
  610.     set_pev(pEntity, pev_solid, SOLID_NOT) 
  611.    
  612.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  613.     write_byte(TE_EXPLOSION)
  614.     write_coord_f(  flOrigin[x])
  615.     write_coord_f(  flOrigin[y])
  616.     write_coord_f( flOrigin[z] +50.0 )
  617.     write_short(g_iEffect[ EXPLODESPR ] )
  618.     write_byte( 50 )
  619.     write_byte( 30 )
  620.     write_byte( 0 )
  621.     message_end()
  622.  
  623.     message_begin(MSG_ALL, SVC_TEMPENTITY)
  624.     write_byte(TE_WORLDDECAL)
  625.     write_coord_f(flOrigin[x])
  626.     write_coord_f( flOrigin[y])
  627.     write_coord_f( flOrigin[z])
  628.     write_byte(g_iEffect[ DECALINDEX ] )
  629.     message_end()
  630.  
  631.     new pOwner = pev( pEntity, pev_owner );
  632.        
  633.     static pevVictim, Float:flDistance,Float:fDamage;
  634.                        
  635.     pevVictim  = -1;
  636.        
  637.     while( ( pevVictim = engfunc( EngFunc_FindEntityInSphere, pevVictim, flOrigin, ROCKET__RADIUS) ) != 0 )
  638.     {
  639.             if( !is_user_alive( pevVictim ) )
  640.                     continue;
  641.  
  642.             if( !zp_get_user_zombie( pevVictim ) )
  643.                 continue;
  644.  
  645.             flDistance = entity_range( pEntity, pevVictim );
  646.  
  647.             fDamage = UTIL_FloatRadius( ROCKET__DAMAGE, ROCKET__RADIUS , flDistance );
  648.  
  649.  
  650.             if( fDamage > 0.0 )
  651.             {
  652.                     ExecuteHamB( Ham_TakeDamage, pevVictim, pEntity, pOwner, fDamage, DMG_BULLET | DMG_ALWAYSGIB);
  653.  
  654.             }
  655.  
  656.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid("ScreenFade"), {0,0,0}, pevVictim )
  657.             write_short(1<<10)
  658.             write_short(1<<10)
  659.             write_short(0x0000)
  660.             write_byte(200)
  661.             write_byte(0)
  662.             write_byte(0)
  663.             write_byte(75)
  664.             message_end()
  665.     }
  666.        
  667.     engfunc( EngFunc_RemoveEntity, pEntity );
  668. }
  669.  
  670. Float:UTIL_FloatRadius( Float:flMaxAmount, Float:flRadius, Float:flDistance )
  671. {
  672.         return floatsub( flMaxAmount, floatmul( floatdiv( flMaxAmount, flRadius ), flDistance ) );
  673. }
  674.  
  675. public CThink_Rocket( iRocket )
  676. {
  677.     if(!pev_valid( iRocket ))
  678.     {
  679.         return
  680.     }  
  681.  
  682.     static Float:fOrigin[3]
  683.     pev( iRocket , pev_origin, fOrigin)
  684.        
  685.     message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  686.     write_byte( TE_SPRITE )
  687.     engfunc( EngFunc_WriteCoord, fOrigin[0] )
  688.     engfunc( EngFunc_WriteCoord, fOrigin[1] )
  689.     engfunc( EngFunc_WriteCoord, fOrigin[2] )
  690.     write_short( g_iEffect[ PUFFSPR ] )
  691.     write_byte( 6 )
  692.     write_byte( 255 )
  693.     message_end( )
  694.    
  695.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  696.     write_byte( TE_SPARKS )
  697.     engfunc( EngFunc_WriteCoord, fOrigin[0] )
  698.     engfunc( EngFunc_WriteCoord, fOrigin[1] )
  699.     engfunc( EngFunc_WriteCoord, fOrigin[2] )
  700.     message_end( )
  701.        
  702.     set_pev( iRocket , pev_nextthink, get_gametime( ) + 0.275 )
  703. }
  704.  
  705. stock UTIL__DropWeapons(id, bitsDropType)
  706. {
  707.     static weapons[32], num, i, weaponid
  708.     num = 0
  709.     get_user_weapons(id, weapons, num)
  710.    
  711.     for (i = 0; i < num; i++)
  712.     {
  713.         weaponid = weapons[i]
  714.        
  715.         if ((bitsDropType == DROP_PRIMARY && ((1<<weaponid) & WEAPONS_PRIMARY_BITSUM)) || (bitsDropType == DROP_SECONDARY && ((1<<weaponid) & WEAPONS_SECONDARY_BITSUM)))
  716.         {
  717.             static wname[32]
  718.             get_weaponname(weaponid, wname, charsmax(wname))
  719.            
  720.             engclient_cmd(id, "drop", wname)
  721.             cs_set_user_bpammo(id, weaponid, 0)
  722.         }
  723.     }
  724. }
  725.  
  726. stock fm_find_ent_by_owner(entity, const classname[], owner)
  727. {
  728.     while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) { /* keep looping */ }
  729.     return entity;
  730. }
  731.  
  732. stock UTIL_SenwWeaponAnim(const pPlayer, const Sequence)
  733. {
  734.     set_pev(pPlayer, pev_weaponanim, Sequence)
  735.    
  736.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = pPlayer)
  737.     write_byte(Sequence)
  738.     write_byte(pev(pPlayer, pev_body))
  739.     message_end()
  740. }
  741.  
  742. UTIL__WeaponList( pPlayer, const szWeapon[ ], int, int2, int3, int4, int5, int6, int7, int8 )
  743. {
  744.     message_begin( MSG_ONE, get_user_msgid( "WeaponList" ) , _, pPlayer );
  745.     write_string( szWeapon );
  746.     write_byte( int );
  747.     write_byte( int2);
  748.     write_byte( int3 );
  749.     write_byte( int4 );
  750.     write_byte( int5 );
  751.     write_byte( int6 );
  752.     write_byte( int7 );
  753.     write_byte( int8 );
  754.     message_end( );
  755. }
  756.  
  757. stock fm_give_item(id, const item[])
  758. {
  759.     static ent
  760.     ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  761.     if (!pev_valid(ent)) return 0;
  762.    
  763.     static Float:originF[3]
  764.     pev(id, pev_origin, originF)
  765.     set_pev(ent, pev_origin, originF)
  766.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  767.     dllfunc(DLLFunc_Spawn, ent)
  768.    
  769.     static save
  770.     save = pev(ent, pev_solid)
  771.     dllfunc(DLLFunc_Touch, ent, id)
  772.     if (pev(ent, pev_solid) != save)
  773.         return ent ;
  774.    
  775.     engfunc(EngFunc_RemoveEntity, ent)
  776.    
  777.     return -1;
  778. }
  779.  
  780. FX_BeamFollow ( const i_Ent, const i_Trail, const i_Life, const i_Width, const i_Red, const i_Green, const i_Blue, const i_Brightness )
  781. {
  782.     message_begin ( MSG_BROADCAST, SVC_TEMPENTITY );
  783.     write_byte ( TE_BEAMFOLLOW );
  784.     write_short ( i_Ent );          // --| Enntity.
  785.     write_short ( i_Trail );        // --| Model.
  786.     write_byte ( i_Life );          // --| Life.
  787.     write_byte ( i_Width );         // --| Width.
  788.     write_byte ( i_Red );           // --| Red color.
  789.     write_byte ( i_Green );         // --| Green color.
  790.     write_byte ( i_Blue );          // --| Blue color.
  791.     write_byte ( i_Brightness );    // --| Brightness.
  792.     message_end ();
  793. }
  794.  
  795. stock UTIL__SetCrosshairStatus( Player, eState:mState )
  796. {
  797.     static afFlags
  798.     afFlags = 0;
  799.    
  800.     if( mState == State_Hidden )
  801.         afFlags |= HIDE_CROSSHAIR;
  802.     else
  803.         afFlags &= ~HIDE_CROSSHAIR;
  804.    
  805.     message_begin( MSG_ONE, get_user_msgid( "HideWeapon" ), _, Player );
  806.     write_byte( afFlags );
  807.     message_end( );
  808. }
  809.  
  810.  
  811. PrecacheSoundsFromModel(const szModelPath[])
  812. {
  813.     new iFile;
  814.    
  815.     if ((iFile = fopen(szModelPath, "rt")))
  816.     {
  817.         new szSoundPath[64];
  818.        
  819.         new iNumSeq, iSeqIndex;
  820.         new iEvent, iNumEvents, iEventIndex;
  821.        
  822.         fseek(iFile, 164, SEEK_SET);
  823.         fread(iFile, iNumSeq, BLOCK_INT);
  824.         fread(iFile, iSeqIndex, BLOCK_INT);
  825.        
  826.         for (new k, i = 0; i < iNumSeq; i++)
  827.         {
  828.             fseek(iFile, iSeqIndex + 48 + 176 * i, SEEK_SET);
  829.             fread(iFile, iNumEvents, BLOCK_INT);
  830.             fread(iFile, iEventIndex, BLOCK_INT);
  831.             fseek(iFile, iEventIndex + 176 * i, SEEK_SET);
  832.  
  833.             for (k = 0; k < iNumEvents; k++)
  834.             {
  835.                 fseek(iFile, iEventIndex + 4 + 76 * k, SEEK_SET);
  836.                 fread(iFile, iEvent, BLOCK_INT);
  837.                 fseek(iFile, 4, SEEK_CUR);
  838.                
  839.                 if (iEvent != 5004)
  840.                 {
  841.                     continue;
  842.                 }
  843.  
  844.                 fread_blocks(iFile, szSoundPath, 64, BLOCK_CHAR);
  845.                
  846.                 if (strlen(szSoundPath))
  847.                 {
  848.                     strtolower(szSoundPath);
  849.                     precache_sound(szSoundPath);
  850.                 }
  851.             }
  852.         }
  853.     }
  854.    
  855.     fclose(iFile);
  856. }

User avatar
Z0uha1r_LK
Moderator
Moderator
Morocco
Posts: 385
Joined: 3 Years Ago
Location: Morocco
Has thanked: 121 times
Been thanked: 41 times
Age: 20
Contact:

#2

Post by Z0uha1r_LK » 4 Months Ago

We can't help you, Maybe you want this in Zombie Plague Mod, This forum is support only our Zombie Escape Mod

Locked

Who is online

Users browsing this forum: No registered users and 1 guest