Resolved Ze Blind Bomb Coding Help

Coding Help/Re-API Supported
Post Reply
johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

Ze Blind Bomb Coding Help

#1

Post by johnnysins2000 » 2 Years Ago

I was having some problems while converting this blind bomb for zm only

This blind bomb can blind humans for 5 sec if hit successfully!


Code:

The Zp Code
    1. /*
    2.     [ZP] Extra Item: Blind Bomb
    3.    
    4.         Credits :- Catastrophe
    5. */
    6.  
    7. #include < amxmodx >
    8. #include < fakemeta >
    9. #include < hamsandwich >
    10. #include < fun >
    11. #include < zombieplague >
    12.  
    13.  
    14. // Defines
    15. #define MAXPLAYERS     32
    16. #define FCVAR_FLAGS     ( FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED )
    17. #define OFFSET_PLAYER    41
    18. #define OFFSET_ACTIVE    373
    19. #define LINUX_DIFF    5
    20. #define NADE_TYPE_BLIND    8634
    21. #define FFADE_IN    0x0000
    22. #define REPEAT        0.2 // Time when next screen fade message is being sent
    23. #define TASK_AFFECT    666
    24. #define ID_AFFECT    ( taskid - TASK_AFFECT )
    25. #define OFFSET_FLAMMO    387
    26.  
    27. // Grenade cost
    28. #define GRENADE_COST    30
    29.  
    30. #define give_nemesis        // Выдавать ли гранату Nemesis
    31.  
    32. // Grenade models
    33. new const grenade_model_p [ ] = "models/p_flashbang.mdl"
    34. new const grenade_model [ ] = "models/zombie_plague/v_grenade_infect.mdl"
    35. new const grenade_model_w [ ] = "models/w_flashbang.mdl"
    36.  
    37. // Sounds
    38. new const explosion_sound [ ] = "zombie_plague/Strider_Buster_stick1.wav"
    39. new const purchase_sound [ ] = "items/gunpickup2.wav"
    40. new const purchase_sound2 [ ] = "items/9mmclip1.wav"
    41.  
    42. // Cached sprite indexes
    43. new m_iTrail, m_iRing
    44.  
    45. // Item ID
    46. new g_blind
    47.  
    48. // Player variables
    49. new g_NadeCount [ MAXPLAYERS+1 ]
    50.  
    51. // Message ID's
    52. new g_msgScreenFade, g_msgAmmoPickup
    53.  
    54. // CVAR pointers
    55. new cvar_nade_radius, cvar_duration
    56.  
    57. // Precache
    58. public plugin_precache ( )
    59. {
    60.     // Precache grenade models
    61.     precache_model ( grenade_model_p )
    62.     precache_model ( grenade_model )
    63.     precache_model ( grenade_model_w )
    64.    
    65.     // Precache sounds
    66.     precache_sound ( explosion_sound )
    67.     precache_sound ( purchase_sound )
    68.     precache_sound ( purchase_sound2 )
    69.    
    70.     // Precache sprites
    71.     m_iRing = precache_model ( "sprites/shockwave.spr" )
    72.     m_iTrail = precache_model ( "sprites/laserbeam.spr" )
    73. }
    74.  
    75. // Plugin initialization
    76. public plugin_init ( )
    77. {
    78.     // New plugin
    79.     register_plugin ( "[ZP] Extra Item: Blind Bomb", "1.1", "Catastrophe" )
    80.    
    81.     // New extra item
    82.     g_blind = zp_register_extra_item("Blind Bomb", 65, ZP_TEAM_ZOMBIE)
    83.    
    84.     // Events
    85.     register_event ( "HLTV", "Event_NewRound", "a", "1=0", "2=0" )
    86.     register_event ( "DeathMsg", "Event_DeathMsg", "a" )
    87.     register_event ( "CurWeapon", "Event_CurrentWeapon", "be", "1=1", "2=25" )
    88.    
    89.     // Forwards
    90.     register_forward ( FM_SetModel, "fw_SetModel" )
    91.     RegisterHam ( Ham_Think, "grenade", "fw_ThinkGrenade" )
    92.     register_forward ( FM_CmdStart, "fw_CmdStart" )
    93.    
    94.     // CVARs
    95.     cvar_nade_radius = register_cvar ( "zp_blind_nade_radius", "500" )
    96.     cvar_duration = register_cvar ( "zp_blind_nade_duration", "5" )
    97.    
    98.     // Messages    
    99.     g_msgScreenFade = get_user_msgid ( "ScreenFade" )
    100.     g_msgAmmoPickup = get_user_msgid ( "AmmoPickup" )
    101. }
    102.  
    103. // Someone decided to buy our an extra item
    104. public zp_extra_item_selected ( Player, Item )
    105. {
    106.     // This is our grenade
    107.     if ( Item == g_blind )
    108.     {
    109.         // Player already have it
    110.         if ( g_NadeCount [ Player ] >= 1 )
    111.         {
    112.             // Increase nade count
    113.             g_NadeCount [ Player ]++
    114.            
    115.             // Increase bp ammo
    116.             set_pdata_int ( Player, OFFSET_FLAMMO, get_pdata_int ( Player, OFFSET_FLAMMO, LINUX_DIFF )+1, LINUX_DIFF )
    117.            
    118.             // Ammo pickup
    119.             message_begin ( MSG_ONE, g_msgAmmoPickup, _, Player )
    120.             write_byte ( 11 ) // Ammo ID
    121.             write_byte ( 1 ) // Ammo amount
    122.             message_end ( )
    123.            
    124.             // Emit sound
    125.             emit_sound ( Player, CHAN_WEAPON, purchase_sound2, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
    126.         }
    127.         else // 0 grenades
    128.         {
    129.             // Increase nade count
    130.             g_NadeCount [ Player ] = 1
    131.            
    132.             // Give him flashbang
    133.             give_item ( Player, "weapon_flashbang" )
    134.            
    135.             // Play purchase sound
    136.             client_cmd ( Player, "spk %s", purchase_sound )    
    137.         }
    138.     }
    139.     return PLUGIN_CONTINUE
    140. }
    141.    
    142. // Someone was infected    
    143. public zp_user_infected_post ( Player, Infector )
    144. {
    145. #if defined give_nemesis
    146.     if ( zp_get_user_nemesis(Player) && zp_is_nemesis_round())
    147.     {
    148.         g_NadeCount [ Player ] = 1
    149.         give_item ( Player, "weapon_flashbang" )
    150.     }
    151. #endif
    152.  
    153.     // We were affected by Blind Bomb
    154.     if ( task_exists ( Player+TASK_AFFECT ) )
    155.         remove_task ( Player+TASK_AFFECT )
    156. }    
    157.  
    158. // Someone were turned back to human
    159. public zp_user_humanized_post ( Player, Survivor )
    160. {
    161.     // We dont' have nade anymore
    162.     if ( g_NadeCount [ Player ] )
    163.     {
    164.         g_NadeCount [ Player ] = 0
    165.     }
    166. }
    167.  
    168. // New round started
    169. public Event_NewRound ( )
    170. {
    171.     // Reset nade count
    172.     arrayset ( g_NadeCount, false, 33 )
    173.  
    174.     // And they aren't affected by conc.grenade
    175.     remove_task ( TASK_AFFECT )    
    176. }
    177.  
    178. // Someone died
    179. public Event_DeathMsg ( )
    180. {
    181.     // Get victim
    182.     new victim = read_data ( 2 )
    183.    
    184.     // Some people had error without this check
    185.     if ( !is_user_connected ( victim ) )
    186.         return
    187.  
    188.     // Remove hallucinations
    189.     remove_task ( victim+TASK_AFFECT )
    190.  
    191.     // Reset nade count    
    192.     g_NadeCount [ victim ] = 0
    193. }
    194.  
    195. // Current weapon player is holding
    196. public Event_CurrentWeapon ( Player )
    197. {
    198.     // Dead or not zombie or don't have conc. grenade
    199.     if ( !is_user_alive ( Player ) || !zp_get_user_zombie ( Player ) || g_NadeCount [ Player ] <= 0 )
    200.         return PLUGIN_CONTINUE
    201.    
    202.     // Replace flashbang model with our ones
    203.     set_pev ( Player, pev_viewmodel2, grenade_model )
    204.     set_pev ( Player, pev_weaponmodel2, grenade_model_p )
    205.    
    206.     return PLUGIN_CONTINUE
    207. }
    208.  
    209. // Set model
    210. public fw_SetModel ( Entity, const Model [ ] )
    211. {
    212.     // Prevent invalid ent messages
    213.     if ( !pev_valid ( Entity ) )
    214.         return FMRES_IGNORED
    215.        
    216.     // Grenade not thrown yet    
    217.     if ( pev ( Entity, pev_dmgtime ) == 0.0 )
    218.         return FMRES_IGNORED
    219.        
    220.     // We are throwing Blind Bomb    
    221.     if ( g_NadeCount [ pev ( Entity, pev_owner ) ] >= 1 && equal ( Model [7 ], "w_fl", 4 ) )
    222.     {
    223.         //Draw trail
    224.         message_begin ( MSG_BROADCAST, SVC_TEMPENTITY )
    225.         write_byte ( TE_BEAMFOLLOW ) // Temp entity ID
    226.         write_short ( Entity ) // Entity to follow
    227.         write_short ( m_iTrail ) // Sprite index
    228.         write_byte ( 10 ) // Life
    229.         write_byte ( 10 ) // Line width
    230.         write_byte ( 255 ) // Red amount
    231.         write_byte ( 255 ) // Blue amount
    232.         write_byte ( 0 ) // Blue amount
    233.         write_byte ( 255 ) // Alpha
    234.         message_end ( )
    235.        
    236.         // Set grenade entity
    237.         set_pev ( Entity, pev_flTimeStepSound, NADE_TYPE_BLIND )
    238.        
    239.         // Decrease nade count
    240.         g_NadeCount [ pev ( Entity, pev_owner ) ]--
    241.        
    242.         // Set world model
    243.         engfunc ( EngFunc_SetModel, Entity, grenade_model_w )
    244.         return FMRES_SUPERCEDE
    245.     }
    246.     return FMRES_IGNORED
    247. }
    248.  
    249. // Grenade is getting to explode
    250. public fw_ThinkGrenade ( Entity )
    251. {
    252.     // Prevent invalid ent messages
    253.     if ( !pev_valid ( Entity ) )
    254.         return HAM_IGNORED
    255.    
    256.     // Get damage time
    257.     static Float:dmg_time
    258.     pev ( Entity, pev_dmgtime, dmg_time )
    259.    
    260.     // maybe it is time to go off
    261.     if ( dmg_time > get_gametime ( ) )
    262.         return HAM_IGNORED
    263.        
    264.     // Our grenade    
    265.     if ( pev ( Entity, pev_flTimeStepSound ) == NADE_TYPE_BLIND )
    266.     {
    267.         // Force to explode
    268.         blind_explode ( Entity )
    269.         return HAM_SUPERCEDE
    270.     }
    271.     return HAM_IGNORED
    272. }
    273.  
    274. // Command start
    275. public fw_CmdStart ( Player, UC_Handle, Seed )
    276. {
    277.     // Dead, zombie or not affected
    278.     if ( !is_user_alive ( Player ) || zp_get_user_zombie ( Player ) || !task_exists ( Player+TASK_AFFECT ) )
    279.         return FMRES_IGNORED
    280.    
    281.     // Get buttons
    282.     new buttons = get_uc ( UC_Handle, UC_Buttons )
    283.    
    284.     // We are firing
    285.     if ( buttons & IN_ATTACK )
    286.     {
    287.         // We are holding an active weapon
    288.         if ( get_pdata_cbase ( Player, OFFSET_ACTIVE, LINUX_DIFF ) )
    289.         {
    290.             // New recoil
    291.             set_pev ( Player, pev_punchangle, Float:{3.0, 3.0, 4.0} )
    292.         }
    293.     }
    294.     return FMRES_HANDLED
    295. }
    296.  
    297. // Grenade explode
    298. public blind_explode ( Entity )
    299. {
    300.     // Invalid entity ?
    301.     if ( !pev_valid ( Entity  ) )
    302.         return
    303.    
    304.     // Get entities origin
    305.     static Float:origin [ 3 ]
    306.     pev ( Entity, pev_origin, origin )
    307.    
    308.     // Draw ring
    309.     UTIL_DrawRing (origin )
    310.    
    311.     // Explosion sound
    312.     emit_sound ( Entity, CHAN_WEAPON, explosion_sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
    313.    
    314.     // Collisions
    315.     static victim
    316.     victim = -1
    317.    
    318.     // Find radius
    319.     static Float:radius
    320.     radius = get_pcvar_float ( cvar_nade_radius )
    321.    
    322.     // Find all players in a radius
    323.     while ( ( victim = engfunc ( EngFunc_FindEntityInSphere, victim, origin, radius ) ) != 0 )
    324.     {
    325.         // Dead or zombie
    326.         if ( !is_user_alive ( victim ) || zp_get_user_zombie ( victim ) )
    327.             continue
    328.  
    329.         // Victim isn't affected yet    
    330.         if ( !task_exists ( victim+TASK_AFFECT ) )
    331.         {
    332.             // Get duration
    333.             new duration = get_pcvar_num ( cvar_duration )
    334.            
    335.             // Calculate affect times
    336.             new affect_count = floatround ( duration / REPEAT )
    337.            
    338.             // Continiously affect them
    339.             set_task ( REPEAT, "affect_victim", victim+TASK_AFFECT, _, _, "a", affect_count )
    340.         }
    341.     }
    342.    
    343.     // Remove entity from ground
    344.     engfunc ( EngFunc_RemoveEntity, Entity )
    345. }
    346.  
    347. // We are going to affect you
    348. public affect_victim ( taskid )
    349. {
    350.     // Dead
    351.     if ( !is_user_alive ( ID_AFFECT ) )
    352.         return;
    353.    
    354.     // Make a screen fade
    355.     ScreenFade(ID_AFFECT, get_pcvar_float( cvar_duration ), 0, 0, 0, 255)
    356.    
    357.     // Remove task after all   
    358.     remove_task( ID_AFFECT )
    359. }
    360.  
    361. // Draw explosion ring ( from zombie_plague40.sma )
    362. stock UTIL_DrawRing ( const Float:origin [ 3 ] )
    363. {
    364.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
    365.     write_byte(TE_BEAMCYLINDER) // TE id
    366.     engfunc(EngFunc_WriteCoord, origin[0]) // x
    367.     engfunc(EngFunc_WriteCoord, origin[1]) // y
    368.     engfunc(EngFunc_WriteCoord, origin[2]) // z
    369.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
    370.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
    371.     engfunc(EngFunc_WriteCoord, origin[2]+555.0) // z axis
    372.     write_short( m_iRing ) // sprite
    373.     write_byte(0) // startframe
    374.     write_byte(0) // framerate
    375.     write_byte(4) // life
    376.     write_byte(60) // width
    377.     write_byte(0) // noise
    378.     write_byte(200) // red
    379.     write_byte(200) // green
    380.     write_byte(200) // blue
    381.     write_byte(200) // brightness
    382.     write_byte(0) // speed
    383.     message_end()
    384. }
    385.  
    386. // ScreenFade
    387. stock ScreenFade(plr, Float:fDuration, red, green, blue, alpha)
    388. {
    389.     new i = plr ? plr : get_maxplayers();
    390.     if( !i )
    391.     {
    392.         return 0;
    393.     }
    394.  
    395.     message_begin(plr ? MSG_ONE : MSG_ALL, g_msgScreenFade, {0, 0, 0}, plr);
    396.     write_short(floatround(4096.0 * fDuration, floatround_round));
    397.     write_short(floatround(4096.0 * fDuration, floatround_round));
    398.     write_short(4096);
    399.     write_byte(red);
    400.     write_byte(green);
    401.     write_byte(blue);
    402.     write_byte(alpha);
    403.     message_end();
    404.    
    405.     return 1;
    406. }
    407.  
    408. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
    409. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
    410. */  



And What i have done :-

I Hhave little bit messed up :/
    1. /*#include <zombie_escape>
    2. #include <cstrike>
    3.  
    4. // Defines
    5. #define MAXPLAYERS     32
    6. #define FCVAR_FLAGS     ( FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED )
    7. #define OFFSET_PLAYER    41
    8. #define OFFSET_ACTIVE    373
    9. #define LINUX_DIFF    5
    10. #define NADE_TYPE_BLIND    8634
    11. #define FFADE_IN    0x0000
    12. #define REPEAT        0.2 // Time when next screen fade message is being sent
    13. #define TASK_AFFECT    666
    14. #define ID_AFFECT    ( taskid - TASK_AFFECT )
    15. #define OFFSET_FLAMMO    387
    16.  
    17. // Grenade models
    18. new const grenade_model_p [ ] = "models/zombie_escape/p_blind_bomb.mdl"
    19. new const grenade_model [ ] = "models/zombie_escape/v_blind_bomb.mdl"
    20. new const grenade_model_w [ ] = "models/zombie_escape/w_blind_bomb.mdl"
    21.  
    22. // Sounds
    23. new const explosion_sound [ ] = "zombie_escape/explode.wav"
    24. new const purchase_sound [ ] = "items/gunpickup2.wav"
    25. new const purchase_sound2 [ ] = "items/9mmclip1.wav"
    26.  
    27. // Cached sprite indexes
    28. new m_iTrail, m_iRing
    29.  
    30. // Item ID
    31. new g_iItemID , g_iLimit[33]
    32.  
    33. // Player variables
    34. new g_NadeCount [ MAXPLAYERS+1 ]
    35.  
    36. // Message ID's
    37. new g_msgScreenFade, g_msgAmmoPickup
    38.  
    39. // CVAR pointers
    40. new cvar_nade_radius, cvar_duration , cvar_limit
    41.  
    42. // Precache
    43. public plugin_precache ( )
    44. {
    45.     // Precache grenade models
    46.     precache_model ( grenade_model_p )
    47.     precache_model ( grenade_model )
    48.     precache_model ( grenade_model_w )
    49.    
    50.     // Precache sounds
    51.     precache_sound ( explosion_sound )
    52.     precache_sound ( purchase_sound )
    53.     precache_sound ( purchase_sound2 )
    54.    
    55.     // Precache sprites
    56.     m_iRing = precache_model ( "sprites/shockwave.spr" )
    57.     m_iTrail = precache_model ( "sprites/laserbeam.spr" )
    58. }
    59.  
    60. // Plugin initialization
    61. public plugin_init ( )
    62. {
    63.     // New plugin
    64.     register_plugin ( "[ZE] Extra Item: Blind Bomb", "1.1", "Catastrophe" )
    65.     g_iItemID = ze_register_item("Blind Bomb", 30)
    66.    
    67.     // Events
    68.     register_event ( "HLTV", "Event_NewRound", "a", "1=0", "2=0" )
    69.     register_event ( "DeathMsg", "Event_DeathMsg", "a" )
    70.     register_event ( "CurWeapon", "Event_CurrentWeapon", "be", "1=1", "2=25" )
    71.    
    72.     // Forwards
    73.     register_forward ( FM_SetModel, "fw_SetModel" )
    74.     RegisterHam ( Ham_Think, "grenade", "fw_ThinkGrenade" )
    75.     register_forward ( FM_CmdStart, "fw_CmdStart" )
    76.    
    77.     // CVARs
    78.     cvar_nade_radius = register_cvar ( "ze_blind_nade_radius", "500" )
    79.     cvar_duration = register_cvar ( "ze_blind_nade_duration", "5" )
    80.     cvar_limit = register_cvar("ze_BlindBomb_limit", "3")
    81.    
    82.     // Messages    
    83.     g_msgScreenFade = get_user_msgid ( "ScreenFade" )
    84.     g_msgAmmoPickup = get_user_msgid ( "AmmoPickup" )
    85. }
    86.  
    87. // Someone decided to buy our an extra item
    88. public  ze_select_item_pre(id, itemid)
    89. {
    90.     // Return Available and we will block it in Post, So it dosen't affect other plugins
    91.     if (itemid != g_iItemID)
    92.         return ZE_ITEM_AVAILABLE
    93.    
    94.     // Available for Zombies only, So don't show it for Humans
    95.     if (!ze_is_user_zombie(id))
    96.         return ZE_ITEM_DONT_SHOW  
    97.    
    98.     // If he bought it more than 3 so return that it's not Available
    99.     if (g_iLimit[id] >= get_pcvar_num(cvar_limit))  
    100.         return ZE_ITEM_UNAVAILABLE
    101.    
    102.     return ZE_ITEM_AVAILABLE
    103. }
    104.  
    105. public  ze_select_item_post(id, itemid)
    106. {
    107.     // This is not our item, Block it here and don't execute the blew code
    108.     if (itemid != g_iItemID)
    109.         return
    110.      
    111.     g_iLimit[id]++
    112.     give_item(player, "weapon_flashbang")
    113.     client_print(id, print_chat, "[ZE] You Have Bought Blind Bomb.Now U Can Blind Humans For 5 Sec")
    114. }
    115.    
    116. // Someone was infected    
    117. public ze_user_infected ( Player, Infector )
    118. {
    119.     // We were affected by Blind Bomb
    120.     if ( task_exists ( Player+TASK_AFFECT ) )
    121.         remove_task ( Player+TASK_AFFECT )
    122. }    
    123.  
    124. // Someone were turned back to human
    125. public ze_user_humanized ( Player, Survivor )
    126. {
    127.     // We dont' have nade anymore
    128.     if ( g_NadeCount [ Player ] )
    129.     {
    130.         g_NadeCount [ Player ] = 0
    131.     }
    132. }
    133.  
    134. // New round started
    135. public Event_NewRound ( )
    136. {
    137.     // Reset nade count
    138.     arrayset ( g_NadeCount, false, 33 )
    139.  
    140.     // And they aren't affected by conc.grenade
    141.     remove_task ( TASK_AFFECT )    
    142. }
    143.  
    144. // Someone died
    145. public Event_DeathMsg ( )
    146. {
    147.     // Get victim
    148.     new victim = read_data ( 2 )
    149.    
    150.     // Some people had error without this check
    151.     if ( !is_user_connected ( victim ) )
    152.         return
    153.  
    154.     // Remove hallucinations
    155.     remove_task ( victim+TASK_AFFECT )
    156.  
    157.     // Reset nade count    
    158.     g_NadeCount [ victim ] = 0
    159. }
    160.  
    161. // Current weapon player is holding
    162. public Event_CurrentWeapon ( Player )
    163. {
    164.     // Dead or not zombie or don't have conc. grenade
    165.     if ( !is_user_alive ( Player ) || !zp_get_user_zombie ( Player ) || g_NadeCount [ Player ] <= 0 )
    166.         return PLUGIN_CONTINUE
    167.    
    168.     // Replace flashbang model with our ones
    169.     set_pev ( Player, pev_viewmodel2, grenade_model )
    170.     set_pev ( Player, pev_weaponmodel2, grenade_model_p )
    171.    
    172.     return PLUGIN_CONTINUE
    173. }
    174.  
    175. // Set model
    176. public fw_SetModel ( Entity, const Model [ ] )
    177. {
    178.     // Prevent invalid ent messages
    179.     if ( !pev_valid ( Entity ) )
    180.         return FMRES_IGNORED
    181.        
    182.     // Grenade not thrown yet    
    183.     if ( pev ( Entity, pev_dmgtime ) == 0.0 )
    184.         return FMRES_IGNORED
    185.        
    186.     // We are throwing Blind Bomb    
    187.     if ( g_NadeCount [ pev ( Entity, pev_owner ) ] >= 1 && equal ( Model [7 ], "w_fl", 4 ) )
    188.     {
    189.         //Draw trail
    190.         message_begin ( MSG_BROADCAST, SVC_TEMPENTITY )
    191.         write_byte ( TE_BEAMFOLLOW ) // Temp entity ID
    192.         write_short ( Entity ) // Entity to follow
    193.         write_short ( m_iTrail ) // Sprite index
    194.         write_byte ( 10 ) // Life
    195.         write_byte ( 10 ) // Line width
    196.         write_byte ( 255 ) // Red amount
    197.         write_byte ( 255 ) // Blue amount
    198.         write_byte ( 0 ) // Blue amount
    199.         write_byte ( 255 ) // Alpha
    200.         message_end ( )
    201.        
    202.         // Set grenade entity
    203.         set_pev ( Entity, pev_flTimeStepSound, NADE_TYPE_BLIND )
    204.        
    205.         // Decrease nade count
    206.         g_NadeCount [ pev ( Entity, pev_owner ) ]--
    207.        
    208.         // Set world model
    209.         engfunc ( EngFunc_SetModel, Entity, grenade_model_w )
    210.         return FMRES_SUPERCEDE
    211.     }
    212.     return FMRES_IGNORED
    213. }
    214.  
    215. // Grenade is getting to explode
    216. public fw_ThinkGrenade ( Entity )
    217. {
    218.     // Prevent invalid ent messages
    219.     if ( !pev_valid ( Entity ) )
    220.         return HAM_IGNORED
    221.    
    222.     // Get damage time
    223.     static Float:dmg_time
    224.     pev ( Entity, pev_dmgtime, dmg_time )
    225.    
    226.     // maybe it is time to go off
    227.     if ( dmg_time > get_gametime ( ) )
    228.         return HAM_IGNORED
    229.        
    230.     // Our grenade    
    231.     if ( pev ( Entity, pev_flTimeStepSound ) == NADE_TYPE_BLIND )
    232.     {
    233.         // Force to explode
    234.         blind_explode ( Entity )
    235.         return HAM_SUPERCEDE
    236.     }
    237.     return HAM_IGNORED
    238. }
    239.  
    240. // Command start
    241. public fw_CmdStart ( Player, UC_Handle, Seed )
    242. {
    243.     // Dead, zombie or not affected
    244.     if ( !is_user_alive ( Player ) || zp_get_user_zombie ( Player ) || !task_exists ( Player+TASK_AFFECT ) )
    245.         return FMRES_IGNORED
    246.    
    247.     // Get buttons
    248.     new buttons = get_uc ( UC_Handle, UC_Buttons )
    249.    
    250.     // We are firing
    251.     if ( buttons & IN_ATTACK )
    252.     {
    253.         // We are holding an active weapon
    254.         if ( get_pdata_cbase ( Player, OFFSET_ACTIVE, LINUX_DIFF ) )
    255.         {
    256.             // New recoil
    257.             set_pev ( Player, pev_punchangle, Float:{3.0, 3.0, 4.0} )
    258.         }
    259.     }
    260.     return FMRES_HANDLED
    261. }
    262.  
    263. // Grenade explode
    264. public blind_explode ( Entity )
    265. {
    266.     // Invalid entity ?
    267.     if ( !pev_valid ( Entity  ) )
    268.         return
    269.    
    270.     // Get entities origin
    271.     static Float:origin [ 3 ]
    272.     pev ( Entity, pev_origin, origin )
    273.    
    274.     // Draw ring
    275.     UTIL_DrawRing (origin )
    276.    
    277.     // Explosion sound
    278.     emit_sound ( Entity, CHAN_WEAPON, explosion_sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
    279.    
    280.     // Collisions
    281.     static victim
    282.     victim = -1
    283.    
    284.     // Find radius
    285.     static Float:radius
    286.     radius = get_pcvar_float ( cvar_nade_radius )
    287.    
    288.     // Find all players in a radius
    289.     while ( ( victim = engfunc ( EngFunc_FindEntityInSphere, victim, origin, radius ) ) != 0 )
    290.     {
    291.         // Dead or zombie
    292.         if ( !is_user_alive ( victim ) || zp_get_user_zombie ( victim ) )
    293.             continue
    294.  
    295.         // Victim isn't affected yet    
    296.         if ( !task_exists ( victim+TASK_AFFECT ) )
    297.         {
    298.             // Get duration
    299.             new duration = get_pcvar_num ( cvar_duration )
    300.            
    301.             // Calculate affect times
    302.             new affect_count = floatround ( duration / REPEAT )
    303.            
    304.             // Continiously affect them
    305.             set_task ( REPEAT, "affect_victim", victim+TASK_AFFECT, _, _, "a", affect_count )
    306.         }
    307.     }
    308.    
    309.     // Remove entity from ground
    310.     engfunc ( EngFunc_RemoveEntity, Entity )
    311. }
    312.  
    313. // We are going to affect you
    314. public affect_victim ( taskid )
    315. {
    316.     // Dead
    317.     if ( !is_user_alive ( ID_AFFECT ) )
    318.         return;
    319.    
    320.     // Make a screen fade
    321.     ScreenFade(ID_AFFECT, get_pcvar_float( cvar_duration ), 0, 0, 0, 255)
    322.    
    323.     // Remove task after all   
    324.     remove_task( ID_AFFECT )
    325. }
    326.  
    327. // Draw explosion ring ( from zombie_plague40.sma )
    328. stock UTIL_DrawRing ( const Float:origin [ 3 ] )
    329. {
    330.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
    331.     write_byte(TE_BEAMCYLINDER) // TE id
    332.     engfunc(EngFunc_WriteCoord, origin[0]) // x
    333.     engfunc(EngFunc_WriteCoord, origin[1]) // y
    334.     engfunc(EngFunc_WriteCoord, origin[2]) // z
    335.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
    336.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
    337.     engfunc(EngFunc_WriteCoord, origin[2]+555.0) // z axis
    338.     write_short( m_iRing ) // sprite
    339.     write_byte(0) // startframe
    340.     write_byte(0) // framerate
    341.     write_byte(4) // life
    342.     write_byte(60) // width
    343.     write_byte(0) // noise
    344.     write_byte(200) // red
    345.     write_byte(200) // green
    346.     write_byte(200) // blue
    347.     write_byte(200) // brightness
    348.     write_byte(0) // speed
    349.     message_end()
    350. }
    351.  
    352. // ScreenFade
    353. stock ScreenFade(plr, Float:fDuration, red, green, blue, alpha)
    354. {
    355.     new i = plr ? plr : get_maxplayers();
    356.     if( !i )
    357.     {
    358.         return 0;
    359.     }
    360.  
    361.     message_begin(plr ? MSG_ONE : MSG_ALL, g_msgScreenFade, {0, 0, 0}, plr);
    362.     write_short(floatround(4096.0 * fDuration, floatround_round));
    363.     write_short(floatround(4096.0 * fDuration, floatround_round));
    364.     write_short(4096);
    365.     write_byte(red);
    366.     write_byte(green);
    367.     write_byte(blue);
    368.     write_byte(alpha);
    369.     message_end();
    370.    
    371.     return 1;
    372. }
    373.  
Nobody Is That Busy If They Make Time :roll:

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#2

Post by Raheem » 2 Years Ago

Here it's converted:
    1. /*
    2.     [ZE] Extra Item: Blind Bomb
    3.    
    4.         Credits :- Catastrophe
    5. */
    6.  
    7. #include < zombie_escape >
    8.  
    9. // Defines
    10. #define MAXPLAYERS     32
    11. #define FCVAR_FLAGS     ( FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED )
    12. #define OFFSET_PLAYER    41
    13. #define OFFSET_ACTIVE    373
    14. #define LINUX_DIFF    5
    15. #define NADE_TYPE_BLIND    8634
    16. #define FFADE_IN    0x0000
    17. #define REPEAT        0.2 // Time when next screen fade message is being sent
    18. #define TASK_AFFECT    666
    19. #define ID_AFFECT    ( taskid - TASK_AFFECT )
    20. #define OFFSET_FLAMMO    387
    21.  
    22. // Grenade cost
    23. #define GRENADE_COST    30
    24.  
    25. // Grenade models
    26. new const grenade_model_p [ ] = "models/p_flashbang.mdl"
    27. new const grenade_model [ ] = "models/zombie_plague/v_grenade_infect.mdl"
    28. new const grenade_model_w [ ] = "models/w_flashbang.mdl"
    29.  
    30. // Sounds
    31. new const explosion_sound [ ] = "zombie_plague/Strider_Buster_stick1.wav"
    32. new const purchase_sound [ ] = "items/gunpickup2.wav"
    33. new const purchase_sound2 [ ] = "items/9mmclip1.wav"
    34.  
    35. // Cached sprite indexes
    36. new m_iTrail, m_iRing
    37.  
    38. // Item ID
    39. new g_blind
    40.  
    41. // Player variables
    42. new g_NadeCount [ MAXPLAYERS+1 ]
    43.  
    44. // Message ID's
    45. new g_msgScreenFade, g_msgAmmoPickup
    46.  
    47. // CVAR pointers
    48. new cvar_nade_radius, cvar_duration
    49.  
    50. // Precache
    51. public plugin_precache ( )
    52. {
    53.     // Precache grenade models
    54.     precache_model ( grenade_model_p )
    55.     precache_model ( grenade_model )
    56.     precache_model ( grenade_model_w )
    57.    
    58.     // Precache sounds
    59.     precache_sound ( explosion_sound )
    60.     precache_sound ( purchase_sound )
    61.     precache_sound ( purchase_sound2 )
    62.    
    63.     // Precache sprites
    64.     m_iRing = precache_model ( "sprites/shockwave.spr" )
    65.     m_iTrail = precache_model ( "sprites/laserbeam.spr" )
    66. }
    67.  
    68. // Plugin initialization
    69. public plugin_init ( )
    70. {
    71.     // New plugin
    72.     register_plugin ( "[ZE] Extra Item: Blind Bomb", "1.1", "Catastrophe" )
    73.    
    74.     // New extra item
    75.     g_blind = ze_register_item("Blind Bomb", 65)
    76.    
    77.     // Events
    78.     register_event ( "HLTV", "Event_NewRound", "a", "1=0", "2=0" )
    79.     register_event ( "DeathMsg", "Event_DeathMsg", "a" )
    80.     register_event ( "CurWeapon", "Event_CurrentWeapon", "be", "1=1", "2=25" )
    81.    
    82.     // Forwards
    83.     register_forward ( FM_SetModel, "fw_SetModel" )
    84.     RegisterHam ( Ham_Think, "grenade", "fw_ThinkGrenade" )
    85.     register_forward ( FM_CmdStart, "fw_CmdStart" )
    86.    
    87.     // CVARs
    88.     cvar_nade_radius = register_cvar ( "ze_blind_nade_radius", "500" )
    89.     cvar_duration = register_cvar ( "ze_blind_nade_duration", "5" )
    90.    
    91.     // Messages    
    92.     g_msgScreenFade = get_user_msgid ( "ScreenFade" )
    93.     g_msgAmmoPickup = get_user_msgid ( "AmmoPickup" )
    94. }
    95.  
    96. public ze_select_item_pre(id, itemid)
    97. {
    98.     // Return Available and we will block it in Post, So it dosen't affect other plugins
    99.     if (itemid != g_blind)
    100.         return ZE_ITEM_AVAILABLE
    101.    
    102.     // Available for Zombies only, So don't show it for Humans
    103.     if (!ze_is_user_zombie(id))
    104.         return ZE_ITEM_DONT_SHOW
    105.    
    106.     return ZE_ITEM_AVAILABLE
    107. }
    108.  
    109. public ze_select_item_post(Player, itemid)
    110. {
    111.     if (itemid != g_blind)
    112.         return
    113.    
    114.    
    115.     // Player already have it
    116.     if ( g_NadeCount [ Player ] >= 1 )
    117.     {
    118.         // Increase nade count
    119.         g_NadeCount [ Player ]++
    120.            
    121.         // Increase bp ammo
    122.         set_pdata_int ( Player, OFFSET_FLAMMO, get_pdata_int ( Player, OFFSET_FLAMMO, LINUX_DIFF )+1, LINUX_DIFF )
    123.            
    124.         // Ammo pickup
    125.         message_begin ( MSG_ONE, g_msgAmmoPickup, _, Player )
    126.         write_byte ( 11 ) // Ammo ID
    127.         write_byte ( 1 ) // Ammo amount
    128.         message_end ( )
    129.            
    130.         // Emit sound
    131.         emit_sound ( Player, CHAN_WEAPON, purchase_sound2, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
    132.     }
    133.     else // 0 grenades
    134.     {
    135.         // Increase nade count
    136.         g_NadeCount [ Player ] = 1
    137.            
    138.         // Give him flashbang
    139.         give_item ( Player, "weapon_flashbang" )
    140.            
    141.         // Play purchase sound
    142.         client_cmd ( Player, "spk %s", purchase_sound )    
    143.     }
    144. }
    145.  
    146. // Someone was infected    
    147. public ze_user_infected ( Player, Infector )
    148. {
    149.     // We were affected by Blind Bomb
    150.     if ( task_exists ( Player+TASK_AFFECT ) )
    151.         remove_task ( Player+TASK_AFFECT )
    152. }    
    153.  
    154. // Someone were turned back to human
    155. public ze_user_humanized ( Player )
    156. {
    157.     // We dont' have nade anymore
    158.     if ( g_NadeCount [ Player ] )
    159.     {
    160.         g_NadeCount [ Player ] = 0
    161.     }
    162. }
    163.  
    164. // New round started
    165. public Event_NewRound ( )
    166. {
    167.     // Reset nade count
    168.     arrayset ( g_NadeCount, false, 33 )
    169.  
    170.     // And they aren't affected by conc.grenade
    171.     remove_task ( TASK_AFFECT )    
    172. }
    173.  
    174. // Someone died
    175. public Event_DeathMsg ( )
    176. {
    177.     // Get victim
    178.     new victim = read_data ( 2 )
    179.    
    180.     // Some people had error without this check
    181.     if ( !is_user_connected ( victim ) )
    182.         return
    183.  
    184.     // Remove hallucinations
    185.     remove_task ( victim+TASK_AFFECT )
    186.  
    187.     // Reset nade count    
    188.     g_NadeCount [ victim ] = 0
    189. }
    190.  
    191. // Current weapon player is holding
    192. public Event_CurrentWeapon ( Player )
    193. {
    194.     // Dead or not zombie or don't have conc. grenade
    195.     if ( !is_user_alive ( Player ) || !ze_is_user_zombie ( Player ) || g_NadeCount [ Player ] <= 0 )
    196.         return PLUGIN_CONTINUE
    197.    
    198.     // Replace flashbang model with our ones
    199.     set_pev ( Player, pev_viewmodel2, grenade_model )
    200.     set_pev ( Player, pev_weaponmodel2, grenade_model_p )
    201.    
    202.     return PLUGIN_CONTINUE
    203. }
    204.  
    205. // Set model
    206. public fw_SetModel ( Entity, const Model [ ] )
    207. {
    208.     // Prevent invalid ent messages
    209.     if ( !pev_valid ( Entity ) )
    210.         return FMRES_IGNORED
    211.        
    212.     // Grenade not thrown yet    
    213.     if ( pev ( Entity, pev_dmgtime ) == 0.0 )
    214.         return FMRES_IGNORED
    215.        
    216.     // We are throwing Blind Bomb    
    217.     if ( g_NadeCount [ pev ( Entity, pev_owner ) ] >= 1 && equal ( Model [7 ], "w_fl", 4 ) )
    218.     {
    219.         //Draw trail
    220.         message_begin ( MSG_BROADCAST, SVC_TEMPENTITY )
    221.         write_byte ( TE_BEAMFOLLOW ) // Temp entity ID
    222.         write_short ( Entity ) // Entity to follow
    223.         write_short ( m_iTrail ) // Sprite index
    224.         write_byte ( 10 ) // Life
    225.         write_byte ( 10 ) // Line width
    226.         write_byte ( 255 ) // Red amount
    227.         write_byte ( 255 ) // Blue amount
    228.         write_byte ( 0 ) // Blue amount
    229.         write_byte ( 255 ) // Alpha
    230.         message_end ( )
    231.        
    232.         // Set grenade entity
    233.         set_pev ( Entity, pev_flTimeStepSound, NADE_TYPE_BLIND )
    234.        
    235.         // Decrease nade count
    236.         g_NadeCount [ pev ( Entity, pev_owner ) ]--
    237.        
    238.         // Set world model
    239.         engfunc ( EngFunc_SetModel, Entity, grenade_model_w )
    240.         return FMRES_SUPERCEDE
    241.     }
    242.     return FMRES_IGNORED
    243. }
    244.  
    245. // Grenade is getting to explode
    246. public fw_ThinkGrenade ( Entity )
    247. {
    248.     // Prevent invalid ent messages
    249.     if ( !pev_valid ( Entity ) )
    250.         return HAM_IGNORED
    251.    
    252.     // Get damage time
    253.     static Float:dmg_time
    254.     pev ( Entity, pev_dmgtime, dmg_time )
    255.    
    256.     // maybe it is time to go off
    257.     if ( dmg_time > get_gametime ( ) )
    258.         return HAM_IGNORED
    259.        
    260.     // Our grenade    
    261.     if ( pev ( Entity, pev_flTimeStepSound ) == NADE_TYPE_BLIND )
    262.     {
    263.         // Force to explode
    264.         blind_explode ( Entity )
    265.         return HAM_SUPERCEDE
    266.     }
    267.     return HAM_IGNORED
    268. }
    269.  
    270. // Command start
    271. public fw_CmdStart ( Player, UC_Handle, Seed )
    272. {
    273.     // Dead, zombie or not affected
    274.     if ( !is_user_alive ( Player ) || ze_is_user_zombie ( Player ) || !task_exists ( Player+TASK_AFFECT ) )
    275.         return FMRES_IGNORED
    276.    
    277.     // Get buttons
    278.     new buttons = get_uc ( UC_Handle, UC_Buttons )
    279.    
    280.     // We are firing
    281.     if ( buttons & IN_ATTACK )
    282.     {
    283.         // We are holding an active weapon
    284.         if ( get_pdata_cbase ( Player, OFFSET_ACTIVE, LINUX_DIFF ) )
    285.         {
    286.             // New recoil
    287.             set_pev ( Player, pev_punchangle, Float:{3.0, 3.0, 4.0} )
    288.         }
    289.     }
    290.     return FMRES_HANDLED
    291. }
    292.  
    293. // Grenade explode
    294. public blind_explode ( Entity )
    295. {
    296.     // Invalid entity ?
    297.     if ( !pev_valid ( Entity  ) )
    298.         return
    299.    
    300.     // Get entities origin
    301.     static Float:origin [ 3 ]
    302.     pev ( Entity, pev_origin, origin )
    303.    
    304.     // Draw ring
    305.     UTIL_DrawRing (origin )
    306.    
    307.     // Explosion sound
    308.     emit_sound ( Entity, CHAN_WEAPON, explosion_sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
    309.    
    310.     // Collisions
    311.     static victim
    312.     victim = -1
    313.    
    314.     // Find radius
    315.     static Float:radius
    316.     radius = get_pcvar_float ( cvar_nade_radius )
    317.    
    318.     // Find all players in a radius
    319.     while ( ( victim = engfunc ( EngFunc_FindEntityInSphere, victim, origin, radius ) ) != 0 )
    320.     {
    321.         // Dead or zombie
    322.         if ( !is_user_alive ( victim ) || ze_is_user_zombie ( victim ) )
    323.             continue
    324.  
    325.         // Victim isn't affected yet    
    326.         if ( !task_exists ( victim+TASK_AFFECT ) )
    327.         {
    328.             // Get duration
    329.             new duration = get_pcvar_num ( cvar_duration )
    330.            
    331.             // Calculate affect times
    332.             new affect_count = floatround ( duration / REPEAT )
    333.            
    334.             // Continiously affect them
    335.             set_task ( REPEAT, "affect_victim", victim+TASK_AFFECT, _, _, "a", affect_count )
    336.         }
    337.     }
    338.    
    339.     // Remove entity from ground
    340.     engfunc ( EngFunc_RemoveEntity, Entity )
    341. }
    342.  
    343. // We are going to affect you
    344. public affect_victim ( taskid )
    345. {
    346.     // Dead
    347.     if ( !is_user_alive ( ID_AFFECT ) )
    348.         return;
    349.    
    350.     // Make a screen fade
    351.     ScreenFade(ID_AFFECT, get_pcvar_float( cvar_duration ), 0, 0, 0, 255)
    352.    
    353.     // Remove task after all  
    354.     remove_task( ID_AFFECT )
    355. }
    356.  
    357. // Draw explosion ring ( from zombie_plague40.sma )
    358. stock UTIL_DrawRing ( const Float:origin [ 3 ] )
    359. {
    360.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
    361.     write_byte(TE_BEAMCYLINDER) // TE id
    362.     engfunc(EngFunc_WriteCoord, origin[0]) // x
    363.     engfunc(EngFunc_WriteCoord, origin[1]) // y
    364.     engfunc(EngFunc_WriteCoord, origin[2]) // z
    365.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
    366.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
    367.     engfunc(EngFunc_WriteCoord, origin[2]+555.0) // z axis
    368.     write_short( m_iRing ) // sprite
    369.     write_byte(0) // startframe
    370.     write_byte(0) // framerate
    371.     write_byte(4) // life
    372.     write_byte(60) // width
    373.     write_byte(0) // noise
    374.     write_byte(200) // red
    375.     write_byte(200) // green
    376.     write_byte(200) // blue
    377.     write_byte(200) // brightness
    378.     write_byte(0) // speed
    379.     message_end()
    380. }
    381.  
    382. // ScreenFade
    383. stock ScreenFade(plr, Float:fDuration, red, green, blue, alpha)
    384. {
    385.     new i = plr ? plr : get_maxplayers();
    386.     if( !i )
    387.     {
    388.         return 0;
    389.     }
    390.  
    391.     message_begin(plr ? MSG_ONE : MSG_ALL, g_msgScreenFade, {0, 0, 0}, plr);
    392.     write_short(floatround(4096.0 * fDuration, floatround_round));
    393.     write_short(floatround(4096.0 * fDuration, floatround_round));
    394.     write_short(4096);
    395.     write_byte(red);
    396.     write_byte(green);
    397.     write_byte(blue);
    398.     write_byte(alpha);
    399.     message_end();
    400.    
    401.     return 1;
    402. }
You don't know? Learn and you will know.

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#3

Post by johnnysins2000 » 2 Years Ago

OK I got my Mistake Thnx
Nobody Is That Busy If They Make Time :roll:

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests