Convert From Zombie Plague >> Zombie Escape

Helping Topics
Post Reply
User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2213
Joined: 7 years ago
Contact:

Convert From Zombie Plague >> Zombie Escape

#1

Post by Raheem » 7 years ago

This simple topic will help you to learn how to convert Extra-Item or other plugins to our Zombie Escape Mod. The most important thing you should know is that this steps not Static! These steps maybe changes from case to another one but keep in mind that the system is one which mean you need to convert 1-Forwards 2-Natives The following steps will help you. Converting from ZP5.0 to Our Mod is easier that's because we use same system which it uses. Also From ZP4.3 to ZE Not so hard thing. Any problem or idea please post it down here.

1- Zombie Plague 4.3 >> Zombie Escape Convert Forwards:
  • Remove these lines:

    1. #include <amxmodx>
    2. #include <fakemeta>
    3. #include <fun>
    4. #include <hamsandwich>
    5. #include <cstrike>
    6. #include <zombieplague>

    And add these ones instead:

    1. #include <zombie_escape>
    2. #include <cstrike>

    This simply because these includes is already included in our zombie_escape.inc
  • Add these lines anywhere, And these lines which decide if this item for Humans or for Zombies:

    1. public ze_select_item_pre(id, itemid)
    2. {
    3.     // Return Available and we will block it in Post, So it dosen't affect other plugins
    4.     if (itemid != g_itemid)
    5.         return ZE_ITEM_AVAILABLE
    6.    
    7.     // Available for Humans only, So don't show it for zombies
    8.     if (ze_is_user_zombie(id))
    9.         return ZE_ITEM_DONT_SHOW
    10.    
    11.     return ZE_ITEM_AVAILABLE
    12. }
  • Change these lines:

    1. public zp_extra_item_selected(player, itemid)
    2. {
    3.     if ( itemid == g_itemid )
    4.     {
    5.         if ( user_has_weapon(player, CSW_M4A1) )
    6.         {
    7.             drop_prim(player)
    8.         }
    9.        
    10.         give_item(player, "weapon_m4a1")
    11.         client_print(player, print_chat, "[ZP] You bought Golden M4A1")
    12.         g_HasM4[player] = true;
    13.     }
    14. }

    To:

    1. public ze_select_item_post(player, itemid)
    2. {
    3.     if (itemid != g_itemid)
    4.         return
    5.    
    6.     if (user_has_weapon(player, CSW_M4A1))
    7.     {
    8.         drop_prim(player)
    9.     }
    10.        
    11.     give_item(player, "weapon_m4a1")
    12.     client_print(player, print_chat, "[ZP] You bought Golden M4A1")
    13.     g_HasM4[player] = true;
    14. }
Convert Natives:
Final Code:
    1. #include <zombie_escape>
    2. #include <cstrike>
    3.  
    4. #define is_valid_player(%1) (1 <= %1 <= 32)
    5.  
    6. new M4_V_MODEL[64] = "models/zombie_plague/v_golden_m4a1_UP.mdl"
    7. new M4_P_MODEL[64] = "models/zombie_plague/p_golden_m4a1_UP.mdl"
    8.  
    9. /* Pcvars */
    10. new cvar_dmgmultiplier, cvar_goldbullets,  cvar_custommodel, cvar_uclip
    11.  
    12. // Item ID
    13. new g_itemid
    14.  
    15. new bool:g_HasM4[33]
    16.  
    17. new g_hasZoom[ 33 ]
    18. new bullets[ 33 ]
    19.  
    20. // Sprite
    21. new m_spriteTexture
    22.  
    23. const Wep_m4a1 = ((1<<CSW_M4A1))
    24.  
    25. public plugin_init()
    26. {
    27.    
    28.     /* CVARS */
    29.     cvar_dmgmultiplier = register_cvar("zp_goldenm4_dmg_multiplier", "12")
    30.     cvar_custommodel = register_cvar("zp_goldenm4_custom_model", "1")
    31.     cvar_goldbullets = register_cvar("zp_goldenm4_gold_bullets", "1")
    32.     cvar_uclip = register_cvar("zp_goldenm4_unlimited_clip", "1")
    33.    
    34.     // Register The Plugin
    35.     register_plugin("[ZE] Extra: Golden M4A1", "1.1", "Bill=Thailand=[UP]")
    36.     // Register Zombie Plague extra item
    37.    
    38.     g_itemid = ze_register_item("Golden M4A1", 20, 0)
    39.     // Death Msg
    40.     register_event("DeathMsg", "Death", "a")
    41.     // Weapon Pick Up
    42.     register_event("WeapPickup","checkModel","b","1=19")
    43.     // Current Weapon Event
    44.     register_event("CurWeapon","checkWeapon","be","1=1")
    45.     register_event("CurWeapon", "make_tracer", "be", "1=1", "3>0")
    46.     // Ham TakeDamage
    47.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
    48.     register_forward( FM_CmdStart, "fw_CmdStart" )
    49.     RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
    50.    
    51. }
    52.  
    53. public client_connect(id)
    54. {
    55.     g_HasM4[id] = false
    56. }
    57.  
    58. public client_disconnect(id)
    59. {
    60.     g_HasM4[id] = false
    61. }
    62.  
    63. public Death()
    64. {
    65.     g_HasM4[read_data(2)] = false
    66. }
    67.  
    68. public fwHamPlayerSpawnPost(id)
    69. {
    70.     g_HasM4[id] = false
    71. }
    72.  
    73. public plugin_precache()
    74. {
    75.     precache_model(M4_V_MODEL)
    76.     precache_model(M4_P_MODEL)
    77.     m_spriteTexture = precache_model("sprites/dot.spr")
    78.     precache_sound("weapons/zoom.wav")
    79. }
    80.  
    81. public ze_user_infected(id, iInfector)
    82. {
    83.     if (ze_is_user_zombie(id))
    84.     {
    85.         g_HasM4[id] = false
    86.     }
    87. }
    88.  
    89. public checkModel(id)
    90. {
    91.     if (ze_is_user_zombie(id))
    92.         return PLUGIN_HANDLED
    93.    
    94.     new szWeapID = read_data(2)
    95.    
    96.     if ( szWeapID == CSW_M4A1 && g_HasM4[id] == true && get_pcvar_num(cvar_custommodel) )
    97.     {
    98.         set_pev(id, pev_viewmodel2, M4_V_MODEL)
    99.         set_pev(id, pev_weaponmodel2, M4_P_MODEL)
    100.     }
    101.     return PLUGIN_HANDLED
    102. }
    103.  
    104. public checkWeapon(id)
    105. {
    106.     new plrClip, plrAmmo, plrWeap[32]
    107.     new plrWeapId
    108.    
    109.     plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
    110.    
    111.     if (plrWeapId == CSW_M4A1 && g_HasM4[id])
    112.     {
    113.         checkModel(id)
    114.     }
    115.     else
    116.     {
    117.         return PLUGIN_CONTINUE
    118.     }
    119.    
    120.     if (plrClip == 0 && get_pcvar_num(cvar_uclip))
    121.     {
    122.         // If the user is out of ammo..
    123.         get_weaponname(plrWeapId, plrWeap, 31)
    124.         // Get the name of their weapon
    125.         give_item(id, plrWeap)
    126.         engclient_cmd(id, plrWeap)
    127.         engclient_cmd(id, plrWeap)
    128.         engclient_cmd(id, plrWeap)
    129.     }
    130.     return PLUGIN_HANDLED
    131. }
    132.  
    133.  
    134.  
    135. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
    136. {
    137.     if ( is_valid_player( attacker ) && get_user_weapon(attacker) == CSW_M4A1 && g_HasM4[attacker] )
    138.     {
    139.         SetHamParamFloat(4, damage * get_pcvar_float( cvar_dmgmultiplier ) )
    140.     }
    141. }
    142.  
    143. public fw_CmdStart( id, uc_handle, seed )
    144. {
    145.     if( !is_user_alive( id ) )
    146.         return PLUGIN_HANDLED
    147.    
    148.     if( ( get_uc( uc_handle, UC_Buttons ) & IN_ATTACK2 ) && !( pev( id, pev_oldbuttons ) & IN_ATTACK2 ) )
    149.     {
    150.         new szClip, szAmmo
    151.         new szWeapID = get_user_weapon( id, szClip, szAmmo )
    152.        
    153.         if( szWeapID == CSW_M4A1 && g_HasM4[id] == true && !g_hasZoom[id] == true)
    154.         {
    155.             g_hasZoom[id] = true
    156.             cs_set_user_zoom( id, CS_SET_AUGSG552_ZOOM, 0 )
    157.             emit_sound( id, CHAN_ITEM, "weapons/zoom.wav", 0.20, 2.40, 0, 100 )
    158.         }
    159.        
    160.         else if ( szWeapID == CSW_M4A1 && g_HasM4[id] == true && g_hasZoom[id])
    161.         {
    162.             g_hasZoom[ id ] = false
    163.             cs_set_user_zoom( id, CS_RESET_ZOOM, 0 )
    164.            
    165.         }
    166.        
    167.     }
    168.     return PLUGIN_HANDLED
    169. }
    170.  
    171.  
    172. public make_tracer(id)
    173. {
    174.     if (get_pcvar_num(cvar_goldbullets))
    175.     {
    176.         new clip,ammo
    177.         new wpnid = get_user_weapon(id,clip,ammo)
    178.         new pteam[16]
    179.        
    180.         get_user_team(id, pteam, 15)
    181.        
    182.         if ((bullets[id] > clip) && (wpnid == CSW_M4A1) && g_HasM4[id])
    183.         {
    184.             new vec1[3], vec2[3]
    185.             get_user_origin(id, vec1, 1) // origin; your camera point.
    186.             get_user_origin(id, vec2, 4) // termina; where your bullet goes (4 is cs-only)
    187.            
    188.            
    189.             //BEAMENTPOINTS
    190.             message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
    191.             write_byte (0)     //TE_BEAMENTPOINTS 0
    192.             write_coord(vec1[0])
    193.             write_coord(vec1[1])
    194.             write_coord(vec1[2])
    195.             write_coord(vec2[0])
    196.             write_coord(vec2[1])
    197.             write_coord(vec2[2])
    198.             write_short( m_spriteTexture )
    199.             write_byte(1) // framestart
    200.             write_byte(5) // framerate
    201.             write_byte(2) // life
    202.             write_byte(10) // width
    203.             write_byte(0) // noise
    204.             write_byte( 255 )     // r, g, b
    205.             write_byte( 215 )       // r, g, b
    206.             write_byte( 0 )       // r, g, b
    207.             write_byte(200) // brightness
    208.             write_byte(150) // speed
    209.             message_end()
    210.         }
    211.    
    212.         bullets[id] = clip
    213.     }
    214.    
    215. }
    216.  
    217. public ze_select_item_pre(id, itemid)
    218. {
    219.     // Return Available and we will block it in Post, So it dosen't affect other plugins
    220.     if (itemid != g_itemid)
    221.         return ZE_ITEM_AVAILABLE
    222.    
    223.     // Available for Humans only, So don't show it for zombies
    224.     if (ze_is_user_zombie(id))
    225.         return ZE_ITEM_DONT_SHOW
    226.    
    227.     return ZE_ITEM_AVAILABLE
    228. }
    229.  
    230. public ze_select_item_post(player, itemid)
    231. {
    232.     if (itemid != g_itemid)
    233.         return
    234.    
    235.     if (user_has_weapon(player, CSW_M4A1))
    236.     {
    237.         drop_prim(player)
    238.     }
    239.        
    240.     give_item(player, "weapon_m4a1")
    241.     client_print(player, print_chat, "[ZP] You bought Golden M4A1")
    242.     g_HasM4[player] = true;
    243. }
    244.  
    245. stock drop_prim(id)
    246. {
    247.     new weapons[32], num
    248.     get_user_weapons(id, weapons, num)
    249.     for (new i = 0; i < num; i++) {
    250.         if (Wep_m4a1 & (1<<weapons[i]))
    251.         {
    252.             static wname[32]
    253.             get_weaponname(weapons[i], wname, sizeof wname - 1)
    254.             engclient_cmd(id, "drop", wname)
    255.         }
    256.     }
    257. }

    [ZE] Extra-Golden M4A1.zip
    [ZE] Extra-Item: Golden M4A1
    (7.43 KiB) Downloaded 619 times
    [ZE] Extra-Golden M4A1.zip
    [ZE] Extra-Item: Golden M4A1
    (7.43 KiB) Downloaded 619 times

1- Zombie Plague 5.0 >> Zombie Escape
  • We will try convert this Item: Skull-3
Convert Forwards:
  • Remove these lines:

    1. #include <amxmodx>
    2. #include <engine>
    3. #include <fakemeta>
    4. #include <fakemeta_util>
    5. #include <hamsandwich>
    6. #include <cstrike>
    7. #include <fun>
    8. #include <zp50_core>
    9. #include <zp50_items>

    And add these ones instead:

    1. #include <zombie_escape>
    2. #include <cstrike>

    This simply because these includes is already included in our zombie_escape.inc
  • Remove this line:

    1. g_skull3_id = zp_items_register("Skull-3 (Double Weapon)", 30)

    Add this instead:

    1. g_skull3_id = ze_register_item("Skull-3 (Double Weapon)", 30, 0)
  • Change these lines:

    1. public zp_fw_items_select_pre(id, itemid, ignorecost)
    2. {
    3.     if (itemid != g_skull3_id)
    4.         return ZP_ITEM_AVAILABLE;
    5.     if (zp_core_is_zombie(id))
    6.         return ZP_ITEM_DONT_SHOW
    7.    
    8.     return ZP_ITEM_AVAILABLE;
    9. }
    10.  
    11. public zp_fw_items_select_post(id, itemid, ignorecost)
    12. {
    13.     if(itemid != g_skull3_id)
    14.         return PLUGIN_HANDLED
    15.    
    16.     drop_weapons(id, 1)
    17.    
    18.     g_had_skull3[id] = 1
    19.     g_skull3_mode[id] = 1
    20.     g_skull3_ammo[id] = 200
    21.     g_skull3_changing[id] = 0
    22.     g_zoomed[id] = 0
    23.     g_oldspeed[id] = get_user_maxspeed(id)
    24.    
    25.     give_item(id, weapon_skull3_m1)
    26.     give_item(id, weapon_skull3_m2)
    27.    
    28.     static skull3_ent
    29.    
    30.     skull3_ent = fm_find_ent_by_owner(-1, weapon_skull3_m1, id)
    31.     set_pev(skull3_ent, pev_iuser4, SKULL3_M1_KEY)
    32.     cs_set_weapon_ammo(skull3_ent, get_pcvar_num(cvar_clip_m1))
    33.     cs_set_user_bpammo(id, CSW_SKULL3_M1, g_skull3_ammo[id])
    34.    
    35.     skull3_ent = fm_find_ent_by_owner(-1, weapon_skull3_m2, id)
    36.     set_pev(skull3_ent, pev_iuser4, SKULL3_M2_KEY)
    37.     cs_set_weapon_ammo(skull3_ent, get_pcvar_num(cvar_clip_m2))
    38.     cs_set_user_bpammo(id, CSW_SKULL3_M2, g_skull3_ammo[id])
    39.    
    40.     engclient_cmd(id, weapon_skull3_m1)
    41.    
    42.     return PLUGIN_CONTINUE
    43. }

    To:

    1. public ze_select_item_pre(id, itemid, ignorecost)
    2. {
    3.     if (itemid != g_skull3_id)
    4.         return ZE_ITEM_AVAILABLE;
    5.    
    6.     if (ze_is_user_zombie(id))
    7.         return ZE_ITEM_DONT_SHOW
    8.    
    9.     return ZE_ITEM_AVAILABLE;
    10. }
    11.  
    12. public ze_select_item_post(id, itemid, ignorecost)
    13. {
    14.     if(itemid != g_skull3_id)
    15.         return
    16.    
    17.     drop_weapons(id, 1)
    18.    
    19.     g_had_skull3[id] = 1
    20.     g_skull3_mode[id] = 1
    21.     g_skull3_ammo[id] = 200
    22.     g_skull3_changing[id] = 0
    23.     g_zoomed[id] = 0
    24.     g_oldspeed[id] = get_user_maxspeed(id)
    25.    
    26.     give_item(id, weapon_skull3_m1)
    27.     give_item(id, weapon_skull3_m2)
    28.    
    29.     static skull3_ent
    30.    
    31.     skull3_ent = fm_find_ent_by_owner(-1, weapon_skull3_m1, id)
    32.     set_pev(skull3_ent, pev_iuser4, SKULL3_M1_KEY)
    33.     cs_set_weapon_ammo(skull3_ent, get_pcvar_num(cvar_clip_m1))
    34.     cs_set_user_bpammo(id, CSW_SKULL3_M1, g_skull3_ammo[id])
    35.    
    36.     skull3_ent = fm_find_ent_by_owner(-1, weapon_skull3_m2, id)
    37.     set_pev(skull3_ent, pev_iuser4, SKULL3_M2_KEY)
    38.     cs_set_weapon_ammo(skull3_ent, get_pcvar_num(cvar_clip_m2))
    39.     cs_set_user_bpammo(id, CSW_SKULL3_M2, g_skull3_ammo[id])
    40.    
    41.     engclient_cmd(id, weapon_skull3_m1)
    42. }
Convert Natives:
Final Code:
    1. #include <zombie_escape>
    2. #include <cstrike>
    3.  
    4. #define PLUGIN "[ZE] Primary Weapon: Skull-3"
    5. #define VERSION "1.0"
    6. #define AUTHOR "Dias"
    7.  
    8. #define weapon_skull3_m1 "weapon_mp5navy"
    9. #define weapon_skull3_m2 "weapon_p90"
    10. #define CSW_SKULL3_M1 CSW_MP5NAVY
    11. #define CSW_SKULL3_M2 CSW_P90
    12. #define SKULL3_M1_KEY 2082
    13. #define SKULL3_M2_KEY 2086
    14.  
    15. const SILENT_BS = ((1<<CSW_USP)|(1<<CSW_SKULL3_M1))
    16. const SILENT_BS2 = ((1<<CSW_USP)|(1<<CSW_SKULL3_M2))
    17. stock const g_iDftMaxClip[CSW_P90+1] = {
    18.     -1,  13, -1, 10,  1,  7,    1, 30, 30,  1,  30,
    19.     20, 25, 30, 35, 25,   12, 20, 10, 30, 100,
    20. 8 , 30, 30, 20,  2,    7, 30, 30, -1,  50}
    21. stock const Float:g_fDelay[CSW_P90+1] = {
    22.     0.00, 2.70, 0.00, 2.00, 0.00, 0.55,   0.00, 3.15, 3.30, 0.00, 4.50,
    23.     2.70, 3.50, 3.35, 2.45, 3.30,   2.70, 2.20, 2.50, 2.63, 4.70,
    24.     0.55, 3.05, 2.12, 3.50, 0.00,   2.20, 3.00, 2.45, 0.00, 3.40
    25. }
    26.  
    27. new const WEAPONENTNAMES[][] =
    28. {
    29.     "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
    30.     "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
    31.     "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_m249",
    32.     "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
    33.     "weapon_ak47", "weapon_knife"
    34. }
    35.  
    36. const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_MAC10)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_MAC10)|(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)
    37.  
    38. new g_skull3_id
    39. new g_had_skull3[33], g_skull3_mode[33], g_skull3_ammo[33], g_skull3_changing[33],
    40. g_zoomed[33], g_remove_ent[33], g_blood, g_bloodspray, g_pbe_skull3_m1,
    41. g_pbe_skull3_m2, g_is_attacking[33],  Float:g_zoom_time[33], g_skull3_m2_ammo[33],
    42. Float:g_recoil[33], g_shot_anim[33], g_skull3_clip[33], g_reload[33], g_reg
    43. new cvar_recoil_m1, cvar_recoil_m2, cvar_clip_m1, cvar_clip_m2, cvar_speed_m1, cvar_speed_m2,
    44. cvar_damage_m1, cvar_damage_m2, cvar_decrease_speed
    45. new Float:g_oldspeed[33]
    46.  
    47. new const v_model[] = "models/zombie_plague/v_skull3.mdl"
    48. new const v_model2[] = "models/zombie_plague/v_skull3_2.mdl"
    49. new const p_model[] = "models/zombie_plague/p_skull3.mdl"
    50. new const p_model2[] = "models/zombie_plague/p_skull3dual.mdl"
    51. new const w_model[] = "models/zombie_plague/w_skull3.mdl"
    52.  
    53. new const skull3_sound[5][] =
    54. {
    55.     "weapons/skull3_shoot.wav",
    56.     "weapons/skull3_shoot_2.wav",
    57.     "weapons/skull3_idle.wav",
    58.     "weapons/skull3_clipin.wav",
    59.     "weapons/skull3_boltpull.wav"
    60. }
    61.  
    62. public plugin_init()
    63. {
    64.     register_plugin(PLUGIN, VERSION, AUTHOR)
    65.    
    66.     g_skull3_id = ze_register_item("Skull-3 (Double Weapon)", 30, 0)
    67.    
    68.     register_forward(FM_CmdStart, "fw_CmdStart")
    69.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)   
    70.     register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
    71.     register_forward(FM_SetModel, "fw_SetModel")   
    72.    
    73.     RegisterHam(Ham_Spawn, "player", "ham_spawn_player_post", 1)
    74.     RegisterHam(Ham_Item_AddToPlayer, weapon_skull3_m1, "ham_add_skull3_m1", 1)
    75.     RegisterHam(Ham_Item_AddToPlayer, weapon_skull3_m2, "ham_add_skull3_m2", 1)
    76.     RegisterHam(Ham_CS_Weapon_SendWeaponAnim, weapon_skull3_m1, "ham_anim_skull3_m1", 1)
    77.     RegisterHam(Ham_CS_Weapon_SendWeaponAnim, weapon_skull3_m2, "ham_anim_skull3_m2", 1)
    78.     RegisterHam(Ham_Item_Deploy, weapon_skull3_m1, "ham_deploy_skull3_m1", 1)
    79.     RegisterHam(Ham_Item_Deploy, weapon_skull3_m2, "ham_deploy_skull3_m2", 1)
    80.    
    81.     for (new i = 1; i <= CSW_P90 - 2; i++)
    82.     {
    83.         if (strlen(WEAPONENTNAMES[i]) && !equal(WEAPONENTNAMES[i], "weapon_knife"))
    84.             RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Ham_Item_Deploy_Post", 1)
    85.     }
    86.    
    87.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_skull3_m1, "ham_attack_skull3")
    88.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_skull3_m2, "ham_attack_skull3")
    89.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_skull3_m1, "ham_attack_skull3_post", 1)   
    90.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_skull3_m2, "ham_attack_skull3_post", 1)   
    91.     RegisterHam(Ham_Weapon_Reload, weapon_skull3_m1, "ham_reload_skull3")
    92.     RegisterHam(Ham_Weapon_Reload, weapon_skull3_m2, "ham_reload_skull3")
    93.     RegisterHam(Ham_Weapon_Reload, weapon_skull3_m1, "ham_reload_skull3_post", 1)
    94.     RegisterHam(Ham_Weapon_Reload, weapon_skull3_m2, "ham_reload_skull3_post", 1)
    95.     RegisterHam(Ham_Item_PostFrame, weapon_skull3_m1, "ham_postframe_skull3")
    96.     RegisterHam(Ham_Item_PostFrame, weapon_skull3_m2, "ham_postframe_skull3")
    97.    
    98.     RegisterHam(Ham_TraceAttack, "worldspawn", "ham_traceattack")
    99.     RegisterHam(Ham_TraceAttack, "player", "ham_traceattack")
    100.    
    101.     cvar_recoil_m1 = register_cvar("skull3_recoil_m1", "0.46")
    102.     cvar_recoil_m2 = register_cvar("skull3_recoil_m2", "0.56")
    103.     cvar_clip_m1 = register_cvar("skull3_clip_m1", "35")
    104.     cvar_clip_m2 = register_cvar("skull3_clip_m2", "70")
    105.     cvar_speed_m1 = register_cvar("skull3_speed_m1", "1.35")
    106.     cvar_speed_m2 = register_cvar("skull3_speed_m2", "1.28")
    107.     cvar_damage_m1 = register_cvar("skull3_damage_m1", "27")
    108.     cvar_damage_m2 = register_cvar("skull3_damage_m2", "31")
    109.     cvar_decrease_speed = register_cvar("skull3_decrease_speed", "110.0")
    110.    
    111.     register_event("CurWeapon", "event_checkweapon", "be", "1=1")
    112.    
    113.     register_clcmd("drop", "cmd_drop")
    114.     register_clcmd("weapon_skull3", "hook_change_weapon1")
    115.     register_clcmd("weapon_skull3_2", "hook_change_weapon2")
    116. }
    117.  
    118. public plugin_precache()
    119. {
    120.     engfunc(EngFunc_PrecacheModel, v_model)
    121.     engfunc(EngFunc_PrecacheModel, v_model2)
    122.     engfunc(EngFunc_PrecacheModel, p_model)
    123.     engfunc(EngFunc_PrecacheModel, p_model2)
    124.     engfunc(EngFunc_PrecacheModel, w_model)
    125.    
    126.     for(new i = 0; i < sizeof(skull3_sound); i++)
    127.         engfunc(EngFunc_PrecacheSound, skull3_sound[i])
    128.    
    129.     engfunc(EngFunc_PrecacheGeneric, "sprites/skull3_hud.spr")
    130.     engfunc(EngFunc_PrecacheGeneric, "sprites/skull3_ammo.spr")
    131.     engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_skull3.txt")
    132.     engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_skull3_2.txt")
    133.    
    134.     g_blood = precache_model("sprites/blood.spr")
    135.     g_bloodspray = precache_model("sprites/bloodspray.spr")        
    136.    
    137.     register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
    138. }
    139.  
    140. public fw_PrecacheEvent_Post(type, const name[])
    141. {
    142.     if(equal("events/mp5n.sc", name))
    143.     {
    144.         g_pbe_skull3_m1 = get_orig_retval()
    145.         return FMRES_HANDLED
    146.     } else if(equal("events/p90.sc", name)) {
    147.         g_pbe_skull3_m2 = get_orig_retval()
    148.         return FMRES_HANDLED
    149.     }
    150.  
    151.     return FMRES_IGNORED
    152. }
    153.  
    154. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
    155. {
    156.     if (!(1 <= invoker <= get_maxplayers()))
    157.         return FMRES_IGNORED   
    158.     if(!g_is_attacking[invoker])
    159.         return FMRES_IGNORED
    160.     if(eventid == g_pbe_skull3_m1 || eventid == g_pbe_skull3_m2)
    161.         playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
    162.    
    163.     return FMRES_SUPERCEDE
    164. }
    165.  
    166. public ze_select_item_pre(id, itemid, ignorecost)
    167. {
    168.     if (itemid != g_skull3_id)
    169.         return ZE_ITEM_AVAILABLE;
    170.    
    171.     if (ze_is_user_zombie(id))
    172.         return ZE_ITEM_DONT_SHOW
    173.    
    174.     return ZE_ITEM_AVAILABLE;
    175. }
    176.  
    177. public ze_select_item_post(id, itemid, ignorecost)
    178. {
    179.     if(itemid != g_skull3_id)
    180.         return
    181.    
    182.     drop_weapons(id, 1)
    183.    
    184.     g_had_skull3[id] = 1
    185.     g_skull3_mode[id] = 1
    186.     g_skull3_ammo[id] = 200
    187.     g_skull3_changing[id] = 0
    188.     g_zoomed[id] = 0
    189.     g_oldspeed[id] = get_user_maxspeed(id)
    190.    
    191.     give_item(id, weapon_skull3_m1)
    192.     give_item(id, weapon_skull3_m2)
    193.    
    194.     static skull3_ent
    195.    
    196.     skull3_ent = fm_find_ent_by_owner(-1, weapon_skull3_m1, id)
    197.     set_pev(skull3_ent, pev_iuser4, SKULL3_M1_KEY)
    198.     cs_set_weapon_ammo(skull3_ent, get_pcvar_num(cvar_clip_m1))
    199.     cs_set_user_bpammo(id, CSW_SKULL3_M1, g_skull3_ammo[id])
    200.    
    201.     skull3_ent = fm_find_ent_by_owner(-1, weapon_skull3_m2, id)
    202.     set_pev(skull3_ent, pev_iuser4, SKULL3_M2_KEY)
    203.     cs_set_weapon_ammo(skull3_ent, get_pcvar_num(cvar_clip_m2))
    204.     cs_set_user_bpammo(id, CSW_SKULL3_M2, g_skull3_ammo[id])
    205.    
    206.     engclient_cmd(id, weapon_skull3_m1)
    207. }
    208.  
    209. public ham_spawn_player_post(id)
    210. {
    211.     remove_skull3(id)
    212. }
    213.  
    214. public ze_user_infected(id, iInfector)
    215. {
    216.     remove_skull3(id)
    217. }
    218.  
    219. public remove_skull3(id)
    220. {
    221.     if(!is_user_connected(id))
    222.         return
    223.    
    224.     g_had_skull3[id] = 0
    225.     g_skull3_mode[id] = 0
    226.     g_skull3_ammo[id] = 0
    227.     g_skull3_changing[id] = 0
    228.     g_zoomed[id] = 0   
    229. }
    230.  
    231. public hook_change_weapon1(id)
    232. {
    233.     if(g_had_skull3[id])
    234.     {
    235.         engclient_cmd(id, weapon_skull3_m1)
    236.     }
    237. }
    238.  
    239. public hook_change_weapon2(id)
    240. {
    241.     if(g_had_skull3[id])
    242.     {
    243.         engclient_cmd(id, weapon_skull3_m2)
    244.     }
    245. }
    246.  
    247. public client_putinserver(id)
    248. {
    249.     if(!g_reg && is_user_bot(id))
    250.     {
    251.         g_reg = 1
    252.         set_task(0.1, "do_register", id)
    253.     }
    254. }
    255.  
    256. public do_register(id)
    257. {
    258.     RegisterHamFromEntity(Ham_TraceAttack, id, "ham_traceattack")  
    259.     RegisterHamFromEntity(Ham_Spawn, id, "ham_spawn_player")   
    260. }
    261.  
    262. public event_checkweapon(id)
    263. {
    264.     if(!is_user_alive(id) || !is_user_connected(id))
    265.         return PLUGIN_HANDLED
    266.     if(ze_is_user_zombie(id))
    267.         return PLUGIN_HANDLED
    268.     if(!g_had_skull3[id])
    269.         return PLUGIN_HANDLED
    270.    
    271.     static CurWeapon
    272.     CurWeapon = get_user_weapon(id)
    273.    
    274.     if(CurWeapon == CSW_SKULL3_M1 && g_skull3_mode[id] == 1)
    275.     {
    276.         set_pev(id, pev_viewmodel2, v_model)
    277.         set_pev(id, pev_weaponmodel2, p_model)
    278.        
    279.         check_weapon_speed(id, 1)
    280.     } else if(CurWeapon == CSW_SKULL3_M2 && g_skull3_mode[id] == 2) {
    281.         set_pev(id, pev_viewmodel2, v_model2)
    282.         set_pev(id, pev_weaponmodel2, p_model2)
    283.        
    284.         check_weapon_speed(id, 2)
    285.     }
    286.    
    287.     return PLUGIN_CONTINUE
    288. }
    289.  
    290. public check_weapon_speed(id, mode)
    291. {
    292.     static Float:iSpeed
    293.    
    294.     if(mode == 1)
    295.         iSpeed = get_pcvar_float(cvar_speed_m1)
    296.     else if(mode == 2)
    297.         iSpeed = get_pcvar_float(cvar_speed_m2)
    298.    
    299.     static weapon_name[32], ent
    300.    
    301.     if(mode == 1)
    302.         get_weaponname(CSW_SKULL3_M1, weapon_name, sizeof(weapon_name))
    303.     else if(mode == 2)
    304.         get_weaponname(CSW_SKULL3_M2, weapon_name, sizeof(weapon_name))
    305.    
    306.     ent = find_ent_by_owner(-1, weapon_name, id)
    307.     if(ent)
    308.     {
    309.         static Float:Delay, Float:M_Delay
    310.         Delay = get_pdata_float(ent, 46, 4) * iSpeed
    311.         M_Delay = get_pdata_float(ent, 47, 4) * iSpeed
    312.         if (Delay > 0.0)
    313.         {
    314.             set_pdata_float(ent, 46, Delay, 4)
    315.             set_pdata_float(ent, 47, M_Delay, 4)
    316.         }
    317.     }  
    318. }
    319.  
    320. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
    321. {
    322.     if(!is_user_alive(id) || !is_user_connected(id))
    323.         return FMRES_IGNORED
    324.     if(ze_is_user_zombie(id))
    325.         return FMRES_IGNORED       
    326.     if(!g_had_skull3[id])
    327.         return FMRES_IGNORED
    328.    
    329.     if(get_user_weapon(id) == CSW_SKULL3_M1 || get_user_weapon(id) == CSW_SKULL3_M2)
    330.     {
    331.         set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001)
    332.        
    333.         if(get_user_weapon(id) == CSW_SKULL3_M2)
    334.         {
    335.             switch(pev(id, pev_sequence))
    336.             {
    337.                 case 10: set_pev(id, pev_sequence, 22)
    338.                 case 11:
    339.                 {
    340.                     if(g_shot_anim[id] == 0)
    341.                     {
    342.                         set_pev(id, pev_sequence, 23)
    343.                     } else if(g_shot_anim[id] == 1) {
    344.                         set_pev(id, pev_sequence, 24)
    345.                     }
    346.                 }
    347.                 case 12: set_pev(id, pev_sequence, 25)             
    348.                 case 13: set_pev(id, pev_sequence, 26)
    349.                 case 14:
    350.                 {
    351.                     if(g_shot_anim[id] == 0)
    352.                     {
    353.                         set_pev(id, pev_sequence, 27)
    354.                     } else if(g_shot_anim[id] == 1) {
    355.                         set_pev(id, pev_sequence, 28)
    356.                     }
    357.                 }
    358.                 case 15: set_pev(id, pev_sequence, 29)
    359.             }
    360.         }
    361.     }
    362.    
    363.     return FMRES_HANDLED
    364. }
    365.  
    366. public cmd_drop(id)
    367. {
    368.     if(get_user_weapon(id) == CSW_SKULL3_M1 || get_user_weapon(id) == CSW_SKULL3_M2 && g_had_skull3[id])
    369.     {
    370.         //return PLUGIN_HANDLED
    371.     }
    372.        
    373.     return PLUGIN_CONTINUE
    374. }
    375.  
    376. public fw_SetModel(entity, model[])
    377. {
    378.     if(!is_valid_ent(entity))
    379.         return FMRES_IGNORED;
    380.    
    381.     static szClassName[33]
    382.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
    383.    
    384.     if(!equal(szClassName, "weaponbox"))
    385.         return FMRES_IGNORED;
    386.    
    387.     static id
    388.     id = entity_get_edict(entity, EV_ENT_owner)
    389.    
    390.     if(equal(model, "models/w_mp5.mdl"))
    391.     {
    392.         static weapon
    393.         weapon = find_ent_by_owner(-1, weapon_skull3_m1, entity)   
    394.        
    395.         if(!pev_valid(weapon))
    396.             return FMRES_IGNORED
    397.        
    398.         if(g_had_skull3[id])
    399.         {
    400.             static weapon2
    401.             weapon2 = find_ent_by_owner(-1, weapon_skull3_m2, id)          
    402.            
    403.             if(pev_valid(weapon2))
    404.             {
    405.                 reset_player_maxspeed(id)                  
    406.                
    407.                 g_skull3_m2_ammo[id] = cs_get_weapon_ammo(weapon2)
    408.                 g_remove_ent[id] = entity
    409.                 //ham_strip_weapon(id, weapon_skull3_m2)
    410.                 //fm_strip_user_gun(id, CSW_SKULL3_M2, weapon_skull3_m2)
    411.                 remove_gun(id, CSW_SKULL3_M2)
    412.                 client_cmd(id, "slot3")
    413.                
    414.                 g_had_skull3[id] = 0
    415.                 entity_set_model(entity, w_model)
    416.                
    417.                 entity_set_int(weapon, EV_INT_impulse, 2085)
    418.                
    419.                 return FMRES_SUPERCEDE
    420.             }
    421.         }
    422.     }
    423.     if(equal(model, "models/w_p90.mdl"))
    424.     {
    425.         static weapon
    426.         weapon = find_ent_by_owner(-1, weapon_skull3_m2, entity)   
    427.        
    428.         if(!pev_valid(weapon))
    429.             return FMRES_IGNORED
    430.        
    431.         if(g_had_skull3[id])
    432.         {
    433.             static weapon1
    434.             weapon1 = find_ent_by_owner(-1, weapon_skull3_m1, id)          
    435.            
    436.             reset_player_maxspeed(id)  
    437.            
    438.             if(pev_valid(weapon1))
    439.             {
    440.                 g_skull3_m2_ammo[id] = cs_get_weapon_ammo(weapon1)
    441.                 g_remove_ent[id] = entity
    442.                 //ham_strip_weapon(id, weapon_skull3_m1)
    443.                 //fm_strip_user_gun(id, CSW_SKULL3_M1, weapon_skull3_m1)
    444.                 remove_gun(id, CSW_SKULL3_M1)
    445.                 client_cmd(id, "slot3")
    446.                
    447.                 g_had_skull3[id] = 0
    448.                 entity_set_model(entity, w_model)
    449.                
    450.                 entity_set_int(weapon, EV_INT_impulse, 2085)
    451.                
    452.                 return FMRES_SUPERCEDE
    453.             }
    454.         }
    455.     }  
    456.    
    457.    
    458.     return FMRES_IGNORED;
    459. }
    460.  
    461. public remove_gun(id, CSW)
    462. {
    463.     new wpnList[32]
    464.     new number
    465.     get_user_weapons(id,wpnList,number)
    466.     for (new i = 0;i < number ;i++) {
    467.         if (wpnList[i] == CSW) {
    468.             fm_strip_user_gun(id, wpnList[i])
    469.         }
    470.     }
    471. }
    472.  
    473. public fw_CmdStart(id, uc_handle, seed)
    474. {
    475.     if(!is_user_alive(id) || !is_user_connected(id))
    476.         return FMRES_IGNORED   
    477.     if(ze_is_user_zombie(id))
    478.         return FMRES_IGNORED       
    479.     if(!g_had_skull3[id])
    480.         return FMRES_IGNORED   
    481.     if(get_user_weapon(id) != CSW_SKULL3_M1 || g_skull3_mode[id] != 1)
    482.         return FMRES_IGNORED
    483.    
    484.     static CurButton
    485.     CurButton = get_uc(uc_handle, UC_Buttons)
    486.    
    487.     if(CurButton & IN_ATTACK2)
    488.     {
    489.         static Float:CurTime
    490.         CurTime = get_gametime()
    491.        
    492.         if(CurTime - 0.5 > g_zoom_time[id])
    493.         {
    494.             if(!g_zoomed[id])
    495.             {
    496.                 cs_set_user_zoom(id, CS_SET_AUGSG552_ZOOM, 1)
    497.                 g_zoomed[id] = 1
    498.                 } else {
    499.                 cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
    500.                 g_zoomed[id] = 0
    501.             }
    502.            
    503.             g_zoom_time[id] = CurTime
    504.         }
    505.     }
    506.    
    507.     return FMRES_HANDLED
    508. }
    509.  
    510. public ham_traceattack(ent, attacker, Float:Damage, Float:fDir[3], ptr, iDamageType)
    511. {
    512.     if(!is_user_alive(attacker) || !is_user_connected(attacker))
    513.         return HAM_IGNORED 
    514.     if(ze_is_user_zombie(attacker))
    515.         return HAM_IGNORED     
    516.     if(!g_had_skull3[attacker])
    517.         return HAM_IGNORED
    518.    
    519.     static Float:flEnd[3]
    520.     get_tr2(ptr, TR_vecEndPos, flEnd)
    521.    
    522.     if(get_user_weapon(attacker) == CSW_SKULL3_M1)
    523.     {
    524.         make_bullet(attacker, flEnd)
    525.        
    526.         static Damage_New
    527.         Damage_New = get_damage_body(get_tr2(ptr, TR_iHitgroup), get_pcvar_float(cvar_damage_m1))
    528.    
    529.         SetHamParamFloat(3, float(Damage_New)) 
    530.     } else if(get_user_weapon(attacker) == CSW_SKULL3_M2) {
    531.         static Damage_New
    532.         Damage_New = get_damage_body(get_tr2(ptr, TR_iHitgroup), get_pcvar_float(cvar_damage_m2))
    533.    
    534.         SetHamParamFloat(3, float(Damage_New))         
    535.     }
    536.    
    537.     return HAM_HANDLED
    538. }
    539.  
    540. public get_damage_body(body, Float:damage)
    541. {
    542.     switch(body)
    543.     {
    544.         case HIT_HEAD: damage *= 4.0
    545.         case HIT_CHEST: damage *= 1.5
    546.         case HIT_STOMACH: damage *= 1.25
    547.         default: damage *= 1.0
    548.     }
    549.  
    550.     return floatround(damage)
    551. }
    552.  
    553. public ham_add_skull3_m1(ent, id)
    554. {
    555.     if(entity_get_int(ent, EV_INT_impulse) == 2085)
    556.     {
    557.         if(pev_valid(g_remove_ent[id]))
    558.         {
    559.             set_pev(g_remove_ent[id], pev_renderfx, kRenderFxGlowShell)
    560.             set_pev(g_remove_ent[id], pev_rendermode, kRenderTransAlpha)
    561.             set_pev(g_remove_ent[id], pev_renderamt, 0)
    562.            
    563.             set_pev(g_remove_ent[id], pev_solid, SOLID_NOT)
    564.             //remove_entity(g_remove_ent[id])
    565.         }
    566.            
    567.         g_had_skull3[id] = 1
    568.         entity_set_int(id, EV_INT_impulse, 0)
    569.        
    570.         fm_give_item(id, weapon_skull3_m2)
    571.        
    572.         g_skull3_mode[id] = 1
    573.         client_cmd(id, weapon_skull3_m1)
    574.        
    575.         static weapon
    576.         weapon = find_ent_by_owner(-1, weapon_skull3_m2, id)       
    577.         cs_set_weapon_ammo(weapon, g_skull3_m2_ammo[id])
    578.        
    579.         set_pev(id, pev_viewmodel2, v_model)
    580.     }          
    581.    
    582.     if(g_had_skull3[id])
    583.     {
    584.         message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
    585.         write_string("weapon_skull3")
    586.         write_byte(10)
    587.         write_byte(120)
    588.         write_byte(-1)
    589.         write_byte(-1)
    590.         write_byte(0)
    591.         write_byte(7)
    592.         write_byte(CSW_SKULL3_M1)
    593.         write_byte(0)
    594.         message_end()          
    595.     }
    596. }
    597.  
    598. public ham_add_skull3_m2(ent, id)
    599. {
    600.     if(entity_get_int(ent, EV_INT_impulse) == 2085)
    601.     {
    602.         if(pev_valid(g_remove_ent[id]))
    603.         {
    604.             set_pev(g_remove_ent[id], pev_renderfx, kRenderFxGlowShell)
    605.             set_pev(g_remove_ent[id], pev_rendermode, kRenderTransAlpha)
    606.             set_pev(g_remove_ent[id], pev_renderamt, 0)
    607.            
    608.             set_pev(g_remove_ent[id], pev_solid, SOLID_NOT)
    609.             //remove_entity(g_remove_ent[id])
    610.         }
    611.            
    612.         g_had_skull3[id] = 1
    613.         entity_set_int(id, EV_INT_impulse, 0)
    614.        
    615.         fm_give_item(id, weapon_skull3_m1)
    616.        
    617.         g_skull3_mode[id] = 2
    618.         client_cmd(id, weapon_skull3_m2)
    619.        
    620.         static weapon
    621.         weapon = find_ent_by_owner(-1, weapon_skull3_m1, id)       
    622.         cs_set_weapon_ammo(weapon, g_skull3_m2_ammo[id])
    623.        
    624.         set_pev(id, pev_viewmodel2, v_model2)
    625.     }  
    626.    
    627.     if(g_had_skull3[id])
    628.     {
    629.         message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
    630.         write_string("weapon_skull3_2")
    631.         write_byte(7)
    632.         write_byte(100)
    633.         write_byte(-1)
    634.         write_byte(-1)
    635.         write_byte(0)
    636.         write_byte(8)
    637.         write_byte(CSW_SKULL3_M2)
    638.         write_byte(0)
    639.         message_end()  
    640.     }
    641. }
    642.  
    643. public ham_anim_skull3_m1(ent, anim, skiplocal, body)
    644. {
    645.     if(!pev_valid(ent))
    646.         return HAM_IGNORED
    647.    
    648.     static id
    649.     id = pev(ent, pev_owner)   
    650.    
    651.     if(is_user_alive(id) && is_user_connected(id) && g_had_skull3[id])
    652.     {
    653.         if(anim == 2)
    654.         {
    655.             if(g_skull3_mode[id] == 2)
    656.             {
    657.                 g_skull3_changing[id] = 1
    658.                
    659.                 set_pev(id, pev_viewmodel2, v_model)
    660.                 set_weapon_anim(id, 6)
    661.                 set_pdata_int(id, 83, 3, 5)
    662.                
    663.                 set_task(3.0, "change_complete1", id)
    664.                 set_nextattack(ent, id, 3.0)
    665.                
    666.                 //event_checkweapon(id)
    667.                
    668.                 reset_player_maxspeed(id)
    669.             } else if(g_skull3_mode[id] == 1) {
    670.                 if(!g_skull3_changing[id])
    671.                 {
    672.                     set_pev(id, pev_viewmodel2, v_model)
    673.                     set_weapon_anim(id, 2)
    674.                    
    675.                     set_nextattack(ent, id, 1.0)
    676.                 } else {
    677.                     set_pev(id, pev_viewmodel2, v_model)
    678.                     set_weapon_anim(id, 2)
    679.                     set_nextattack(ent, id, 1.0)
    680.                    
    681.                     remove_task(id)
    682.                    
    683.                     reset_player_maxspeed(id)
    684.                 }
    685.             }
    686.         }  
    687.         if(anim == 0)
    688.         {
    689.             if(g_skull3_mode[id] == 1)
    690.             {
    691.                 cs_set_user_bpammo(id, CSW_SKULL3_M2, cs_get_user_bpammo(id, CSW_SKULL3_M1))
    692.                 g_skull3_ammo[id] = cs_get_user_bpammo(id, CSW_SKULL3_M2)
    693.                 } else if(g_skull3_mode[id] == 2) {
    694.                 cs_set_user_bpammo(id, CSW_SKULL3_M1, cs_get_user_bpammo(id, CSW_SKULL3_M2))
    695.                 g_skull3_ammo[id] = cs_get_user_bpammo(id, CSW_SKULL3_M1)
    696.             }
    697.         }
    698.     }
    699.    
    700.     return HAM_HANDLED
    701. }
    702.  
    703. public ham_anim_skull3_m2(ent, anim, skiplocal, body)
    704. {
    705.     if(!pev_valid(ent))
    706.         return HAM_IGNORED
    707.    
    708.     static id
    709.     id = pev(ent, pev_owner)
    710.    
    711.     if(is_user_alive(id) && is_user_connected(id) && g_had_skull3[id])
    712.     {
    713.         if(anim == 2)
    714.         {
    715.             if(g_skull3_mode[id] == 1)
    716.             {
    717.                 g_skull3_changing[id] = 1
    718.                
    719.                 set_pev(id, pev_viewmodel2, v_model2)
    720.                 set_weapon_anim(id, 6)
    721.                 set_pdata_int(id, 83, 3, 5)
    722.                
    723.                 set_task(3.0, "change_complete2", id)
    724.                 set_nextattack(ent, id, 3.0)
    725.            
    726.                 //event_checkweapon(id)
    727.                
    728.                 if(pev(id, pev_maxspeed) != get_pcvar_float(cvar_decrease_speed))
    729.                     set_user_maxspeed(id, get_pcvar_float(cvar_decrease_speed))
    730.             } else if(g_skull3_mode[id] == 2) {
    731.                 set_pev(id, pev_viewmodel2, v_model2)
    732.                 set_weapon_anim(id, 2)
    733.                
    734.                 set_nextattack(ent, id, 1.0)
    735.             }
    736.         }  
    737.        
    738.         if(anim == 0)
    739.         {
    740.             if(g_skull3_mode[id] == 1)
    741.             {
    742.                 cs_set_user_bpammo(id, CSW_SKULL3_M2, cs_get_user_bpammo(id, CSW_SKULL3_M1))
    743.                 g_skull3_ammo[id] = cs_get_user_bpammo(id, CSW_SKULL3_M2)
    744.                 } else if(g_skull3_mode[id] == 2) {
    745.                 cs_set_user_bpammo(id, CSW_SKULL3_M1, cs_get_user_bpammo(id, CSW_SKULL3_M2))
    746.                 g_skull3_ammo[id] = cs_get_user_bpammo(id, CSW_SKULL3_M1)
    747.             }
    748.         }      
    749.     }
    750.    
    751.     return HAM_HANDLED
    752. }
    753.  
    754. public fw_Ham_Item_Deploy_Post(ent)
    755. {
    756.     if(!pev_valid(ent))
    757.         return HAM_IGNORED
    758.    
    759.     static id
    760.     id = pev(ent, pev_owner)
    761.    
    762.     if(is_user_alive(id) && is_user_connected(id))
    763.     {  
    764.         if(pev(id, pev_maxspeed) == get_pcvar_float(cvar_decrease_speed))
    765.             reset_player_maxspeed(id)
    766.     }
    767.    
    768.     return HAM_HANDLED
    769. }
    770.  
    771. public ham_deploy_skull3_m1(ent)
    772. {
    773.     if(!pev_valid(ent))
    774.         return HAM_IGNORED
    775.    
    776.     static id
    777.     id = pev(ent, pev_owner)
    778.    
    779.     if(is_user_alive(id) && is_user_connected(id) && g_had_skull3[id] && g_skull3_changing[id])
    780.     {  
    781.         set_nextattack(ent, id, 3.0)
    782.     }
    783.    
    784.     return HAM_HANDLED
    785. }
    786.  
    787. public ham_deploy_skull3_m2(ent)
    788. {
    789.     if(!pev_valid(ent))
    790.         return HAM_IGNORED
    791.    
    792.     static id
    793.     id = pev(ent, pev_owner)
    794.    
    795.     if(is_user_alive(id) && is_user_connected(id) && g_had_skull3[id] && g_skull3_changing[id])
    796.     {  
    797.         set_nextattack(ent, id, 3.0)
    798.     }
    799.    
    800.     return HAM_HANDLED
    801. }
    802.  
    803. public ham_attack_skull3(ent)
    804. {
    805.     if(!pev_valid(ent))
    806.         return HAM_IGNORED
    807.    
    808.     static id
    809.     id = pev(ent, pev_owner)
    810.    
    811.     if(is_user_alive(id) && is_user_connected(id) && g_had_skull3[id])
    812.     {  
    813.         g_is_attacking[id] = 1
    814.         pev(id, pev_punchangle, g_recoil[id])
    815.     }
    816.    
    817.     return HAM_HANDLED
    818. }
    819.  
    820. public ham_attack_skull3_post(ent)
    821. {
    822.     if(!pev_valid(ent))
    823.         return HAM_IGNORED
    824.    
    825.     static id
    826.     id = pev(ent, pev_owner)
    827.    
    828.     if(is_user_alive(id) && is_user_connected(id) && g_had_skull3[id])
    829.     {  
    830.         g_is_attacking[id] = 0
    831.        
    832.         new Float:static_recoil[3]
    833.         pev(id, pev_punchangle, static_recoil)
    834.        
    835.         xs_vec_sub(static_recoil, g_recoil[id], static_recoil)
    836.        
    837.         if(g_skull3_mode[id] == 1)
    838.             xs_vec_mul_scalar(static_recoil, get_pcvar_float(cvar_recoil_m1), static_recoil)
    839.         else if(g_skull3_mode[id] == 2)
    840.             xs_vec_mul_scalar(static_recoil, get_pcvar_float(cvar_recoil_m2), static_recoil)
    841.        
    842.         xs_vec_add(static_recoil, g_recoil[id], static_recoil)
    843.         set_pev(id, pev_punchangle, static_recoil)
    844.        
    845.         if (!cs_get_weapon_ammo(ent))
    846.             return HAM_IGNORED
    847.        
    848.         emit_sound(id, CHAN_WEAPON, skull3_sound[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    849.        
    850.         if(g_skull3_mode[id] == 1)
    851.         {
    852.             set_weapon_anim(id, 3)
    853.         } else if(g_skull3_mode[id] == 2) {
    854.             set_pdata_float(ent, 62, 0.4, 4)
    855.             if(g_shot_anim[id] == 0)
    856.             {
    857.                 set_weapon_anim(id, 3)
    858.                 g_shot_anim[id] = 1
    859.                 } else if(g_shot_anim[id] == 1) {
    860.                 set_weapon_anim(id, 5)
    861.                 g_shot_anim[id] = 0
    862.             }
    863.         }
    864.     }
    865.    
    866.     return HAM_HANDLED
    867. }
    868.  
    869. public ham_reload_skull3(ent)
    870. {
    871.     if(!pev_valid(ent))
    872.         return HAM_IGNORED
    873.    
    874.     static id
    875.     id = pev(ent, pev_owner)
    876.    
    877.     if(is_user_alive(id) && is_user_connected(id) && g_had_skull3[id])
    878.     {      
    879.         g_skull3_clip[id] = -1
    880.        
    881.         new bpammo
    882.        
    883.         if(g_skull3_mode[id] == 1)
    884.             bpammo = cs_get_user_bpammo(id, CSW_SKULL3_M1)
    885.         else if(g_skull3_mode[id] == 2)
    886.             bpammo = cs_get_user_bpammo(id, CSW_SKULL3_M2)
    887.        
    888.         new iClip = get_pdata_int(ent, 51, 4)
    889.        
    890.         if (bpammo <= 0)
    891.             return HAM_SUPERCEDE
    892.        
    893.         if(g_skull3_mode[id] == 1)
    894.         {
    895.             if(iClip >= get_pcvar_num(cvar_clip_m1))
    896.                 return HAM_SUPERCEDE       
    897.             } else if(g_skull3_mode[id] == 2) {
    898.             if(iClip >= get_pcvar_num(cvar_clip_m2))
    899.                 return HAM_SUPERCEDE           
    900.         }
    901.        
    902.         g_skull3_clip[id] = iClip
    903.         g_reload[id] = 1
    904.     }
    905.    
    906.     return HAM_IGNORED
    907. }
    908.  
    909. public ham_reload_skull3_post(ent)
    910. {
    911.     if(!pev_valid(ent))
    912.         return HAM_IGNORED
    913.    
    914.     static id
    915.     id = pev(ent, pev_owner)
    916.    
    917.     if(is_user_alive(id) && is_user_connected(id) && g_had_skull3[id])
    918.     {  
    919.         if (g_skull3_clip[id] == -1)
    920.             return HAM_IGNORED
    921.        
    922.         static Float:reload_time
    923.         if(g_skull3_mode[id] == 1)
    924.             reload_time = 2.2
    925.         else if(g_skull3_mode[id] == 2)
    926.             reload_time = 3.4
    927.        
    928.         set_pdata_int(ent, 51, g_skull3_clip[id], 4)
    929.         set_pdata_float(ent, 48, reload_time, 4)
    930.         set_pdata_float(id, 83, reload_time, 5)
    931.         set_pdata_int(ent, 54, 1, 4)
    932.        
    933.         set_weapon_anim(id, 1)
    934.     }
    935.    
    936.     return HAM_IGNORED
    937. }
    938.  
    939. public ham_postframe_skull3(ent)
    940. {
    941.     if(!pev_valid(ent))
    942.         return HAM_IGNORED
    943.    
    944.     static id
    945.     id = pev(ent, pev_owner)
    946.    
    947.     if(is_user_alive(id) && is_user_connected(id) && g_had_skull3[id])
    948.     {  
    949.         new Float:flNextAttack = get_pdata_float(id, 83, 5)
    950.        
    951.         new bpammo
    952.         if(g_skull3_mode[id] == 1)
    953.             bpammo = cs_get_user_bpammo(id, CSW_SKULL3_M1)
    954.         else if(g_skull3_mode[id] == 2)
    955.             bpammo = cs_get_user_bpammo(id, CSW_SKULL3_M2)
    956.        
    957.         new iClip = get_pdata_int(ent, 51, 4)
    958.         new fInReload = get_pdata_int(ent, 54, 4)
    959.        
    960.         if(fInReload && flNextAttack <= 0.0)
    961.         {
    962.             new temp1
    963.             if(g_skull3_mode[id] == 1)
    964.             {
    965.                 temp1 = min(get_pcvar_num(cvar_clip_m1) - iClip, bpammo)
    966.                 } else if(g_skull3_mode[id] == 2) {
    967.                 temp1 = min(get_pcvar_num(cvar_clip_m2) - iClip, bpammo)           
    968.             }
    969.            
    970.             set_pdata_int(ent, 51, iClip + temp1, 4)
    971.            
    972.             if(g_skull3_mode[id] == 1)
    973.                 cs_set_user_bpammo(id, CSW_SKULL3_M1, bpammo-temp1)
    974.             else if(g_skull3_mode[id] == 2)
    975.                 cs_set_user_bpammo(id, CSW_SKULL3_M2, bpammo-temp1)    
    976.            
    977.             set_pdata_int(ent, 54, 0, 4)
    978.            
    979.             fInReload = 0
    980.             g_reload[id] = 0
    981.         }      
    982.     }
    983.    
    984.     return HAM_IGNORED
    985. }
    986.  
    987. public ham_takedamage_player(victim, inflictor, attacker, Float:damage, damagebits)
    988. {
    989.     if(!is_user_alive(victim) || !is_user_connected(victim))
    990.         return HAM_IGNORED
    991.     if(!is_user_alive(attacker) || !is_user_connected(attacker))
    992.         return HAM_IGNORED     
    993.     if(ze_is_user_zombie(attacker))
    994.         return HAM_IGNORED     
    995.     if(!g_had_skull3[attacker])
    996.         return HAM_IGNORED
    997.    
    998.     if(get_user_weapon(attacker) == CSW_SKULL3_M1 && g_skull3_mode[attacker] == 1)
    999.     {
    1000.         SetHamParamFloat(4, damage * get_pcvar_float(cvar_damage_m1))
    1001.         } else if(get_user_weapon(attacker) == CSW_SKULL3_M2 && g_skull3_mode[attacker] == 2) {
    1002.         SetHamParamFloat(4, damage * get_pcvar_float(cvar_damage_m2))
    1003.     }
    1004.    
    1005.     return HAM_HANDLED
    1006. }
    1007.  
    1008. public client_PostThink(id)
    1009. {
    1010.     if(!is_user_alive(id) || !is_user_connected(id))
    1011.         return
    1012.     if(ze_is_user_zombie(id))
    1013.         return     
    1014.     if(!g_had_skull3[id])
    1015.         return
    1016.     if(get_user_weapon(id) != CSW_SKULL3_M2 || g_skull3_mode[id] != 2)
    1017.         return
    1018.    
    1019.     if(pev(id, pev_maxspeed) != get_pcvar_float(cvar_decrease_speed))
    1020.         set_user_maxspeed(id, get_pcvar_float(cvar_decrease_speed))
    1021. }
    1022.  
    1023. public change_complete1(id)
    1024. {
    1025.     g_skull3_changing[id] = 0
    1026.    
    1027.     if(get_user_weapon(id) == CSW_SKULL3_M1 && g_had_skull3[id])
    1028.         g_skull3_mode[id] = 1
    1029. }
    1030.  
    1031. public change_complete2(id)
    1032. {
    1033.     g_skull3_changing[id] = 0
    1034.    
    1035.     if(get_user_weapon(id) == CSW_SKULL3_M2 && g_had_skull3[id])
    1036.         g_skull3_mode[id] = 2
    1037. }
    1038.  
    1039. stock set_weapon_anim(id, anim)
    1040. {
    1041.     set_pev(id, pev_weaponanim, anim)
    1042.    
    1043.     message_begin(MSG_ONE, SVC_WEAPONANIM, _, id)
    1044.     write_byte(anim)
    1045.     write_byte(pev(id, pev_body))
    1046.     message_end()
    1047. }
    1048.  
    1049. stock set_nextattack(const weapon, const player, const Float:nextTime)
    1050. {
    1051.     const m_flNextPrimaryAttack = 46
    1052.     const m_flNextSecondaryAttack = 47
    1053.     const m_flTimeWeaponIdle = 48
    1054.     const m_flNextAttack = 83
    1055.    
    1056.     set_pdata_float(weapon, m_flNextPrimaryAttack  , nextTime, 4)
    1057.     set_pdata_float(weapon, m_flNextSecondaryAttack, nextTime, 4)
    1058.     set_pdata_float(weapon, m_flTimeWeaponIdle, nextTime, 4)
    1059.     set_pdata_float(player, m_flNextAttack, nextTime, 5)
    1060. }
    1061.  
    1062. stock make_bullet(id, Float:Origin[3])
    1063. {
    1064.     // Find target
    1065.     new target, body
    1066.     get_user_aiming(id, target, body, 999999)
    1067.    
    1068.     if(target > 0 && target <= get_maxplayers())
    1069.     {
    1070.         new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
    1071.         pev(id, pev_origin, fStart)
    1072.        
    1073.         // Get ids view direction
    1074.         velocity_by_aim(id, 64, fVel)
    1075.        
    1076.         // Calculate position where blood should be displayed
    1077.         fStart[0] = Origin[0]
    1078.         fStart[1] = Origin[1]
    1079.         fStart[2] = Origin[2]
    1080.         fEnd[0] = fStart[0]+fVel[0]
    1081.         fEnd[1] = fStart[1]+fVel[1]
    1082.         fEnd[2] = fStart[2]+fVel[2]
    1083.        
    1084.         // Draw traceline from victims origin into ids view direction to find
    1085.         // the location on the wall to put some blood on there
    1086.         new res
    1087.         engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
    1088.         get_tr2(res, TR_vecEndPos, fRes)
    1089.        
    1090.         // Show some blood :)
    1091.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    1092.         write_byte(TE_BLOODSPRITE)
    1093.         write_coord(floatround(fStart[0]))
    1094.         write_coord(floatround(fStart[1]))
    1095.         write_coord(floatround(fStart[2]))
    1096.         write_short(g_bloodspray)
    1097.         write_short(g_blood)
    1098.         write_byte(70)
    1099.         write_byte(random_num(1,2))
    1100.         message_end()
    1101.        
    1102.        
    1103.         } else {
    1104.         new decal = 41
    1105.        
    1106.         // Check if the wall hit is an entity
    1107.         if(target)
    1108.         {
    1109.             // Put decal on an entity
    1110.             message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    1111.             write_byte(TE_DECAL)
    1112.             write_coord(floatround(Origin[0]))
    1113.             write_coord(floatround(Origin[1]))
    1114.             write_coord(floatround(Origin[2]))
    1115.             write_byte(decal)
    1116.             write_short(target)
    1117.             message_end()
    1118.             } else {
    1119.             // Put decal on "world" (a wall)
    1120.             message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    1121.             write_byte(TE_WORLDDECAL)
    1122.             write_coord(floatround(Origin[0]))
    1123.             write_coord(floatround(Origin[1]))
    1124.             write_coord(floatround(Origin[2]))
    1125.             write_byte(decal)
    1126.             message_end()
    1127.         }
    1128.        
    1129.         // Show sparcles
    1130.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    1131.         write_byte(TE_GUNSHOTDECAL)
    1132.         write_coord(floatround(Origin[0]))
    1133.         write_coord(floatround(Origin[1]))
    1134.         write_coord(floatround(Origin[2]))
    1135.         write_short(id)
    1136.         write_byte(decal)
    1137.         message_end()
    1138.     }
    1139. }
    1140.  
    1141. stock drop_weapons(id, dropwhat)
    1142. {
    1143.     static weapons[32], num, i, weaponid
    1144.     num = 0
    1145.     get_user_weapons(id, weapons, num)
    1146.    
    1147.     for (i = 0; i < num; i++)
    1148.     {
    1149.         weaponid = weapons[i]
    1150.        
    1151.         if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
    1152.         {
    1153.             static wname[32]
    1154.             get_weaponname(weaponid, wname, sizeof wname - 1)
    1155.             engclient_cmd(id, "drop", wname)
    1156.         }
    1157.     }
    1158. }
    1159.  
    1160. stock ham_strip_weapon(id, weapon[])
    1161. {
    1162.     if(!equal(weapon,"weapon_",7))
    1163.         return 0
    1164.    
    1165.     new wId = get_weaponid(weapon);
    1166.     if(!wId)
    1167.         return 0;
    1168.    
    1169.     new wEnt;
    1170.     while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
    1171.     if(!wEnt)
    1172.         return 0;
    1173.    
    1174.     if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);
    1175.    
    1176.     if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt))
    1177.         return 0;
    1178.     ExecuteHamB(Ham_Item_Kill,wEnt);
    1179.    
    1180.     set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));
    1181.    
    1182.     return 1
    1183. }
    1184.  
    1185. stock reset_player_maxspeed(id)
    1186. {
    1187.     if(!is_user_alive(id))
    1188.         return
    1189.        
    1190.     set_user_maxspeed(id, g_oldspeed[id])
    1191. }

    I'am not going to Compile this one as you need to update your hamsandwich module to work. I only need to learn you how to convert only this is my point.
He who fails to plan is planning to fail

johnnysins2000
Veteran Member
Veteran Member
Paraguay
Posts: 679
Joined: 7 years ago
Location: Paraguay
Contact:

#2

Post by johnnysins2000 » 7 years ago

U know u can make other Turotial : Changing Zp Natives to ZE

Tell them that If U are Having zp_get_user_zombie

Change it too ze_is_user_zombie


If Zp_User_humanized_post then change it too

Ze_user_humanized

This Type of tutorial will make this extra Item converting Even Easier

Or u want me to do it ? Posting Turotial On Converting Extra Items
Nobody Is That Busy If They Make Time :roll:

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2213
Joined: 7 years ago
Contact:

#3

Post by Raheem » 7 years ago

For other plugins yes you are right. I'll add it also.
He who fails to plan is planning to fail

LosT
Member
Member
Belgium
Posts: 13
Joined: 6 years ago
Contact:

#4

Post by LosT » 6 years ago

not working....

Code: Select all

#include <zombie_escape>
#include <cstrike>

#define PLUGIN "[CSO] PlasmaGun"
#define VERSION "1.0"
#define AUTHOR "Dias Leon"

// ================= Config =================
// ZP Config
//#define COST 30

// Level 1 Config
#define V_MODEL "models/v_plasmagun2.mdl"
#define P_MODEL "models/p_plasmagun.mdl"
#define W_MODEL "models/w_plasmagun.mdl"

new const WeaponSounds[7][] =
{
	"weapons/plasmagun-1.wav",
	"weapons/plasmagun_exp.wav",
	"weapons/plasmagun_idle.wav",
	"weapons/plasmagun_draw.wav",
	"weapons/plasmagun_clipin1.wav",
	"weapons/plasmagun_clipin2.wav",
	"weapons/plasmagun_clipout.wav"
}

new const WeaponResources[3][] =
{
	"sprites/weapon_plasmagun.txt",
	"sprites/640hud3_2.spr",
	"sprites/640hud91_2.spr"
}

new const WeaponFiles[2][] =
{
	"sprites/plasmaball.spr",
	"sprites/plasmabomb.spr"
}

new const MuzzleFlash[] = "sprites/muzzleflash27.spr"

// Level 2 Config
#define DAMAGE 86
#define CLIP 45
#define BPAMMO 250
#define SPEED 1.5
#define RECOIL 0.75

#define PLASMA_SPEED 1000.0
#define PLASMA_RADIUS 100.0

// Level 3 Config
#define CSW_PLASMA CSW_AK47
#define weapon_plasma "weapon_ak47"

#define WEAPON_EVENT "events/ak47.sc"
#define WEAPON_ANIMEXT "carbine"
#define WEAPON_OLD_WMODEL "models/w_ak47.mdl"
#define WEAPON_SECRETCODE 1946

#define WEAPONANIM_SHOOT random_num(3, 5)
#define WEAPONANIM_RELOAD 1

#define WEAPONTIME_DRAW 0.75
#define WEAPONTIME_RELOAD 3.5

// Level 4 Config
#define PLASMABALL_CLASSNAME "plasmaball"
// ============== End of Config ==============

// MACROS
#define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
#define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
#define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))

enum
{
	TEAM_T = 1,
	TEAM_CT
}

// Vars
new g_PlasmaGun
new g_Had_Plasma, g_WeaponClip[33], Float:g_WeaponRecoil[33][3]
new g_Msg_WeaponList, g_Msg_CurWeapon, g_Msg_AmmoX
new g_MuzzleFlash_SprId, g_PlasmaExp_SprId, g_weapon_event, g_HamBot, g_MaxPlayers

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)

	register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0")
	
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)	
	register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")	
	register_forward(FM_SetModel, "fw_SetModel")		
	
	register_think(PLASMABALL_CLASSNAME, "fw_Think_Plasma")
	register_touch(PLASMABALL_CLASSNAME, "*", "fw_Touch_Plasma")
	
	RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_World")
	RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack_Player")	
	RegisterHam(Ham_Weapon_PrimaryAttack, weapon_plasma, "fw_Weapon_PrimaryAttack")
	RegisterHam(Ham_Weapon_PrimaryAttack, weapon_plasma, "fw_Weapon_PrimaryAttack_Post", 1)
	RegisterHam(Ham_Item_Deploy, weapon_plasma, "fw_Item_Deploy_Post", 1)
	RegisterHam(Ham_Item_PostFrame, weapon_plasma, "fw_Item_PostFrame")	
	RegisterHam(Ham_Weapon_Reload, weapon_plasma, "fw_Weapon_Reload")
	RegisterHam(Ham_Weapon_Reload, weapon_plasma, "fw_Weapon_Reload_Post", 1)
	RegisterHam(Ham_Item_AddToPlayer, weapon_plasma, "fw_Item_AddToPlayer_Post", 1)
	
	g_Msg_WeaponList = get_user_msgid("WeaponList")
	g_Msg_CurWeapon = get_user_msgid("CurWeapon")
	g_Msg_AmmoX = get_user_msgid("AmmoX")
	g_MaxPlayers = get_maxplayers()
	
	//register_clcmd("admin_get_plasmagun", "Get_Plasma", ADMIN_KICK)
	register_clcmd("weapon_plasmagun", "Hook_WeaponHud")
}

public plugin_precache()
{
	engfunc(EngFunc_PrecacheModel, V_MODEL)
	engfunc(EngFunc_PrecacheModel, P_MODEL)
	engfunc(EngFunc_PrecacheModel, W_MODEL)
	
	new i
	for(i = 0; i < sizeof(WeaponSounds); i++)
		engfunc(EngFunc_PrecacheSound, WeaponSounds[i])
	for(i = 0; i < sizeof(WeaponResources); i++)
	{
		if(i == 0) engfunc(EngFunc_PrecacheGeneric, WeaponResources[i])
		else engfunc(EngFunc_PrecacheModel, WeaponResources[i])
	}
	for(i = 0; i < sizeof(WeaponFiles); i++)
	{
		if(i == 1) g_PlasmaExp_SprId = engfunc(EngFunc_PrecacheModel, WeaponFiles[i])
		else engfunc(EngFunc_PrecacheModel, WeaponFiles[i])
	}
		
	g_MuzzleFlash_SprId = engfunc(EngFunc_PrecacheModel, MuzzleFlash)
	g_PlasmaGun = ze_register_item("Plazma", 30, 0)
	register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
}

public ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_itemid)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    return ZE_ITEM_AVAILABLE
}

public fw_PrecacheEvent_Post(type, const name[])
{
	if(equal(WEAPON_EVENT, name)) g_weapon_event = get_orig_retval()		
}

public client_putinserver(id)
{
	if(!g_HamBot && is_user_bot(id))
	{
		g_HamBot = 1
		set_task(0.1, "Do_RegisterHam", id)
	}
}

public Do_RegisterHam(id)
{
	RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack_Player")	
}

public ze_select_item_post(player, itemid)
{
    if (itemid != g_itemid)
        return
   
    if (user_has_weapon(player, CSW_M4A1))
    {
        drop_prim(player)
    }
       
    give_item(player, "weapon_m4a1")
    client_print(player, print_chat, "[ZP] You bought Plasma Gun")
    g_HasM4[player] = true;
}
{
	if(ItemID == g_PlasmaGun) Get_Plasma(id)
}

public ze_user_infected(id, iInfector) Remove_Plasma(id)
public ze_user_humanized(id) Remove_Plasma(id)

public Get_Plasma(id)
{
	if(!is_user_alive(id))
		return
		
	Set_BitVar(g_Had_Plasma, id)
	fm_give_item(id, weapon_plasma)
	
	// Set Weapon
	engclient_cmd(id, weapon_plasma)
	
	set_pev(id, pev_viewmodel2, V_MODEL)
	set_pev(id, pev_weaponmodel2, P_MODEL)
	
	set_pdata_string(id, (492) * 4, WEAPON_ANIMEXT, -1 , 20)	
	
	// Set Weapon Base
	static Ent; Ent = fm_get_user_weapon_entity(id, CSW_PLASMA)
	if(!pev_valid(Ent)) return
	
	cs_set_weapon_ammo(Ent, CLIP)
	cs_set_user_bpammo(id, CSW_PLASMA, BPAMMO)
	
	Update_AmmoHud(id, CSW_PLASMA, CLIP, BPAMMO)
}

public Remove_Plasma(id)
{
	UnSet_BitVar(g_Had_Plasma, id)
}

public Hook_WeaponHud(id)
{
	engclient_cmd(id, weapon_plasma)
	return PLUGIN_HANDLED
}

public Event_NewRound() remove_entity_name(PLASMABALL_CLASSNAME)

public fw_Think_Plasma(Ent)
{
	if(!pev_valid(Ent))
		return
		
	static Float:RenderAmt; pev(Ent, pev_renderamt, RenderAmt)
	
	RenderAmt += 50.0
	RenderAmt = float(clamp(floatround(RenderAmt), 0, 255))
	
	set_pev(Ent, pev_renderamt, RenderAmt)
	set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
}

public fw_Touch_Plasma(Ent, Id)
{
	if(!pev_valid(Ent))
		return
	if(pev(Ent, pev_movetype) == MOVETYPE_NONE)
		return
		
	// Exp Sprite
	static Float:Origin[3], TE_FLAG
	pev(Ent, pev_origin, Origin)
	
	TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
	TE_FLAG |= TE_EXPLFLAG_NOSOUND
	TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
	
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(g_PlasmaExp_SprId)
	write_byte(7)
	write_byte(30)
	write_byte(TE_FLAG)
	message_end()	
	
	// Exp Sound
	emit_sound(Ent, CHAN_BODY, WeaponSounds[1], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	
	// Damage
	Damage_Plasma(Ent, Id)
	
	// Remove Ent
	set_pev(Ent, pev_movetype, MOVETYPE_NONE)
	set_task(0.1, "Remove_PlasmaBall", Ent)
}

public Damage_Plasma(Ent, Id)
{
	static Owner; Owner = pev(Ent, pev_iuser1)
	static Attacker; 
	if(!is_user_alive(Owner)) 
	{
		Attacker = 0
		return
	} else Attacker = Owner
	
	if(is_user_alive(Id) && ze_is_user_zombie(Id))
		ExecuteHamB(Ham_TakeDamage, Id, 0, Attacker, float(DAMAGE), DMG_ACID)
	
	for(new i = 0; i < g_MaxPlayers; i++)
	{
		if(!is_user_alive(i))
			continue
		if(entity_range(i, Ent) > PLASMA_RADIUS)
			continue
		if(!ze_is_user_zombie(i))
			continue
			
		ExecuteHamB(Ham_TakeDamage, i, 0, Attacker, float(DAMAGE) / random_float(1.25, 1.5), DMG_ACID)
	}
}

public Remove_PlasmaBall(Ent)
{
	if(!pev_valid(Ent)) return
	engfunc(EngFunc_RemoveEntity, Ent)
}

public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
{
	if(!is_user_alive(id))
		return FMRES_IGNORED	
	if(get_user_weapon(id) == CSW_PLASMA && Get_BitVar(g_Had_Plasma, id))
		set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001) 
	
	return FMRES_HANDLED
}

public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if (!is_user_connected(invoker))
		return FMRES_IGNORED	
	if(get_user_weapon(invoker) != CSW_PLASMA || !Get_BitVar(g_Had_Plasma, invoker))
		return FMRES_IGNORED
	if(eventid != g_weapon_event)
		return FMRES_IGNORED
	
	engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
	
	return FMRES_SUPERCEDE
}

public fw_SetModel(entity, model[])
{
	if(!pev_valid(entity))
		return FMRES_IGNORED
	
	static Classname[32]
	pev(entity, pev_classname, Classname, sizeof(Classname))
	
	if(!equal(Classname, "weaponbox"))
		return FMRES_IGNORED
	
	static iOwner
	iOwner = pev(entity, pev_owner)
	
	if(equal(model, WEAPON_OLD_WMODEL))
	{
		static weapon; weapon = fm_find_ent_by_owner(-1, weapon_plasma, entity)
		
		if(!pev_valid(weapon))
			return FMRES_IGNORED;
		
		if(Get_BitVar(g_Had_Plasma, iOwner))
		{
			Remove_Plasma(iOwner)
			
			set_pev(weapon, pev_impulse, WEAPON_SECRETCODE)
			engfunc(EngFunc_SetModel, entity, W_MODEL)
			
			return FMRES_SUPERCEDE
		}
	}

	return FMRES_IGNORED;
}

public fw_TraceAttack_World(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
{
	if(!is_user_connected(Attacker))
		return HAM_IGNORED	
	if(get_user_weapon(Attacker) != CSW_PLASMA || !Get_BitVar(g_Had_Plasma, Attacker))
		return HAM_IGNORED
	
	return HAM_SUPERCEDE
}

public fw_TraceAttack_Player(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
{
	if(!is_user_connected(Attacker))
		return HAM_IGNORED	
	if(get_user_weapon(Attacker) != CSW_PLASMA || !Get_BitVar(g_Had_Plasma, Attacker))
		return HAM_IGNORED
		
	return HAM_SUPERCEDE
}

public fw_Weapon_PrimaryAttack(Ent)
{
	if(!pev_valid(Ent))
		return
		
	static Id; Id = pev(Ent, pev_owner)
	if(!Get_BitVar(g_Had_Plasma, Id))
		return
	static Ammo; Ammo = cs_get_weapon_ammo(Ent)
	if(Ammo <= 0) return

	// Weapon Shoot
	Set_Weapon_Anim(Id, WEAPONANIM_SHOOT)
	emit_sound(Id, CHAN_WEAPON, WeaponSounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	
	// MuzzleFlash & Effect
	Make_Muzzleflash(Id)
	
	// Create Plasma Effect
	Create_PlasmaBall(Id)
	
	// Speed & Recoil
	pev(Ent, pev_punchangle, g_WeaponRecoil[Id])
}

public fw_Weapon_PrimaryAttack_Post(Ent)
{
	if(!pev_valid(Ent))
		return
		
	static Id; Id = pev(Ent, pev_owner)
	if(!Get_BitVar(g_Had_Plasma, Id))
		return
	static Ammo; Ammo = cs_get_weapon_ammo(Ent)
	if(Ammo <= 0) return
	
	// Speed & Recoil
	set_pdata_float(Ent, 46, get_pdata_float(Ent, 46, 4) * SPEED, 4)
	
	static Float:Push[3]; pev(Id, pev_punchangle, Push)
	
	xs_vec_sub(Push, g_WeaponRecoil[Id], Push)
	xs_vec_mul_scalar(Push, RECOIL, Push)
	xs_vec_add(Push,  g_WeaponRecoil[Id], Push)

	set_pev(Id, pev_punchangle, Push)
}

public fw_Item_Deploy_Post(Ent)
{
	if(!pev_valid(Ent))
		return
		
	static Id; Id = pev(Ent, pev_owner)
	if(!Get_BitVar(g_Had_Plasma, Id))
		return
		
	set_pev(Id, pev_viewmodel2, V_MODEL)
	set_pev(Id, pev_weaponmodel2, P_MODEL)
	
	set_pdata_string(Id, (492) * 4, WEAPON_ANIMEXT, -1 , 20)
	
	// Set Draw
	Set_Player_NextAttack(Id, WEAPONTIME_DRAW)
	Set_Weapon_TimeIdle(Id, CSW_PLASMA, WEAPONTIME_DRAW)
}

public fw_Item_PostFrame(Ent)
{
	if(!pev_valid(Ent))
		return
		
	static Id; Id = pev(Ent, pev_owner)
	if(!Get_BitVar(g_Had_Plasma, Id))
		return
	
	static Float:flNextAttack; flNextAttack = get_pdata_float(Id, 83, 5)
	static bpammo; bpammo = cs_get_user_bpammo(Id, CSW_PLASMA)
	static iClip; iClip = get_pdata_int(Ent, 51, 4)

	if(get_pdata_int(Ent, 54, 4) && flNextAttack <= 0.0)
	{
		static temp1; temp1 = min(CLIP - iClip, bpammo)

		set_pdata_int(Ent, 51, iClip + temp1, 4)
		cs_set_user_bpammo(Id, CSW_PLASMA, bpammo - temp1)		
		
		set_pdata_int(Ent, 54, 0, 4)
	}		
}

public fw_Weapon_Reload(Ent)
{
	if(!pev_valid(Ent))
		return HAM_IGNORED
		
	static Id; Id = pev(Ent, pev_owner)
	if(!Get_BitVar(g_Had_Plasma, Id))
		return HAM_IGNORED
		
	g_WeaponClip[Id] = -1
	
	static bpammo; bpammo = cs_get_user_bpammo(Id, CSW_PLASMA)
	static iClip; iClip = get_pdata_int(Ent, 51, 4)
	
	if(bpammo <= 0) return HAM_SUPERCEDE
	if(iClip >= CLIP) return HAM_SUPERCEDE
		
	g_WeaponClip[Id] = iClip
	return HAM_IGNORED
}

public fw_Weapon_Reload_Post(Ent)
{
	if(!pev_valid(Ent))
		return
		
	static Id; Id = pev(Ent, pev_owner)
	if(!Get_BitVar(g_Had_Plasma, Id))
		return
	if(g_WeaponClip[Id] == -1)
		return
	
	set_pdata_int(Ent, 51, g_WeaponClip[Id], 4)
	set_pdata_int(Ent, 54, 1, 4)
	
	Set_Weapon_Anim(Id, WEAPONANIM_RELOAD)
	set_pdata_float(Id, 83, WEAPONTIME_RELOAD, 5)
}

public fw_Item_AddToPlayer_Post(Ent, Id)
{
	if(!pev_valid(Ent))
		return
		
	if(pev(Ent, pev_impulse) == WEAPON_SECRETCODE)
	{
		Set_BitVar(g_Had_Plasma, Id)
		set_pev(Ent, pev_impulse, 0)
		
		set_task(0.01, "AddToPlayer_Delay", Id)
	}		

	message_begin(MSG_ONE_UNRELIABLE, g_Msg_WeaponList, _, Id)
	write_string(Get_BitVar(g_Had_Plasma, Id) ? "weapon_plasmagun" : "weapon_ak47")
	write_byte(2)
	write_byte(Get_BitVar(g_Had_Plasma, Id) ? 200 : 90)
	write_byte(-1)
	write_byte(-1)
	write_byte(0)
	write_byte(1)
	write_byte(Get_BitVar(g_Had_Plasma, Id) ? CSW_PLASMA : CSW_AK47)
	write_byte(0)
	message_end()			
	
	return
}

public AddToPlayer_Delay(Id)
{
	set_pev(Id, pev_viewmodel2, V_MODEL)
	set_pev(Id, pev_weaponmodel2, P_MODEL)
	
	set_pdata_string(Id, (492) * 4, WEAPON_ANIMEXT, -1 , 20)	
}
		
public Create_PlasmaBall(id)
{
	static Float:StartOrigin[3], Float:TargetOrigin[3], Float:MyVelocity[3], Float:VecLength
	
	get_position(id, 48.0, 10.0, -5.0, StartOrigin)
	get_position(id, 1024.0, 0.0, 0.0, TargetOrigin)
	
	pev(id, pev_velocity, MyVelocity)
	VecLength = vector_length(MyVelocity)
	
	if(VecLength) 
	{
		TargetOrigin[0] += random_float(-16.0, 16.0); TargetOrigin[1] += random_float(-16.0, 16.0); TargetOrigin[2] += random_float(-16.0, 16.0)
	} else {
		TargetOrigin[0] += random_float(-8.0, 8.0); TargetOrigin[1] += random_float(-8.0, 8.0); TargetOrigin[2] += random_float(-8.0, 8.0)
	}
	
	static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
	if(!pev_valid(Ent)) return
	
	// Set info for ent
	set_pev(Ent, pev_movetype, MOVETYPE_FLY)
	set_pev(Ent, pev_rendermode, kRenderTransAdd)
	set_pev(Ent, pev_renderamt, 10.0)
	set_pev(Ent, pev_iuser1, id) // Better than pev_owner
	set_pev(Ent, pev_iuser2, Get_SpecialTeam(id, cs_get_user_team(id)))
	set_pev(Ent, pev_fuser1, get_gametime() + 3.0)
	set_pev(Ent, pev_scale, random_float(0.1, 0.25))
	set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
	
	entity_set_string(Ent, EV_SZ_classname, PLASMABALL_CLASSNAME)
	engfunc(EngFunc_SetModel, Ent, WeaponFiles[0])
	set_pev(Ent, pev_mins, Float:{-1.0, -1.0, -1.0})
	set_pev(Ent, pev_maxs, Float:{1.0, 1.0, 1.0})
	set_pev(Ent, pev_origin, StartOrigin)
	set_pev(Ent, pev_gravity, 0.01)
	set_pev(Ent, pev_solid, SOLID_TRIGGER)
	set_pev(Ent, pev_frame, 0.0)
	
	static Float:Velocity[3]
	get_speed_vector(StartOrigin, TargetOrigin, PLASMA_SPEED, Velocity)
	set_pev(Ent, pev_velocity, Velocity)
}

public Make_Muzzleflash(id)
{
	static Float:Origin[3], TE_FLAG
	get_position(id, 32.0, 6.0, -15.0, Origin)
	
	TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
	TE_FLAG |= TE_EXPLFLAG_NOSOUND
	TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
	
	engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, Origin, id)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(g_MuzzleFlash_SprId)
	write_byte(2)
	write_byte(30)
	write_byte(TE_FLAG)
	message_end()
}

public Update_AmmoHud(id, CSWID, Ammo, BpAmmo)
{
	message_begin(MSG_ONE_UNRELIABLE, g_Msg_CurWeapon, _, id)
	write_byte(1)
	write_byte(CSWID)
	write_byte(Ammo)
	message_end()
	
	message_begin(MSG_ONE_UNRELIABLE, g_Msg_AmmoX, _, id)
	write_byte(10)
	write_byte(BpAmmo)
	message_end()
}

public Get_SpecialTeam(Ent, CsTeams:Team)
{
	if(Team == CS_TEAM_T) return TEAM_T
	else if(Team == CS_TEAM_CT) return TEAM_CT
	
	return 0
}

public CsTeams:Get_PlasmaTeam(Ent)
{
	if(pev(Ent, pev_iuser2) == TEAM_T) return CS_TEAM_T
	else if(pev(Ent, pev_iuser2) == TEAM_CT) return CS_TEAM_CT
	
	return CS_TEAM_UNASSIGNED
}

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
{
	new_velocity[0] = origin2[0] - origin1[0]
	new_velocity[1] = origin2[1] - origin1[1]
	new_velocity[2] = origin2[2] - origin1[2]
	static Float:num; num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
	new_velocity[0] *= num
	new_velocity[1] *= num
	new_velocity[2] *= num
	
	return 1;
}

stock Set_Weapon_TimeIdle(id, WeaponId, Float:TimeIdle)
{
	static Ent; Ent = fm_get_user_weapon_entity(id, WeaponId)
	if(!pev_valid(Ent)) return
		
	set_pdata_float(Ent, 46, TimeIdle, 4)
	set_pdata_float(Ent, 47, TimeIdle, 4)
	set_pdata_float(Ent, 48, TimeIdle + 0.5, 4)
}

stock Set_Player_NextAttack(id, Float:nexttime)
{
	set_pdata_float(id, 83, nexttime, 5)
}

stock Set_Weapon_Anim(id, WeaponAnim)
{
	set_pev(id, pev_weaponanim, WeaponAnim)
	
	message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
	write_byte(WeaponAnim)
	write_byte(pev(id, pev_body))
	message_end()
}

stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
{
	static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
	
	pev(id, pev_origin, vOrigin)
	pev(id, pev_view_ofs, vUp) //for player
	xs_vec_add(vOrigin, vUp, vOrigin)
	pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
	
	angle_vector(vAngle, ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
	angle_vector(vAngle, ANGLEVECTOR_RIGHT, vRight)
	angle_vector(vAngle, ANGLEVECTOR_UP, vUp)
	
	vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
	vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
	vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
}

Code: Select all

//// zp_extra_PlasmaGun.sma
//
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(99) : error 017: undefined symbol "register_think"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(100) : error 017: undefined symbol "register_touch"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(149) : error 017: undefined symbol "g_itemid"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(180) : error 017: undefined symbol "g_itemid"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(185) : error 017: undefined symbol "drop_prim"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(188) : error 017: undefined symbol "give_item"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(190) : error 017: undefined symbol "g_HasM4"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(190) : warning 215: expression has no effect
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(190) : error 001: expected token: ";", but found "]"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(190) : error 029: invalid expression, assumed zero
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(190) : fatal error 107: too many error messages on one line
//
// Compilation aborted.
// 10 Errors.
// Could not locate output file C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\compiled\zp_extra_PlasmaGun.amx (compile failed).

johnnysins2000
Veteran Member
Veteran Member
Paraguay
Posts: 679
Joined: 7 years ago
Location: Paraguay
Contact:

#5

Post by johnnysins2000 » 6 years ago

LosT wrote: 6 years ago not working....

Code: Select all

#include <zombie_escape>
#include <cstrike>

#define PLUGIN "[CSO] PlasmaGun"
#define VERSION "1.0"
#define AUTHOR "Dias Leon"

// ================= Config =================
// ZP Config
//#define COST 30

// Level 1 Config
#define V_MODEL "models/v_plasmagun2.mdl"
#define P_MODEL "models/p_plasmagun.mdl"
#define W_MODEL "models/w_plasmagun.mdl"

new const WeaponSounds[7][] =
{
	"weapons/plasmagun-1.wav",
	"weapons/plasmagun_exp.wav",
	"weapons/plasmagun_idle.wav",
	"weapons/plasmagun_draw.wav",
	"weapons/plasmagun_clipin1.wav",
	"weapons/plasmagun_clipin2.wav",
	"weapons/plasmagun_clipout.wav"
}

new const WeaponResources[3][] =
{
	"sprites/weapon_plasmagun.txt",
	"sprites/640hud3_2.spr",
	"sprites/640hud91_2.spr"
}

new const WeaponFiles[2][] =
{
	"sprites/plasmaball.spr",
	"sprites/plasmabomb.spr"
}

new const MuzzleFlash[] = "sprites/muzzleflash27.spr"

// Level 2 Config
#define DAMAGE 86
#define CLIP 45
#define BPAMMO 250
#define SPEED 1.5
#define RECOIL 0.75

#define PLASMA_SPEED 1000.0
#define PLASMA_RADIUS 100.0

// Level 3 Config
#define CSW_PLASMA CSW_AK47
#define weapon_plasma "weapon_ak47"

#define WEAPON_EVENT "events/ak47.sc"
#define WEAPON_ANIMEXT "carbine"
#define WEAPON_OLD_WMODEL "models/w_ak47.mdl"
#define WEAPON_SECRETCODE 1946

#define WEAPONANIM_SHOOT random_num(3, 5)
#define WEAPONANIM_RELOAD 1

#define WEAPONTIME_DRAW 0.75
#define WEAPONTIME_RELOAD 3.5

// Level 4 Config
#define PLASMABALL_CLASSNAME "plasmaball"
// ============== End of Config ==============

// MACROS
#define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
#define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
#define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))

enum
{
	TEAM_T = 1,
	TEAM_CT
}

// Vars
new g_PlasmaGun
new g_Had_Plasma, g_WeaponClip[33], Float:g_WeaponRecoil[33][3]
new g_Msg_WeaponList, g_Msg_CurWeapon, g_Msg_AmmoX
new g_MuzzleFlash_SprId, g_PlasmaExp_SprId, g_weapon_event, g_HamBot, g_MaxPlayers

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)

	register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0")
	
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)	
	register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")	
	register_forward(FM_SetModel, "fw_SetModel")		
	
	register_think(PLASMABALL_CLASSNAME, "fw_Think_Plasma")
	register_touch(PLASMABALL_CLASSNAME, "*", "fw_Touch_Plasma")
	
	RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_World")
	RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack_Player")	
	RegisterHam(Ham_Weapon_PrimaryAttack, weapon_plasma, "fw_Weapon_PrimaryAttack")
	RegisterHam(Ham_Weapon_PrimaryAttack, weapon_plasma, "fw_Weapon_PrimaryAttack_Post", 1)
	RegisterHam(Ham_Item_Deploy, weapon_plasma, "fw_Item_Deploy_Post", 1)
	RegisterHam(Ham_Item_PostFrame, weapon_plasma, "fw_Item_PostFrame")	
	RegisterHam(Ham_Weapon_Reload, weapon_plasma, "fw_Weapon_Reload")
	RegisterHam(Ham_Weapon_Reload, weapon_plasma, "fw_Weapon_Reload_Post", 1)
	RegisterHam(Ham_Item_AddToPlayer, weapon_plasma, "fw_Item_AddToPlayer_Post", 1)
	
	g_Msg_WeaponList = get_user_msgid("WeaponList")
	g_Msg_CurWeapon = get_user_msgid("CurWeapon")
	g_Msg_AmmoX = get_user_msgid("AmmoX")
	g_MaxPlayers = get_maxplayers()
	
	//register_clcmd("admin_get_plasmagun", "Get_Plasma", ADMIN_KICK)
	register_clcmd("weapon_plasmagun", "Hook_WeaponHud")
}

public plugin_precache()
{
	engfunc(EngFunc_PrecacheModel, V_MODEL)
	engfunc(EngFunc_PrecacheModel, P_MODEL)
	engfunc(EngFunc_PrecacheModel, W_MODEL)
	
	new i
	for(i = 0; i < sizeof(WeaponSounds); i++)
		engfunc(EngFunc_PrecacheSound, WeaponSounds[i])
	for(i = 0; i < sizeof(WeaponResources); i++)
	{
		if(i == 0) engfunc(EngFunc_PrecacheGeneric, WeaponResources[i])
		else engfunc(EngFunc_PrecacheModel, WeaponResources[i])
	}
	for(i = 0; i < sizeof(WeaponFiles); i++)
	{
		if(i == 1) g_PlasmaExp_SprId = engfunc(EngFunc_PrecacheModel, WeaponFiles[i])
		else engfunc(EngFunc_PrecacheModel, WeaponFiles[i])
	}
		
	g_MuzzleFlash_SprId = engfunc(EngFunc_PrecacheModel, MuzzleFlash)
	g_PlasmaGun = ze_register_item("Plazma", 30, 0)
	register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
}

public ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_itemid)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    return ZE_ITEM_AVAILABLE
}

public fw_PrecacheEvent_Post(type, const name[])
{
	if(equal(WEAPON_EVENT, name)) g_weapon_event = get_orig_retval()		
}

public client_putinserver(id)
{
	if(!g_HamBot && is_user_bot(id))
	{
		g_HamBot = 1
		set_task(0.1, "Do_RegisterHam", id)
	}
}

public Do_RegisterHam(id)
{
	RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack_Player")	
}

public ze_select_item_post(player, itemid)
{
    if (itemid != g_itemid)
        return
   
    if (user_has_weapon(player, CSW_M4A1))
    {
        drop_prim(player)
    }
       
    give_item(player, "weapon_m4a1")
    client_print(player, print_chat, "[ZP] You bought Plasma Gun")
    g_HasM4[player] = true;
}
{
	if(ItemID == g_PlasmaGun) Get_Plasma(id)
}

public ze_user_infected(id, iInfector) Remove_Plasma(id)
public ze_user_humanized(id) Remove_Plasma(id)

public Get_Plasma(id)
{
	if(!is_user_alive(id))
		return
		
	Set_BitVar(g_Had_Plasma, id)
	fm_give_item(id, weapon_plasma)
	
	// Set Weapon
	engclient_cmd(id, weapon_plasma)
	
	set_pev(id, pev_viewmodel2, V_MODEL)
	set_pev(id, pev_weaponmodel2, P_MODEL)
	
	set_pdata_string(id, (492) * 4, WEAPON_ANIMEXT, -1 , 20)	
	
	// Set Weapon Base
	static Ent; Ent = fm_get_user_weapon_entity(id, CSW_PLASMA)
	if(!pev_valid(Ent)) return
	
	cs_set_weapon_ammo(Ent, CLIP)
	cs_set_user_bpammo(id, CSW_PLASMA, BPAMMO)
	
	Update_AmmoHud(id, CSW_PLASMA, CLIP, BPAMMO)
}

public Remove_Plasma(id)
{
	UnSet_BitVar(g_Had_Plasma, id)
}

public Hook_WeaponHud(id)
{
	engclient_cmd(id, weapon_plasma)
	return PLUGIN_HANDLED
}

public Event_NewRound() remove_entity_name(PLASMABALL_CLASSNAME)

public fw_Think_Plasma(Ent)
{
	if(!pev_valid(Ent))
		return
		
	static Float:RenderAmt; pev(Ent, pev_renderamt, RenderAmt)
	
	RenderAmt += 50.0
	RenderAmt = float(clamp(floatround(RenderAmt), 0, 255))
	
	set_pev(Ent, pev_renderamt, RenderAmt)
	set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
}

public fw_Touch_Plasma(Ent, Id)
{
	if(!pev_valid(Ent))
		return
	if(pev(Ent, pev_movetype) == MOVETYPE_NONE)
		return
		
	// Exp Sprite
	static Float:Origin[3], TE_FLAG
	pev(Ent, pev_origin, Origin)
	
	TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
	TE_FLAG |= TE_EXPLFLAG_NOSOUND
	TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
	
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(g_PlasmaExp_SprId)
	write_byte(7)
	write_byte(30)
	write_byte(TE_FLAG)
	message_end()	
	
	// Exp Sound
	emit_sound(Ent, CHAN_BODY, WeaponSounds[1], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	
	// Damage
	Damage_Plasma(Ent, Id)
	
	// Remove Ent
	set_pev(Ent, pev_movetype, MOVETYPE_NONE)
	set_task(0.1, "Remove_PlasmaBall", Ent)
}

public Damage_Plasma(Ent, Id)
{
	static Owner; Owner = pev(Ent, pev_iuser1)
	static Attacker; 
	if(!is_user_alive(Owner)) 
	{
		Attacker = 0
		return
	} else Attacker = Owner
	
	if(is_user_alive(Id) && ze_is_user_zombie(Id))
		ExecuteHamB(Ham_TakeDamage, Id, 0, Attacker, float(DAMAGE), DMG_ACID)
	
	for(new i = 0; i < g_MaxPlayers; i++)
	{
		if(!is_user_alive(i))
			continue
		if(entity_range(i, Ent) > PLASMA_RADIUS)
			continue
		if(!ze_is_user_zombie(i))
			continue
			
		ExecuteHamB(Ham_TakeDamage, i, 0, Attacker, float(DAMAGE) / random_float(1.25, 1.5), DMG_ACID)
	}
}

public Remove_PlasmaBall(Ent)
{
	if(!pev_valid(Ent)) return
	engfunc(EngFunc_RemoveEntity, Ent)
}

public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
{
	if(!is_user_alive(id))
		return FMRES_IGNORED	
	if(get_user_weapon(id) == CSW_PLASMA && Get_BitVar(g_Had_Plasma, id))
		set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001) 
	
	return FMRES_HANDLED
}

public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if (!is_user_connected(invoker))
		return FMRES_IGNORED	
	if(get_user_weapon(invoker) != CSW_PLASMA || !Get_BitVar(g_Had_Plasma, invoker))
		return FMRES_IGNORED
	if(eventid != g_weapon_event)
		return FMRES_IGNORED
	
	engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
	
	return FMRES_SUPERCEDE
}

public fw_SetModel(entity, model[])
{
	if(!pev_valid(entity))
		return FMRES_IGNORED
	
	static Classname[32]
	pev(entity, pev_classname, Classname, sizeof(Classname))
	
	if(!equal(Classname, "weaponbox"))
		return FMRES_IGNORED
	
	static iOwner
	iOwner = pev(entity, pev_owner)
	
	if(equal(model, WEAPON_OLD_WMODEL))
	{
		static weapon; weapon = fm_find_ent_by_owner(-1, weapon_plasma, entity)
		
		if(!pev_valid(weapon))
			return FMRES_IGNORED;
		
		if(Get_BitVar(g_Had_Plasma, iOwner))
		{
			Remove_Plasma(iOwner)
			
			set_pev(weapon, pev_impulse, WEAPON_SECRETCODE)
			engfunc(EngFunc_SetModel, entity, W_MODEL)
			
			return FMRES_SUPERCEDE
		}
	}

	return FMRES_IGNORED;
}

public fw_TraceAttack_World(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
{
	if(!is_user_connected(Attacker))
		return HAM_IGNORED	
	if(get_user_weapon(Attacker) != CSW_PLASMA || !Get_BitVar(g_Had_Plasma, Attacker))
		return HAM_IGNORED
	
	return HAM_SUPERCEDE
}

public fw_TraceAttack_Player(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
{
	if(!is_user_connected(Attacker))
		return HAM_IGNORED	
	if(get_user_weapon(Attacker) != CSW_PLASMA || !Get_BitVar(g_Had_Plasma, Attacker))
		return HAM_IGNORED
		
	return HAM_SUPERCEDE
}

public fw_Weapon_PrimaryAttack(Ent)
{
	if(!pev_valid(Ent))
		return
		
	static Id; Id = pev(Ent, pev_owner)
	if(!Get_BitVar(g_Had_Plasma, Id))
		return
	static Ammo; Ammo = cs_get_weapon_ammo(Ent)
	if(Ammo <= 0) return

	// Weapon Shoot
	Set_Weapon_Anim(Id, WEAPONANIM_SHOOT)
	emit_sound(Id, CHAN_WEAPON, WeaponSounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	
	// MuzzleFlash & Effect
	Make_Muzzleflash(Id)
	
	// Create Plasma Effect
	Create_PlasmaBall(Id)
	
	// Speed & Recoil
	pev(Ent, pev_punchangle, g_WeaponRecoil[Id])
}

public fw_Weapon_PrimaryAttack_Post(Ent)
{
	if(!pev_valid(Ent))
		return
		
	static Id; Id = pev(Ent, pev_owner)
	if(!Get_BitVar(g_Had_Plasma, Id))
		return
	static Ammo; Ammo = cs_get_weapon_ammo(Ent)
	if(Ammo <= 0) return
	
	// Speed & Recoil
	set_pdata_float(Ent, 46, get_pdata_float(Ent, 46, 4) * SPEED, 4)
	
	static Float:Push[3]; pev(Id, pev_punchangle, Push)
	
	xs_vec_sub(Push, g_WeaponRecoil[Id], Push)
	xs_vec_mul_scalar(Push, RECOIL, Push)
	xs_vec_add(Push,  g_WeaponRecoil[Id], Push)

	set_pev(Id, pev_punchangle, Push)
}

public fw_Item_Deploy_Post(Ent)
{
	if(!pev_valid(Ent))
		return
		
	static Id; Id = pev(Ent, pev_owner)
	if(!Get_BitVar(g_Had_Plasma, Id))
		return
		
	set_pev(Id, pev_viewmodel2, V_MODEL)
	set_pev(Id, pev_weaponmodel2, P_MODEL)
	
	set_pdata_string(Id, (492) * 4, WEAPON_ANIMEXT, -1 , 20)
	
	// Set Draw
	Set_Player_NextAttack(Id, WEAPONTIME_DRAW)
	Set_Weapon_TimeIdle(Id, CSW_PLASMA, WEAPONTIME_DRAW)
}

public fw_Item_PostFrame(Ent)
{
	if(!pev_valid(Ent))
		return
		
	static Id; Id = pev(Ent, pev_owner)
	if(!Get_BitVar(g_Had_Plasma, Id))
		return
	
	static Float:flNextAttack; flNextAttack = get_pdata_float(Id, 83, 5)
	static bpammo; bpammo = cs_get_user_bpammo(Id, CSW_PLASMA)
	static iClip; iClip = get_pdata_int(Ent, 51, 4)

	if(get_pdata_int(Ent, 54, 4) && flNextAttack <= 0.0)
	{
		static temp1; temp1 = min(CLIP - iClip, bpammo)

		set_pdata_int(Ent, 51, iClip + temp1, 4)
		cs_set_user_bpammo(Id, CSW_PLASMA, bpammo - temp1)		
		
		set_pdata_int(Ent, 54, 0, 4)
	}		
}

public fw_Weapon_Reload(Ent)
{
	if(!pev_valid(Ent))
		return HAM_IGNORED
		
	static Id; Id = pev(Ent, pev_owner)
	if(!Get_BitVar(g_Had_Plasma, Id))
		return HAM_IGNORED
		
	g_WeaponClip[Id] = -1
	
	static bpammo; bpammo = cs_get_user_bpammo(Id, CSW_PLASMA)
	static iClip; iClip = get_pdata_int(Ent, 51, 4)
	
	if(bpammo <= 0) return HAM_SUPERCEDE
	if(iClip >= CLIP) return HAM_SUPERCEDE
		
	g_WeaponClip[Id] = iClip
	return HAM_IGNORED
}

public fw_Weapon_Reload_Post(Ent)
{
	if(!pev_valid(Ent))
		return
		
	static Id; Id = pev(Ent, pev_owner)
	if(!Get_BitVar(g_Had_Plasma, Id))
		return
	if(g_WeaponClip[Id] == -1)
		return
	
	set_pdata_int(Ent, 51, g_WeaponClip[Id], 4)
	set_pdata_int(Ent, 54, 1, 4)
	
	Set_Weapon_Anim(Id, WEAPONANIM_RELOAD)
	set_pdata_float(Id, 83, WEAPONTIME_RELOAD, 5)
}

public fw_Item_AddToPlayer_Post(Ent, Id)
{
	if(!pev_valid(Ent))
		return
		
	if(pev(Ent, pev_impulse) == WEAPON_SECRETCODE)
	{
		Set_BitVar(g_Had_Plasma, Id)
		set_pev(Ent, pev_impulse, 0)
		
		set_task(0.01, "AddToPlayer_Delay", Id)
	}		

	message_begin(MSG_ONE_UNRELIABLE, g_Msg_WeaponList, _, Id)
	write_string(Get_BitVar(g_Had_Plasma, Id) ? "weapon_plasmagun" : "weapon_ak47")
	write_byte(2)
	write_byte(Get_BitVar(g_Had_Plasma, Id) ? 200 : 90)
	write_byte(-1)
	write_byte(-1)
	write_byte(0)
	write_byte(1)
	write_byte(Get_BitVar(g_Had_Plasma, Id) ? CSW_PLASMA : CSW_AK47)
	write_byte(0)
	message_end()			
	
	return
}

public AddToPlayer_Delay(Id)
{
	set_pev(Id, pev_viewmodel2, V_MODEL)
	set_pev(Id, pev_weaponmodel2, P_MODEL)
	
	set_pdata_string(Id, (492) * 4, WEAPON_ANIMEXT, -1 , 20)	
}
		
public Create_PlasmaBall(id)
{
	static Float:StartOrigin[3], Float:TargetOrigin[3], Float:MyVelocity[3], Float:VecLength
	
	get_position(id, 48.0, 10.0, -5.0, StartOrigin)
	get_position(id, 1024.0, 0.0, 0.0, TargetOrigin)
	
	pev(id, pev_velocity, MyVelocity)
	VecLength = vector_length(MyVelocity)
	
	if(VecLength) 
	{
		TargetOrigin[0] += random_float(-16.0, 16.0); TargetOrigin[1] += random_float(-16.0, 16.0); TargetOrigin[2] += random_float(-16.0, 16.0)
	} else {
		TargetOrigin[0] += random_float(-8.0, 8.0); TargetOrigin[1] += random_float(-8.0, 8.0); TargetOrigin[2] += random_float(-8.0, 8.0)
	}
	
	static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
	if(!pev_valid(Ent)) return
	
	// Set info for ent
	set_pev(Ent, pev_movetype, MOVETYPE_FLY)
	set_pev(Ent, pev_rendermode, kRenderTransAdd)
	set_pev(Ent, pev_renderamt, 10.0)
	set_pev(Ent, pev_iuser1, id) // Better than pev_owner
	set_pev(Ent, pev_iuser2, Get_SpecialTeam(id, cs_get_user_team(id)))
	set_pev(Ent, pev_fuser1, get_gametime() + 3.0)
	set_pev(Ent, pev_scale, random_float(0.1, 0.25))
	set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
	
	entity_set_string(Ent, EV_SZ_classname, PLASMABALL_CLASSNAME)
	engfunc(EngFunc_SetModel, Ent, WeaponFiles[0])
	set_pev(Ent, pev_mins, Float:{-1.0, -1.0, -1.0})
	set_pev(Ent, pev_maxs, Float:{1.0, 1.0, 1.0})
	set_pev(Ent, pev_origin, StartOrigin)
	set_pev(Ent, pev_gravity, 0.01)
	set_pev(Ent, pev_solid, SOLID_TRIGGER)
	set_pev(Ent, pev_frame, 0.0)
	
	static Float:Velocity[3]
	get_speed_vector(StartOrigin, TargetOrigin, PLASMA_SPEED, Velocity)
	set_pev(Ent, pev_velocity, Velocity)
}

public Make_Muzzleflash(id)
{
	static Float:Origin[3], TE_FLAG
	get_position(id, 32.0, 6.0, -15.0, Origin)
	
	TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
	TE_FLAG |= TE_EXPLFLAG_NOSOUND
	TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
	
	engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, Origin, id)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(g_MuzzleFlash_SprId)
	write_byte(2)
	write_byte(30)
	write_byte(TE_FLAG)
	message_end()
}

public Update_AmmoHud(id, CSWID, Ammo, BpAmmo)
{
	message_begin(MSG_ONE_UNRELIABLE, g_Msg_CurWeapon, _, id)
	write_byte(1)
	write_byte(CSWID)
	write_byte(Ammo)
	message_end()
	
	message_begin(MSG_ONE_UNRELIABLE, g_Msg_AmmoX, _, id)
	write_byte(10)
	write_byte(BpAmmo)
	message_end()
}

public Get_SpecialTeam(Ent, CsTeams:Team)
{
	if(Team == CS_TEAM_T) return TEAM_T
	else if(Team == CS_TEAM_CT) return TEAM_CT
	
	return 0
}

public CsTeams:Get_PlasmaTeam(Ent)
{
	if(pev(Ent, pev_iuser2) == TEAM_T) return CS_TEAM_T
	else if(pev(Ent, pev_iuser2) == TEAM_CT) return CS_TEAM_CT
	
	return CS_TEAM_UNASSIGNED
}

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
{
	new_velocity[0] = origin2[0] - origin1[0]
	new_velocity[1] = origin2[1] - origin1[1]
	new_velocity[2] = origin2[2] - origin1[2]
	static Float:num; num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
	new_velocity[0] *= num
	new_velocity[1] *= num
	new_velocity[2] *= num
	
	return 1;
}

stock Set_Weapon_TimeIdle(id, WeaponId, Float:TimeIdle)
{
	static Ent; Ent = fm_get_user_weapon_entity(id, WeaponId)
	if(!pev_valid(Ent)) return
		
	set_pdata_float(Ent, 46, TimeIdle, 4)
	set_pdata_float(Ent, 47, TimeIdle, 4)
	set_pdata_float(Ent, 48, TimeIdle + 0.5, 4)
}

stock Set_Player_NextAttack(id, Float:nexttime)
{
	set_pdata_float(id, 83, nexttime, 5)
}

stock Set_Weapon_Anim(id, WeaponAnim)
{
	set_pev(id, pev_weaponanim, WeaponAnim)
	
	message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
	write_byte(WeaponAnim)
	write_byte(pev(id, pev_body))
	message_end()
}

stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
{
	static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
	
	pev(id, pev_origin, vOrigin)
	pev(id, pev_view_ofs, vUp) //for player
	xs_vec_add(vOrigin, vUp, vOrigin)
	pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
	
	angle_vector(vAngle, ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
	angle_vector(vAngle, ANGLEVECTOR_RIGHT, vRight)
	angle_vector(vAngle, ANGLEVECTOR_UP, vUp)
	
	vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
	vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
	vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
}

Code: Select all

//// zp_extra_PlasmaGun.sma
//
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(99) : error 017: undefined symbol "register_think"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(100) : error 017: undefined symbol "register_touch"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(149) : error 017: undefined symbol "g_itemid"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(180) : error 017: undefined symbol "g_itemid"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(185) : error 017: undefined symbol "drop_prim"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(188) : error 017: undefined symbol "give_item"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(190) : error 017: undefined symbol "g_HasM4"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(190) : warning 215: expression has no effect
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(190) : error 001: expected token: ";", but found "]"
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(190) : error 029: invalid expression, assumed zero
// C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\zp_extra_PlasmaGun.sma(190) : fatal error 107: too many error messages on one line
//
// Compilation aborted.
// 10 Errors.
// Could not locate output file C:\Users\rappe\Desktop\SCRIPTING-ZE1.2\compiled\zp_extra_PlasmaGun.amx (compile failed).
You have Not Converted it Correctly !

Give me the original sma code of

Zp_extra_plasmagun.sma

I will show u how to convert correctly !
Nobody Is That Busy If They Make Time :roll:

johnnysins2000
Veteran Member
Veteran Member
Paraguay
Posts: 679
Joined: 7 years ago
Location: Paraguay
Contact:

#6

Post by johnnysins2000 » 6 years ago

oo forgot I have already converted it

http://escapers-zone.net/viewtopic.php? ... p=375#p375
Nobody Is That Busy If They Make Time :roll:

User avatar
Luxurious
Mod Tester
Mod Tester
Egypt
Posts: 177
Joined: 6 years ago
Location: Egypt
Contact:

#7

Post by Luxurious » 5 years ago

Some Problem ...

Code: Select all

// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\Compiler v1.8.3\scripting\compi.sma(94) : error 017: undefined symbol "register_think"
// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\Compiler v1.8.3\scripting\compi.sma(95) : error 017: undefined symbol "register_think"
// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\Compiler v1.8.3\scripting\compi.sma(96) : error 017: undefined symbol "register_touch"
// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\Compiler v1.8.3\scripting\compi.sma(152) : warning 233: symbol "client_disconnect" is marked as deprecated: Use client_disconnected() instead.
//
// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\Compiler v1.8.3\scripting\compi.sma(600) : error 017: undefined symbol "fm_get_aim_origin"
// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\Compiler v1.8.3\scripting\compi.sma(684) : error 017: undefined symbol "find_ent_in_sphere"
//
// 5 Errors.
// Could not locate output file D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\Compiler v1.8.3\scripting\compiled\compi.amx (compile failed).

Code :

Code: Select all

/* Plugin generated by AMXX-Studio */

#pragma compress 1

#include <zombie_escape>
#include <cstrike>
#include <xs>


#define PLUGIN "Star Chaser AR"
#define VERSION "1.0"
#define AUTHOR "Bim Bim Cay"

// Models
#define v_model "models/csnz/v_starchaserar.mdl"
#define w_model "models/csnz/w_starchaserar.mdl"
#define p_model "models/csnz/p_starchaserar.mdl"

// Sounds
#define attack1_sound "weapons/starchaserar-1.wav"
#define attack2_sound "weapons/starchaserar-2.wav"
#define explode_sound "weapons/starchasersr_exp.wav"

// Sprites
#define muzzle_flash "sprites/muzzleflash76.spr"
#define ef_ball "sprites/ef_starchasersr_star.spr"
#define ef_line "sprites/ef_starchasersr_line.spr"
#define ef_explosion "sprites/ef_starchasersr_explosion.spr"

// Anims
#define ANIM_IDLE		0
#define ANIM_RELOAD		1
#define ANIM_DRAW		2
#define ANIM_SHOOT1		3
#define ANIM_SHOOT2		4
#define ANIM_SHOOT3		5

#define ANIM_EXTENSION 		"carbine"

// Entity Classname
#define BALL_CLASSNAME "StarChaserAREf_Ball"
#define MUZZLEFLASH_CLASSNAME "Muzzle_StarChaserAR"

// Configs
#define WEAPON_NAME 		"weapon_starchaserar"
#define WEAPON_BASE		"weapon_aug"

#define WEAPON_MAX_CLIP		35
#define WEAPON_DEFAULT_AMMO	90

#define WEAPON_SHOOT_DAMAGE	45.0
#define WEAPON_EXPLODE_DAMAGE	150.0
#define WEAPON_EXPLODE_RADIUS	100.0

#define WEAPON_TIME_NEXT_ATTACK 0.1
#define WEAPON_TIME_NEXT_ATTACKZ 0.135
#define AMMO_CHARGE 7

// MACROS
#define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
#define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
#define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))

#define INSTANCE(%0) ((%0 == -1) ? 0 : %0)
#define IsValidPev(%0) (pev_valid(%0) == 2)
#define IsObserver(%0) pev(%0,pev_iuser1)
#define OBS_IN_EYE 4

new g_starchaserar
new g_iszWeaponKey
new g_iForwardDecalIndex
new g_Line_SprId, g_Explode_SprId

// Safety
new g_HamBot
new g_IsConnected, g_IsAlive

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	// Safety
	Register_SafetyFunc()
	
	// Forward
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
	register_forward(FM_TraceLine, "fw_TraceLine_Post", 1)
	register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
	register_forward(FM_SetModel, "fw_SetModel")
	
	unregister_forward(FM_DecalIndex, g_iForwardDecalIndex, 1)
	
	// Think
	register_think(MUZZLEFLASH_CLASSNAME, "fw_MuzzleFlash_Think") 
	register_think(BALL_CLASSNAME, "fw_Ball_Think")
	register_touch(BALL_CLASSNAME, "*", "fw_Ball_Touch")
	
	// Ham
	RegisterHam(Ham_Spawn, "weaponbox", "fw_Weaponbox_Spawn_Post", 1)
	
	RegisterHam(Ham_Item_Deploy, WEAPON_BASE, "fw_Item_Deploy_Post", 1)
	RegisterHam(Ham_Item_PostFrame, WEAPON_BASE, "fw_Item_PostFrame")
	RegisterHam(Ham_Weapon_Reload, WEAPON_BASE, "fw_Weapon_Reload")
	RegisterHam(Ham_Weapon_WeaponIdle, WEAPON_BASE, "fw_Weapon_WeaponIdle")
	RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON_BASE, "fw_Weapon_PrimaryAttack")
	
	RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Entity")
	RegisterHam(Ham_TraceAttack, "info_target", "fw_TraceAttack_Entity")
	RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack_Entity")
	
	g_starchaserar = ze_register_item("Star Chaser AR", 30, 0)
}

public plugin_precache()
{
	precache_model(v_model)
	precache_model(w_model)
	precache_model(p_model)
	
	precache_model(ef_ball)
	precache_model(muzzle_flash)
	
	g_Line_SprId = precache_model(ef_line)
	g_Explode_SprId = precache_model(ef_explosion)
	
	precache_sound(attack1_sound)
	precache_sound(attack2_sound)
	precache_sound(explode_sound)
	
	g_iszWeaponKey = engfunc(EngFunc_AllocString, WEAPON_NAME)
	g_iForwardDecalIndex = register_forward(FM_DecalIndex, "fw_DecalIndex_Post", 1)
}

public client_putinserver(iPlayer)
{
	Safety_Connected(iPlayer)
	
	if(!g_HamBot && is_user_bot(iPlayer))
	{
		g_HamBot = 1
		set_task(0.1, "Register_HamBot", iPlayer)
	}
}
 
public Register_HamBot(iPlayer)
{
	Register_SafetyFuncBot(iPlayer)
	RegisterHamFromEntity(Ham_TraceAttack, iPlayer, "fw_TraceAttack_Entity")	
}

public client_disconnect(iPlayer)
{
	Safety_Disconnected(iPlayer)
}

public ze_select_item_post(id, itemid)
{
	if(itemid == g_starchaserar)
	     return
}

public Get_MyWeapon(iPlayer)
{
	Weapon_Give(iPlayer)
} 

//**********************************************
//* Forward Hooking                            *
//********************************************** 
public fw_UpdateClientData_Post(iPlayer, sendweapons, CD_Handle)
{
	enum
	{
		SPEC_MODE,
		SPEC_TARGET,
		SPEC_END
	}
	 
	static aSpecInfo[33][SPEC_END]
	
	static iTarget
	static iSpecMode 
	static iActiveItem
	
	iTarget = (iSpecMode = IsObserver(iPlayer)) ? pev(iPlayer, pev_iuser2) : iPlayer
	
	if(!is_alive(iTarget))
		return FMRES_IGNORED
	
	iActiveItem = get_pdata_cbase(iTarget, 373, 5)
	
	if(!IsValidPev(iActiveItem) || !IsCustomItem(iActiveItem))
		return FMRES_IGNORED
	
	if(iSpecMode)
	{
		if(aSpecInfo[iPlayer][SPEC_MODE] != iSpecMode)
		{
			aSpecInfo[iPlayer][SPEC_MODE] = iSpecMode
			aSpecInfo[iPlayer][SPEC_TARGET] = 0
		}
		
		if(iSpecMode == OBS_IN_EYE && aSpecInfo[iPlayer][SPEC_TARGET] != iTarget)
		{
			aSpecInfo[iPlayer][SPEC_TARGET] = iTarget
			
			Weapon_SendAnim(iPlayer, iActiveItem, ANIM_IDLE)
		}
	}
	
	set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001)
	
	return FMRES_HANDLED
}

public fw_TraceLine_Post(Float:TraceStart[3], Float:TraceEnd[3], fNoMonsters, iEntToSkip, iTrace) <FireBullets: Enabled>
{
	static Float:vecEndPos[3]
	
	get_tr2(iTrace, TR_vecEndPos, vecEndPos)
	engfunc(EngFunc_TraceLine, vecEndPos, TraceStart, fNoMonsters, iEntToSkip, 0)
	
	UTIL_GunshotDecalTrace(0)
	UTIL_GunshotDecalTrace(iTrace, true)
}

public fw_TraceLine_Post() </* Empty statement */>
{
	/* Fallback */
}

public fw_TraceLine_Post() <FireBullets: Disabled>	
{
	/* Do notning */
}

public fw_PlaybackEvent() <FireBullets: Enabled>
{
	return FMRES_SUPERCEDE
}

public fw_PlaybackEvent() </* Empty statement */>		
{ 
	return FMRES_IGNORED 
}

public fw_PlaybackEvent() <FireBullets: Disabled>		
{ 
	return FMRES_IGNORED 
}

//**********************************************
//* Weaponbox world model.                     *
//**********************************************
public fw_SetModel(iEntity) <WeaponBox: Enabled>
{
	state WeaponBox: Disabled
	
	if(!IsValidPev(iEntity))
		return FMRES_IGNORED
	
	#define MAX_ITEM_TYPES	6
	for(new i, iItem; i < MAX_ITEM_TYPES; i++)
	{
		iItem = get_pdata_cbase(iEntity, 34 + i, 4)
		
		if(IsValidPev(iItem) && IsCustomItem(iItem))
		{
			engfunc(EngFunc_SetModel, iEntity, w_model)
			return FMRES_SUPERCEDE
		}
	}
	
	return FMRES_IGNORED
}

public fw_SetModel() </* Empty statement */>	
{ 
	/*  Fallback  */ 
	return FMRES_IGNORED 
}
public fw_SetModel() <WeaponBox: Disabled>	
{ 
	/* Do nothing */ 
	return FMRES_IGNORED 
}

public fw_Weaponbox_Spawn_Post(iWeaponBox)
{
	if(IsValidPev(iWeaponBox))
	{
		state (IsValidPev(pev(iWeaponBox, pev_owner))) WeaponBox: Enabled
	}
	
	return HAM_IGNORED
}

//**********************************************
//* Weapon's codes.                     *
//**********************************************
public fw_Item_Deploy_Post(iItem)
{
	if(!IsCustomItem(iItem))
		return
		
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)	
	
	set_pev(iPlayer, pev_viewmodel2, v_model)
	set_pev(iPlayer, pev_weaponmodel2, p_model)
	
	Weapon_SendAnim(iPlayer, iItem, ANIM_DRAW)
	
	set_pdata_string(iPlayer, (492) * 4, ANIM_EXTENSION, -1 , 20)
}

public fw_Item_PostFrame(iItem)
{
	if(!IsCustomItem(iItem))
		return HAM_IGNORED
	
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)
	
	if(get_pdata_int(iItem, 54, 4))
	{
		static iClip; iClip = get_pdata_int(iItem, 51, 4)
		static iPrimaryAmmoIndex; iPrimaryAmmoIndex = PrimaryAmmoIndex(iItem)
		static iAmmoPrimary; iAmmoPrimary = GetAmmoInventory(iPlayer, iPrimaryAmmoIndex)
		static iAmount; iAmount = min(WEAPON_MAX_CLIP - iClip, iAmmoPrimary)
		
		set_pdata_int(iItem, 51, iClip + iAmount, 4)
		SetAmmoInventory(iPlayer, iPrimaryAmmoIndex, iAmmoPrimary - iAmount)
		
		set_pdata_int(iItem, 54, 0, 4)
	}	
	
	return HAM_IGNORED
}

public fw_Weapon_Reload(iItem)
{
	if(!IsCustomItem(iItem))
		return HAM_IGNORED
		
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)	
	
	static iClip; iClip = get_pdata_int(iItem, 51, 4)
	static iPrimaryAmmoIndex; iPrimaryAmmoIndex = PrimaryAmmoIndex(iItem)
	static iAmmoPrimary; iAmmoPrimary = GetAmmoInventory(iPlayer, iPrimaryAmmoIndex)
	
	if(min(WEAPON_MAX_CLIP - iClip, iAmmoPrimary) <= 0)
		return HAM_SUPERCEDE
	
	set_pdata_int(iItem, 51, 0, 4)
	
	ExecuteHam(Ham_Weapon_Reload, iItem)
	
	set_pdata_int(iItem, 51, iClip, 4)
	
	set_pdata_float(iPlayer, 83, 3.2, 5)
	set_pdata_float(iItem, 48, 3.2, 4)
	
	Weapon_SendAnim(iPlayer, iItem, ANIM_RELOAD)
	
	return HAM_SUPERCEDE	
}

public fw_Weapon_WeaponIdle(iItem)
{
	if(!IsCustomItem(iItem))
		return HAM_IGNORED
		
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)	
	
	ExecuteHamB(Ham_Weapon_ResetEmptySound, iItem)

	if(get_pdata_float(iItem, 48, 4) > 0.0)
		return HAM_SUPERCEDE
	
	set_pdata_float(iItem, 48, 10.0, 4)
	
	Weapon_SendAnim(iPlayer, iItem, ANIM_IDLE)
	
	return HAM_SUPERCEDE
}

public fw_Weapon_PrimaryAttack(iItem)
{
	if(!IsCustomItem(iItem))
		return HAM_IGNORED
		
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)	
	static iClip; iClip = get_pdata_int(iItem, 51, 4)
	
	if(iClip <= 0)
	{
		// No ammo, play empty sound and cancel
		if(get_pdata_int(iItem, 45, 4))
		{
			ExecuteHamB(Ham_Weapon_PlayEmptySound, iItem)
			set_pdata_float(iItem, 46, 0.2, 4)
		}
	
		return HAM_SUPERCEDE
	}
	
	CallOriginalFireBullets(iItem, iPlayer)
	
	static iFlags
	static szAnimation[64], Float:Velocity[3]

	iFlags = pev(iPlayer, pev_flags)
	
	if(iFlags & FL_DUCKING)
	{
		formatex(szAnimation, charsmax(szAnimation), "crouch_shoot_%s", ANIM_EXTENSION)
	}
	else
	{
		formatex(szAnimation, charsmax(szAnimation), "ref_shoot_%s", ANIM_EXTENSION)
	}
	
	Player_SetAnimation(iPlayer, szAnimation)
	
	static ShootAnim
	switch(random_num(0, 2))
	{
		case 0: ShootAnim = ANIM_SHOOT1
		case 1: ShootAnim = ANIM_SHOOT2
		case 2: ShootAnim = ANIM_SHOOT3
	}
		
	Weapon_SendAnim(iPlayer, iItem, ShootAnim)
	
	set_pdata_float(iItem, 48, 0.7, 4)
	
	if(pev(iPlayer, pev_fov) == 90)
	{
		set_pdata_float(iItem, 46, WEAPON_TIME_NEXT_ATTACK, 4)
		set_pdata_float(iItem, 47, WEAPON_TIME_NEXT_ATTACK, 4)
	}
	else
	{
		set_pdata_float(iItem, 46, WEAPON_TIME_NEXT_ATTACKZ, 4)
		set_pdata_float(iItem, 47, WEAPON_TIME_NEXT_ATTACKZ, 4)
	}
	
	pev(iPlayer, pev_velocity, Velocity)
	
	if(xs_vec_len(Velocity) > 0)
	{
		Weapon_KickBack(iItem, iPlayer, 1.0, 0.45, 0.275, 0.05, 4.0, 2.5, 7)
	}
	else if(!(iFlags & FL_ONGROUND))
	{
		Weapon_KickBack(iItem, iPlayer, 1.25, 0.45, 0.22, 0.18, 5.5, 4.0, 5)
	}
	else if(iFlags & FL_DUCKING)
	{
		Weapon_KickBack(iItem, iPlayer, 0.575, 0.325, 0.2, 0.011, 3.25, 2.0, 8)
	}
	else
	{
		Weapon_KickBack(iItem, iPlayer, 0.625, 0.375, 0.25, 0.0125, 3.5, 2.25, 8)
	}

	Make_MuzzleFlash(iPlayer)
	
	static AmmoCharge; AmmoCharge = get_pdata_int(iItem, 30, 4)
	
	if(AmmoCharge < AMMO_CHARGE)
	{
		set_pdata_int(iItem, 30, AmmoCharge + 1, 4)
		
		emit_sound(iPlayer, CHAN_WEAPON, attack1_sound, 1.0, 0.4, 0, 94 + random_num(0, 15))
	}
	else
	{
		set_pdata_int(iItem, 30, 0, 4)
		
		emit_sound(iPlayer, CHAN_WEAPON, attack2_sound, 1.0, 0.4, 0, 94 + random_num(0, 15))
		
		Create_Star(iPlayer)	
	}
	
	return HAM_SUPERCEDE
}

public fw_TraceAttack_Entity(iEntity, iAttacker, Float: flDamage) <FireBullets: Enabled>
{
	SetHamParamFloat(3, WEAPON_SHOOT_DAMAGE)
}

public fw_TraceAttack_Entity() </* Empty statement */>		
{ 
	/* Fallback */ 
}

public fw_TraceAttack_Entity() <FireBullets: Disabled>		
{ 
	/* Do notning */ 
}

//**********************************************
//* Effects                                    *
//**********************************************
Make_MuzzleFlash(iPlayer)
{
	static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))

	set_pev(Ent, pev_classname, MUZZLEFLASH_CLASSNAME)
	
	set_pev(Ent, pev_owner, iPlayer)
	set_pev(Ent, pev_body, 1)
	set_pev(Ent, pev_skin, iPlayer)
	set_pev(Ent, pev_aiment, iPlayer)
	set_pev(Ent, pev_movetype, MOVETYPE_FOLLOW)
	
	engfunc(EngFunc_SetModel, Ent, muzzle_flash)
	
	set_pev(Ent, pev_scale, 0.04)
	set_pev(Ent, pev_frame, 0.0)
	set_pev(Ent, pev_rendermode, kRenderTransAdd)
	set_pev(Ent, pev_renderamt, 250.0)
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.04)
}

public fw_MuzzleFlash_Think(Ent)
{
	if(!pev_valid(Ent))
		return
	
	static Owner; Owner = pev(Ent, pev_owner)
	
	if(!is_alive(Owner))
	{
		set_pev(Ent, pev_flags, FL_KILLME)
		return
	}
	
	static iActiveItem; iActiveItem = get_pdata_cbase(Owner, 373, 5)
	
	if(!IsValidPev(iActiveItem) || !IsCustomItem(iActiveItem))
	{
		set_pev(Ent, pev_flags, FL_KILLME)
		return
	}

	static Float:Frame; pev(Ent, pev_frame, Frame)
	if(Frame > 2.0) 
	{
		set_pev(Ent, pev_flags, FL_KILLME)
		return
	}
	else
	{
		Frame += 1.0
		set_pev(Ent, pev_frame, Frame)
	}
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.04)
}

public Create_Star(iPlayer)
{
	static Float:Origin[3]
	
	if(get_cvar_num("cl_righthand"))
	{
		Get_Position(iPlayer, 48.0, 10.0, -5.0, Origin)
	}
	else
	{
		Get_Position(iPlayer, 48.0, -10.0, -5.0, Origin)
	}

	static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	
	if(!pev_valid(Ent)) 
		return
		
	engfunc(EngFunc_SetModel, Ent, ef_ball)	
	
	set_pev(Ent, pev_classname, BALL_CLASSNAME)
	set_pev(Ent, pev_movetype, MOVETYPE_FLYMISSILE)
	set_pev(Ent, pev_owner, iPlayer)
	set_pev(Ent, pev_origin, Origin)
	
	set_pev(Ent, pev_solid, SOLID_SLIDEBOX)
	set_pev(Ent, pev_mins, {-1.0, -1.0, -1.0})
	set_pev(Ent, pev_maxs, {1.0, 1.0, 1.0})
	
	set_pev(Ent, pev_rendermode, kRenderTransAdd)
	set_pev(Ent, pev_renderamt, 255.0)
	set_pev(Ent, pev_scale, 0.075)
	set_pev(Ent, pev_frame, 0.0)
	
	// Create Velocity
	static Float:Velocity[3], Float:TargetOrigin[3]
	
	fm_get_aim_origin(iPlayer, TargetOrigin)
	get_speed_vector(Origin, TargetOrigin, 2500.0, Velocity)
	
	set_pev(Ent, pev_velocity, Velocity)
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.05)
}

public fw_Ball_Think(Ent)
{
	if(!pev_valid(Ent))
		return
		
	new Float:fFrame
	pev(Ent, pev_frame, fFrame)
	
	// effect exp
	if(fFrame <= 14.0) 
	{
		fFrame += 1.0
		
	}
	else
	{
		fFrame = 0.0
	}
	
	set_pev(Ent, pev_frame, fFrame)
	
	static Float:Origin[3]
	pev(Ent, pev_origin, Origin)
	
	static TE_FLAG
	
	TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
	TE_FLAG |= TE_EXPLFLAG_NOSOUND
	TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
	
	engfunc(EngFunc_MessageBegin, MSG_BROADCAST, SVC_TEMPENTITY, Origin, 0)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(g_Line_SprId)	// sprite index
	write_byte(3)	// scale in 3.4's
	write_byte(20)	// framerate
	write_byte(TE_FLAG)	// flags
	message_end()
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.05)	
}

public fw_Ball_Touch(Ent, Touch)
{
	if(!pev_valid(Ent)) 
		return
		
	static Float:Origin[3]
	pev(Ent, pev_origin, Origin)
	
	static TE_FLAG
	
	TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
	TE_FLAG |= TE_EXPLFLAG_NOSOUND
	TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
	
	engfunc(EngFunc_MessageBegin, MSG_BROADCAST, SVC_TEMPENTITY, Origin, 0)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(g_Explode_SprId)	// sprite index
	write_byte(7)	// scale in 3.4's
	write_byte(45)	// framerate
	write_byte(TE_FLAG)	// flags
	message_end()
	
	emit_sound(Ent, CHAN_BODY, explode_sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	
	static Owner; Owner = pev(Ent, pev_owner)
	
	if(is_connected(Owner))
	{
		static Victim; Victim = -1
		while((Victim = find_ent_in_sphere(Victim, Origin, WEAPON_EXPLODE_RADIUS)) != 0)
		{
			if(is_alive(Victim))
			{
				if(Victim == Owner)
					continue
			}
			else
			{
				if(pev(Victim, pev_takedamage) == DAMAGE_NO)
					continue
			}
		
			ExecuteHamB(Ham_TakeDamage, Victim, Ent, Owner, WEAPON_EXPLODE_DAMAGE, DMG_BULLET)
		}
	}
	
	set_pev(Ent, pev_flags, FL_KILLME)
}


public ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_starchaserar)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW 
   
    return ZE_ITEM_AVAILABLE
}



//**********************************************
//* Safety Functions        		       *
//**********************************************
public Register_SafetyFunc()
{
	RegisterHam(Ham_Spawn, "player", "fw_Safety_Spawn_Post", 1)
	RegisterHam(Ham_Killed, "player", "fw_Safety_Killed_Post", 1)
}

public Register_SafetyFuncBot(iPlayer)
{
	RegisterHamFromEntity(Ham_Spawn, iPlayer, "fw_Safety_Spawn_Post", 1)
	RegisterHamFromEntity(Ham_Killed, iPlayer, "fw_Safety_Killed_Post", 1)
}

public Safety_Connected(iPlayer)
{
	Set_BitVar(g_IsConnected, iPlayer)
	UnSet_BitVar(g_IsAlive, iPlayer)
}

public Safety_Disconnected(iPlayer)
{
	UnSet_BitVar(g_IsConnected, iPlayer)
	UnSet_BitVar(g_IsAlive, iPlayer)
}

public fw_Safety_Spawn_Post(iPlayer)
{
	if(!is_user_alive(iPlayer))
		return
		
	Set_BitVar(g_IsAlive, iPlayer)
}

public fw_Safety_Killed_Post(iPlayer)
{
	UnSet_BitVar(g_IsAlive, iPlayer)
}

public is_connected(iPlayer)
{
	if(!(1 <= iPlayer <= 32))
		return 0
	if(!Get_BitVar(g_IsConnected, iPlayer))
		return 0

	return 1
}

public is_alive(iPlayer)
{
	if(!is_connected(iPlayer))
		return 0
	if(!Get_BitVar(g_IsAlive, iPlayer))
		return 0
		
	return 1
}

//**********************************************
//* Create and check our custom weapon.        *
//**********************************************
IsCustomItem(iItem)
{
	return (pev(iItem, pev_impulse) == g_iszWeaponKey)
}

Weapon_Create(Float: Origin[3] = {0.0, 0.0, 0.0}, Float: Angles[3] = {0.0, 0.0, 0.0})
{
	new iWeapon

	static iszAllocStringCached
	if (iszAllocStringCached || (iszAllocStringCached = engfunc(EngFunc_AllocString, WEAPON_BASE)))
	{
		iWeapon = engfunc(EngFunc_CreateNamedEntity, iszAllocStringCached)
	}
	
	if(!IsValidPev(iWeapon))
		return FM_NULLENT
	
	dllfunc(DLLFunc_Spawn, iWeapon)
	set_pev(iWeapon, pev_origin, Origin)

	set_pdata_int(iWeapon, 51, WEAPON_MAX_CLIP, 4)
	set_pdata_int(iWeapon, 30, 0, 4)

	set_pev(iWeapon, pev_impulse, g_iszWeaponKey)
	set_pev(iWeapon, pev_angles, Angles)
	
	engfunc(EngFunc_SetModel, iWeapon, w_model)

	return iWeapon
}

Weapon_Give(iPlayer)
{
	if(!IsValidPev(iPlayer))
	{
		return FM_NULLENT
	}
	
	new iWeapon, Float: vecOrigin[3]
	pev(iPlayer, pev_origin, vecOrigin)
	
	if((iWeapon = Weapon_Create(vecOrigin)) != FM_NULLENT)
	{
		Player_DropWeapons(iPlayer, ExecuteHamB(Ham_Item_ItemSlot, iWeapon))
		
		set_pev(iWeapon, pev_spawnflags, pev(iWeapon, pev_spawnflags) | SF_NORESPAWN)
		dllfunc(DLLFunc_Touch, iWeapon, iPlayer)
		
		SetAmmoInventory(iPlayer, PrimaryAmmoIndex(iWeapon), WEAPON_DEFAULT_AMMO)
		
		return iWeapon
	}
	
	return FM_NULLENT
}

Player_DropWeapons(iPlayer, iSlot)
{
	new szWeaponName[32], iItem = get_pdata_cbase(iPlayer, 367 + iSlot, 5)

	while(IsValidPev(iItem))
	{
		pev(iItem, pev_classname, szWeaponName, charsmax(szWeaponName))
		engclient_cmd(iPlayer, "drop", szWeaponName)

		iItem = get_pdata_cbase(iItem, 42, 4)
	}
}

//**********************************************
//* Ammo Inventory.                            *
//**********************************************
PrimaryAmmoIndex(iItem)
{
	return get_pdata_int(iItem, 49, 4)
}

GetAmmoInventory(iPlayer, iAmmoIndex)
{
	if(iAmmoIndex == -1)
		return -1
	
	return get_pdata_int(iPlayer, 376 + iAmmoIndex, 5)
}

SetAmmoInventory(iPlayer, iAmmoIndex, iAmount)
{
	if(iAmmoIndex == -1)
		return 0
	
	set_pdata_int(iPlayer, 376 + iAmmoIndex, iAmount, 5)
	
	return 1
}

//**********************************************
//* Fire Bullets.                              *
//**********************************************
CallOriginalFireBullets(iItem, iPlayer)
{
	state FireBullets: Enabled
	static Float:g_Recoil[3]

	pev(iPlayer, pev_punchangle, g_Recoil)
	ExecuteHam(Ham_Weapon_PrimaryAttack, iItem)
	set_pev(iPlayer, pev_punchangle, g_Recoil)
	
	state FireBullets: Disabled
}

//**********************************************
//* Decals.                                    *
//**********************************************
new Array: g_hDecals

public fw_DecalIndex_Post()
{
	if(!g_hDecals)
	{
		g_hDecals = ArrayCreate(1, 1)
	}
	
	ArrayPushCell(g_hDecals, get_orig_retval())
}

UTIL_GunshotDecalTrace(iTrace, bool: bIsGunshot = false)
{
	static iHit
	static iMessage
	static iDecalIndex
	
	static Float:flFraction 
	static Float:vecEndPos[3]
	
	iHit = INSTANCE(get_tr2(iTrace, TR_pHit))
	
	if(iHit && !IsValidPev(iHit) || (pev(iHit, pev_flags) & FL_KILLME))
		return
	
	if(pev(iHit, pev_solid) != SOLID_BSP && pev(iHit, pev_movetype) != MOVETYPE_PUSHSTEP)
		return
	
	iDecalIndex = ExecuteHamB(Ham_DamageDecal, iHit, 0)
	
	if(iDecalIndex < 0 || iDecalIndex >=  ArraySize(g_hDecals))
		return
	
	iDecalIndex = ArrayGetCell(g_hDecals, iDecalIndex)
	
	get_tr2(iTrace, TR_flFraction, flFraction)
	get_tr2(iTrace, TR_vecEndPos, vecEndPos)
	
	if(iDecalIndex < 0 || flFraction >= 1.0)
		return
	
	if(bIsGunshot)
	{
		iMessage = TE_GUNSHOTDECAL
	}
	else
	{
		iMessage = TE_DECAL
		
		if(iHit != 0)
		{
			if(iDecalIndex > 255)
			{
				iMessage = TE_DECALHIGH
				iDecalIndex -= 256
			}
		}
		else
		{
			iMessage = TE_WORLDDECAL
			
			if(iDecalIndex > 255)
			{
				iMessage = TE_WORLDDECALHIGH
				iDecalIndex -= 256
			}
		}
	}
	
	engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEndPos, 0)
	write_byte(iMessage)
	engfunc(EngFunc_WriteCoord, vecEndPos[0])
	engfunc(EngFunc_WriteCoord, vecEndPos[1])
	engfunc(EngFunc_WriteCoord, vecEndPos[2])

	if(bIsGunshot)
	{
		write_short(iHit)
		write_byte(iDecalIndex)
	}
	else 
	{
		write_byte(iDecalIndex)
		
		if(iHit)
		{
			write_short(iHit)
		}
	}
    
	message_end()
}

//**********************************************
//* Set Animations.                            *
//**********************************************
stock Weapon_SendAnim(iPlayer, iItem, iAnim)
{
	static i, iCount, iSpectator, aSpectators[32]
	
	set_pev(iPlayer, pev_weaponanim, iAnim)

	message_begin(MSG_ONE, SVC_WEAPONANIM, .player = iPlayer)
	write_byte(iAnim)
	write_byte(pev(iItem, pev_body))
	message_end()
	
	if(IsObserver(iPlayer))
		return
	
	get_players(aSpectators, iCount, "bch")

	for(i = 0; i < iCount; i++)
	{
		iSpectator = aSpectators[i]
		
		if(IsObserver(iSpectator) != OBS_IN_EYE || pev(iSpectator, pev_iuser2) != iPlayer)
			continue
		
		set_pev(iSpectator, pev_weaponanim, iAnim)

		message_begin(MSG_ONE, SVC_WEAPONANIM, .player = iSpectator)
		write_byte(iAnim)
		write_byte(pev(iItem, pev_body))
		message_end()
	}
}

stock Player_SetAnimation(iPlayer, szAnim[])
{
	#define ACT_RANGE_ATTACK1   28
   
	// Linux extra offsets
	#define extra_offset_animating   4
	#define extra_offset_player 5
   
	// CBaseAnimating
	#define m_flFrameRate      36
	#define m_flGroundSpeed      37
	#define m_flLastEventCheck   38
	#define m_fSequenceFinished   39
	#define m_fSequenceLoops   40
   
	// CBaseMonster
	#define m_Activity      73
	#define m_IdealActivity      74
   
	// CBasePlayer
	#define m_flLastAttackTime   220
   
	new iAnimDesired, Float:flFrameRate, Float:flGroundSpeed, bool:bLoops
      
	if((iAnimDesired = lookup_sequence(iPlayer, szAnim, flFrameRate, bLoops, flGroundSpeed)) == -1)
	{
		iAnimDesired = 0
	}
   
	static Float:flGametime; flGametime = get_gametime()

	set_pev(iPlayer, pev_frame, 0.0)
	set_pev(iPlayer, pev_framerate, 1.0)
	set_pev(iPlayer, pev_animtime, flGametime)
	set_pev(iPlayer, pev_sequence, iAnimDesired)
   
	set_pdata_int(iPlayer, m_fSequenceLoops, bLoops, extra_offset_animating)
	set_pdata_int(iPlayer, m_fSequenceFinished, 0, extra_offset_animating)
   
	set_pdata_float(iPlayer, m_flFrameRate, flFrameRate, extra_offset_animating)
	set_pdata_float(iPlayer, m_flGroundSpeed, flGroundSpeed, extra_offset_animating)
	set_pdata_float(iPlayer, m_flLastEventCheck, flGametime , extra_offset_animating)
   
	set_pdata_int(iPlayer, m_Activity, ACT_RANGE_ATTACK1, extra_offset_player)
	set_pdata_int(iPlayer, m_IdealActivity, ACT_RANGE_ATTACK1, extra_offset_player)  
	set_pdata_float(iPlayer, m_flLastAttackTime, flGametime , extra_offset_player)
}

//**********************************************
//* Kick back.                                 *
//**********************************************
Weapon_KickBack(iItem, iPlayer, Float:upBase, Float:lateralBase, Float:upMod, Float:lateralMod, Float:upMax, Float:lateralMax, directionChange)
{
	static iDirection
	static iShotsFired 
	
	static Float: Punchangle[3]
	pev(iPlayer, pev_punchangle, Punchangle)
	
	if((iShotsFired = get_pdata_int(iItem, 64, 4)) != 1)
	{
		upBase += iShotsFired * upMod
		lateralBase += iShotsFired * lateralMod
	}
	
	upMax *= -1.0
	Punchangle[0] -= upBase
 
	if(upMax >= Punchangle[0])
	{
		Punchangle[0] = upMax
	}
	
	if((iDirection = get_pdata_int(iItem, 60, 4)))
	{
		Punchangle[1] += lateralBase
		
		if(lateralMax < Punchangle[1])
		{
			Punchangle[1] = lateralMax
		}
	}
	else
	{
		lateralMax *= -1.0;
		Punchangle[1] -= lateralBase
		
		if(lateralMax > Punchangle[1])
		{
			Punchangle[1] = lateralMax
		}
	}
	
	if(!random_num(0, directionChange))
	{
		set_pdata_int(iItem, 60, !iDirection, 4)
	}
	
	set_pev(iPlayer, pev_punchangle, Punchangle)
}

//**********************************************
//* Some useful stocks.                        *
//**********************************************
stock get_speed_vector(Float:Origin1[3], Float:Origin2[3], Float:Speed, Float:NewVelocity[3])
{
	NewVelocity[0] = Origin2[0] - Origin1[0]
	NewVelocity[1] = Origin2[1] - Origin1[1]
	NewVelocity[2] = Origin2[2] - Origin1[2]
	new Float:num = floatsqroot(Speed*Speed / (NewVelocity[0]*NewVelocity[0] + NewVelocity[1]*NewVelocity[1] + NewVelocity[2]*NewVelocity[2]))
	NewVelocity[0] *= num
	NewVelocity[1] *= num
	NewVelocity[2] *= num
	
	return 1
}

stock Get_Position(iPlayer, Float:forw, Float:right, Float:up, Float:vStart[])
{
	new Float:Origin[3], Float:Angles[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
	
	pev(iPlayer, pev_origin, Origin)
	pev(iPlayer, pev_view_ofs,vUp) //for player
	xs_vec_add(Origin, vUp, Origin)
	pev(iPlayer, pev_v_angle, Angles) // if normal entity ,use pev_angles
	
	angle_vector(Angles, ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
	angle_vector(Angles, ANGLEVECTOR_RIGHT, vRight)
	angle_vector(Angles, ANGLEVECTOR_UP, vUp)
	
	vStart[0] = Origin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
	vStart[1] = Origin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
	vStart[2] = Origin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
}
DRK Zombie-Escape V1.6
IP : 81.169.153.129:27015

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 599
Joined: 7 years ago
Contact:

#8

Post by czirimbolo » 5 years ago

Luxurious wrote: 5 years ago Some Problem ...

Code: Select all

// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\Compiler v1.8.3\scripting\compi.sma(94) : error 017: undefined symbol "register_think"
// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\Compiler v1.8.3\scripting\compi.sma(95) : error 017: undefined symbol "register_think"
// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\Compiler v1.8.3\scripting\compi.sma(96) : error 017: undefined symbol "register_touch"
// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\Compiler v1.8.3\scripting\compi.sma(152) : warning 233: symbol "client_disconnect" is marked as deprecated: Use client_disconnected() instead.
//
// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\Compiler v1.8.3\scripting\compi.sma(600) : error 017: undefined symbol "fm_get_aim_origin"
// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\Compiler v1.8.3\scripting\compi.sma(684) : error 017: undefined symbol "find_ent_in_sphere"
//
// 5 Errors.
// Could not locate output file D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v 1.8.3\Compiler v1.8.3\scripting\compiled\compi.amx (compile failed).

Code :

Code: Select all

/* Plugin generated by AMXX-Studio */

#pragma compress 1

#include <zombie_escape>
#include <cstrike>
#include <xs>


#define PLUGIN "Star Chaser AR"
#define VERSION "1.0"
#define AUTHOR "Bim Bim Cay"

// Models
#define v_model "models/csnz/v_starchaserar.mdl"
#define w_model "models/csnz/w_starchaserar.mdl"
#define p_model "models/csnz/p_starchaserar.mdl"

// Sounds
#define attack1_sound "weapons/starchaserar-1.wav"
#define attack2_sound "weapons/starchaserar-2.wav"
#define explode_sound "weapons/starchasersr_exp.wav"

// Sprites
#define muzzle_flash "sprites/muzzleflash76.spr"
#define ef_ball "sprites/ef_starchasersr_star.spr"
#define ef_line "sprites/ef_starchasersr_line.spr"
#define ef_explosion "sprites/ef_starchasersr_explosion.spr"

// Anims
#define ANIM_IDLE		0
#define ANIM_RELOAD		1
#define ANIM_DRAW		2
#define ANIM_SHOOT1		3
#define ANIM_SHOOT2		4
#define ANIM_SHOOT3		5

#define ANIM_EXTENSION 		"carbine"

// Entity Classname
#define BALL_CLASSNAME "StarChaserAREf_Ball"
#define MUZZLEFLASH_CLASSNAME "Muzzle_StarChaserAR"

// Configs
#define WEAPON_NAME 		"weapon_starchaserar"
#define WEAPON_BASE		"weapon_aug"

#define WEAPON_MAX_CLIP		35
#define WEAPON_DEFAULT_AMMO	90

#define WEAPON_SHOOT_DAMAGE	45.0
#define WEAPON_EXPLODE_DAMAGE	150.0
#define WEAPON_EXPLODE_RADIUS	100.0

#define WEAPON_TIME_NEXT_ATTACK 0.1
#define WEAPON_TIME_NEXT_ATTACKZ 0.135
#define AMMO_CHARGE 7

// MACROS
#define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
#define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
#define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))

#define INSTANCE(%0) ((%0 == -1) ? 0 : %0)
#define IsValidPev(%0) (pev_valid(%0) == 2)
#define IsObserver(%0) pev(%0,pev_iuser1)
#define OBS_IN_EYE 4

new g_starchaserar
new g_iszWeaponKey
new g_iForwardDecalIndex
new g_Line_SprId, g_Explode_SprId

// Safety
new g_HamBot
new g_IsConnected, g_IsAlive

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	// Safety
	Register_SafetyFunc()
	
	// Forward
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
	register_forward(FM_TraceLine, "fw_TraceLine_Post", 1)
	register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
	register_forward(FM_SetModel, "fw_SetModel")
	
	unregister_forward(FM_DecalIndex, g_iForwardDecalIndex, 1)
	
	// Think
	register_think(MUZZLEFLASH_CLASSNAME, "fw_MuzzleFlash_Think") 
	register_think(BALL_CLASSNAME, "fw_Ball_Think")
	register_touch(BALL_CLASSNAME, "*", "fw_Ball_Touch")
	
	// Ham
	RegisterHam(Ham_Spawn, "weaponbox", "fw_Weaponbox_Spawn_Post", 1)
	
	RegisterHam(Ham_Item_Deploy, WEAPON_BASE, "fw_Item_Deploy_Post", 1)
	RegisterHam(Ham_Item_PostFrame, WEAPON_BASE, "fw_Item_PostFrame")
	RegisterHam(Ham_Weapon_Reload, WEAPON_BASE, "fw_Weapon_Reload")
	RegisterHam(Ham_Weapon_WeaponIdle, WEAPON_BASE, "fw_Weapon_WeaponIdle")
	RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON_BASE, "fw_Weapon_PrimaryAttack")
	
	RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Entity")
	RegisterHam(Ham_TraceAttack, "info_target", "fw_TraceAttack_Entity")
	RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack_Entity")
	
	g_starchaserar = ze_register_item("Star Chaser AR", 30, 0)
}

public plugin_precache()
{
	precache_model(v_model)
	precache_model(w_model)
	precache_model(p_model)
	
	precache_model(ef_ball)
	precache_model(muzzle_flash)
	
	g_Line_SprId = precache_model(ef_line)
	g_Explode_SprId = precache_model(ef_explosion)
	
	precache_sound(attack1_sound)
	precache_sound(attack2_sound)
	precache_sound(explode_sound)
	
	g_iszWeaponKey = engfunc(EngFunc_AllocString, WEAPON_NAME)
	g_iForwardDecalIndex = register_forward(FM_DecalIndex, "fw_DecalIndex_Post", 1)
}

public client_putinserver(iPlayer)
{
	Safety_Connected(iPlayer)
	
	if(!g_HamBot && is_user_bot(iPlayer))
	{
		g_HamBot = 1
		set_task(0.1, "Register_HamBot", iPlayer)
	}
}
 
public Register_HamBot(iPlayer)
{
	Register_SafetyFuncBot(iPlayer)
	RegisterHamFromEntity(Ham_TraceAttack, iPlayer, "fw_TraceAttack_Entity")	
}

public client_disconnect(iPlayer)
{
	Safety_Disconnected(iPlayer)
}

public ze_select_item_post(id, itemid)
{
	if(itemid == g_starchaserar)
	     return
}

public Get_MyWeapon(iPlayer)
{
	Weapon_Give(iPlayer)
} 

//**********************************************
//* Forward Hooking                            *
//********************************************** 
public fw_UpdateClientData_Post(iPlayer, sendweapons, CD_Handle)
{
	enum
	{
		SPEC_MODE,
		SPEC_TARGET,
		SPEC_END
	}
	 
	static aSpecInfo[33][SPEC_END]
	
	static iTarget
	static iSpecMode 
	static iActiveItem
	
	iTarget = (iSpecMode = IsObserver(iPlayer)) ? pev(iPlayer, pev_iuser2) : iPlayer
	
	if(!is_alive(iTarget))
		return FMRES_IGNORED
	
	iActiveItem = get_pdata_cbase(iTarget, 373, 5)
	
	if(!IsValidPev(iActiveItem) || !IsCustomItem(iActiveItem))
		return FMRES_IGNORED
	
	if(iSpecMode)
	{
		if(aSpecInfo[iPlayer][SPEC_MODE] != iSpecMode)
		{
			aSpecInfo[iPlayer][SPEC_MODE] = iSpecMode
			aSpecInfo[iPlayer][SPEC_TARGET] = 0
		}
		
		if(iSpecMode == OBS_IN_EYE && aSpecInfo[iPlayer][SPEC_TARGET] != iTarget)
		{
			aSpecInfo[iPlayer][SPEC_TARGET] = iTarget
			
			Weapon_SendAnim(iPlayer, iActiveItem, ANIM_IDLE)
		}
	}
	
	set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001)
	
	return FMRES_HANDLED
}

public fw_TraceLine_Post(Float:TraceStart[3], Float:TraceEnd[3], fNoMonsters, iEntToSkip, iTrace) <FireBullets: Enabled>
{
	static Float:vecEndPos[3]
	
	get_tr2(iTrace, TR_vecEndPos, vecEndPos)
	engfunc(EngFunc_TraceLine, vecEndPos, TraceStart, fNoMonsters, iEntToSkip, 0)
	
	UTIL_GunshotDecalTrace(0)
	UTIL_GunshotDecalTrace(iTrace, true)
}

public fw_TraceLine_Post() </* Empty statement */>
{
	/* Fallback */
}

public fw_TraceLine_Post() <FireBullets: Disabled>	
{
	/* Do notning */
}

public fw_PlaybackEvent() <FireBullets: Enabled>
{
	return FMRES_SUPERCEDE
}

public fw_PlaybackEvent() </* Empty statement */>		
{ 
	return FMRES_IGNORED 
}

public fw_PlaybackEvent() <FireBullets: Disabled>		
{ 
	return FMRES_IGNORED 
}

//**********************************************
//* Weaponbox world model.                     *
//**********************************************
public fw_SetModel(iEntity) <WeaponBox: Enabled>
{
	state WeaponBox: Disabled
	
	if(!IsValidPev(iEntity))
		return FMRES_IGNORED
	
	#define MAX_ITEM_TYPES	6
	for(new i, iItem; i < MAX_ITEM_TYPES; i++)
	{
		iItem = get_pdata_cbase(iEntity, 34 + i, 4)
		
		if(IsValidPev(iItem) && IsCustomItem(iItem))
		{
			engfunc(EngFunc_SetModel, iEntity, w_model)
			return FMRES_SUPERCEDE
		}
	}
	
	return FMRES_IGNORED
}

public fw_SetModel() </* Empty statement */>	
{ 
	/*  Fallback  */ 
	return FMRES_IGNORED 
}
public fw_SetModel() <WeaponBox: Disabled>	
{ 
	/* Do nothing */ 
	return FMRES_IGNORED 
}

public fw_Weaponbox_Spawn_Post(iWeaponBox)
{
	if(IsValidPev(iWeaponBox))
	{
		state (IsValidPev(pev(iWeaponBox, pev_owner))) WeaponBox: Enabled
	}
	
	return HAM_IGNORED
}

//**********************************************
//* Weapon's codes.                     *
//**********************************************
public fw_Item_Deploy_Post(iItem)
{
	if(!IsCustomItem(iItem))
		return
		
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)	
	
	set_pev(iPlayer, pev_viewmodel2, v_model)
	set_pev(iPlayer, pev_weaponmodel2, p_model)
	
	Weapon_SendAnim(iPlayer, iItem, ANIM_DRAW)
	
	set_pdata_string(iPlayer, (492) * 4, ANIM_EXTENSION, -1 , 20)
}

public fw_Item_PostFrame(iItem)
{
	if(!IsCustomItem(iItem))
		return HAM_IGNORED
	
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)
	
	if(get_pdata_int(iItem, 54, 4))
	{
		static iClip; iClip = get_pdata_int(iItem, 51, 4)
		static iPrimaryAmmoIndex; iPrimaryAmmoIndex = PrimaryAmmoIndex(iItem)
		static iAmmoPrimary; iAmmoPrimary = GetAmmoInventory(iPlayer, iPrimaryAmmoIndex)
		static iAmount; iAmount = min(WEAPON_MAX_CLIP - iClip, iAmmoPrimary)
		
		set_pdata_int(iItem, 51, iClip + iAmount, 4)
		SetAmmoInventory(iPlayer, iPrimaryAmmoIndex, iAmmoPrimary - iAmount)
		
		set_pdata_int(iItem, 54, 0, 4)
	}	
	
	return HAM_IGNORED
}

public fw_Weapon_Reload(iItem)
{
	if(!IsCustomItem(iItem))
		return HAM_IGNORED
		
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)	
	
	static iClip; iClip = get_pdata_int(iItem, 51, 4)
	static iPrimaryAmmoIndex; iPrimaryAmmoIndex = PrimaryAmmoIndex(iItem)
	static iAmmoPrimary; iAmmoPrimary = GetAmmoInventory(iPlayer, iPrimaryAmmoIndex)
	
	if(min(WEAPON_MAX_CLIP - iClip, iAmmoPrimary) <= 0)
		return HAM_SUPERCEDE
	
	set_pdata_int(iItem, 51, 0, 4)
	
	ExecuteHam(Ham_Weapon_Reload, iItem)
	
	set_pdata_int(iItem, 51, iClip, 4)
	
	set_pdata_float(iPlayer, 83, 3.2, 5)
	set_pdata_float(iItem, 48, 3.2, 4)
	
	Weapon_SendAnim(iPlayer, iItem, ANIM_RELOAD)
	
	return HAM_SUPERCEDE	
}

public fw_Weapon_WeaponIdle(iItem)
{
	if(!IsCustomItem(iItem))
		return HAM_IGNORED
		
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)	
	
	ExecuteHamB(Ham_Weapon_ResetEmptySound, iItem)

	if(get_pdata_float(iItem, 48, 4) > 0.0)
		return HAM_SUPERCEDE
	
	set_pdata_float(iItem, 48, 10.0, 4)
	
	Weapon_SendAnim(iPlayer, iItem, ANIM_IDLE)
	
	return HAM_SUPERCEDE
}

public fw_Weapon_PrimaryAttack(iItem)
{
	if(!IsCustomItem(iItem))
		return HAM_IGNORED
		
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)	
	static iClip; iClip = get_pdata_int(iItem, 51, 4)
	
	if(iClip <= 0)
	{
		// No ammo, play empty sound and cancel
		if(get_pdata_int(iItem, 45, 4))
		{
			ExecuteHamB(Ham_Weapon_PlayEmptySound, iItem)
			set_pdata_float(iItem, 46, 0.2, 4)
		}
	
		return HAM_SUPERCEDE
	}
	
	CallOriginalFireBullets(iItem, iPlayer)
	
	static iFlags
	static szAnimation[64], Float:Velocity[3]

	iFlags = pev(iPlayer, pev_flags)
	
	if(iFlags & FL_DUCKING)
	{
		formatex(szAnimation, charsmax(szAnimation), "crouch_shoot_%s", ANIM_EXTENSION)
	}
	else
	{
		formatex(szAnimation, charsmax(szAnimation), "ref_shoot_%s", ANIM_EXTENSION)
	}
	
	Player_SetAnimation(iPlayer, szAnimation)
	
	static ShootAnim
	switch(random_num(0, 2))
	{
		case 0: ShootAnim = ANIM_SHOOT1
		case 1: ShootAnim = ANIM_SHOOT2
		case 2: ShootAnim = ANIM_SHOOT3
	}
		
	Weapon_SendAnim(iPlayer, iItem, ShootAnim)
	
	set_pdata_float(iItem, 48, 0.7, 4)
	
	if(pev(iPlayer, pev_fov) == 90)
	{
		set_pdata_float(iItem, 46, WEAPON_TIME_NEXT_ATTACK, 4)
		set_pdata_float(iItem, 47, WEAPON_TIME_NEXT_ATTACK, 4)
	}
	else
	{
		set_pdata_float(iItem, 46, WEAPON_TIME_NEXT_ATTACKZ, 4)
		set_pdata_float(iItem, 47, WEAPON_TIME_NEXT_ATTACKZ, 4)
	}
	
	pev(iPlayer, pev_velocity, Velocity)
	
	if(xs_vec_len(Velocity) > 0)
	{
		Weapon_KickBack(iItem, iPlayer, 1.0, 0.45, 0.275, 0.05, 4.0, 2.5, 7)
	}
	else if(!(iFlags & FL_ONGROUND))
	{
		Weapon_KickBack(iItem, iPlayer, 1.25, 0.45, 0.22, 0.18, 5.5, 4.0, 5)
	}
	else if(iFlags & FL_DUCKING)
	{
		Weapon_KickBack(iItem, iPlayer, 0.575, 0.325, 0.2, 0.011, 3.25, 2.0, 8)
	}
	else
	{
		Weapon_KickBack(iItem, iPlayer, 0.625, 0.375, 0.25, 0.0125, 3.5, 2.25, 8)
	}

	Make_MuzzleFlash(iPlayer)
	
	static AmmoCharge; AmmoCharge = get_pdata_int(iItem, 30, 4)
	
	if(AmmoCharge < AMMO_CHARGE)
	{
		set_pdata_int(iItem, 30, AmmoCharge + 1, 4)
		
		emit_sound(iPlayer, CHAN_WEAPON, attack1_sound, 1.0, 0.4, 0, 94 + random_num(0, 15))
	}
	else
	{
		set_pdata_int(iItem, 30, 0, 4)
		
		emit_sound(iPlayer, CHAN_WEAPON, attack2_sound, 1.0, 0.4, 0, 94 + random_num(0, 15))
		
		Create_Star(iPlayer)	
	}
	
	return HAM_SUPERCEDE
}

public fw_TraceAttack_Entity(iEntity, iAttacker, Float: flDamage) <FireBullets: Enabled>
{
	SetHamParamFloat(3, WEAPON_SHOOT_DAMAGE)
}

public fw_TraceAttack_Entity() </* Empty statement */>		
{ 
	/* Fallback */ 
}

public fw_TraceAttack_Entity() <FireBullets: Disabled>		
{ 
	/* Do notning */ 
}

//**********************************************
//* Effects                                    *
//**********************************************
Make_MuzzleFlash(iPlayer)
{
	static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))

	set_pev(Ent, pev_classname, MUZZLEFLASH_CLASSNAME)
	
	set_pev(Ent, pev_owner, iPlayer)
	set_pev(Ent, pev_body, 1)
	set_pev(Ent, pev_skin, iPlayer)
	set_pev(Ent, pev_aiment, iPlayer)
	set_pev(Ent, pev_movetype, MOVETYPE_FOLLOW)
	
	engfunc(EngFunc_SetModel, Ent, muzzle_flash)
	
	set_pev(Ent, pev_scale, 0.04)
	set_pev(Ent, pev_frame, 0.0)
	set_pev(Ent, pev_rendermode, kRenderTransAdd)
	set_pev(Ent, pev_renderamt, 250.0)
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.04)
}

public fw_MuzzleFlash_Think(Ent)
{
	if(!pev_valid(Ent))
		return
	
	static Owner; Owner = pev(Ent, pev_owner)
	
	if(!is_alive(Owner))
	{
		set_pev(Ent, pev_flags, FL_KILLME)
		return
	}
	
	static iActiveItem; iActiveItem = get_pdata_cbase(Owner, 373, 5)
	
	if(!IsValidPev(iActiveItem) || !IsCustomItem(iActiveItem))
	{
		set_pev(Ent, pev_flags, FL_KILLME)
		return
	}

	static Float:Frame; pev(Ent, pev_frame, Frame)
	if(Frame > 2.0) 
	{
		set_pev(Ent, pev_flags, FL_KILLME)
		return
	}
	else
	{
		Frame += 1.0
		set_pev(Ent, pev_frame, Frame)
	}
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.04)
}

public Create_Star(iPlayer)
{
	static Float:Origin[3]
	
	if(get_cvar_num("cl_righthand"))
	{
		Get_Position(iPlayer, 48.0, 10.0, -5.0, Origin)
	}
	else
	{
		Get_Position(iPlayer, 48.0, -10.0, -5.0, Origin)
	}

	static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	
	if(!pev_valid(Ent)) 
		return
		
	engfunc(EngFunc_SetModel, Ent, ef_ball)	
	
	set_pev(Ent, pev_classname, BALL_CLASSNAME)
	set_pev(Ent, pev_movetype, MOVETYPE_FLYMISSILE)
	set_pev(Ent, pev_owner, iPlayer)
	set_pev(Ent, pev_origin, Origin)
	
	set_pev(Ent, pev_solid, SOLID_SLIDEBOX)
	set_pev(Ent, pev_mins, {-1.0, -1.0, -1.0})
	set_pev(Ent, pev_maxs, {1.0, 1.0, 1.0})
	
	set_pev(Ent, pev_rendermode, kRenderTransAdd)
	set_pev(Ent, pev_renderamt, 255.0)
	set_pev(Ent, pev_scale, 0.075)
	set_pev(Ent, pev_frame, 0.0)
	
	// Create Velocity
	static Float:Velocity[3], Float:TargetOrigin[3]
	
	fm_get_aim_origin(iPlayer, TargetOrigin)
	get_speed_vector(Origin, TargetOrigin, 2500.0, Velocity)
	
	set_pev(Ent, pev_velocity, Velocity)
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.05)
}

public fw_Ball_Think(Ent)
{
	if(!pev_valid(Ent))
		return
		
	new Float:fFrame
	pev(Ent, pev_frame, fFrame)
	
	// effect exp
	if(fFrame <= 14.0) 
	{
		fFrame += 1.0
		
	}
	else
	{
		fFrame = 0.0
	}
	
	set_pev(Ent, pev_frame, fFrame)
	
	static Float:Origin[3]
	pev(Ent, pev_origin, Origin)
	
	static TE_FLAG
	
	TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
	TE_FLAG |= TE_EXPLFLAG_NOSOUND
	TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
	
	engfunc(EngFunc_MessageBegin, MSG_BROADCAST, SVC_TEMPENTITY, Origin, 0)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(g_Line_SprId)	// sprite index
	write_byte(3)	// scale in 3.4's
	write_byte(20)	// framerate
	write_byte(TE_FLAG)	// flags
	message_end()
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.05)	
}

public fw_Ball_Touch(Ent, Touch)
{
	if(!pev_valid(Ent)) 
		return
		
	static Float:Origin[3]
	pev(Ent, pev_origin, Origin)
	
	static TE_FLAG
	
	TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
	TE_FLAG |= TE_EXPLFLAG_NOSOUND
	TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
	
	engfunc(EngFunc_MessageBegin, MSG_BROADCAST, SVC_TEMPENTITY, Origin, 0)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(g_Explode_SprId)	// sprite index
	write_byte(7)	// scale in 3.4's
	write_byte(45)	// framerate
	write_byte(TE_FLAG)	// flags
	message_end()
	
	emit_sound(Ent, CHAN_BODY, explode_sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	
	static Owner; Owner = pev(Ent, pev_owner)
	
	if(is_connected(Owner))
	{
		static Victim; Victim = -1
		while((Victim = find_ent_in_sphere(Victim, Origin, WEAPON_EXPLODE_RADIUS)) != 0)
		{
			if(is_alive(Victim))
			{
				if(Victim == Owner)
					continue
			}
			else
			{
				if(pev(Victim, pev_takedamage) == DAMAGE_NO)
					continue
			}
		
			ExecuteHamB(Ham_TakeDamage, Victim, Ent, Owner, WEAPON_EXPLODE_DAMAGE, DMG_BULLET)
		}
	}
	
	set_pev(Ent, pev_flags, FL_KILLME)
}


public ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_starchaserar)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW 
   
    return ZE_ITEM_AVAILABLE
}



//**********************************************
//* Safety Functions        		       *
//**********************************************
public Register_SafetyFunc()
{
	RegisterHam(Ham_Spawn, "player", "fw_Safety_Spawn_Post", 1)
	RegisterHam(Ham_Killed, "player", "fw_Safety_Killed_Post", 1)
}

public Register_SafetyFuncBot(iPlayer)
{
	RegisterHamFromEntity(Ham_Spawn, iPlayer, "fw_Safety_Spawn_Post", 1)
	RegisterHamFromEntity(Ham_Killed, iPlayer, "fw_Safety_Killed_Post", 1)
}

public Safety_Connected(iPlayer)
{
	Set_BitVar(g_IsConnected, iPlayer)
	UnSet_BitVar(g_IsAlive, iPlayer)
}

public Safety_Disconnected(iPlayer)
{
	UnSet_BitVar(g_IsConnected, iPlayer)
	UnSet_BitVar(g_IsAlive, iPlayer)
}

public fw_Safety_Spawn_Post(iPlayer)
{
	if(!is_user_alive(iPlayer))
		return
		
	Set_BitVar(g_IsAlive, iPlayer)
}

public fw_Safety_Killed_Post(iPlayer)
{
	UnSet_BitVar(g_IsAlive, iPlayer)
}

public is_connected(iPlayer)
{
	if(!(1 <= iPlayer <= 32))
		return 0
	if(!Get_BitVar(g_IsConnected, iPlayer))
		return 0

	return 1
}

public is_alive(iPlayer)
{
	if(!is_connected(iPlayer))
		return 0
	if(!Get_BitVar(g_IsAlive, iPlayer))
		return 0
		
	return 1
}

//**********************************************
//* Create and check our custom weapon.        *
//**********************************************
IsCustomItem(iItem)
{
	return (pev(iItem, pev_impulse) == g_iszWeaponKey)
}

Weapon_Create(Float: Origin[3] = {0.0, 0.0, 0.0}, Float: Angles[3] = {0.0, 0.0, 0.0})
{
	new iWeapon

	static iszAllocStringCached
	if (iszAllocStringCached || (iszAllocStringCached = engfunc(EngFunc_AllocString, WEAPON_BASE)))
	{
		iWeapon = engfunc(EngFunc_CreateNamedEntity, iszAllocStringCached)
	}
	
	if(!IsValidPev(iWeapon))
		return FM_NULLENT
	
	dllfunc(DLLFunc_Spawn, iWeapon)
	set_pev(iWeapon, pev_origin, Origin)

	set_pdata_int(iWeapon, 51, WEAPON_MAX_CLIP, 4)
	set_pdata_int(iWeapon, 30, 0, 4)

	set_pev(iWeapon, pev_impulse, g_iszWeaponKey)
	set_pev(iWeapon, pev_angles, Angles)
	
	engfunc(EngFunc_SetModel, iWeapon, w_model)

	return iWeapon
}

Weapon_Give(iPlayer)
{
	if(!IsValidPev(iPlayer))
	{
		return FM_NULLENT
	}
	
	new iWeapon, Float: vecOrigin[3]
	pev(iPlayer, pev_origin, vecOrigin)
	
	if((iWeapon = Weapon_Create(vecOrigin)) != FM_NULLENT)
	{
		Player_DropWeapons(iPlayer, ExecuteHamB(Ham_Item_ItemSlot, iWeapon))
		
		set_pev(iWeapon, pev_spawnflags, pev(iWeapon, pev_spawnflags) | SF_NORESPAWN)
		dllfunc(DLLFunc_Touch, iWeapon, iPlayer)
		
		SetAmmoInventory(iPlayer, PrimaryAmmoIndex(iWeapon), WEAPON_DEFAULT_AMMO)
		
		return iWeapon
	}
	
	return FM_NULLENT
}

Player_DropWeapons(iPlayer, iSlot)
{
	new szWeaponName[32], iItem = get_pdata_cbase(iPlayer, 367 + iSlot, 5)

	while(IsValidPev(iItem))
	{
		pev(iItem, pev_classname, szWeaponName, charsmax(szWeaponName))
		engclient_cmd(iPlayer, "drop", szWeaponName)

		iItem = get_pdata_cbase(iItem, 42, 4)
	}
}

//**********************************************
//* Ammo Inventory.                            *
//**********************************************
PrimaryAmmoIndex(iItem)
{
	return get_pdata_int(iItem, 49, 4)
}

GetAmmoInventory(iPlayer, iAmmoIndex)
{
	if(iAmmoIndex == -1)
		return -1
	
	return get_pdata_int(iPlayer, 376 + iAmmoIndex, 5)
}

SetAmmoInventory(iPlayer, iAmmoIndex, iAmount)
{
	if(iAmmoIndex == -1)
		return 0
	
	set_pdata_int(iPlayer, 376 + iAmmoIndex, iAmount, 5)
	
	return 1
}

//**********************************************
//* Fire Bullets.                              *
//**********************************************
CallOriginalFireBullets(iItem, iPlayer)
{
	state FireBullets: Enabled
	static Float:g_Recoil[3]

	pev(iPlayer, pev_punchangle, g_Recoil)
	ExecuteHam(Ham_Weapon_PrimaryAttack, iItem)
	set_pev(iPlayer, pev_punchangle, g_Recoil)
	
	state FireBullets: Disabled
}

//**********************************************
//* Decals.                                    *
//**********************************************
new Array: g_hDecals

public fw_DecalIndex_Post()
{
	if(!g_hDecals)
	{
		g_hDecals = ArrayCreate(1, 1)
	}
	
	ArrayPushCell(g_hDecals, get_orig_retval())
}

UTIL_GunshotDecalTrace(iTrace, bool: bIsGunshot = false)
{
	static iHit
	static iMessage
	static iDecalIndex
	
	static Float:flFraction 
	static Float:vecEndPos[3]
	
	iHit = INSTANCE(get_tr2(iTrace, TR_pHit))
	
	if(iHit && !IsValidPev(iHit) || (pev(iHit, pev_flags) & FL_KILLME))
		return
	
	if(pev(iHit, pev_solid) != SOLID_BSP && pev(iHit, pev_movetype) != MOVETYPE_PUSHSTEP)
		return
	
	iDecalIndex = ExecuteHamB(Ham_DamageDecal, iHit, 0)
	
	if(iDecalIndex < 0 || iDecalIndex >=  ArraySize(g_hDecals))
		return
	
	iDecalIndex = ArrayGetCell(g_hDecals, iDecalIndex)
	
	get_tr2(iTrace, TR_flFraction, flFraction)
	get_tr2(iTrace, TR_vecEndPos, vecEndPos)
	
	if(iDecalIndex < 0 || flFraction >= 1.0)
		return
	
	if(bIsGunshot)
	{
		iMessage = TE_GUNSHOTDECAL
	}
	else
	{
		iMessage = TE_DECAL
		
		if(iHit != 0)
		{
			if(iDecalIndex > 255)
			{
				iMessage = TE_DECALHIGH
				iDecalIndex -= 256
			}
		}
		else
		{
			iMessage = TE_WORLDDECAL
			
			if(iDecalIndex > 255)
			{
				iMessage = TE_WORLDDECALHIGH
				iDecalIndex -= 256
			}
		}
	}
	
	engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEndPos, 0)
	write_byte(iMessage)
	engfunc(EngFunc_WriteCoord, vecEndPos[0])
	engfunc(EngFunc_WriteCoord, vecEndPos[1])
	engfunc(EngFunc_WriteCoord, vecEndPos[2])

	if(bIsGunshot)
	{
		write_short(iHit)
		write_byte(iDecalIndex)
	}
	else 
	{
		write_byte(iDecalIndex)
		
		if(iHit)
		{
			write_short(iHit)
		}
	}
    
	message_end()
}

//**********************************************
//* Set Animations.                            *
//**********************************************
stock Weapon_SendAnim(iPlayer, iItem, iAnim)
{
	static i, iCount, iSpectator, aSpectators[32]
	
	set_pev(iPlayer, pev_weaponanim, iAnim)

	message_begin(MSG_ONE, SVC_WEAPONANIM, .player = iPlayer)
	write_byte(iAnim)
	write_byte(pev(iItem, pev_body))
	message_end()
	
	if(IsObserver(iPlayer))
		return
	
	get_players(aSpectators, iCount, "bch")

	for(i = 0; i < iCount; i++)
	{
		iSpectator = aSpectators[i]
		
		if(IsObserver(iSpectator) != OBS_IN_EYE || pev(iSpectator, pev_iuser2) != iPlayer)
			continue
		
		set_pev(iSpectator, pev_weaponanim, iAnim)

		message_begin(MSG_ONE, SVC_WEAPONANIM, .player = iSpectator)
		write_byte(iAnim)
		write_byte(pev(iItem, pev_body))
		message_end()
	}
}

stock Player_SetAnimation(iPlayer, szAnim[])
{
	#define ACT_RANGE_ATTACK1   28
   
	// Linux extra offsets
	#define extra_offset_animating   4
	#define extra_offset_player 5
   
	// CBaseAnimating
	#define m_flFrameRate      36
	#define m_flGroundSpeed      37
	#define m_flLastEventCheck   38
	#define m_fSequenceFinished   39
	#define m_fSequenceLoops   40
   
	// CBaseMonster
	#define m_Activity      73
	#define m_IdealActivity      74
   
	// CBasePlayer
	#define m_flLastAttackTime   220
   
	new iAnimDesired, Float:flFrameRate, Float:flGroundSpeed, bool:bLoops
      
	if((iAnimDesired = lookup_sequence(iPlayer, szAnim, flFrameRate, bLoops, flGroundSpeed)) == -1)
	{
		iAnimDesired = 0
	}
   
	static Float:flGametime; flGametime = get_gametime()

	set_pev(iPlayer, pev_frame, 0.0)
	set_pev(iPlayer, pev_framerate, 1.0)
	set_pev(iPlayer, pev_animtime, flGametime)
	set_pev(iPlayer, pev_sequence, iAnimDesired)
   
	set_pdata_int(iPlayer, m_fSequenceLoops, bLoops, extra_offset_animating)
	set_pdata_int(iPlayer, m_fSequenceFinished, 0, extra_offset_animating)
   
	set_pdata_float(iPlayer, m_flFrameRate, flFrameRate, extra_offset_animating)
	set_pdata_float(iPlayer, m_flGroundSpeed, flGroundSpeed, extra_offset_animating)
	set_pdata_float(iPlayer, m_flLastEventCheck, flGametime , extra_offset_animating)
   
	set_pdata_int(iPlayer, m_Activity, ACT_RANGE_ATTACK1, extra_offset_player)
	set_pdata_int(iPlayer, m_IdealActivity, ACT_RANGE_ATTACK1, extra_offset_player)  
	set_pdata_float(iPlayer, m_flLastAttackTime, flGametime , extra_offset_player)
}

//**********************************************
//* Kick back.                                 *
//**********************************************
Weapon_KickBack(iItem, iPlayer, Float:upBase, Float:lateralBase, Float:upMod, Float:lateralMod, Float:upMax, Float:lateralMax, directionChange)
{
	static iDirection
	static iShotsFired 
	
	static Float: Punchangle[3]
	pev(iPlayer, pev_punchangle, Punchangle)
	
	if((iShotsFired = get_pdata_int(iItem, 64, 4)) != 1)
	{
		upBase += iShotsFired * upMod
		lateralBase += iShotsFired * lateralMod
	}
	
	upMax *= -1.0
	Punchangle[0] -= upBase
 
	if(upMax >= Punchangle[0])
	{
		Punchangle[0] = upMax
	}
	
	if((iDirection = get_pdata_int(iItem, 60, 4)))
	{
		Punchangle[1] += lateralBase
		
		if(lateralMax < Punchangle[1])
		{
			Punchangle[1] = lateralMax
		}
	}
	else
	{
		lateralMax *= -1.0;
		Punchangle[1] -= lateralBase
		
		if(lateralMax > Punchangle[1])
		{
			Punchangle[1] = lateralMax
		}
	}
	
	if(!random_num(0, directionChange))
	{
		set_pdata_int(iItem, 60, !iDirection, 4)
	}
	
	set_pev(iPlayer, pev_punchangle, Punchangle)
}

//**********************************************
//* Some useful stocks.                        *
//**********************************************
stock get_speed_vector(Float:Origin1[3], Float:Origin2[3], Float:Speed, Float:NewVelocity[3])
{
	NewVelocity[0] = Origin2[0] - Origin1[0]
	NewVelocity[1] = Origin2[1] - Origin1[1]
	NewVelocity[2] = Origin2[2] - Origin1[2]
	new Float:num = floatsqroot(Speed*Speed / (NewVelocity[0]*NewVelocity[0] + NewVelocity[1]*NewVelocity[1] + NewVelocity[2]*NewVelocity[2]))
	NewVelocity[0] *= num
	NewVelocity[1] *= num
	NewVelocity[2] *= num
	
	return 1
}

stock Get_Position(iPlayer, Float:forw, Float:right, Float:up, Float:vStart[])
{
	new Float:Origin[3], Float:Angles[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
	
	pev(iPlayer, pev_origin, Origin)
	pev(iPlayer, pev_view_ofs,vUp) //for player
	xs_vec_add(Origin, vUp, Origin)
	pev(iPlayer, pev_v_angle, Angles) // if normal entity ,use pev_angles
	
	angle_vector(Angles, ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
	angle_vector(Angles, ANGLEVECTOR_RIGHT, vRight)
	angle_vector(Angles, ANGLEVECTOR_UP, vUp)
	
	vStart[0] = Origin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
	vStart[1] = Origin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
	vStart[2] = Origin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
}
Try

Code: Select all

/* Plugin generated by AMXX-Studio */

#pragma compress 1

#include <zombie_escape>
#include <engine>
#include <fakemeta_util>
#include <cstrike>
#include <xs>


#define PLUGIN "Star Chaser AR"
#define VERSION "1.0"
#define AUTHOR "Bim Bim Cay"

// Models
#define v_model "models/csnz/v_starchaserar.mdl"
#define w_model "models/csnz/w_starchaserar.mdl"
#define p_model "models/csnz/p_starchaserar.mdl"

// Sounds
#define attack1_sound "weapons/starchaserar-1.wav"
#define attack2_sound "weapons/starchaserar-2.wav"
#define explode_sound "weapons/starchasersr_exp.wav"

// Sprites
#define muzzle_flash "sprites/muzzleflash76.spr"
#define ef_ball "sprites/ef_starchasersr_star.spr"
#define ef_line "sprites/ef_starchasersr_line.spr"
#define ef_explosion "sprites/ef_starchasersr_explosion.spr"

// Anims
#define ANIM_IDLE		0
#define ANIM_RELOAD		1
#define ANIM_DRAW		2
#define ANIM_SHOOT1		3
#define ANIM_SHOOT2		4
#define ANIM_SHOOT3		5

#define ANIM_EXTENSION 		"carbine"

// Entity Classname
#define BALL_CLASSNAME "StarChaserAREf_Ball"
#define MUZZLEFLASH_CLASSNAME "Muzzle_StarChaserAR"

// Configs
#define WEAPON_NAME 		"weapon_starchaserar"
#define WEAPON_BASE		"weapon_aug"

#define WEAPON_MAX_CLIP		35
#define WEAPON_DEFAULT_AMMO	90

#define WEAPON_SHOOT_DAMAGE	45.0
#define WEAPON_EXPLODE_DAMAGE	150.0
#define WEAPON_EXPLODE_RADIUS	100.0

#define WEAPON_TIME_NEXT_ATTACK 0.1
#define WEAPON_TIME_NEXT_ATTACKZ 0.135
#define AMMO_CHARGE 7

// MACROS
#define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
#define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
#define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))

#define INSTANCE(%0) ((%0 == -1) ? 0 : %0)
#define IsValidPev(%0) (pev_valid(%0) == 2)
#define IsObserver(%0) pev(%0,pev_iuser1)
#define OBS_IN_EYE 4

new g_starchaserar
new g_iszWeaponKey
new g_iForwardDecalIndex
new g_Line_SprId, g_Explode_SprId

// Safety
new g_HamBot
new g_IsConnected, g_IsAlive

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	// Safety
	Register_SafetyFunc()
	
	// Forward
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
	register_forward(FM_TraceLine, "fw_TraceLine_Post", 1)
	register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
	register_forward(FM_SetModel, "fw_SetModel")
	
	unregister_forward(FM_DecalIndex, g_iForwardDecalIndex, 1)
	
	// Think
	register_think(MUZZLEFLASH_CLASSNAME, "fw_MuzzleFlash_Think") 
	register_think(BALL_CLASSNAME, "fw_Ball_Think")
	register_touch(BALL_CLASSNAME, "*", "fw_Ball_Touch")
	
	// Ham
	RegisterHam(Ham_Spawn, "weaponbox", "fw_Weaponbox_Spawn_Post", 1)
	
	RegisterHam(Ham_Item_Deploy, WEAPON_BASE, "fw_Item_Deploy_Post", 1)
	RegisterHam(Ham_Item_PostFrame, WEAPON_BASE, "fw_Item_PostFrame")
	RegisterHam(Ham_Weapon_Reload, WEAPON_BASE, "fw_Weapon_Reload")
	RegisterHam(Ham_Weapon_WeaponIdle, WEAPON_BASE, "fw_Weapon_WeaponIdle")
	RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON_BASE, "fw_Weapon_PrimaryAttack")
	
	RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Entity")
	RegisterHam(Ham_TraceAttack, "info_target", "fw_TraceAttack_Entity")
	RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack_Entity")
	
	g_starchaserar = ze_register_item("Star Chaser AR", 30, 0)
}

public plugin_precache()
{
	precache_model(v_model)
	precache_model(w_model)
	precache_model(p_model)
	
	precache_model(ef_ball)
	precache_model(muzzle_flash)
	
	g_Line_SprId = precache_model(ef_line)
	g_Explode_SprId = precache_model(ef_explosion)
	
	precache_sound(attack1_sound)
	precache_sound(attack2_sound)
	precache_sound(explode_sound)
	
	g_iszWeaponKey = engfunc(EngFunc_AllocString, WEAPON_NAME)
	g_iForwardDecalIndex = register_forward(FM_DecalIndex, "fw_DecalIndex_Post", 1)
}

public client_putinserver(iPlayer)
{
	Safety_Connected(iPlayer)
	
	if(!g_HamBot && is_user_bot(iPlayer))
	{
		g_HamBot = 1
		set_task(0.1, "Register_HamBot", iPlayer)
	}
}
 
public Register_HamBot(iPlayer)
{
	Register_SafetyFuncBot(iPlayer)
	RegisterHamFromEntity(Ham_TraceAttack, iPlayer, "fw_TraceAttack_Entity")	
}

public client_disconnected(iPlayer)
{
	Safety_Disconnected(iPlayer)
}

public ze_select_item_post(id, itemid)
{
	if(itemid == g_starchaserar)
	     return
}

public Get_MyWeapon(iPlayer)
{
	Weapon_Give(iPlayer)
} 

//**********************************************
//* Forward Hooking                            *
//********************************************** 
public fw_UpdateClientData_Post(iPlayer, sendweapons, CD_Handle)
{
	enum
	{
		SPEC_MODE,
		SPEC_TARGET,
		SPEC_END
	}
	 
	static aSpecInfo[33][SPEC_END]
	
	static iTarget
	static iSpecMode 
	static iActiveItem
	
	iTarget = (iSpecMode = IsObserver(iPlayer)) ? pev(iPlayer, pev_iuser2) : iPlayer
	
	if(!is_alive(iTarget))
		return FMRES_IGNORED
	
	iActiveItem = get_pdata_cbase(iTarget, 373, 5)
	
	if(!IsValidPev(iActiveItem) || !IsCustomItem(iActiveItem))
		return FMRES_IGNORED
	
	if(iSpecMode)
	{
		if(aSpecInfo[iPlayer][SPEC_MODE] != iSpecMode)
		{
			aSpecInfo[iPlayer][SPEC_MODE] = iSpecMode
			aSpecInfo[iPlayer][SPEC_TARGET] = 0
		}
		
		if(iSpecMode == OBS_IN_EYE && aSpecInfo[iPlayer][SPEC_TARGET] != iTarget)
		{
			aSpecInfo[iPlayer][SPEC_TARGET] = iTarget
			
			Weapon_SendAnim(iPlayer, iActiveItem, ANIM_IDLE)
		}
	}
	
	set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001)
	
	return FMRES_HANDLED
}

public fw_TraceLine_Post(Float:TraceStart[3], Float:TraceEnd[3], fNoMonsters, iEntToSkip, iTrace) <FireBullets: Enabled>
{
	static Float:vecEndPos[3]
	
	get_tr2(iTrace, TR_vecEndPos, vecEndPos)
	engfunc(EngFunc_TraceLine, vecEndPos, TraceStart, fNoMonsters, iEntToSkip, 0)
	
	UTIL_GunshotDecalTrace(0)
	UTIL_GunshotDecalTrace(iTrace, true)
}

public fw_TraceLine_Post() </* Empty statement */>
{
	/* Fallback */
}

public fw_TraceLine_Post() <FireBullets: Disabled>	
{
	/* Do notning */
}

public fw_PlaybackEvent() <FireBullets: Enabled>
{
	return FMRES_SUPERCEDE
}

public fw_PlaybackEvent() </* Empty statement */>		
{ 
	return FMRES_IGNORED 
}

public fw_PlaybackEvent() <FireBullets: Disabled>		
{ 
	return FMRES_IGNORED 
}

//**********************************************
//* Weaponbox world model.                     *
//**********************************************
public fw_SetModel(iEntity) <WeaponBox: Enabled>
{
	state WeaponBox: Disabled
	
	if(!IsValidPev(iEntity))
		return FMRES_IGNORED
	
	#define MAX_ITEM_TYPES	6
	for(new i, iItem; i < MAX_ITEM_TYPES; i++)
	{
		iItem = get_pdata_cbase(iEntity, 34 + i, 4)
		
		if(IsValidPev(iItem) && IsCustomItem(iItem))
		{
			engfunc(EngFunc_SetModel, iEntity, w_model)
			return FMRES_SUPERCEDE
		}
	}
	
	return FMRES_IGNORED
}

public fw_SetModel() </* Empty statement */>	
{ 
	/*  Fallback  */ 
	return FMRES_IGNORED 
}
public fw_SetModel() <WeaponBox: Disabled>	
{ 
	/* Do nothing */ 
	return FMRES_IGNORED 
}

public fw_Weaponbox_Spawn_Post(iWeaponBox)
{
	if(IsValidPev(iWeaponBox))
	{
		state (IsValidPev(pev(iWeaponBox, pev_owner))) WeaponBox: Enabled
	}
	
	return HAM_IGNORED
}

//**********************************************
//* Weapon's codes.                     *
//**********************************************
public fw_Item_Deploy_Post(iItem)
{
	if(!IsCustomItem(iItem))
		return
		
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)	
	
	set_pev(iPlayer, pev_viewmodel2, v_model)
	set_pev(iPlayer, pev_weaponmodel2, p_model)
	
	Weapon_SendAnim(iPlayer, iItem, ANIM_DRAW)
	
	set_pdata_string(iPlayer, (492) * 4, ANIM_EXTENSION, -1 , 20)
}

public fw_Item_PostFrame(iItem)
{
	if(!IsCustomItem(iItem))
		return HAM_IGNORED
	
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)
	
	if(get_pdata_int(iItem, 54, 4))
	{
		static iClip; iClip = get_pdata_int(iItem, 51, 4)
		static iPrimaryAmmoIndex; iPrimaryAmmoIndex = PrimaryAmmoIndex(iItem)
		static iAmmoPrimary; iAmmoPrimary = GetAmmoInventory(iPlayer, iPrimaryAmmoIndex)
		static iAmount; iAmount = min(WEAPON_MAX_CLIP - iClip, iAmmoPrimary)
		
		set_pdata_int(iItem, 51, iClip + iAmount, 4)
		SetAmmoInventory(iPlayer, iPrimaryAmmoIndex, iAmmoPrimary - iAmount)
		
		set_pdata_int(iItem, 54, 0, 4)
	}	
	
	return HAM_IGNORED
}

public fw_Weapon_Reload(iItem)
{
	if(!IsCustomItem(iItem))
		return HAM_IGNORED
		
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)	
	
	static iClip; iClip = get_pdata_int(iItem, 51, 4)
	static iPrimaryAmmoIndex; iPrimaryAmmoIndex = PrimaryAmmoIndex(iItem)
	static iAmmoPrimary; iAmmoPrimary = GetAmmoInventory(iPlayer, iPrimaryAmmoIndex)
	
	if(min(WEAPON_MAX_CLIP - iClip, iAmmoPrimary) <= 0)
		return HAM_SUPERCEDE
	
	set_pdata_int(iItem, 51, 0, 4)
	
	ExecuteHam(Ham_Weapon_Reload, iItem)
	
	set_pdata_int(iItem, 51, iClip, 4)
	
	set_pdata_float(iPlayer, 83, 3.2, 5)
	set_pdata_float(iItem, 48, 3.2, 4)
	
	Weapon_SendAnim(iPlayer, iItem, ANIM_RELOAD)
	
	return HAM_SUPERCEDE	
}

public fw_Weapon_WeaponIdle(iItem)
{
	if(!IsCustomItem(iItem))
		return HAM_IGNORED
		
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)	
	
	ExecuteHamB(Ham_Weapon_ResetEmptySound, iItem)

	if(get_pdata_float(iItem, 48, 4) > 0.0)
		return HAM_SUPERCEDE
	
	set_pdata_float(iItem, 48, 10.0, 4)
	
	Weapon_SendAnim(iPlayer, iItem, ANIM_IDLE)
	
	return HAM_SUPERCEDE
}

public fw_Weapon_PrimaryAttack(iItem)
{
	if(!IsCustomItem(iItem))
		return HAM_IGNORED
		
	static iPlayer; iPlayer = get_pdata_cbase(iItem, 41, 4)	
	static iClip; iClip = get_pdata_int(iItem, 51, 4)
	
	if(iClip <= 0)
	{
		// No ammo, play empty sound and cancel
		if(get_pdata_int(iItem, 45, 4))
		{
			ExecuteHamB(Ham_Weapon_PlayEmptySound, iItem)
			set_pdata_float(iItem, 46, 0.2, 4)
		}
	
		return HAM_SUPERCEDE
	}
	
	CallOriginalFireBullets(iItem, iPlayer)
	
	static iFlags
	static szAnimation[64], Float:Velocity[3]

	iFlags = pev(iPlayer, pev_flags)
	
	if(iFlags & FL_DUCKING)
	{
		formatex(szAnimation, charsmax(szAnimation), "crouch_shoot_%s", ANIM_EXTENSION)
	}
	else
	{
		formatex(szAnimation, charsmax(szAnimation), "ref_shoot_%s", ANIM_EXTENSION)
	}
	
	Player_SetAnimation(iPlayer, szAnimation)
	
	static ShootAnim
	switch(random_num(0, 2))
	{
		case 0: ShootAnim = ANIM_SHOOT1
		case 1: ShootAnim = ANIM_SHOOT2
		case 2: ShootAnim = ANIM_SHOOT3
	}
		
	Weapon_SendAnim(iPlayer, iItem, ShootAnim)
	
	set_pdata_float(iItem, 48, 0.7, 4)
	
	if(pev(iPlayer, pev_fov) == 90)
	{
		set_pdata_float(iItem, 46, WEAPON_TIME_NEXT_ATTACK, 4)
		set_pdata_float(iItem, 47, WEAPON_TIME_NEXT_ATTACK, 4)
	}
	else
	{
		set_pdata_float(iItem, 46, WEAPON_TIME_NEXT_ATTACKZ, 4)
		set_pdata_float(iItem, 47, WEAPON_TIME_NEXT_ATTACKZ, 4)
	}
	
	pev(iPlayer, pev_velocity, Velocity)
	
	if(xs_vec_len(Velocity) > 0)
	{
		Weapon_KickBack(iItem, iPlayer, 1.0, 0.45, 0.275, 0.05, 4.0, 2.5, 7)
	}
	else if(!(iFlags & FL_ONGROUND))
	{
		Weapon_KickBack(iItem, iPlayer, 1.25, 0.45, 0.22, 0.18, 5.5, 4.0, 5)
	}
	else if(iFlags & FL_DUCKING)
	{
		Weapon_KickBack(iItem, iPlayer, 0.575, 0.325, 0.2, 0.011, 3.25, 2.0, 8)
	}
	else
	{
		Weapon_KickBack(iItem, iPlayer, 0.625, 0.375, 0.25, 0.0125, 3.5, 2.25, 8)
	}

	Make_MuzzleFlash(iPlayer)
	
	static AmmoCharge; AmmoCharge = get_pdata_int(iItem, 30, 4)
	
	if(AmmoCharge < AMMO_CHARGE)
	{
		set_pdata_int(iItem, 30, AmmoCharge + 1, 4)
		
		emit_sound(iPlayer, CHAN_WEAPON, attack1_sound, 1.0, 0.4, 0, 94 + random_num(0, 15))
	}
	else
	{
		set_pdata_int(iItem, 30, 0, 4)
		
		emit_sound(iPlayer, CHAN_WEAPON, attack2_sound, 1.0, 0.4, 0, 94 + random_num(0, 15))
		
		Create_Star(iPlayer)	
	}
	
	return HAM_SUPERCEDE
}

public fw_TraceAttack_Entity(iEntity, iAttacker, Float: flDamage) <FireBullets: Enabled>
{
	SetHamParamFloat(3, WEAPON_SHOOT_DAMAGE)
}

public fw_TraceAttack_Entity() </* Empty statement */>		
{ 
	/* Fallback */ 
}

public fw_TraceAttack_Entity() <FireBullets: Disabled>		
{ 
	/* Do notning */ 
}

//**********************************************
//* Effects                                    *
//**********************************************
Make_MuzzleFlash(iPlayer)
{
	static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))

	set_pev(Ent, pev_classname, MUZZLEFLASH_CLASSNAME)
	
	set_pev(Ent, pev_owner, iPlayer)
	set_pev(Ent, pev_body, 1)
	set_pev(Ent, pev_skin, iPlayer)
	set_pev(Ent, pev_aiment, iPlayer)
	set_pev(Ent, pev_movetype, MOVETYPE_FOLLOW)
	
	engfunc(EngFunc_SetModel, Ent, muzzle_flash)
	
	set_pev(Ent, pev_scale, 0.04)
	set_pev(Ent, pev_frame, 0.0)
	set_pev(Ent, pev_rendermode, kRenderTransAdd)
	set_pev(Ent, pev_renderamt, 250.0)
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.04)
}

public fw_MuzzleFlash_Think(Ent)
{
	if(!pev_valid(Ent))
		return
	
	static Owner; Owner = pev(Ent, pev_owner)
	
	if(!is_alive(Owner))
	{
		set_pev(Ent, pev_flags, FL_KILLME)
		return
	}
	
	static iActiveItem; iActiveItem = get_pdata_cbase(Owner, 373, 5)
	
	if(!IsValidPev(iActiveItem) || !IsCustomItem(iActiveItem))
	{
		set_pev(Ent, pev_flags, FL_KILLME)
		return
	}

	static Float:Frame; pev(Ent, pev_frame, Frame)
	if(Frame > 2.0) 
	{
		set_pev(Ent, pev_flags, FL_KILLME)
		return
	}
	else
	{
		Frame += 1.0
		set_pev(Ent, pev_frame, Frame)
	}
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.04)
}

public Create_Star(iPlayer)
{
	static Float:Origin[3]
	
	if(get_cvar_num("cl_righthand"))
	{
		Get_Position(iPlayer, 48.0, 10.0, -5.0, Origin)
	}
	else
	{
		Get_Position(iPlayer, 48.0, -10.0, -5.0, Origin)
	}

	static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	
	if(!pev_valid(Ent)) 
		return
		
	engfunc(EngFunc_SetModel, Ent, ef_ball)	
	
	set_pev(Ent, pev_classname, BALL_CLASSNAME)
	set_pev(Ent, pev_movetype, MOVETYPE_FLYMISSILE)
	set_pev(Ent, pev_owner, iPlayer)
	set_pev(Ent, pev_origin, Origin)
	
	set_pev(Ent, pev_solid, SOLID_SLIDEBOX)
	set_pev(Ent, pev_mins, {-1.0, -1.0, -1.0})
	set_pev(Ent, pev_maxs, {1.0, 1.0, 1.0})
	
	set_pev(Ent, pev_rendermode, kRenderTransAdd)
	set_pev(Ent, pev_renderamt, 255.0)
	set_pev(Ent, pev_scale, 0.075)
	set_pev(Ent, pev_frame, 0.0)
	
	// Create Velocity
	static Float:Velocity[3], Float:TargetOrigin[3]
	
	fm_get_aim_origin(iPlayer, TargetOrigin)
	get_speed_vector(Origin, TargetOrigin, 2500.0, Velocity)
	
	set_pev(Ent, pev_velocity, Velocity)
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.05)
}

public fw_Ball_Think(Ent)
{
	if(!pev_valid(Ent))
		return
		
	new Float:fFrame
	pev(Ent, pev_frame, fFrame)
	
	// effect exp
	if(fFrame <= 14.0) 
	{
		fFrame += 1.0
		
	}
	else
	{
		fFrame = 0.0
	}
	
	set_pev(Ent, pev_frame, fFrame)
	
	static Float:Origin[3]
	pev(Ent, pev_origin, Origin)
	
	static TE_FLAG
	
	TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
	TE_FLAG |= TE_EXPLFLAG_NOSOUND
	TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
	
	engfunc(EngFunc_MessageBegin, MSG_BROADCAST, SVC_TEMPENTITY, Origin, 0)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(g_Line_SprId)	// sprite index
	write_byte(3)	// scale in 3.4's
	write_byte(20)	// framerate
	write_byte(TE_FLAG)	// flags
	message_end()
	
	set_pev(Ent, pev_nextthink, get_gametime() + 0.05)	
}

public fw_Ball_Touch(Ent, Touch)
{
	if(!pev_valid(Ent)) 
		return
		
	static Float:Origin[3]
	pev(Ent, pev_origin, Origin)
	
	static TE_FLAG
	
	TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
	TE_FLAG |= TE_EXPLFLAG_NOSOUND
	TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
	
	engfunc(EngFunc_MessageBegin, MSG_BROADCAST, SVC_TEMPENTITY, Origin, 0)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_short(g_Explode_SprId)	// sprite index
	write_byte(7)	// scale in 3.4's
	write_byte(45)	// framerate
	write_byte(TE_FLAG)	// flags
	message_end()
	
	emit_sound(Ent, CHAN_BODY, explode_sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	
	static Owner; Owner = pev(Ent, pev_owner)
	
	if(is_connected(Owner))
	{
		static Victim; Victim = -1
		while((Victim = find_ent_in_sphere(Victim, Origin, WEAPON_EXPLODE_RADIUS)) != 0)
		{
			if(is_alive(Victim))
			{
				if(Victim == Owner)
					continue
			}
			else
			{
				if(pev(Victim, pev_takedamage) == DAMAGE_NO)
					continue
			}
		
			ExecuteHamB(Ham_TakeDamage, Victim, Ent, Owner, WEAPON_EXPLODE_DAMAGE, DMG_BULLET)
		}
	}
	
	set_pev(Ent, pev_flags, FL_KILLME)
}


public ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_starchaserar)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW 
   
    return ZE_ITEM_AVAILABLE
}



//**********************************************
//* Safety Functions        		       *
//**********************************************
public Register_SafetyFunc()
{
	RegisterHam(Ham_Spawn, "player", "fw_Safety_Spawn_Post", 1)
	RegisterHam(Ham_Killed, "player", "fw_Safety_Killed_Post", 1)
}

public Register_SafetyFuncBot(iPlayer)
{
	RegisterHamFromEntity(Ham_Spawn, iPlayer, "fw_Safety_Spawn_Post", 1)
	RegisterHamFromEntity(Ham_Killed, iPlayer, "fw_Safety_Killed_Post", 1)
}

public Safety_Connected(iPlayer)
{
	Set_BitVar(g_IsConnected, iPlayer)
	UnSet_BitVar(g_IsAlive, iPlayer)
}

public Safety_Disconnected(iPlayer)
{
	UnSet_BitVar(g_IsConnected, iPlayer)
	UnSet_BitVar(g_IsAlive, iPlayer)
}

public fw_Safety_Spawn_Post(iPlayer)
{
	if(!is_user_alive(iPlayer))
		return
		
	Set_BitVar(g_IsAlive, iPlayer)
}

public fw_Safety_Killed_Post(iPlayer)
{
	UnSet_BitVar(g_IsAlive, iPlayer)
}

public is_connected(iPlayer)
{
	if(!(1 <= iPlayer <= 32))
		return 0
	if(!Get_BitVar(g_IsConnected, iPlayer))
		return 0

	return 1
}

public is_alive(iPlayer)
{
	if(!is_connected(iPlayer))
		return 0
	if(!Get_BitVar(g_IsAlive, iPlayer))
		return 0
		
	return 1
}

//**********************************************
//* Create and check our custom weapon.        *
//**********************************************
IsCustomItem(iItem)
{
	return (pev(iItem, pev_impulse) == g_iszWeaponKey)
}

Weapon_Create(Float: Origin[3] = {0.0, 0.0, 0.0}, Float: Angles[3] = {0.0, 0.0, 0.0})
{
	new iWeapon

	static iszAllocStringCached
	if (iszAllocStringCached || (iszAllocStringCached = engfunc(EngFunc_AllocString, WEAPON_BASE)))
	{
		iWeapon = engfunc(EngFunc_CreateNamedEntity, iszAllocStringCached)
	}
	
	if(!IsValidPev(iWeapon))
		return FM_NULLENT
	
	dllfunc(DLLFunc_Spawn, iWeapon)
	set_pev(iWeapon, pev_origin, Origin)

	set_pdata_int(iWeapon, 51, WEAPON_MAX_CLIP, 4)
	set_pdata_int(iWeapon, 30, 0, 4)

	set_pev(iWeapon, pev_impulse, g_iszWeaponKey)
	set_pev(iWeapon, pev_angles, Angles)
	
	engfunc(EngFunc_SetModel, iWeapon, w_model)

	return iWeapon
}

Weapon_Give(iPlayer)
{
	if(!IsValidPev(iPlayer))
	{
		return FM_NULLENT
	}
	
	new iWeapon, Float: vecOrigin[3]
	pev(iPlayer, pev_origin, vecOrigin)
	
	if((iWeapon = Weapon_Create(vecOrigin)) != FM_NULLENT)
	{
		Player_DropWeapons(iPlayer, ExecuteHamB(Ham_Item_ItemSlot, iWeapon))
		
		set_pev(iWeapon, pev_spawnflags, pev(iWeapon, pev_spawnflags) | SF_NORESPAWN)
		dllfunc(DLLFunc_Touch, iWeapon, iPlayer)
		
		SetAmmoInventory(iPlayer, PrimaryAmmoIndex(iWeapon), WEAPON_DEFAULT_AMMO)
		
		return iWeapon
	}
	
	return FM_NULLENT
}

Player_DropWeapons(iPlayer, iSlot)
{
	new szWeaponName[32], iItem = get_pdata_cbase(iPlayer, 367 + iSlot, 5)

	while(IsValidPev(iItem))
	{
		pev(iItem, pev_classname, szWeaponName, charsmax(szWeaponName))
		engclient_cmd(iPlayer, "drop", szWeaponName)

		iItem = get_pdata_cbase(iItem, 42, 4)
	}
}

//**********************************************
//* Ammo Inventory.                            *
//**********************************************
PrimaryAmmoIndex(iItem)
{
	return get_pdata_int(iItem, 49, 4)
}

GetAmmoInventory(iPlayer, iAmmoIndex)
{
	if(iAmmoIndex == -1)
		return -1
	
	return get_pdata_int(iPlayer, 376 + iAmmoIndex, 5)
}

SetAmmoInventory(iPlayer, iAmmoIndex, iAmount)
{
	if(iAmmoIndex == -1)
		return 0
	
	set_pdata_int(iPlayer, 376 + iAmmoIndex, iAmount, 5)
	
	return 1
}

//**********************************************
//* Fire Bullets.                              *
//**********************************************
CallOriginalFireBullets(iItem, iPlayer)
{
	state FireBullets: Enabled
	static Float:g_Recoil[3]

	pev(iPlayer, pev_punchangle, g_Recoil)
	ExecuteHam(Ham_Weapon_PrimaryAttack, iItem)
	set_pev(iPlayer, pev_punchangle, g_Recoil)
	
	state FireBullets: Disabled
}

//**********************************************
//* Decals.                                    *
//**********************************************
new Array: g_hDecals

public fw_DecalIndex_Post()
{
	if(!g_hDecals)
	{
		g_hDecals = ArrayCreate(1, 1)
	}
	
	ArrayPushCell(g_hDecals, get_orig_retval())
}

UTIL_GunshotDecalTrace(iTrace, bool: bIsGunshot = false)
{
	static iHit
	static iMessage
	static iDecalIndex
	
	static Float:flFraction 
	static Float:vecEndPos[3]
	
	iHit = INSTANCE(get_tr2(iTrace, TR_pHit))
	
	if(iHit && !IsValidPev(iHit) || (pev(iHit, pev_flags) & FL_KILLME))
		return
	
	if(pev(iHit, pev_solid) != SOLID_BSP && pev(iHit, pev_movetype) != MOVETYPE_PUSHSTEP)
		return
	
	iDecalIndex = ExecuteHamB(Ham_DamageDecal, iHit, 0)
	
	if(iDecalIndex < 0 || iDecalIndex >=  ArraySize(g_hDecals))
		return
	
	iDecalIndex = ArrayGetCell(g_hDecals, iDecalIndex)
	
	get_tr2(iTrace, TR_flFraction, flFraction)
	get_tr2(iTrace, TR_vecEndPos, vecEndPos)
	
	if(iDecalIndex < 0 || flFraction >= 1.0)
		return
	
	if(bIsGunshot)
	{
		iMessage = TE_GUNSHOTDECAL
	}
	else
	{
		iMessage = TE_DECAL
		
		if(iHit != 0)
		{
			if(iDecalIndex > 255)
			{
				iMessage = TE_DECALHIGH
				iDecalIndex -= 256
			}
		}
		else
		{
			iMessage = TE_WORLDDECAL
			
			if(iDecalIndex > 255)
			{
				iMessage = TE_WORLDDECALHIGH
				iDecalIndex -= 256
			}
		}
	}
	
	engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEndPos, 0)
	write_byte(iMessage)
	engfunc(EngFunc_WriteCoord, vecEndPos[0])
	engfunc(EngFunc_WriteCoord, vecEndPos[1])
	engfunc(EngFunc_WriteCoord, vecEndPos[2])

	if(bIsGunshot)
	{
		write_short(iHit)
		write_byte(iDecalIndex)
	}
	else 
	{
		write_byte(iDecalIndex)
		
		if(iHit)
		{
			write_short(iHit)
		}
	}
    
	message_end()
}

//**********************************************
//* Set Animations.                            *
//**********************************************
stock Weapon_SendAnim(iPlayer, iItem, iAnim)
{
	static i, iCount, iSpectator, aSpectators[32]
	
	set_pev(iPlayer, pev_weaponanim, iAnim)

	message_begin(MSG_ONE, SVC_WEAPONANIM, .player = iPlayer)
	write_byte(iAnim)
	write_byte(pev(iItem, pev_body))
	message_end()
	
	if(IsObserver(iPlayer))
		return
	
	get_players(aSpectators, iCount, "bch")

	for(i = 0; i < iCount; i++)
	{
		iSpectator = aSpectators[i]
		
		if(IsObserver(iSpectator) != OBS_IN_EYE || pev(iSpectator, pev_iuser2) != iPlayer)
			continue
		
		set_pev(iSpectator, pev_weaponanim, iAnim)

		message_begin(MSG_ONE, SVC_WEAPONANIM, .player = iSpectator)
		write_byte(iAnim)
		write_byte(pev(iItem, pev_body))
		message_end()
	}
}

stock Player_SetAnimation(iPlayer, szAnim[])
{
	#define ACT_RANGE_ATTACK1   28
   
	// Linux extra offsets
	#define extra_offset_animating   4
	#define extra_offset_player 5
   
	// CBaseAnimating
	#define m_flFrameRate      36
	#define m_flGroundSpeed      37
	#define m_flLastEventCheck   38
	#define m_fSequenceFinished   39
	#define m_fSequenceLoops   40
   
	// CBaseMonster
	#define m_Activity      73
	#define m_IdealActivity      74
   
	// CBasePlayer
	#define m_flLastAttackTime   220
   
	new iAnimDesired, Float:flFrameRate, Float:flGroundSpeed, bool:bLoops
      
	if((iAnimDesired = lookup_sequence(iPlayer, szAnim, flFrameRate, bLoops, flGroundSpeed)) == -1)
	{
		iAnimDesired = 0
	}
   
	static Float:flGametime; flGametime = get_gametime()

	set_pev(iPlayer, pev_frame, 0.0)
	set_pev(iPlayer, pev_framerate, 1.0)
	set_pev(iPlayer, pev_animtime, flGametime)
	set_pev(iPlayer, pev_sequence, iAnimDesired)
   
	set_pdata_int(iPlayer, m_fSequenceLoops, bLoops, extra_offset_animating)
	set_pdata_int(iPlayer, m_fSequenceFinished, 0, extra_offset_animating)
   
	set_pdata_float(iPlayer, m_flFrameRate, flFrameRate, extra_offset_animating)
	set_pdata_float(iPlayer, m_flGroundSpeed, flGroundSpeed, extra_offset_animating)
	set_pdata_float(iPlayer, m_flLastEventCheck, flGametime , extra_offset_animating)
   
	set_pdata_int(iPlayer, m_Activity, ACT_RANGE_ATTACK1, extra_offset_player)
	set_pdata_int(iPlayer, m_IdealActivity, ACT_RANGE_ATTACK1, extra_offset_player)  
	set_pdata_float(iPlayer, m_flLastAttackTime, flGametime , extra_offset_player)
}

//**********************************************
//* Kick back.                                 *
//**********************************************
Weapon_KickBack(iItem, iPlayer, Float:upBase, Float:lateralBase, Float:upMod, Float:lateralMod, Float:upMax, Float:lateralMax, directionChange)
{
	static iDirection
	static iShotsFired 
	
	static Float: Punchangle[3]
	pev(iPlayer, pev_punchangle, Punchangle)
	
	if((iShotsFired = get_pdata_int(iItem, 64, 4)) != 1)
	{
		upBase += iShotsFired * upMod
		lateralBase += iShotsFired * lateralMod
	}
	
	upMax *= -1.0
	Punchangle[0] -= upBase
 
	if(upMax >= Punchangle[0])
	{
		Punchangle[0] = upMax
	}
	
	if((iDirection = get_pdata_int(iItem, 60, 4)))
	{
		Punchangle[1] += lateralBase
		
		if(lateralMax < Punchangle[1])
		{
			Punchangle[1] = lateralMax
		}
	}
	else
	{
		lateralMax *= -1.0;
		Punchangle[1] -= lateralBase
		
		if(lateralMax > Punchangle[1])
		{
			Punchangle[1] = lateralMax
		}
	}
	
	if(!random_num(0, directionChange))
	{
		set_pdata_int(iItem, 60, !iDirection, 4)
	}
	
	set_pev(iPlayer, pev_punchangle, Punchangle)
}

//**********************************************
//* Some useful stocks.                        *
//**********************************************
stock get_speed_vector(Float:Origin1[3], Float:Origin2[3], Float:Speed, Float:NewVelocity[3])
{
	NewVelocity[0] = Origin2[0] - Origin1[0]
	NewVelocity[1] = Origin2[1] - Origin1[1]
	NewVelocity[2] = Origin2[2] - Origin1[2]
	new Float:num = floatsqroot(Speed*Speed / (NewVelocity[0]*NewVelocity[0] + NewVelocity[1]*NewVelocity[1] + NewVelocity[2]*NewVelocity[2]))
	NewVelocity[0] *= num
	NewVelocity[1] *= num
	NewVelocity[2] *= num
	
	return 1
}

stock Get_Position(iPlayer, Float:forw, Float:right, Float:up, Float:vStart[])
{
	new Float:Origin[3], Float:Angles[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
	
	pev(iPlayer, pev_origin, Origin)
	pev(iPlayer, pev_view_ofs,vUp) //for player
	xs_vec_add(Origin, vUp, Origin)
	pev(iPlayer, pev_v_angle, Angles) // if normal entity ,use pev_angles
	
	angle_vector(Angles, ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
	angle_vector(Angles, ANGLEVECTOR_RIGHT, vRight)
	angle_vector(Angles, ANGLEVECTOR_UP, vUp)
	
	vStart[0] = Origin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
	vStart[1] = Origin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
	vStart[2] = Origin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
}
Image

User avatar
Luxurious
Mod Tester
Mod Tester
Egypt
Posts: 177
Joined: 6 years ago
Location: Egypt
Contact:

#9

Post by Luxurious » 5 years ago

have Problem when i buy it .
DRK Zombie-Escape V1.6
IP : 81.169.153.129:27015

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#10

Post by Night Fury » 5 years ago

Luxurious wrote: 5 years ago have Problem when i buy it .
What's the problem is exactly?
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

User avatar
Luxurious
Mod Tester
Mod Tester
Egypt
Posts: 177
Joined: 6 years ago
Location: Egypt
Contact:

#11

Post by Luxurious » 5 years ago

Jack GamePlay wrote: 5 years ago
Luxurious wrote: 5 years ago have Problem when i buy it .
What's the problem is exactly?
fixed ! 😁
DRK Zombie-Escape V1.6
IP : 81.169.153.129:27015

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 0 guests