Approved Frost M4A1

Zombies/Humans Extra-Items
karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 4 Years Ago
Location: India
Has thanked: 3 times
Been thanked: 10 times
Age: 24
Contact:

Re: Frost M4A1

#11

Post by karan » 1 Week Ago

  1. #include <zombie_escape>
  2. #include <cstrike>
  3. #include <engine>
  4.  
  5. new const V_M4A1_MODEL[] = "models/zombie_escape/v_frost_m4a1.mdl"
  6. new const P_M4A1_MODEL[] = "models/zombie_escape/p_frost_m4a1.mdl"
  7. new const W_M4A1_MODEL[] = "models/zombie_escape/w_frost_m4a1.mdl"
  8. new const W_OLD_M4A1_MODEL[] = "models/w_m4a1.mdl"
  9.  
  10. new g_iItemID, g_iHudSync, g_iSpriteLaser, g_iFreezeDmg, g_iDmgMultiplier
  11. new bool:g_bHasFrostM4A1[33]
  12. new g_iDmg[33]
  13.  
  14. public plugin_init()
  15. {
  16.     register_plugin("[ZE] Extra Item: Frost M4A1", "1.0", "Raheem")
  17.    
  18.     // Cvars
  19.     g_iFreezeDmg = register_cvar("ze_freezing_m4a1_damage", "2000") // Damage Requried So Zombie got Frozen
  20.     g_iDmgMultiplier = register_cvar("ze_multiplier_m4a1_damage", "2") // Multiplie Weapon Damage
  21.  
  22.     // Message IDS
  23.     g_iHudSync = CreateHudSyncObj()
  24.    
  25.     // ITEM NAME & COST
  26.     g_iItemID = ze_register_item("Frost M4A1", 30, 0) // It's cost 30 Ammo Pack
  27.    
  28.     // Events
  29.     register_event("WeapPickup", "CheckModel", "b", "1=19")
  30.     register_event("CurWeapon", "CurrentWeapon", "be", "1=1")
  31.    
  32.     // Forwards
  33.     register_forward(FM_SetModel, "Fw_SetModel")
  34.    
  35.     // HookChains
  36.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  37.    
  38.     // Hams
  39.     RegisterHam(Ham_TraceAttack, "player", "Fw_TraceAttack_Post", 1)
  40.     RegisterHam(Ham_TraceAttack, "worldspawn", "Fw_TraceAttack_Post", 1)
  41.     RegisterHam(Ham_Item_AddToPlayer, "weapon_m4a1", "Fw_AddFrostM4A1ToPlayer")
  42. }
  43.  
  44. public plugin_precache()
  45. {
  46.     // Models
  47.     precache_model(V_M4A1_MODEL)
  48.     precache_model(P_M4A1_MODEL)
  49.     precache_model(W_M4A1_MODEL)
  50.    
  51.     // Sprites
  52.     g_iSpriteLaser = precache_model( "sprites/Newlightning.spr")
  53. }
  54.  
  55. public client_disconnected(id)
  56. {
  57.     g_bHasFrostM4A1[id] = false
  58. }
  59.  
  60. public ze_select_item_pre(id, itemid)
  61. {
  62.     // Return Available and we will block it in Post, So it dosen't affect other plugins
  63.     if (itemid != g_iItemID)
  64.         return ZE_ITEM_AVAILABLE
  65.    
  66.     // Available for Humans only, So don't show it for zombies
  67.     if (ze_is_user_zombie(id))
  68.         return ZE_ITEM_DONT_SHOW
  69.    
  70.     return ZE_ITEM_AVAILABLE
  71. }
  72.  
  73. public ze_select_item_post(player, itemid)
  74. {
  75.     if (itemid != g_iItemID)
  76.         return
  77.  
  78.     g_bHasFrostM4A1[player] = true
  79.  
  80.     rg_remove_item(player, "weapon_m4a1")
  81.     rg_give_item(player, "weapon_m4a1", GT_APPEND)
  82.     rg_set_user_bpammo(player, WeaponIdType:get_weaponid("weapon_m4a1"), 90)
  83.    
  84.     new szName[32]
  85.     get_user_name(player, szName, charsmax(szName))
  86.    
  87.     set_hudmessage(random(255), random(255), random(255), -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
  88.     show_hudmessage(0, "%s Has bought Frost M4A1!", szName)
  89.    
  90.     ze_colored_print(player, "!tYou Have bought Frost M4A1!y!")
  91. }
  92.  
  93. public Fw_TraceAttack_Post(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  94. {
  95.     if(!is_user_alive(iAttacker) && ze_is_user_zombie(iEnt))
  96.         return
  97.    
  98.     if(get_user_weapon(iAttacker) != CSW_M4A1 || !g_bHasFrostM4A1[iAttacker])
  99.         return
  100.    
  101.     set_hudmessage(34, 138, 255, -1.0, 0.17, 1, 0.0, 2.0, 1.0, 1.0, -1)
  102.     ShowSyncHudMsg(iAttacker, g_iHudSync, "Freeze Damage^n%d/%d", g_iDmg[iAttacker], get_pcvar_num(g_iFreezeDmg))
  103.    
  104.     new vec1[3], vec2[3]
  105.     get_user_origin(iAttacker, vec1, 1)
  106.     get_user_origin(iAttacker, vec2, 4)
  107.  
  108.     make_beam(vec1, vec2, g_iSpriteLaser, 0, 50, 200, 200)
  109. }
  110.  
  111. public ze_user_infected(infected)
  112. {
  113.     if (g_bHasFrostM4A1[infected])
  114.     {
  115.         g_bHasFrostM4A1[infected] = false
  116.     }
  117. }
  118.  
  119. public ze_user_humanized(id)
  120. {
  121.     g_bHasFrostM4A1[id] = false
  122.     g_iDmg[id] = 0
  123. }
  124.  
  125. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
  126. {
  127.     // Not Vaild Victim or Attacker
  128.     if (!ze_is_user_zombie(iVictim) || !is_user_connected(iAttacker))
  129.         return HC_CONTINUE
  130.    
  131.     if (g_bHasFrostM4A1[iAttacker] && (get_user_weapon(iAttacker) == CSW_M4A1))
  132.     {
  133.         SetHookChainArg(4 , ATYPE_FLOAT, fDamage * get_pcvar_num(g_iDmgMultiplier))
  134.     }
  135.    
  136.     if((get_user_weapon(iAttacker) == CSW_M4A1) && g_bHasFrostM4A1[iAttacker])
  137.     {
  138.         g_iDmg[iAttacker] += (floatround(fDamage) * get_pcvar_num(g_iDmgMultiplier))
  139.     }
  140.    
  141.     if((g_iDmg[iAttacker] >= get_pcvar_num(g_iFreezeDmg)) && (get_user_weapon(iAttacker) == CSW_M4A1) && g_bHasFrostM4A1[iAttacker])
  142.     {
  143.         new szName[32]
  144.         get_user_name(iVictim, szName, charsmax(szName))
  145.        
  146.         ze_set_frost_grenade(iVictim, true)
  147.        
  148.         g_iDmg[iAttacker] = 0
  149.        
  150.         set_dhudmessage(34, 138, 255, -1.0, 0.25, 2, 6.0, 3.0, 0.1, 1.5)
  151.         show_dhudmessage(iAttacker, "%s Has been Freezed!", szName)
  152.     }
  153.     return HC_CONTINUE
  154. }
  155.  
  156. public CheckModel(id)
  157. {
  158.     if (is_user_alive(id))
  159.     {
  160.         set_pev(id, pev_viewmodel2, V_M4A1_MODEL)
  161.         set_pev(id, pev_weaponmodel2, P_M4A1_MODEL)
  162.     }
  163.     return PLUGIN_CONTINUE
  164. }
  165.  
  166. public CurrentWeapon(id)
  167. {
  168.     if ((get_user_weapon(id) == CSW_M4A1) && g_bHasFrostM4A1[id] == true)
  169.     {
  170.         CheckModel(id)
  171.     }
  172.     else
  173.     {
  174.         ClearSyncHud(id, g_iHudSync)
  175.     }
  176.     return PLUGIN_CONTINUE
  177. }
  178.  
  179. make_beam(const origin2[3], const origin[3], sprite, red, green, blue, alpha)
  180. {
  181.     //BEAMENTPOINTS
  182.     message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
  183.     write_byte (0) //TE_BEAMENTPOINTS 0
  184.     write_coord(origin2[0])
  185.     write_coord(origin2[1])
  186.     write_coord(origin2[2])
  187.     write_coord(origin[0])
  188.     write_coord(origin[1])
  189.     write_coord(origin[2])
  190.     write_short(sprite) // sprite
  191.     write_byte(1) // framestart
  192.     write_byte(5) // framerate
  193.     write_byte(2) // life
  194.     write_byte(20) // width
  195.     write_byte(0) // noise
  196.     write_byte(red) // r, g, b
  197.     write_byte(green) // r, g, b
  198.     write_byte(blue) // r, g, b
  199.     write_byte(alpha) // brightness
  200.     write_byte(150) // speed
  201.     message_end()
  202. }
  203.  
  204. public Fw_SetModel(entity, model[])
  205. {
  206.    
  207.     if(!is_valid_ent(entity))
  208.         return FMRES_IGNORED
  209.  
  210.     if(!equali(model, W_OLD_M4A1_MODEL))
  211.         return FMRES_IGNORED
  212.  
  213.     new className[33]
  214.     entity_get_string(entity, EV_SZ_classname, className, 32)
  215.  
  216.     static iOwner, iStoredM4A1ID
  217.  
  218.     // Frost M4A1 Owner
  219.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  220.  
  221.     // Get drop weapon index (Frost M4A1) to use in fw_FrostM4A1AddToPlayer forward
  222.     iStoredM4A1ID = find_ent_by_owner(-1, "weapon_m4a1", entity)
  223.  
  224.     // If Player Has Frost M4A1 and It's weapon_m4a1
  225.     if(g_bHasFrostM4A1[iOwner] && is_valid_ent(iStoredM4A1ID))
  226.     {
  227.         // Setting weapon options
  228.         entity_set_int(iStoredM4A1ID, EV_INT_impulse, 1997)
  229.  
  230.         // Rest Var
  231.         g_bHasFrostM4A1[iOwner] = false
  232.        
  233.         // Set weaponbox new model
  234.         entity_set_model(entity, W_M4A1_MODEL)
  235.         return FMRES_SUPERCEDE
  236.     }
  237.     return FMRES_IGNORED
  238. }
  239.  
  240. public Fw_AddFrostM4A1ToPlayer(FrostM4A1, id)
  241. {
  242.     // Make sure that this is M4A1
  243.     if(is_valid_ent(FrostM4A1) && is_user_connected(id) && entity_get_int(FrostM4A1, EV_INT_impulse) == 1997)
  244.     {
  245.         // Update Var
  246.         g_bHasFrostM4A1[id] = true
  247.  
  248.         // Reset weapon options
  249.         entity_set_int(FrostM4A1, EV_INT_impulse, 0)
  250.         return HAM_HANDLED
  251.     }
  252.     return HAM_IGNORED
  253. }
this code is freezing humans too also counting breakables dmg so here's the fix
Image

User avatar
Z0uha1r_LK
Moderator
Moderator
Morocco
Posts: 342
Joined: 2 Years Ago
Location: Morocco
Has thanked: 92 times
Been thanked: 39 times
Age: 19
Contact:

#12

Post by Z0uha1r_LK » 6 Days Ago

Check Now:
  1. #include <zombie_escape>
  2. #include <cstrike>
  3. #include <engine>
  4.  
  5. new const V_M4A1_MODEL[] = "models/zombie_escape/v_frost_m4a1.mdl"
  6. new const P_M4A1_MODEL[] = "models/zombie_escape/p_frost_m4a1.mdl"
  7. new const W_M4A1_MODEL[] = "models/zombie_escape/w_frost_m4a1.mdl"
  8. new const W_OLD_M4A1_MODEL[] = "models/w_m4a1.mdl"
  9.  
  10. new g_iItemID, g_iHudSync, g_iSpriteLaser, g_iFreezeDmg, g_iDmgMultiplier
  11. new bool:g_bHasFrostM4A1[33]
  12. new g_iDmg[33]
  13.  
  14. public plugin_init()
  15. {
  16.     register_plugin("[ZE] Extra Item: Frost M4A1", "1.0", "Raheem")
  17.    
  18.     // Cvars
  19.     g_iFreezeDmg = register_cvar("ze_freezing_m4a1_damage", "2000") // Damage Requried So Zombie got Frozen
  20.     g_iDmgMultiplier = register_cvar("ze_multiplier_m4a1_damage", "2") // Multiplie Weapon Damage
  21.  
  22.     // Message IDS
  23.     g_iHudSync = CreateHudSyncObj()
  24.    
  25.     // ITEM NAME & COST
  26.     g_iItemID = ze_register_item("Frost M4A1", 30, 0) // It's cost 30 Ammo Pack
  27.    
  28.     // Events
  29.     register_event("WeapPickup", "CheckModel", "b", "1=19")
  30.     register_event("CurWeapon", "CurrentWeapon", "be", "1=1")
  31.    
  32.     // Forwards
  33.     register_forward(FM_SetModel, "Fw_SetModel")
  34.    
  35.     // HookChains
  36.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  37.    
  38.     // Hams
  39.     RegisterHam(Ham_TraceAttack, "player", "Fw_TraceAttack_Post", 1)
  40.     RegisterHam(Ham_TraceAttack, "worldspawn", "Fw_TraceAttack_Post", 1)
  41.     RegisterHam(Ham_Item_AddToPlayer, "weapon_m4a1", "Fw_AddFrostM4A1ToPlayer")
  42. }
  43.  
  44. public plugin_precache()
  45. {
  46.     // Models
  47.     precache_model(V_M4A1_MODEL)
  48.     precache_model(P_M4A1_MODEL)
  49.     precache_model(W_M4A1_MODEL)
  50.    
  51.     // Sprites
  52.     g_iSpriteLaser = precache_model( "sprites/Newlightning.spr")
  53. }
  54.  
  55. public client_disconnected(id)
  56. {
  57.     g_bHasFrostM4A1[id] = false
  58. }
  59.  
  60. public ze_select_item_pre(id, itemid)
  61. {
  62.     // Return Available and we will block it in Post, So it dosen't affect other plugins
  63.     if (itemid != g_iItemID)
  64.         return ZE_ITEM_AVAILABLE
  65.    
  66.     // Available for Humans only, So don't show it for zombies
  67.     if (ze_is_user_zombie(id))
  68.         return ZE_ITEM_DONT_SHOW
  69.    
  70.     return ZE_ITEM_AVAILABLE
  71. }
  72.  
  73. public ze_select_item_post(player, itemid)
  74. {
  75.     if (itemid != g_iItemID)
  76.         return
  77.  
  78.     g_bHasFrostM4A1[player] = true
  79.  
  80.     rg_remove_item(player, "weapon_m4a1")
  81.     rg_give_item(player, "weapon_m4a1", GT_APPEND)
  82.     rg_set_user_bpammo(player, WeaponIdType:get_weaponid("weapon_m4a1"), 90)
  83.    
  84.     new szName[32]
  85.     get_user_name(player, szName, charsmax(szName))
  86.    
  87.     set_hudmessage(random(255), random(255), random(255), -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
  88.     show_hudmessage(0, "%s Has bought Frost M4A1!", szName)
  89.    
  90.     ze_colored_print(player, "!tYou Have bought Frost M4A1!y!")
  91. }
  92.  
  93. public Fw_TraceAttack_Post(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  94. {
  95.     if(!is_user_alive(iAttacker) && ze_is_user_zombie(iEnt))
  96.         return
  97.    
  98.     if(get_user_weapon(iAttacker) != CSW_M4A1 || !g_bHasFrostM4A1[iAttacker])
  99.         return
  100.    
  101.     set_hudmessage(34, 138, 255, -1.0, 0.17, 1, 0.0, 2.0, 1.0, 1.0, -1)
  102.     ShowSyncHudMsg(iAttacker, g_iHudSync, "Freeze Damage^n%d/%d", g_iDmg[iAttacker], get_pcvar_num(g_iFreezeDmg))
  103.    
  104.     new vec1[3], vec2[3]
  105.     get_user_origin(iAttacker, vec1, 1)
  106.     get_user_origin(iAttacker, vec2, 4)
  107.  
  108.     make_beam(vec1, vec2, g_iSpriteLaser, 0, 50, 200, 200)
  109. }
  110.  
  111. public ze_user_infected(infected)
  112. {
  113.     if (g_bHasFrostM4A1[infected])
  114.     {
  115.         g_bHasFrostM4A1[infected] = false
  116.     }
  117. }
  118.  
  119. public ze_user_humanized(id)
  120. {
  121.     g_bHasFrostM4A1[id] = false
  122.     g_iDmg[id] = 0
  123. }
  124.  
  125. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
  126. {
  127.     // Not Vaild Victim or Attacker
  128.     if (!is_user_connected(iVictim) || !is_user_connected(iAttacker))
  129.         return HC_CONTINUE
  130.    
  131.     // Victim is not a Zombie.
  132.     if (!ze_is_user_zombie(iVictim))
  133.         return HC_CONTINUE
  134.  
  135.     if (g_bHasFrostM4A1[iAttacker] && (get_user_weapon(iAttacker) == CSW_M4A1))
  136.     {
  137.         SetHookChainArg(4 , ATYPE_FLOAT, fDamage * get_pcvar_num(g_iDmgMultiplier))
  138.     }
  139.    
  140.     if((get_user_weapon(iAttacker) == CSW_M4A1) && g_bHasFrostM4A1[iAttacker])
  141.     {
  142.         g_iDmg[iAttacker] += (floatround(fDamage) * get_pcvar_num(g_iDmgMultiplier))
  143.     }
  144.    
  145.     if((g_iDmg[iAttacker] >= get_pcvar_num(g_iFreezeDmg)) && (get_user_weapon(iAttacker) == CSW_M4A1) && g_bHasFrostM4A1[iAttacker])
  146.     {
  147.         new szName[32]
  148.         get_user_name(iVictim, szName, charsmax(szName))
  149.        
  150.         ze_set_frost_grenade(iVictim, true)
  151.        
  152.         g_iDmg[iAttacker] = 0
  153.        
  154.         set_dhudmessage(34, 138, 255, -1.0, 0.25, 2, 6.0, 3.0, 0.1, 1.5)
  155.         show_dhudmessage(iAttacker, "%s Has been Freezed!", szName)
  156.     }
  157.     return HC_CONTINUE
  158. }
  159.  
  160. public CheckModel(id)
  161. {
  162.     if (is_user_alive(id))
  163.     {
  164.         set_pev(id, pev_viewmodel2, V_M4A1_MODEL)
  165.         set_pev(id, pev_weaponmodel2, P_M4A1_MODEL)
  166.     }
  167.     return PLUGIN_CONTINUE
  168. }
  169.  
  170. public CurrentWeapon(id)
  171. {
  172.     if ((get_user_weapon(id) == CSW_M4A1) && g_bHasFrostM4A1[id] == true)
  173.     {
  174.         CheckModel(id)
  175.     }
  176.     else
  177.     {
  178.         ClearSyncHud(id, g_iHudSync)
  179.     }
  180.     return PLUGIN_CONTINUE
  181. }
  182.  
  183. make_beam(const origin2[3], const origin[3], sprite, red, green, blue, alpha)
  184. {
  185.     //BEAMENTPOINTS
  186.     message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
  187.     write_byte (0) //TE_BEAMENTPOINTS 0
  188.     write_coord(origin2[0])
  189.     write_coord(origin2[1])
  190.     write_coord(origin2[2])
  191.     write_coord(origin[0])
  192.     write_coord(origin[1])
  193.     write_coord(origin[2])
  194.     write_short(sprite) // sprite
  195.     write_byte(1) // framestart
  196.     write_byte(5) // framerate
  197.     write_byte(2) // life
  198.     write_byte(20) // width
  199.     write_byte(0) // noise
  200.     write_byte(red) // r, g, b
  201.     write_byte(green) // r, g, b
  202.     write_byte(blue) // r, g, b
  203.     write_byte(alpha) // brightness
  204.     write_byte(150) // speed
  205.     message_end()
  206. }
  207.  
  208. public Fw_SetModel(entity, model[])
  209. {
  210.    
  211.     if(!is_valid_ent(entity))
  212.         return FMRES_IGNORED
  213.  
  214.     if(!equali(model, W_OLD_M4A1_MODEL))
  215.         return FMRES_IGNORED
  216.  
  217.     new className[33]
  218.     entity_get_string(entity, EV_SZ_classname, className, 32)
  219.  
  220.     static iOwner, iStoredM4A1ID
  221.  
  222.     // Frost M4A1 Owner
  223.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  224.  
  225.     // Get drop weapon index (Frost M4A1) to use in fw_FrostM4A1AddToPlayer forward
  226.     iStoredM4A1ID = find_ent_by_owner(-1, "weapon_m4a1", entity)
  227.  
  228.     // If Player Has Frost M4A1 and It's weapon_m4a1
  229.     if(g_bHasFrostM4A1[iOwner] && is_valid_ent(iStoredM4A1ID))
  230.     {
  231.         // Setting weapon options
  232.         entity_set_int(iStoredM4A1ID, EV_INT_impulse, 1997)
  233.  
  234.         // Rest Var
  235.         g_bHasFrostM4A1[iOwner] = false
  236.        
  237.         // Set weaponbox new model
  238.         entity_set_model(entity, W_M4A1_MODEL)
  239.         return FMRES_SUPERCEDE
  240.     }
  241.     return FMRES_IGNORED
  242. }
  243.  
  244. public Fw_AddFrostM4A1ToPlayer(FrostM4A1, id)
  245. {
  246.     // Make sure that this is M4A1
  247.     if(is_valid_ent(FrostM4A1) && is_user_connected(id) && entity_get_int(FrostM4A1, EV_INT_impulse) == 1997)
  248.     {
  249.         // Update Var
  250.         g_bHasFrostM4A1[id] = true
  251.  
  252.         // Reset weapon options
  253.         entity_set_int(FrostM4A1, EV_INT_impulse, 0)
  254.         return HAM_HANDLED
  255.     }
  256.     return HAM_IGNORED
  257. }

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 4 Years Ago
Location: India
Has thanked: 3 times
Been thanked: 10 times
Age: 24
Contact:

#13

Post by karan » 6 Days Ago

Z0uha1r_LK wrote:
6 Days Ago
Check Now:
  1. #include <zombie_escape>
  2. #include <cstrike>
  3. #include <engine>
  4.  
  5. new const V_M4A1_MODEL[] = "models/zombie_escape/v_frost_m4a1.mdl"
  6. new const P_M4A1_MODEL[] = "models/zombie_escape/p_frost_m4a1.mdl"
  7. new const W_M4A1_MODEL[] = "models/zombie_escape/w_frost_m4a1.mdl"
  8. new const W_OLD_M4A1_MODEL[] = "models/w_m4a1.mdl"
  9.  
  10. new g_iItemID, g_iHudSync, g_iSpriteLaser, g_iFreezeDmg, g_iDmgMultiplier
  11. new bool:g_bHasFrostM4A1[33]
  12. new g_iDmg[33]
  13.  
  14. public plugin_init()
  15. {
  16.     register_plugin("[ZE] Extra Item: Frost M4A1", "1.0", "Raheem")
  17.    
  18.     // Cvars
  19.     g_iFreezeDmg = register_cvar("ze_freezing_m4a1_damage", "2000") // Damage Requried So Zombie got Frozen
  20.     g_iDmgMultiplier = register_cvar("ze_multiplier_m4a1_damage", "2") // Multiplie Weapon Damage
  21.  
  22.     // Message IDS
  23.     g_iHudSync = CreateHudSyncObj()
  24.    
  25.     // ITEM NAME & COST
  26.     g_iItemID = ze_register_item("Frost M4A1", 30, 0) // It's cost 30 Ammo Pack
  27.    
  28.     // Events
  29.     register_event("WeapPickup", "CheckModel", "b", "1=19")
  30.     register_event("CurWeapon", "CurrentWeapon", "be", "1=1")
  31.    
  32.     // Forwards
  33.     register_forward(FM_SetModel, "Fw_SetModel")
  34.    
  35.     // HookChains
  36.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  37.    
  38.     // Hams
  39.     RegisterHam(Ham_TraceAttack, "player", "Fw_TraceAttack_Post", 1)
  40.     RegisterHam(Ham_TraceAttack, "worldspawn", "Fw_TraceAttack_Post", 1)
  41.     RegisterHam(Ham_Item_AddToPlayer, "weapon_m4a1", "Fw_AddFrostM4A1ToPlayer")
  42. }
  43.  
  44. public plugin_precache()
  45. {
  46.     // Models
  47.     precache_model(V_M4A1_MODEL)
  48.     precache_model(P_M4A1_MODEL)
  49.     precache_model(W_M4A1_MODEL)
  50.    
  51.     // Sprites
  52.     g_iSpriteLaser = precache_model( "sprites/Newlightning.spr")
  53. }
  54.  
  55. public client_disconnected(id)
  56. {
  57.     g_bHasFrostM4A1[id] = false
  58. }
  59.  
  60. public ze_select_item_pre(id, itemid)
  61. {
  62.     // Return Available and we will block it in Post, So it dosen't affect other plugins
  63.     if (itemid != g_iItemID)
  64.         return ZE_ITEM_AVAILABLE
  65.    
  66.     // Available for Humans only, So don't show it for zombies
  67.     if (ze_is_user_zombie(id))
  68.         return ZE_ITEM_DONT_SHOW
  69.    
  70.     return ZE_ITEM_AVAILABLE
  71. }
  72.  
  73. public ze_select_item_post(player, itemid)
  74. {
  75.     if (itemid != g_iItemID)
  76.         return
  77.  
  78.     g_bHasFrostM4A1[player] = true
  79.  
  80.     rg_remove_item(player, "weapon_m4a1")
  81.     rg_give_item(player, "weapon_m4a1", GT_APPEND)
  82.     rg_set_user_bpammo(player, WeaponIdType:get_weaponid("weapon_m4a1"), 90)
  83.    
  84.     new szName[32]
  85.     get_user_name(player, szName, charsmax(szName))
  86.    
  87.     set_hudmessage(random(255), random(255), random(255), -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
  88.     show_hudmessage(0, "%s Has bought Frost M4A1!", szName)
  89.    
  90.     ze_colored_print(player, "!tYou Have bought Frost M4A1!y!")
  91. }
  92.  
  93. public Fw_TraceAttack_Post(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  94. {
  95.     if(!is_user_alive(iAttacker) && ze_is_user_zombie(iEnt))
  96.         return
  97.    
  98.     if(get_user_weapon(iAttacker) != CSW_M4A1 || !g_bHasFrostM4A1[iAttacker])
  99.         return
  100.    
  101.     set_hudmessage(34, 138, 255, -1.0, 0.17, 1, 0.0, 2.0, 1.0, 1.0, -1)
  102.     ShowSyncHudMsg(iAttacker, g_iHudSync, "Freeze Damage^n%d/%d", g_iDmg[iAttacker], get_pcvar_num(g_iFreezeDmg))
  103.    
  104.     new vec1[3], vec2[3]
  105.     get_user_origin(iAttacker, vec1, 1)
  106.     get_user_origin(iAttacker, vec2, 4)
  107.  
  108.     make_beam(vec1, vec2, g_iSpriteLaser, 0, 50, 200, 200)
  109. }
  110.  
  111. public ze_user_infected(infected)
  112. {
  113.     if (g_bHasFrostM4A1[infected])
  114.     {
  115.         g_bHasFrostM4A1[infected] = false
  116.     }
  117. }
  118.  
  119. public ze_user_humanized(id)
  120. {
  121.     g_bHasFrostM4A1[id] = false
  122.     g_iDmg[id] = 0
  123. }
  124.  
  125. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
  126. {
  127.     // Not Vaild Victim or Attacker
  128.     if (!is_user_connected(iVictim) || !is_user_connected(iAttacker))
  129.         return HC_CONTINUE
  130.    
  131.     // Victim is not a Zombie.
  132.     if (!ze_is_user_zombie(iVictim))
  133.         return HC_CONTINUE
  134.  
  135.     if (g_bHasFrostM4A1[iAttacker] && (get_user_weapon(iAttacker) == CSW_M4A1))
  136.     {
  137.         SetHookChainArg(4 , ATYPE_FLOAT, fDamage * get_pcvar_num(g_iDmgMultiplier))
  138.     }
  139.    
  140.     if((get_user_weapon(iAttacker) == CSW_M4A1) && g_bHasFrostM4A1[iAttacker])
  141.     {
  142.         g_iDmg[iAttacker] += (floatround(fDamage) * get_pcvar_num(g_iDmgMultiplier))
  143.     }
  144.    
  145.     if((g_iDmg[iAttacker] >= get_pcvar_num(g_iFreezeDmg)) && (get_user_weapon(iAttacker) == CSW_M4A1) && g_bHasFrostM4A1[iAttacker])
  146.     {
  147.         new szName[32]
  148.         get_user_name(iVictim, szName, charsmax(szName))
  149.        
  150.         ze_set_frost_grenade(iVictim, true)
  151.        
  152.         g_iDmg[iAttacker] = 0
  153.        
  154.         set_dhudmessage(34, 138, 255, -1.0, 0.25, 2, 6.0, 3.0, 0.1, 1.5)
  155.         show_dhudmessage(iAttacker, "%s Has been Freezed!", szName)
  156.     }
  157.     return HC_CONTINUE
  158. }
  159.  
  160. public CheckModel(id)
  161. {
  162.     if (is_user_alive(id))
  163.     {
  164.         set_pev(id, pev_viewmodel2, V_M4A1_MODEL)
  165.         set_pev(id, pev_weaponmodel2, P_M4A1_MODEL)
  166.     }
  167.     return PLUGIN_CONTINUE
  168. }
  169.  
  170. public CurrentWeapon(id)
  171. {
  172.     if ((get_user_weapon(id) == CSW_M4A1) && g_bHasFrostM4A1[id] == true)
  173.     {
  174.         CheckModel(id)
  175.     }
  176.     else
  177.     {
  178.         ClearSyncHud(id, g_iHudSync)
  179.     }
  180.     return PLUGIN_CONTINUE
  181. }
  182.  
  183. make_beam(const origin2[3], const origin[3], sprite, red, green, blue, alpha)
  184. {
  185.     //BEAMENTPOINTS
  186.     message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
  187.     write_byte (0) //TE_BEAMENTPOINTS 0
  188.     write_coord(origin2[0])
  189.     write_coord(origin2[1])
  190.     write_coord(origin2[2])
  191.     write_coord(origin[0])
  192.     write_coord(origin[1])
  193.     write_coord(origin[2])
  194.     write_short(sprite) // sprite
  195.     write_byte(1) // framestart
  196.     write_byte(5) // framerate
  197.     write_byte(2) // life
  198.     write_byte(20) // width
  199.     write_byte(0) // noise
  200.     write_byte(red) // r, g, b
  201.     write_byte(green) // r, g, b
  202.     write_byte(blue) // r, g, b
  203.     write_byte(alpha) // brightness
  204.     write_byte(150) // speed
  205.     message_end()
  206. }
  207.  
  208. public Fw_SetModel(entity, model[])
  209. {
  210.    
  211.     if(!is_valid_ent(entity))
  212.         return FMRES_IGNORED
  213.  
  214.     if(!equali(model, W_OLD_M4A1_MODEL))
  215.         return FMRES_IGNORED
  216.  
  217.     new className[33]
  218.     entity_get_string(entity, EV_SZ_classname, className, 32)
  219.  
  220.     static iOwner, iStoredM4A1ID
  221.  
  222.     // Frost M4A1 Owner
  223.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  224.  
  225.     // Get drop weapon index (Frost M4A1) to use in fw_FrostM4A1AddToPlayer forward
  226.     iStoredM4A1ID = find_ent_by_owner(-1, "weapon_m4a1", entity)
  227.  
  228.     // If Player Has Frost M4A1 and It's weapon_m4a1
  229.     if(g_bHasFrostM4A1[iOwner] && is_valid_ent(iStoredM4A1ID))
  230.     {
  231.         // Setting weapon options
  232.         entity_set_int(iStoredM4A1ID, EV_INT_impulse, 1997)
  233.  
  234.         // Rest Var
  235.         g_bHasFrostM4A1[iOwner] = false
  236.        
  237.         // Set weaponbox new model
  238.         entity_set_model(entity, W_M4A1_MODEL)
  239.         return FMRES_SUPERCEDE
  240.     }
  241.     return FMRES_IGNORED
  242. }
  243.  
  244. public Fw_AddFrostM4A1ToPlayer(FrostM4A1, id)
  245. {
  246.     // Make sure that this is M4A1
  247.     if(is_valid_ent(FrostM4A1) && is_user_connected(id) && entity_get_int(FrostM4A1, EV_INT_impulse) == 1997)
  248.     {
  249.         // Update Var
  250.         g_bHasFrostM4A1[id] = true
  251.  
  252.         // Reset weapon options
  253.         entity_set_int(FrostM4A1, EV_INT_impulse, 0)
  254.         return HAM_HANDLED
  255.     }
  256.     return HAM_IGNORED
  257. }
i posted the fix xD
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 4 Years Ago
Location: India
Has thanked: 3 times
Been thanked: 10 times
Age: 24
Contact:

#14

Post by karan » 6 Days Ago

karan wrote:
1 Week Ago
  1. #include <zombie_escape>
  2. #include <cstrike>
  3. #include <engine>
  4.  
  5. new const V_M4A1_MODEL[] = "models/zombie_escape/v_frost_m4a1.mdl"
  6. new const P_M4A1_MODEL[] = "models/zombie_escape/p_frost_m4a1.mdl"
  7. new const W_M4A1_MODEL[] = "models/zombie_escape/w_frost_m4a1.mdl"
  8. new const W_OLD_M4A1_MODEL[] = "models/w_m4a1.mdl"
  9.  
  10. new g_iItemID, g_iHudSync, g_iSpriteLaser, g_iFreezeDmg, g_iDmgMultiplier
  11. new bool:g_bHasFrostM4A1[33]
  12. new g_iDmg[33]
  13.  
  14. public plugin_init()
  15. {
  16.     register_plugin("[ZE] Extra Item: Frost M4A1", "1.0", "Raheem")
  17.    
  18.     // Cvars
  19.     g_iFreezeDmg = register_cvar("ze_freezing_m4a1_damage", "2000") // Damage Requried So Zombie got Frozen
  20.     g_iDmgMultiplier = register_cvar("ze_multiplier_m4a1_damage", "2") // Multiplie Weapon Damage
  21.  
  22.     // Message IDS
  23.     g_iHudSync = CreateHudSyncObj()
  24.    
  25.     // ITEM NAME & COST
  26.     g_iItemID = ze_register_item("Frost M4A1", 30, 0) // It's cost 30 Ammo Pack
  27.    
  28.     // Events
  29.     register_event("WeapPickup", "CheckModel", "b", "1=19")
  30.     register_event("CurWeapon", "CurrentWeapon", "be", "1=1")
  31.    
  32.     // Forwards
  33.     register_forward(FM_SetModel, "Fw_SetModel")
  34.    
  35.     // HookChains
  36.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  37.    
  38.     // Hams
  39.     RegisterHam(Ham_TraceAttack, "player", "Fw_TraceAttack_Post", 1)
  40.     RegisterHam(Ham_TraceAttack, "worldspawn", "Fw_TraceAttack_Post", 1)
  41.     RegisterHam(Ham_Item_AddToPlayer, "weapon_m4a1", "Fw_AddFrostM4A1ToPlayer")
  42. }
  43.  
  44. public plugin_precache()
  45. {
  46.     // Models
  47.     precache_model(V_M4A1_MODEL)
  48.     precache_model(P_M4A1_MODEL)
  49.     precache_model(W_M4A1_MODEL)
  50.    
  51.     // Sprites
  52.     g_iSpriteLaser = precache_model( "sprites/Newlightning.spr")
  53. }
  54.  
  55. public client_disconnected(id)
  56. {
  57.     g_bHasFrostM4A1[id] = false
  58. }
  59.  
  60. public ze_select_item_pre(id, itemid)
  61. {
  62.     // Return Available and we will block it in Post, So it dosen't affect other plugins
  63.     if (itemid != g_iItemID)
  64.         return ZE_ITEM_AVAILABLE
  65.    
  66.     // Available for Humans only, So don't show it for zombies
  67.     if (ze_is_user_zombie(id))
  68.         return ZE_ITEM_DONT_SHOW
  69.    
  70.     return ZE_ITEM_AVAILABLE
  71. }
  72.  
  73. public ze_select_item_post(player, itemid)
  74. {
  75.     if (itemid != g_iItemID)
  76.         return
  77.  
  78.     g_bHasFrostM4A1[player] = true
  79.  
  80.     rg_remove_item(player, "weapon_m4a1")
  81.     rg_give_item(player, "weapon_m4a1", GT_APPEND)
  82.     rg_set_user_bpammo(player, WeaponIdType:get_weaponid("weapon_m4a1"), 90)
  83.    
  84.     new szName[32]
  85.     get_user_name(player, szName, charsmax(szName))
  86.    
  87.     set_hudmessage(random(255), random(255), random(255), -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
  88.     show_hudmessage(0, "%s Has bought Frost M4A1!", szName)
  89.    
  90.     ze_colored_print(player, "!tYou Have bought Frost M4A1!y!")
  91. }
  92.  
  93. public Fw_TraceAttack_Post(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  94. {
  95.     if(!is_user_alive(iAttacker) && ze_is_user_zombie(iEnt))
  96.         return
  97.    
  98.     if(get_user_weapon(iAttacker) != CSW_M4A1 || !g_bHasFrostM4A1[iAttacker])
  99.         return
  100.    
  101.     set_hudmessage(34, 138, 255, -1.0, 0.17, 1, 0.0, 2.0, 1.0, 1.0, -1)
  102.     ShowSyncHudMsg(iAttacker, g_iHudSync, "Freeze Damage^n%d/%d", g_iDmg[iAttacker], get_pcvar_num(g_iFreezeDmg))
  103.    
  104.     new vec1[3], vec2[3]
  105.     get_user_origin(iAttacker, vec1, 1)
  106.     get_user_origin(iAttacker, vec2, 4)
  107.  
  108.     make_beam(vec1, vec2, g_iSpriteLaser, 0, 50, 200, 200)
  109. }
  110.  
  111. public ze_user_infected(infected)
  112. {
  113.     if (g_bHasFrostM4A1[infected])
  114.     {
  115.         g_bHasFrostM4A1[infected] = false
  116.     }
  117. }
  118.  
  119. public ze_user_humanized(id)
  120. {
  121.     g_bHasFrostM4A1[id] = false
  122.     g_iDmg[id] = 0
  123. }
  124.  
  125. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
  126. {
  127.     // Not Vaild Victim or Attacker
  128.     if (!ze_is_user_zombie(iVictim) || !is_user_connected(iAttacker))
  129.         return HC_CONTINUE
  130.    
  131.     if (g_bHasFrostM4A1[iAttacker] && (get_user_weapon(iAttacker) == CSW_M4A1))
  132.     {
  133.         SetHookChainArg(4 , ATYPE_FLOAT, fDamage * get_pcvar_num(g_iDmgMultiplier))
  134.     }
  135.    
  136.     if((get_user_weapon(iAttacker) == CSW_M4A1) && g_bHasFrostM4A1[iAttacker])
  137.     {
  138.         g_iDmg[iAttacker] += (floatround(fDamage) * get_pcvar_num(g_iDmgMultiplier))
  139.     }
  140.    
  141.     if((g_iDmg[iAttacker] >= get_pcvar_num(g_iFreezeDmg)) && (get_user_weapon(iAttacker) == CSW_M4A1) && g_bHasFrostM4A1[iAttacker])
  142.     {
  143.         new szName[32]
  144.         get_user_name(iVictim, szName, charsmax(szName))
  145.        
  146.         ze_set_frost_grenade(iVictim, true)
  147.        
  148.         g_iDmg[iAttacker] = 0
  149.        
  150.         set_dhudmessage(34, 138, 255, -1.0, 0.25, 2, 6.0, 3.0, 0.1, 1.5)
  151.         show_dhudmessage(iAttacker, "%s Has been Freezed!", szName)
  152.     }
  153.     return HC_CONTINUE
  154. }
  155.  
  156. public CheckModel(id)
  157. {
  158.     if (is_user_alive(id))
  159.     {
  160.         set_pev(id, pev_viewmodel2, V_M4A1_MODEL)
  161.         set_pev(id, pev_weaponmodel2, P_M4A1_MODEL)
  162.     }
  163.     return PLUGIN_CONTINUE
  164. }
  165.  
  166. public CurrentWeapon(id)
  167. {
  168.     if ((get_user_weapon(id) == CSW_M4A1) && g_bHasFrostM4A1[id] == true)
  169.     {
  170.         CheckModel(id)
  171.     }
  172.     else
  173.     {
  174.         ClearSyncHud(id, g_iHudSync)
  175.     }
  176.     return PLUGIN_CONTINUE
  177. }
  178.  
  179. make_beam(const origin2[3], const origin[3], sprite, red, green, blue, alpha)
  180. {
  181.     //BEAMENTPOINTS
  182.     message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
  183.     write_byte (0) //TE_BEAMENTPOINTS 0
  184.     write_coord(origin2[0])
  185.     write_coord(origin2[1])
  186.     write_coord(origin2[2])
  187.     write_coord(origin[0])
  188.     write_coord(origin[1])
  189.     write_coord(origin[2])
  190.     write_short(sprite) // sprite
  191.     write_byte(1) // framestart
  192.     write_byte(5) // framerate
  193.     write_byte(2) // life
  194.     write_byte(20) // width
  195.     write_byte(0) // noise
  196.     write_byte(red) // r, g, b
  197.     write_byte(green) // r, g, b
  198.     write_byte(blue) // r, g, b
  199.     write_byte(alpha) // brightness
  200.     write_byte(150) // speed
  201.     message_end()
  202. }
  203.  
  204. public Fw_SetModel(entity, model[])
  205. {
  206.    
  207.     if(!is_valid_ent(entity))
  208.         return FMRES_IGNORED
  209.  
  210.     if(!equali(model, W_OLD_M4A1_MODEL))
  211.         return FMRES_IGNORED
  212.  
  213.     new className[33]
  214.     entity_get_string(entity, EV_SZ_classname, className, 32)
  215.  
  216.     static iOwner, iStoredM4A1ID
  217.  
  218.     // Frost M4A1 Owner
  219.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  220.  
  221.     // Get drop weapon index (Frost M4A1) to use in fw_FrostM4A1AddToPlayer forward
  222.     iStoredM4A1ID = find_ent_by_owner(-1, "weapon_m4a1", entity)
  223.  
  224.     // If Player Has Frost M4A1 and It's weapon_m4a1
  225.     if(g_bHasFrostM4A1[iOwner] && is_valid_ent(iStoredM4A1ID))
  226.     {
  227.         // Setting weapon options
  228.         entity_set_int(iStoredM4A1ID, EV_INT_impulse, 1997)
  229.  
  230.         // Rest Var
  231.         g_bHasFrostM4A1[iOwner] = false
  232.        
  233.         // Set weaponbox new model
  234.         entity_set_model(entity, W_M4A1_MODEL)
  235.         return FMRES_SUPERCEDE
  236.     }
  237.     return FMRES_IGNORED
  238. }
  239.  
  240. public Fw_AddFrostM4A1ToPlayer(FrostM4A1, id)
  241. {
  242.     // Make sure that this is M4A1
  243.     if(is_valid_ent(FrostM4A1) && is_user_connected(id) && entity_get_int(FrostM4A1, EV_INT_impulse) == 1997)
  244.     {
  245.         // Update Var
  246.         g_bHasFrostM4A1[id] = true
  247.  
  248.         // Reset weapon options
  249.         entity_set_int(FrostM4A1, EV_INT_impulse, 0)
  250.         return HAM_HANDLED
  251.     }
  252.     return HAM_IGNORED
  253. }
this code is freezing humans too also counting breakables dmg so here's the fix
this one hh
These users thanked the author karan for the post:
Z0uha1r_LK (5 Days Ago)
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests