Resolved Convert to ZE Tactical Knife

Coding Help/Re-API Supported
Post Reply
User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 258
Joined: 6 Months Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 19 times
Age: 33
Contact:

Convert to ZE Tactical Knife

#1

Post by Mark » 6 Months Ago

lol the first one i try im having issues lol.
  1. //// ze_tact_knife.sma
  2. //
  3. // C:\Users\marcu\Desktop\Compiler v1.8.3\Compiler v1.8.3\scripting\include\engine.inc(799) : error 017: undefined symbol "kRenderFxNone"
  4. // C:\Users\marcu\Desktop\Compiler v1.8.3\Compiler v1.8.3\scripting\ze_tact_knife.sma(219) : warning 213: tag mismatch
  5. // C:\Users\marcu\Desktop\Compiler v1.8.3\Compiler v1.8.3\scripting\ze_tact_knife.sma(219) : warning 213: tag mismatch
  6. // C:\Users\marcu\Desktop\Compiler v1.8.3\Compiler v1.8.3\scripting\ze_tact_knife.sma(904) : warning 213: tag mismatch
  7. //
  8. // 1 Error.
  9. // Could not locate output file compiled\ze_tact_knife.amx (compile failed).
  10. //
  11. // Compilation Time: 1.47 sec

  1. #include <engine>
  2. #include <fakemeta_util>
  3. #include <cstrike>
  4. #include <fun>
  5. #include <zombie_escape>
  6. #include <ze_vip>
  7.  
  8. #define PLUGIN "ze_Tactical Knife"
  9. #define VERSION "1.0"
  10. #define AUTHOR "?"
  11.  
  12. #define CSW_TACT CSW_P228
  13. #define weapon_tact "weapon_p228"
  14. #define old_event "events/p228.sc"
  15. #define old_w_model "models/w_p228.mdl"
  16. #define WEAPON_SECRETCODE 4234234
  17.  
  18.  
  19. #define RELOAD_TIME 0.435
  20. #define STAB_TIME 1.1
  21. #define ATTACK_TIME 1.0
  22. #define SYSTEM_CLASSNAME "tact_knife"
  23. #define SYSTEM_CLASSNAME2 "tact_knife2"
  24. #define WEAPON_ANIMEXT "grenade"
  25.  
  26. const PDATA_SAFE = 2
  27. const OFFSET_LINUX_WEAPONS = 4
  28. const OFFSET_WEAPONOWNER = 41
  29. const m_flNextAttack = 83
  30. const m_szAnimExtention = 492
  31.  
  32. new const v_model[] = "models/v_tknifeex2.mdl"
  33. new const p_model[] = "models/p_tknifeex2.mdl"
  34. new const w_model[] = "models/w_tknifeex2.mdl"
  35. new const ARROW_MODEL[] = "models/tknifeb.mdl"
  36. new const tact_wall[][] = {"weapons/tknife_stone1.wav", "weapons/tknife_stone2.wav"}
  37. new const weapon_sound[4][] =
  38. {
  39.     "weapons/tknife_shoot1.wav",
  40.     "weapons/tknifeex2_shoot1.wav",
  41.     "weapons/tknifeex2_draw.wav",
  42.     "weapons/tact_hit.wav"
  43. }
  44.  
  45.  
  46. new const WeaponResource[4][] =
  47. {
  48.     "sprites/weapon_tknifeex2.txt",
  49.     "sprites/640hud12.spr",
  50.     "sprites/640hud96.spr",
  51.     "sprites/640hud97.spr"
  52. }
  53.  
  54. enum
  55. {
  56.     ANIM_IDLE = 0,
  57.     ANIM_SHOOT,
  58.     ANIM_DRAW,
  59.     ANIM_SHOOT2
  60. }
  61.  
  62. new g_MsgDeathMsg, g_endround
  63.  
  64. new g_had_tact[33], g_tact_ammo[33], g_Shoot_Count[33]
  65. new g_old_weapon[33], m_iBlood[2]
  66. new sTrail, item_tact, cvar_dmg_slash_tact, cvar_dmg_stab_tact, cvar_ammo_tactical
  67.  
  68. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
  69.  
  70. public plugin_precache()
  71. {
  72.     precache_model(v_model)
  73.     precache_model(p_model)
  74.     precache_model(w_model)
  75.     precache_model(ARROW_MODEL)
  76.    
  77.     for(new i = 0; i < sizeof(weapon_sound); i++)
  78.         precache_sound(weapon_sound[i])
  79.    
  80.     for(new i = 0; i < sizeof(tact_wall); i++)
  81.         precache_sound(tact_wall[i])
  82.    
  83.     precache_generic(WeaponResource[0])
  84.     for(new i = 1; i < sizeof(WeaponResource); i++)
  85.         precache_model(WeaponResource[i])
  86.    
  87.     m_iBlood[0] = precache_model("sprites/blood.spr")
  88.     m_iBlood[1] = precache_model("sprites/bloodspray.spr")
  89.     sTrail = precache_model("sprites/laserbeam.spr")
  90. }
  91.  
  92. public plugin_init()
  93. {
  94.     register_plugin(PLUGIN, VERSION, AUTHOR)
  95.     register_cvar("tact_version", "m4m3ts", FCVAR_SERVER|FCVAR_SPONLY)
  96.     register_forward(FM_CmdStart, "fw_CmdStart")
  97.     register_forward(FM_SetModel, "fw_SetModel")
  98.     register_think(SYSTEM_CLASSNAME, "fw_Think")
  99.     register_think(SYSTEM_CLASSNAME2, "fw_Think")
  100.     register_touch(SYSTEM_CLASSNAME, "*", "fw_touch")
  101.     register_touch(SYSTEM_CLASSNAME2, "*", "fw_touch2")
  102.     register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
  103.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)   
  104.     RegisterHam(Ham_Spawn, "player", "Player_Spawn", 1)
  105.     RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  106.     RegisterHam(Ham_Item_AddToPlayer, weapon_tact, "fw_AddToPlayer_Post", 1)
  107.     register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
  108.    
  109.     register_clcmd("weapon_tknifeex2", "hook_weapon")
  110.    
  111.     cvar_dmg_slash_tact = register_cvar("zp_tactical_dmg_slash", "61.0")
  112.     cvar_dmg_stab_tact = register_cvar("zp_tactical_dmg_stab", "140.0")
  113.     cvar_ammo_tactical = register_cvar("zp_tactical_ammo", "60")
  114.    
  115.     item_tact = ze_register_item("Triple Tactical Knife", 65, 0)
  116.    
  117.     g_MsgDeathMsg = get_user_msgid("DeathMsg")
  118.    
  119.     g_endround = 1
  120. }
  121.  
  122. public ze_user_humanized(id)
  123. {
  124.     remove_tact(id)
  125. }
  126.  
  127. public ze_user_infected(Victim)
  128. {
  129.     remove_tact(Victim)
  130. }
  131.  
  132. public client_putinserver(id)
  133. {
  134.     remove_tact(id)
  135. }
  136.  
  137. public client_disconnected(id)
  138. {
  139.     remove_tact(id)
  140. }
  141.  
  142. public ze_select_item_pre(id, itemid)
  143. {  
  144.     if (itemid != item_tact)
  145.         return ZE_ITEM_AVAILABLE
  146.    
  147.     if (ze_is_user_zombie(id))
  148.         return ZE_ITEM_DONT_SHOW
  149.        
  150.     return ZE_ITEM_AVAILABLE
  151. }
  152.  
  153. public ze_select_item_post(id, itemid)
  154. {
  155.     if (itemid != item_tact)
  156.         return
  157.        
  158.     ze_colored_print(id, "Congrats! You Bought a ^3Tactical Knife^1!! :D")
  159.    
  160.     get_tact(id)
  161. }
  162.  
  163. public fw_PlayerKilled(id)
  164. {
  165.     remove_tact(id)
  166. }
  167.  
  168. public hook_weapon(id)
  169. {
  170.     engclient_cmd(id, weapon_tact)
  171.     return
  172. }
  173.  
  174. public get_tact(id)
  175. {
  176.     if(!is_user_alive(id))
  177.         return
  178.     drop_weapons(id, 1)
  179.     g_had_tact[id] = 1
  180.     g_tact_ammo[id] = get_pcvar_num(cvar_ammo_tactical)
  181.    
  182.     give_item(id, weapon_tact)
  183.    
  184.     static weapon_ent; weapon_ent = fm_find_ent_by_owner(-1, weapon_tact, id)
  185.     if(pev_valid(weapon_ent)) cs_set_weapon_ammo(weapon_ent, 1)
  186. }
  187.  
  188. public remove_tact(id)
  189. {
  190.     g_had_tact[id] = 0
  191.     g_tact_ammo[id] = 0
  192. }
  193.  
  194. public refill_tact(id)
  195. {
  196.     g_tact_ammo[id] = get_pcvar_num(cvar_ammo_tactical)
  197.     update_ammo(id)
  198. }
  199.    
  200. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  201. {
  202.     if(!is_user_alive(id) || !is_user_connected(id))
  203.         return FMRES_IGNORED   
  204.     if(get_user_weapon(id) == CSW_TACT && g_had_tact[id])
  205.         set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  206.    
  207.     return FMRES_HANDLED
  208. }
  209.  
  210. public Event_CurWeapon(id)
  211. {
  212.     if(!is_user_alive(id))
  213.         return
  214.        
  215.     if(get_user_weapon(id) == CSW_TACT && g_had_tact[id])
  216.     {
  217.         set_pev(id, pev_viewmodel2, v_model)
  218.         set_pev(id, pev_weaponmodel2, p_model)
  219.         set_pdata_string(id, m_szAnimExtention * 4, WEAPON_ANIMEXT, -1 , 20)
  220.         set_weapon_anim(id, ANIM_DRAW)
  221.         update_ammo(id)
  222.     }
  223.    
  224.     g_old_weapon[id] = get_user_weapon(id)
  225. }
  226.  
  227. public fw_CmdStart(id, uc_handle, seed)
  228. {
  229.     if(!is_user_alive(id) || !is_user_connected(id))
  230.         return
  231.     if(get_user_weapon(id) != CSW_TACT || !g_had_tact[id])
  232.         return
  233.    
  234.     static ent; ent = fm_get_user_weapon_entity(id, CSW_TACT)
  235.     if(!pev_valid(ent))
  236.         return
  237.     if(get_pdata_float(ent, 46, OFFSET_LINUX_WEAPONS) > 0.0 || get_pdata_float(ent, 47, OFFSET_LINUX_WEAPONS) > 0.0)
  238.         return
  239.    
  240.     static CurButton
  241.     CurButton = get_uc(uc_handle, UC_Buttons)
  242.    
  243.     if(CurButton & IN_ATTACK)
  244.     {
  245.         CurButton &= ~IN_ATTACK
  246.         set_uc(uc_handle, UC_Buttons, CurButton)
  247.        
  248.         if(g_tact_ammo[id] == 0)
  249.             return
  250.         if(get_pdata_float(id, 83, 5) <= 0.0)
  251.         {
  252.             g_tact_ammo[id]--
  253.             g_Shoot_Count[id] = 0
  254.             update_ammo(id)
  255.             set_task(0.2, "throw_knife", id)
  256.             set_weapon_anim(id, ANIM_SHOOT)
  257.             set_weapons_timeidle(id, CSW_TACT, ATTACK_TIME)
  258.             set_player_nextattackx(id, ATTACK_TIME)
  259.         }
  260.     }
  261.     else if(CurButton & IN_ATTACK2)
  262.     {
  263.         if(get_pdata_float(id, 83, 5) <= 0.0)
  264.         {
  265.             set_weapon_anim(id, ANIM_SHOOT2)
  266.             FireArrow_Charge(id)
  267.             emit_sound(id, CHAN_VOICE, weapon_sound[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
  268.             set_weapons_timeidle(id, CSW_TACT, STAB_TIME)
  269.             set_player_nextattackx(id, STAB_TIME)
  270.         }
  271.     }
  272. }
  273.  
  274. public throw_knife(id)
  275. {
  276.     FireArrow1(id)
  277.     FireArrow2(id)
  278.     FireArrow3(id)
  279. }
  280.  
  281. public FireArrow1(id)
  282. {
  283.     static Float:StartOrigin[3], Float:TargetOrigin[3], Float:angles[3], Float:anglestrue[3]
  284.     get_position(id, 2.0, 4.0, -3.0, StartOrigin)
  285.  
  286.     pev(id,pev_v_angle,angles)
  287.     static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  288.     if(!pev_valid(Ent)) return
  289.     anglestrue[0] = 180.0 - angles[0]
  290.     anglestrue[1] = angles[1]
  291.     anglestrue[2] = angles[2]
  292.    
  293.     // Set info for ent
  294.     set_pev(Ent, pev_movetype, MOVETYPE_TOSS)
  295.     set_pev(Ent, pev_owner, id) // Better than pev_owner
  296.     set_pev(Ent, pev_fuser1, get_gametime() + 4.0)
  297.     set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
  298.    
  299.     entity_set_string(Ent, EV_SZ_classname, SYSTEM_CLASSNAME)
  300.     engfunc(EngFunc_SetModel, Ent, ARROW_MODEL)
  301.     set_pev(Ent, pev_mins, Float:{-0.1, -0.1, -0.1})
  302.     set_pev(Ent, pev_maxs, Float:{0.1, 0.1, 0.1})
  303.     set_pev(Ent, pev_origin, StartOrigin)
  304.     set_pev(Ent, pev_angles, anglestrue)
  305.     set_pev(Ent, pev_gravity, 0.5)
  306.     set_pev(Ent, pev_solid, SOLID_BBOX)
  307.     set_pev(Ent, pev_frame, 0.0)
  308.    
  309.     static Float:Velocity[3]
  310.     get_position(id, 1024.0, 12.0, -12.0, TargetOrigin)
  311.     get_speed_vector(StartOrigin, TargetOrigin, 2300.0, Velocity)
  312.     set_pev(Ent, pev_velocity, Velocity)
  313.  
  314.    
  315.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  316.     write_byte(TE_BEAMFOLLOW) // Temporary entity ID
  317.     write_short(Ent) // Entity
  318.     write_short(sTrail) // Sprite index
  319.     write_byte(7) // Life
  320.     write_byte(1) // Line width
  321.     write_byte(255) // Red
  322.     write_byte(255) // Green
  323.     write_byte(255) // Blue
  324.     write_byte(65) // Alpha
  325.     message_end()
  326. }
  327.  
  328. public FireArrow2(id)
  329. {
  330.     static Float:StartOrigin[3], Float:TargetOrigin[3], Float:angles[3], Float:anglestrue[3]
  331.     get_position(id, 2.0, -4.0, -2.0, StartOrigin)
  332.  
  333.     pev(id,pev_v_angle,angles)
  334.     static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  335.     if(!pev_valid(Ent)) return
  336.     anglestrue[0] = 180.0 - angles[0]
  337.     anglestrue[1] = angles[1]
  338.     anglestrue[2] = angles[2]
  339.    
  340.     // Set info for ent
  341.     set_pev(Ent, pev_movetype, MOVETYPE_TOSS)
  342.     set_pev(Ent, pev_owner, id) // Better than pev_owner
  343.     set_pev(Ent, pev_fuser1, get_gametime() + 4.0)
  344.     set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
  345.    
  346.     entity_set_string(Ent, EV_SZ_classname, SYSTEM_CLASSNAME)
  347.     engfunc(EngFunc_SetModel, Ent, ARROW_MODEL)
  348.     set_pev(Ent, pev_mins, Float:{-0.1, -0.1, -0.1})
  349.     set_pev(Ent, pev_maxs, Float:{0.1, 0.1, 0.1})
  350.     set_pev(Ent, pev_origin, StartOrigin)
  351.     set_pev(Ent, pev_angles, anglestrue)
  352.     set_pev(Ent, pev_gravity, 0.5)
  353.     set_pev(Ent, pev_solid, SOLID_BBOX)
  354.     set_pev(Ent, pev_frame, 0.0)
  355.    
  356.     static Float:Velocity[3]
  357.     get_position(id, 1024.0, -12.0, -12.0, TargetOrigin)
  358.     get_speed_vector(StartOrigin, TargetOrigin, 2300.0, Velocity)
  359.     set_pev(Ent, pev_velocity, Velocity)
  360.  
  361.    
  362.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  363.     write_byte(TE_BEAMFOLLOW) // Temporary entity ID
  364.     write_short(Ent) // Entity
  365.     write_short(sTrail) // Sprite index
  366.     write_byte(7) // Life
  367.     write_byte(1) // Line width
  368.     write_byte(255) // Red
  369.     write_byte(255) // Green
  370.     write_byte(255) // Blue
  371.     write_byte(65) // Alpha
  372.     message_end()
  373. }
  374.  
  375. public FireArrow3(id)
  376. {
  377.     static Float:StartOrigin[3], Float:TargetOrigin[3], Float:angles[3], Float:anglestrue[3]
  378.     get_position(id, 2.0, 2.0, 4.0, StartOrigin)
  379.  
  380.     pev(id,pev_v_angle,angles)
  381.     static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  382.     if(!pev_valid(Ent)) return
  383.     anglestrue[0] = 180.0 - angles[0]
  384.     anglestrue[1] = angles[1]
  385.     anglestrue[2] = angles[2]
  386.    
  387.     // Set info for ent
  388.     set_pev(Ent, pev_movetype, MOVETYPE_TOSS)
  389.     set_pev(Ent, pev_owner, id) // Better than pev_owner
  390.     set_pev(Ent, pev_fuser1, get_gametime() + 4.0)
  391.     set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
  392.    
  393.     entity_set_string(Ent, EV_SZ_classname, SYSTEM_CLASSNAME)
  394.     engfunc(EngFunc_SetModel, Ent, ARROW_MODEL)
  395.     set_pev(Ent, pev_mins, Float:{-0.1, -0.1, -0.1})
  396.     set_pev(Ent, pev_maxs, Float:{0.1, 0.1, 0.1})
  397.     set_pev(Ent, pev_origin, StartOrigin)
  398.     set_pev(Ent, pev_angles, anglestrue)
  399.     set_pev(Ent, pev_gravity, 0.5)
  400.     set_pev(Ent, pev_solid, SOLID_BBOX)
  401.     set_pev(Ent, pev_frame, 0.0)
  402.    
  403.     static Float:Velocity[3]
  404.     get_position(id, 1024.0, 12.0, 12.0, TargetOrigin)
  405.     get_speed_vector(StartOrigin, TargetOrigin, 2300.0, Velocity)
  406.     set_pev(Ent, pev_velocity, Velocity)
  407.  
  408.    
  409.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  410.     write_byte(TE_BEAMFOLLOW) // Temporary entity ID
  411.     write_short(Ent) // Entity
  412.     write_short(sTrail) // Sprite index
  413.     write_byte(7) // Life
  414.     write_byte(1) // Line width
  415.     write_byte(255) // Red
  416.     write_byte(255) // Green
  417.     write_byte(255) // Blue
  418.     write_byte(65) // Alpha
  419.     message_end()
  420. }
  421.  
  422. public FireArrow_Charge(id)
  423. {
  424.     static Float:StartOrigin[3], Float:TargetOrigin[3], Float:angles[3]
  425.     get_position(id, 2.0, 0.0, 0.0, StartOrigin)
  426.  
  427.     pev(id,pev_angles,angles)
  428.     static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  429.     if(!pev_valid(Ent)) return
  430.    
  431.     // Set info for ent
  432.     set_pev(Ent, pev_movetype, MOVETYPE_FLY)
  433.     set_pev(Ent, pev_owner, id) // Better than pev_owner
  434.     set_pev(Ent, pev_rendermode, kRenderTransAdd)
  435.     set_pev(Ent, pev_renderamt, 1.0)
  436.     set_pev(Ent, pev_fuser1, get_gametime() + 0.1)
  437.     set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
  438.    
  439.     entity_set_string(Ent, EV_SZ_classname, SYSTEM_CLASSNAME2)
  440.     engfunc(EngFunc_SetModel, Ent, ARROW_MODEL)
  441.     set_pev(Ent, pev_mins, Float:{-0.1, -0.1, -0.1})
  442.     set_pev(Ent, pev_maxs, Float:{0.1, 0.1, 0.1})
  443.     set_pev(Ent, pev_origin, StartOrigin)
  444.     set_pev(Ent, pev_angles, angles)
  445.     set_pev(Ent, pev_gravity, 0.01)
  446.     set_pev(Ent, pev_solid, SOLID_BBOX)
  447.     set_pev(Ent, pev_frame, 0.0)
  448.    
  449.     static Float:Velocity[3]
  450.     fm_get_aim_origin(id, TargetOrigin)
  451.     get_speed_vector(StartOrigin, TargetOrigin, 800.0, Velocity)
  452.     set_pev(Ent, pev_velocity, Velocity)
  453. }
  454.  
  455. public fw_Think(ent)
  456. {
  457.     if(!pev_valid(ent))
  458.         return
  459.    
  460.     static Float:fFrame; pev(ent, pev_frame, fFrame)
  461.    
  462.     fFrame += 1.5
  463.     fFrame = floatmin(21.0, fFrame)
  464.    
  465.     set_pev(ent, pev_frame, fFrame)
  466.     set_pev(ent, pev_nextthink, get_gametime() + 0.05)
  467.    
  468.     // time remove
  469.     static Float:fTimeRemove, Float:Amount
  470.     pev(ent, pev_fuser1, fTimeRemove)
  471.     pev(ent, pev_renderamt, Amount)
  472.    
  473.     if(get_gametime() >= fTimeRemove)
  474.     {
  475.         remove_entity(ent)
  476.     }
  477. }
  478.  
  479. public fw_touch(Ent, Id)
  480. {
  481.     // If ent is valid
  482.     if(!pev_valid(Ent))
  483.         return
  484.     static Owner; Owner = pev(Ent, pev_owner)
  485.     if(pev(Ent, pev_movetype) == MOVETYPE_NONE)
  486.         return
  487.     static classnameptd[32]
  488.     pev(Id, pev_classname, classnameptd, 31)
  489.     if (equali(classnameptd, "func_breakable")) ExecuteHamB( Ham_TakeDamage, Id, 0, 0, 60.0, DMG_GENERIC )
  490.     Damage_tact(Ent, Id)
  491.    
  492.     // Get it's origin
  493.     new Float:originF[3]
  494.     pev(Ent, pev_origin, originF)
  495.     // Alive...
  496.    
  497.     if(is_user_alive(Id) && ze_is_user_zombie(Id))
  498.     {
  499.         remove_entity(Ent)
  500.         create_blood(originF)
  501.         create_blood(originF)
  502.         emit_sound(Id, CHAN_BODY, weapon_sound[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
  503.     }
  504.    
  505.     else if(is_user_alive(Id) && !ze_is_user_zombie(Id))
  506.     {
  507.         remove_entity(Ent)
  508.         emit_sound(Id, CHAN_VOICE, weapon_sound[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
  509.     }
  510.    
  511.     else
  512.     {
  513.         set_pev(Ent, pev_fuser1, get_gametime() + 1.0)
  514.         make_bullet(Owner, originF)
  515.         engfunc(EngFunc_EmitSound, Ent, CHAN_WEAPON, tact_wall[random( sizeof(tact_wall))], 1.0, ATTN_STATIC, 0, PITCH_NORM)
  516.         set_pev(Ent, pev_movetype, MOVETYPE_NONE)
  517.         set_pev(Ent, pev_solid, SOLID_NOT)
  518.     }
  519. }
  520.  
  521. public fw_touch2(Ent, Id)
  522. {
  523.     // If ent is valid
  524.     if(!pev_valid(Ent))
  525.         return
  526.     if(pev(Ent, pev_movetype) == MOVETYPE_NONE)
  527.         return
  528.    
  529.     static classnameptd[32]
  530.     pev(Id, pev_classname, classnameptd, 31)
  531.     if (equali(classnameptd, "func_breakable")) ExecuteHamB( Ham_TakeDamage, Id, 0, 0, 200.0, DMG_GENERIC )
  532.     Damage_tact2(Ent, Id)
  533.    
  534.     // Get it's origin
  535.     new Float:originF[3]
  536.     pev(Ent, pev_origin, originF)
  537.     // Alive...
  538.    
  539.     if(is_user_alive(Id) && ze_is_user_zombie(Id))
  540.     {
  541.         remove_entity(Ent)
  542.         create_blood(originF)
  543.         create_blood(originF)
  544.         emit_sound(Id, CHAN_BODY, weapon_sound[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
  545.     }
  546.    
  547.     else if(is_user_alive(Id) && !ze_is_user_zombie(Id))
  548.     {
  549.         remove_entity(Ent)
  550.         emit_sound(Id, CHAN_VOICE, weapon_sound[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
  551.     }
  552.    
  553.     else
  554.     {
  555.         engfunc(EngFunc_EmitSound, Ent, CHAN_WEAPON, tact_wall[random( sizeof(tact_wall))], 1.0, ATTN_STATIC, 0, PITCH_NORM)
  556.         set_pev(Ent, pev_movetype, MOVETYPE_NONE)
  557.         set_pev(Ent, pev_solid, SOLID_NOT)
  558.     }
  559. }
  560.        
  561. public Remove_tactBall(Ent)
  562. {
  563.     if(!pev_valid(Ent)) return
  564.     engfunc(EngFunc_RemoveEntity, Ent)
  565. }
  566.  
  567. public Damage_tact(Ent, Id)
  568. {
  569.     static Owner; Owner = pev(Ent, pev_owner)
  570.     static Attacker;
  571.     if(!is_user_alive(Owner))
  572.     {
  573.         Attacker = 0
  574.         return
  575.     } else Attacker = Owner
  576.    
  577.     if(g_endround)
  578.         return
  579.  
  580.     new bool:bIsHeadShot; // never make that one static
  581.     new Float:flAdjustedDamage, bool:death
  582.  
  583.     switch( Get_MissileWeaponHitGroup(Ent) )
  584.     {
  585.         case HIT_GENERIC: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 1.5
  586.         case HIT_CHEST: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 1.0
  587.         case HIT_STOMACH: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 1.0
  588.         case HIT_LEFTLEG, HIT_RIGHTLEG: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 0.75
  589.         case HIT_LEFTARM, HIT_RIGHTARM: flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 0.35
  590.         case HIT_HEAD:
  591.         {
  592.             flAdjustedDamage = get_pcvar_float(cvar_dmg_slash_tact) * 2.50
  593.             bIsHeadShot = true;
  594.         }
  595.     }
  596.     if(pev(Id, pev_health) <= flAdjustedDamage) death = true
  597.    
  598.     if(is_user_alive(Id))
  599.     {
  600.         if( bIsHeadShot && death)
  601.         {
  602.             emessage_begin(MSG_BROADCAST, g_MsgDeathMsg)
  603.             ewrite_byte(Attacker)
  604.             ewrite_byte(Id)
  605.             ewrite_byte(1)
  606.             ewrite_string("Triple Tactical Knife")
  607.             emessage_end()
  608.            
  609.             set_msg_block(g_MsgDeathMsg, BLOCK_SET)
  610.             user_silentkill(Id)
  611.             set_msg_block(g_MsgDeathMsg, BLOCK_NOT)
  612.  
  613.             death = false
  614.         }
  615.         else ExecuteHamB(Ham_TakeDamage, Id, Ent, Attacker, flAdjustedDamage, DMG_BULLET)
  616.     }
  617. }
  618.  
  619. public Damage_tact2(Ent, Id)
  620. {
  621.     static Owner; Owner = pev(Ent, pev_owner)
  622.     static Attacker;
  623.     if(!is_user_alive(Owner))
  624.     {
  625.         Attacker = 0
  626.         return
  627.     } else Attacker = Owner
  628.    
  629.     if(g_endround)
  630.         return
  631.    
  632.     new bool:bIsHeadShot; // never make that one static
  633.     new Float:flAdjustedDamage, bool:death
  634.  
  635.     switch( Get_MissileWeaponHitGroup(Ent) )
  636.     {
  637.         case HIT_GENERIC: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 1.5
  638.         case HIT_CHEST: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 1.0
  639.         case HIT_STOMACH: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 1.0
  640.         case HIT_LEFTLEG, HIT_RIGHTLEG: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 0.75
  641.         case HIT_LEFTARM, HIT_RIGHTARM: flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 0.35
  642.         case HIT_HEAD:
  643.         {
  644.             flAdjustedDamage = get_pcvar_float(cvar_dmg_stab_tact) * 2.50
  645.             bIsHeadShot = true;
  646.         }
  647.     }
  648.     if(pev(Id, pev_health) <= flAdjustedDamage) death = true
  649.    
  650.     if(is_user_alive(Id))
  651.     {
  652.         if( bIsHeadShot && death)
  653.         {
  654.             emessage_begin(MSG_BROADCAST, g_MsgDeathMsg)
  655.             ewrite_byte(Attacker)
  656.             ewrite_byte(Id)
  657.             ewrite_byte(1)
  658.             ewrite_string("Triple Tactical Knife")
  659.             emessage_end()
  660.            
  661.             set_msg_block(g_MsgDeathMsg, BLOCK_SET)
  662.             user_silentkill(Id)
  663.             set_msg_block(g_MsgDeathMsg, BLOCK_NOT)
  664.  
  665.             death = false
  666.         }
  667.         else ExecuteHamB(Ham_TakeDamage, Id, Ent, Attacker, flAdjustedDamage, DMG_BULLET)
  668.     }
  669. }
  670.  
  671. public fw_SetModel(entity, model[])
  672. {
  673.     if(!pev_valid(entity))
  674.         return FMRES_IGNORED
  675.    
  676.     static Classname[64]
  677.     pev(entity, pev_classname, Classname, sizeof(Classname))
  678.    
  679.     if(!equal(Classname, "weaponbox"))
  680.         return FMRES_IGNORED
  681.    
  682.     static id
  683.     id = pev(entity, pev_owner)
  684.    
  685.     if(equal(model, old_w_model))
  686.     {
  687.         static weapon
  688.         weapon = fm_get_user_weapon_entity(entity, CSW_TACT)
  689.        
  690.         if(!pev_valid(weapon))
  691.             return FMRES_IGNORED
  692.        
  693.         if(g_had_tact[id])
  694.         {
  695.             set_pev(weapon, pev_impulse, WEAPON_SECRETCODE)
  696.             set_pev(weapon, pev_iuser4, g_tact_ammo[id])
  697.             engfunc(EngFunc_SetModel, entity, w_model)
  698.            
  699.             g_had_tact[id] = 0
  700.             g_tact_ammo[id] = 0
  701.            
  702.             return FMRES_SUPERCEDE
  703.         }
  704.     }
  705.  
  706.     return FMRES_IGNORED;
  707. }
  708.  
  709. public fw_AddToPlayer_Post(ent, id)
  710. {
  711.     if(pev(ent, pev_impulse) == WEAPON_SECRETCODE)
  712.     {
  713.         g_had_tact[id] = 1
  714.         g_tact_ammo[id] = pev(ent, pev_iuser4)
  715.        
  716.         set_pev(ent, pev_impulse, 0)
  717.     }          
  718.    
  719.     message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("WeaponList"), _, id)
  720.     write_string((g_had_tact[id] == 1 ? "weapon_tknifeex2" : "weapon_p228"))
  721.     write_byte(1)
  722.     write_byte(52)
  723.     write_byte(-1)
  724.     write_byte(-1)
  725.     write_byte(1)
  726.     write_byte(3)
  727.     write_byte(CSW_TACT)
  728.     write_byte(0)
  729.     message_end()
  730. }
  731.  
  732. public update_ammo(id)
  733. {
  734.     if(!is_user_alive(id))
  735.         return
  736.    
  737.     static weapon_ent; weapon_ent = fm_find_ent_by_owner(-1, weapon_tact, id)
  738.     if(pev_valid(weapon_ent)) cs_set_weapon_ammo(weapon_ent, 1)
  739.    
  740.     cs_set_user_bpammo(id, CSW_P228, 0)
  741.    
  742.     engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, get_user_msgid("CurWeapon"), {0, 0, 0}, id)
  743.     write_byte(1)
  744.     write_byte(CSW_TACT)
  745.     write_byte(-1)
  746.     message_end()
  747.    
  748.     message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("AmmoX"), _, id)
  749.     write_byte(1)
  750.     write_byte(g_tact_ammo[id])
  751.     message_end()
  752. }
  753.  
  754. stock make_bullet(id, Float:Origin[3])
  755. {
  756.     // Find target
  757.     new decal = random_num(41, 45)
  758.     const loop_time = 2
  759.    
  760.     static Body, Target
  761.     get_user_aiming(id, Target, Body, 999999)
  762.    
  763.     if(is_user_connected(Target))
  764.         return
  765.    
  766.     for(new i = 0; i < loop_time; i++)
  767.     {
  768.         // Put decal on "world" (a wall)
  769.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  770.         write_byte(TE_WORLDDECAL)
  771.         engfunc(EngFunc_WriteCoord, Origin[0])
  772.         engfunc(EngFunc_WriteCoord, Origin[1])
  773.         engfunc(EngFunc_WriteCoord, Origin[2])
  774.         write_byte(decal)
  775.         message_end()
  776.        
  777.         // Show sparcles
  778.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  779.         write_byte(TE_GUNSHOTDECAL)
  780.         engfunc(EngFunc_WriteCoord, Origin[0])
  781.         engfunc(EngFunc_WriteCoord, Origin[1])
  782.         engfunc(EngFunc_WriteCoord, Origin[2])
  783.         write_short(id)
  784.         write_byte(decal)
  785.         message_end()
  786.     }
  787. }
  788.  
  789. stock set_weapon_anim(id, anim)
  790. {
  791.     if(!is_user_alive(id))
  792.         return
  793.    
  794.     set_pev(id, pev_weaponanim, anim)
  795.    
  796.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
  797.     write_byte(anim)
  798.     write_byte(pev(id, pev_body))
  799.     message_end()
  800. }
  801.  
  802. stock create_blood(const Float:origin[3])
  803. {
  804.     // Show some blood :)
  805.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  806.     write_byte(TE_BLOODSPRITE)
  807.     engfunc(EngFunc_WriteCoord, origin[0])
  808.     engfunc(EngFunc_WriteCoord, origin[1])
  809.     engfunc(EngFunc_WriteCoord, origin[2])
  810.     write_short(m_iBlood[1])
  811.     write_short(m_iBlood[0])
  812.     write_byte(75)
  813.     write_byte(8)
  814.     message_end()
  815. }
  816.  
  817. stock drop_weapons(id, dropwhat)
  818. {
  819.     static weapons[32], num, i, weaponid
  820.     num = 0
  821.     get_user_weapons(id, weapons, num)
  822.      
  823.     for (i = 0; i < num; i++)
  824.     {
  825.         weaponid = weapons[i]
  826.          
  827.         if (dropwhat == 1 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM))
  828.         {
  829.             static wname[32]
  830.             get_weaponname(weaponid, wname, sizeof wname - 1)
  831.             engclient_cmd(id, "drop", wname)
  832.         }
  833.     }
  834. }
  835.  
  836. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  837. {
  838.     new_velocity[0] = origin2[0] - origin1[0]
  839.     new_velocity[1] = origin2[1] - origin1[1]
  840.     new_velocity[2] = origin2[2] - origin1[2]
  841.     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]))
  842.     new_velocity[0] *= num
  843.     new_velocity[1] *= num
  844.     new_velocity[2] *= num
  845.    
  846.     return 1;
  847. }
  848.  
  849. stock Get_MissileWeaponHitGroup( iEnt )
  850. {
  851.     new Float:flStart[ 3 ], Float:flEnd[ 3 ];
  852.    
  853.     pev( iEnt, pev_origin, flStart );
  854.     pev( iEnt, pev_velocity, flEnd );
  855.     xs_vec_add( flStart, flEnd, flEnd );
  856.    
  857.     new ptr = create_tr2();
  858.     engfunc( EngFunc_TraceLine, flStart, flEnd, 0, iEnt, ptr );
  859.    
  860.     new iHitGroup
  861.     iHitGroup = get_tr2( ptr, TR_iHitgroup )
  862.     free_tr2( ptr );
  863.    
  864.     return iHitGroup;
  865. }
  866.  
  867. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
  868. {
  869.     static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  870.    
  871.     pev(id, pev_origin, vOrigin)
  872.     pev(id, pev_view_ofs, vUp) //for player
  873.     xs_vec_add(vOrigin, vUp, vOrigin)
  874.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
  875.    
  876.     angle_vector(vAngle, ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
  877.     angle_vector(vAngle, ANGLEVECTOR_RIGHT, vRight)
  878.     angle_vector(vAngle, ANGLEVECTOR_UP, vUp)
  879.    
  880.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  881.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  882.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  883. }
  884.  
  885. stock set_weapons_timeidle(id, WeaponId ,Float:TimeIdle)
  886. {
  887.     if(!is_user_alive(id))
  888.         return
  889.        
  890.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
  891.     if(!pev_valid(entwpn))
  892.         return
  893.        
  894.     set_pdata_float(entwpn, 46, TimeIdle, OFFSET_LINUX_WEAPONS)
  895.     set_pdata_float(entwpn, 47, TimeIdle, OFFSET_LINUX_WEAPONS)
  896.     set_pdata_float(entwpn, 48, TimeIdle + 0.5, OFFSET_LINUX_WEAPONS)
  897. }
  898.  
  899. stock set_player_nextattackx(id, Float:nexttime)
  900. {
  901.     if(!is_user_alive(id))
  902.         return
  903.        
  904.     set_pdata_float(id, m_flNextAttack, nexttime, 5)
  905. }
  906. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  907. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  908. */

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1755
Joined: 2 Years Ago
Location: Egypt
Has thanked: 30 times
Been thanked: 87 times
Age: 21
Contact:

#2

Post by Raheem » 6 Months Ago

You should arrange includes, so change:
    1. #include <engine>
    2. #include <fakemeta_util>
    3. #include <cstrike>
    4. #include <fun>
    5. #include <zombie_escape>
    6. #include <ze_vip>
To:
    1. #include <zombie_escape>
    2. #include <engine>
    3. #include <fakemeta_util>
    4. #include <cstrike>
    5. #include <fun>
    6. #include <ze_vip>
amxmodx.inc should be first include i think, i'm not sure.
You don't know? Learn and you will know.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests