Page 1 of 1

Cyclone

Posted: 18 Jan 2018, 22:51
by Raheem
Cyclone

Description:
  • A new extra-item for Humans, It's Cyclone. Original plugin Here.
Installation & Instructions:
  • Simply install it like any plugin and Don't forget to copy Models, Sounds, Sprites.
Screenshots:
  • 1.png
    2.png
    3.png
    4.png
Downloads: Surely use the fixed one by Mark.

Re: Cyclone

Posted: 22 Jan 2018, 15:06
by Dark Shadow
bro its converted but its have a bug; gun is functioning like pistol not like rifle

Re: Cyclone

Posted: 23 Jan 2018, 23:45
by Raheem
Explain more, I don't understand you at all.

Re: Cyclone

Posted: 26 Jan 2018, 13:28
by Rain1153
He is saying that cyclone works semi automatic like pistols do one click= 1 shot not like the normal cyclone which is automatic! (We two tested it btw).So can you find out a solutions.It's a cool plugin when defending!

Re: Cyclone

Posted: 26 Jan 2018, 16:36
by Raheem
It's automatic so what's problem? Not like normal pistols..

Re: Cyclone

Posted: 27 Jan 2018, 20:25
by Dark Shadow
watch this video raheem bro so u can get what actually we want
https://www.youtube.com/watch?v=7oMF0X6c01I
cyclone have to work like this

Re: Cyclone

Posted: 31 Jan 2018, 18:32
by Dark Shadow
can u optimize cyclone ZE DEV Team?

Re: Cyclone

Posted: 31 Jan 2018, 20:02
by Raheem
No time to optimize, This weapon have something strange.. In my LAN server with bots it was working nice automatically, But in my online server it does not work...

Re: Cyclone

Posted: 31 Jan 2018, 20:20
by Dark Shadow
oh

Re: Cyclone

Posted: 05 Sep 2018, 04:06
by Mark
This needs set to a primary weapon right now its set to a secondary weapon does anyone know how todo this?

Re: Cyclone

Posted: 05 Sep 2018, 07:50
by Raheem
You will need to change weapon_p228 to your new weapon name. EX:

  1. #include <zombie_escape>
  2. #include <engine>
  3. #include <fakemeta_util>
  4. #include <xs>
  5. #include <cstrike>
  6. #include <fun>
  7.  
  8. #define WEAPON_BASE "weapon_ak47"
  9. #define ENG_NULLENT         -1
  10. #define EV_INT_WEAPONKEY    EV_INT_impulse
  11. #define sfpistol_WEAPONKEY  625
  12. #define MAX_PLAYERS         32
  13. #define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
  14.  
  15. const OFFSET_ACTIVE_ITEM = 373
  16. const OFFSET_WEAPONOWNER = 41
  17. const OFFSET_LINUX = 5
  18. const OFFSET_LINUX_WEAPONS = 4
  19.  
  20. #define WEAP_LINUX_XTRA_OFF     4
  21. #define m_fKnown                    44
  22. #define m_flNextPrimaryAttack       46
  23. #define m_flTimeWeaponIdle          48
  24. #define m_iClip                 51
  25. #define m_fInReload             54
  26. #define PLAYER_LINUX_XTRA_OFF   5
  27. #define m_flNextAttack              83
  28.  
  29. #define sfpistol_SHOOT1         1
  30. #define sfpistol_SHOOTEND       2
  31. #define sfpistol_RELOAD         3
  32. #define sfpistol_DRAW           4
  33. #define sfpistol_RELOAD_TIME 2.7
  34. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
  35.  
  36. new const Fire_Sounds[][] = { "weapons/sfpistol_shoot5.wav", "weapons/sfpistol_shoot5.wav" }
  37. new const MuzzleFlash[] = "sprites/muzzleflash27.spr"
  38. new sfpistol_V_MODEL[64] = "models/v_sfpistol.mdl"
  39. new sfpistol_P_MODEL[64] = "models/p_sfpistol.mdl"
  40. new sfpistol_W_MODEL[64] = "models/w_sfpistol.mdl"
  41.  
  42. const m_iShotsFired = 64
  43.  
  44. new cvar_dmg_sfpistol, cvar_clip_sfpistol, cvar_sfpistol_ammo
  45. new g_MaxPlayers, g_orig_event_sfpistol, g_IsInPrimaryAttack, g_iClip, g_smokepuff_id, g_MuzzleFlash_SprId
  46. new Float:cl_pushangle[MAX_PLAYERS + 1][3]
  47. new g_has_sfpistol[33], g_clip_ammo[33], oldweap[33],g_sfpistol_TmpClip[33], zz[33], udah[33]
  48. new gmsgWeaponList, setrum, item_cyclone
  49.  
  50. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
  51. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10", "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550", WEAPON_BASE, "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  52. "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  53. "weapon_ak47", "weapon_knife", "weapon_p90" }
  54.  
  55. public plugin_init()
  56. {
  57.     register_plugin("Cyclone", "1.0", "m4m3ts")
  58.     register_cvar("cyclone_version", "m4m3ts", FCVAR_SERVER|FCVAR_SPONLY)
  59.     register_event("CurWeapon","CurrentWeapon","be","1=1")
  60.     RegisterHam(Ham_Item_AddToPlayer, WEAPON_BASE, "fw_sfpistol_AddToPlayer")
  61.     for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
  62.     if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
  63.     RegisterHam(Ham_Item_PostFrame, WEAPON_BASE, "sfpistol_ItemPostFrame")
  64.     RegisterHam(Ham_Weapon_Reload, WEAPON_BASE, "sfpistol_Reload")
  65.     RegisterHam(Ham_Weapon_Reload, WEAPON_BASE, "sfpistol_Reload_Post", 1)
  66.     RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON_BASE, "fw_sfpistol_PrimaryAttack")
  67.     RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON_BASE, "fw_sfpistol_PrimaryAttack_Post", 1)
  68.     RegisterHam(Ham_Weapon_WeaponIdle, WEAPON_BASE, "fw_cycloneidleanim", 1)
  69.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  70.     RegisterHam(Ham_Spawn, "player", "Player_Spawn", 1)
  71.     register_forward(FM_SetModel, "fw_SetModel")
  72.     register_forward(FM_CmdStart, "fw_CmdStart")
  73.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  74.     register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
  75.    
  76.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
  77.     RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
  78.     RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
  79.     RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
  80.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
  81.     RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
  82.     RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
  83.    
  84.     item_cyclone = ze_register_item("Cyclone", 20, 0)
  85.    
  86.     new const weaponIdentifiers[][] =
  87.     {
  88.         WEAPON_BASE
  89.     }
  90.    
  91.     for( new i = 0; i < sizeof weaponIdentifiers; i++ )
  92.     {
  93.         RegisterHam( Ham_Weapon_PrimaryAttack, weaponIdentifiers[ i ], "Pistols_PrimaryAttack_Pre", false )
  94.     }
  95.  
  96.     cvar_dmg_sfpistol = register_cvar("ze_sfpistol_dmg", "1.0")
  97.     cvar_clip_sfpistol = register_cvar("ze_sfpistol_clip", "50")
  98.     cvar_sfpistol_ammo = register_cvar("ze_sfpistol_ammo", "200")
  99.        
  100.     g_MaxPlayers = get_maxplayers()
  101.     gmsgWeaponList = get_user_msgid("WeaponList")
  102. }
  103.  
  104. public plugin_precache()
  105. {
  106.     precache_model(sfpistol_V_MODEL)
  107.     precache_model(sfpistol_P_MODEL)
  108.     precache_model(sfpistol_W_MODEL)
  109.     for(new i = 0; i < sizeof Fire_Sounds; i++)
  110.     precache_sound(Fire_Sounds[i]) 
  111.     precache_sound("weapons/sfpistol_clipin.wav")
  112.     precache_sound("weapons/sfpistol_clipout.wav")
  113.     precache_sound("weapons/sfpistol_draw.wav")
  114.     precache_sound("weapons/sfpistol_idle.wav")
  115.     precache_sound("weapons/sfpistol_shoot_end.wav")
  116.     precache_generic("sprites/weapon_sfpistol.txt")
  117.     precache_generic("sprites/640hud104.spr")
  118.         precache_generic("sprites/640hud4.spr")
  119.     register_clcmd("weapon_sfpistol", "weapon_hook")
  120.     setrum = precache_model("sprites/laserbeam.spr")
  121.     g_smokepuff_id = engfunc(EngFunc_PrecacheModel, "sprites/ef_smoke_poison.spr")
  122.     g_MuzzleFlash_SprId = engfunc(EngFunc_PrecacheModel, MuzzleFlash)
  123.    
  124.     register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
  125. }
  126.  
  127. public weapon_hook(id)
  128. {
  129.     engclient_cmd(id, WEAPON_BASE)
  130.     return PLUGIN_HANDLED
  131. }
  132.  
  133. public client_putinserver(id)
  134. {  
  135.     new g_Ham_Bot
  136.  
  137.     if(!g_Ham_Bot && is_user_bot(id))
  138.     {
  139.         g_Ham_Bot = 1
  140.         set_task(0.1, "Do_RegisterHam_Bot", id)
  141.     }
  142. }
  143.  
  144. public Do_RegisterHam_Bot(id)
  145. {
  146.     RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage")
  147.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack", 1)
  148. }
  149.  
  150. public Player_Spawn(id)
  151. {
  152.     if (is_user_alive(id))
  153.     {
  154.         g_has_sfpistol[id] = false
  155.         zz[id] = 0
  156.         udah[id] = 0
  157.     }
  158. }
  159.  
  160. public fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  161. {
  162.     if(!is_user_alive(iAttacker))
  163.         return
  164.  
  165.     new g_currentweapon = get_user_weapon(iAttacker)
  166.  
  167.     if(g_currentweapon != CSW_P228) return
  168.    
  169.     if(!g_has_sfpistol[iAttacker]) return
  170.  
  171.     static Float:flEnd[3]
  172.     get_tr2(ptr, TR_vecEndPos, flEnd)
  173. }
  174.  
  175. public Pistols_PrimaryAttack_Pre(weapon)
  176. {
  177.     new Player = get_pdata_cbase(weapon, 41, 4)
  178.    
  179.     if (!g_has_sfpistol[Player])
  180.         return
  181.        
  182.     set_pdata_int( weapon, m_iShotsFired, -1 );
  183. }
  184.  
  185. public ze_user_humanized(id)
  186. {
  187.     g_has_sfpistol[id] = false
  188. }
  189.  
  190. public plugin_natives ()
  191. {
  192.     register_native("give_sfpistol", "native_give_sfpistol", 1)
  193. }
  194. public native_give_sfpistol(id)
  195. {
  196.     give_sfpistol(id)
  197. }
  198.  
  199. public ze_select_item_pre(id, itemid)
  200. {
  201.     // Return Available and we will block it in Post, So it dosen't affect other plugins
  202.     if (itemid != item_cyclone)
  203.         return ZE_ITEM_AVAILABLE
  204.    
  205.     // Available for Humans only, So don't show it for zombies
  206.     if (ze_is_user_zombie(id))
  207.         return ZE_ITEM_DONT_SHOW
  208.    
  209.     return ZE_ITEM_AVAILABLE
  210. }
  211.  
  212. public ze_select_item_post(player, itemid)
  213. {
  214.     if (itemid != item_cyclone)
  215.         return
  216.    
  217.     give_sfpistol(player)
  218. }
  219.  
  220. public fwPrecacheEvent_Post(type, const name[])
  221. {
  222.     if (equal("events/p228.sc", name))
  223.     {
  224.         g_orig_event_sfpistol = get_orig_retval()
  225.         return FMRES_HANDLED
  226.     }
  227.     return FMRES_IGNORED
  228. }
  229.  
  230. public client_connect(id)
  231. {
  232.     g_has_sfpistol[id] = false
  233. }
  234.  
  235. public client_disconnected(id)
  236. {
  237.     g_has_sfpistol[id] = false
  238. }
  239.  
  240. public ze_user_infected(id)
  241. {
  242.     g_has_sfpistol[id] = false
  243.     zz[id] = 0
  244.     udah[id] = 0
  245. }
  246.  
  247. public fw_SetModel(entity, model[])
  248. {
  249.     if(!is_valid_ent(entity))
  250.         return FMRES_IGNORED
  251.    
  252.     static szClassName[33]
  253.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  254.        
  255.     if(!equal(szClassName, "weaponbox"))
  256.         return FMRES_IGNORED
  257.    
  258.     static iOwner
  259.    
  260.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  261.    
  262.     if(equal(model, "models/w_p228.mdl"))
  263.     {
  264.         static iStoredAugID
  265.        
  266.         iStoredAugID = find_ent_by_owner(ENG_NULLENT, WEAPON_BASE, entity)
  267.    
  268.         if(!is_valid_ent(iStoredAugID))
  269.             return FMRES_IGNORED
  270.    
  271.         if(g_has_sfpistol[iOwner])
  272.         {
  273.             entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, sfpistol_WEAPONKEY)
  274.            
  275.             g_has_sfpistol[iOwner] = false
  276.            
  277.             entity_set_model(entity, sfpistol_W_MODEL)
  278.            
  279.             return FMRES_SUPERCEDE
  280.         }
  281.     }
  282.     return FMRES_IGNORED
  283. }
  284.  
  285. public give_sfpistol(id)
  286. {
  287.     drop_weapons(id, 2)
  288.     new iWep2 = fm_give_item(id,WEAPON_BASE)
  289.     if( iWep2 > 0 )
  290.     {
  291.         cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_sfpistol))
  292.         cs_set_user_bpammo (id, CSW_P228, get_pcvar_num(cvar_sfpistol_ammo))   
  293.        
  294.         set_weapons_timeidle(id, CSW_P228, 1.0)
  295.         set_player_nextattackx(id, 1.0)
  296.        
  297.         message_begin(MSG_ONE, gmsgWeaponList, _, id)
  298.         write_string("weapon_sfpistol")
  299.         write_byte(1)
  300.         write_byte(52)
  301.         write_byte(-1)
  302.         write_byte(-1)
  303.         write_byte(1)
  304.         write_byte(3)
  305.         write_byte(CSW_P228)
  306.         message_end()
  307.     }
  308.     g_has_sfpistol[id] = true
  309.     zz[id] = 0
  310.     udah[id] = 0
  311. }
  312.  
  313. public setrums(id)
  314. {
  315.     new Float:flAim[3]
  316.     fm_get_aim_origin(id, flAim)
  317.    
  318.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY )
  319.     write_byte(TE_BEAMENTPOINT)
  320.     write_short(id | 0x1000)
  321.     engfunc(EngFunc_WriteCoord, flAim[0])
  322.     engfunc(EngFunc_WriteCoord, flAim[1])
  323.     engfunc(EngFunc_WriteCoord, flAim[2])
  324.     write_short(setrum)
  325.     write_byte(0) // framerate
  326.     write_byte(0) // framerate
  327.     write_byte(1) // life
  328.     write_byte(12)  // width
  329.     write_byte(0)// noise
  330.     write_byte(120)// r, g, b
  331.     write_byte(238)// r, g, b
  332.     write_byte(3)// r, g, b
  333.     write_byte(255) // brightness
  334.     write_byte(255) // speed
  335.     message_end()
  336. }
  337.  
  338. public fw_CmdStart(id, uc_handle, seed)
  339. {
  340.     if(!is_user_alive(id) || !is_user_connected(id))
  341.         return
  342.     if(get_user_weapon(id) != CSW_P228 || !g_has_sfpistol[id])
  343.         return
  344.    
  345.     static ent; ent = fm_get_user_weapon_entity(id, CSW_P228)
  346.     if(!pev_valid(ent))
  347.         return
  348.     if(get_pdata_float(ent, 46, WEAP_LINUX_XTRA_OFF) > 0.0 || get_pdata_float(ent, 47, WEAP_LINUX_XTRA_OFF) > 0.0)
  349.         return
  350.        
  351.     if(!(pev(id, pev_oldbuttons) & IN_ATTACK))
  352.     {
  353.         if(zz[id] && g_clip_ammo[id])
  354.         {
  355.             zz[id] = 0
  356.             udah[id] = 0
  357.             emit_sound(id, CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  358.             UTIL_PlayWeaponAnimation(id, sfpistol_SHOOTEND)
  359.             set_weapons_timeidle(id, CSW_P228, 0.5)
  360.             set_player_nextattackx(id, 0.5)
  361.         }
  362.     }
  363. }
  364.  
  365. public fw_cycloneidleanim(Weapon)
  366. {
  367.     new id = get_pdata_cbase(Weapon, 41, 4)
  368.  
  369.     if(!is_user_alive(id) || ze_is_user_zombie(id) || !g_has_sfpistol[id] || get_user_weapon(id) != CSW_P228)
  370.         return HAM_IGNORED;
  371.  
  372.     if(get_pdata_float(Weapon, 48, 4) <= 0.25)
  373.     {
  374.         UTIL_PlayWeaponAnimation(id, 0)
  375.         set_pdata_float(Weapon, 48, 20.0, 4)
  376.         return HAM_SUPERCEDE;
  377.     }
  378.  
  379.     return HAM_IGNORED;
  380. }
  381.  
  382. public fw_sfpistol_AddToPlayer(sfpistol, id)
  383. {
  384.     if(!is_valid_ent(sfpistol) || !is_user_connected(id))
  385.         return HAM_IGNORED
  386.    
  387.     if(entity_get_int(sfpistol, EV_INT_WEAPONKEY) == sfpistol_WEAPONKEY)
  388.     {
  389.         g_has_sfpistol[id] = true
  390.        
  391.         entity_set_int(sfpistol, EV_INT_WEAPONKEY, 0)
  392.  
  393.         message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  394.         write_string("weapon_sfpistol")
  395.         write_byte(9)
  396.         write_byte(52)
  397.         write_byte(-1)
  398.         write_byte(-1)
  399.         write_byte(1)  
  400.         write_byte(3)
  401.         write_byte(CSW_P228)
  402.         message_end()
  403.        
  404.         return HAM_HANDLED
  405.     }
  406.     else
  407.     {
  408.         message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  409.         write_string(WEAPON_BASE)
  410.         write_byte(9)
  411.         write_byte(52)
  412.         write_byte(-1)
  413.         write_byte(-1)
  414.         write_byte(1)
  415.         write_byte(3)
  416.         write_byte(CSW_P228)
  417.         message_end()
  418.     }
  419.     return HAM_IGNORED
  420. }
  421.  
  422. public fw_Item_Deploy_Post(weapon_ent)
  423. {
  424.     static owner
  425.     owner = fm_cs_get_weapon_ent_owner(weapon_ent)
  426.    
  427.     static weaponid
  428.     weaponid = cs_get_weapon_id(weapon_ent)
  429.     replace_weapon_models(owner, weaponid)
  430.     zz[owner] = 0
  431.     udah[owner] = 0
  432. }
  433.  
  434. public CurrentWeapon(id)
  435. {
  436.      replace_weapon_models(id, read_data(2))
  437.      
  438.      if(read_data(2) != CSW_P228 || !g_has_sfpistol[id])
  439.           return
  440.      
  441.      static Float:iSpeed
  442.      if(g_has_sfpistol[id])
  443.           iSpeed = 0.075
  444.      
  445.      static weapon[32],Ent
  446.      get_weaponname(read_data(2),weapon,31)
  447.      Ent = find_ent_by_owner(-1,weapon,id)
  448.      if(Ent)
  449.      {
  450.           static Float:Delay
  451.           Delay = get_pdata_float( Ent, 46, 4) * iSpeed
  452.           if (Delay > 0.0)
  453.           {
  454.                set_pdata_float(Ent, 46, Delay, 4)
  455.           }
  456.      }
  457. }
  458.  
  459. replace_weapon_models(id, weaponid)
  460. {
  461.     switch (weaponid)
  462.     {
  463.         case CSW_P228:
  464.         {
  465.             if (ze_is_user_zombie(id))
  466.                 return
  467.            
  468.             if(g_has_sfpistol[id])
  469.             {
  470.                 set_pev(id, pev_viewmodel2, sfpistol_V_MODEL)
  471.                 set_pev(id, pev_weaponmodel2, sfpistol_P_MODEL)
  472.                 if(oldweap[id] != CSW_P228)
  473.                 {
  474.                     UTIL_PlayWeaponAnimation(id, sfpistol_DRAW)
  475.                     set_weapons_timeidle(id, CSW_P228, 1.0)
  476.                     set_player_nextattackx(id, 1.0)
  477.                     message_begin(MSG_ONE, gmsgWeaponList, _, id)
  478.                     write_string("weapon_sfpistol")
  479.                     write_byte(9)
  480.                     write_byte(52)
  481.                     write_byte(-1)
  482.                     write_byte(-1)
  483.                     write_byte(1)
  484.                     write_byte(3)
  485.                     write_byte(CSW_P228)
  486.                     message_end()
  487.                 }
  488.             }
  489.         }
  490.     }
  491.     oldweap[id] = weaponid
  492. }
  493.  
  494. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  495. {
  496.     if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_P228 || !g_has_sfpistol[Player]))
  497.         return FMRES_IGNORED
  498.    
  499.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  500.     return FMRES_HANDLED
  501. }
  502.  
  503. public fw_sfpistol_PrimaryAttack(Weapon)
  504. {
  505.     new Player = get_pdata_cbase(Weapon, 41, 4)
  506.    
  507.     if (!g_has_sfpistol[Player])
  508.         return
  509.    
  510.     g_IsInPrimaryAttack = 1
  511.     pev(Player,pev_punchangle,cl_pushangle[Player])
  512.    
  513.     g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
  514.     g_iClip = cs_get_weapon_ammo(Weapon)
  515. }
  516.  
  517. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  518. {
  519.     if ((eventid != g_orig_event_sfpistol) || !g_IsInPrimaryAttack)
  520.         return FMRES_IGNORED
  521.     if (!(1 <= invoker <= g_MaxPlayers))
  522.     return FMRES_IGNORED
  523.  
  524.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  525.     return FMRES_SUPERCEDE
  526. }
  527.  
  528. public fw_sfpistol_PrimaryAttack_Post(Weapon)
  529. {
  530.     g_IsInPrimaryAttack = 0
  531.     new Player = get_pdata_cbase(Weapon, 41, 4)
  532.    
  533.     new szClip, szAmmo
  534.     get_user_weapon(Player, szClip, szAmmo)
  535.    
  536.     if(!is_user_alive(Player))
  537.         return
  538.  
  539.     if (g_iClip <= cs_get_weapon_ammo(Weapon))
  540.         return
  541.  
  542.     if(g_has_sfpistol[Player])
  543.     {
  544.         if (!g_clip_ammo[Player])
  545.             return
  546.  
  547.         new Float:push[3]
  548.         pev(Player,pev_punchangle,push)
  549.         xs_vec_sub(push,cl_pushangle[Player],push)
  550.        
  551.         xs_vec_mul_scalar(push,0.0,push)
  552.         xs_vec_add(push,cl_pushangle[Player],push)
  553.         set_pev(Player,pev_punchangle,push)
  554.         set_weapons_timeidle(Player, CSW_P228, 0.075)
  555.         set_player_nextattackx(Player, 0.075)
  556.         UTIL_PlayWeaponAnimation(Player, sfpistol_SHOOT1)
  557.         Make_Muzzleflash(Player)
  558.         entity_set_int(Player, EV_INT_sequence, 19)
  559.         zz[Player] = 1
  560.         fake_smoke(Player)
  561.         setrums(Player)
  562.        
  563.         if(!udah[Player])
  564.         {
  565.             emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
  566.             udah[Player] = 1
  567.         }
  568.     }
  569. }
  570.  
  571. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
  572. {
  573.     if (victim != attacker && is_user_connected(attacker))
  574.     {
  575.         if(get_user_weapon(attacker) == CSW_P228)
  576.         {
  577.             if(g_has_sfpistol[attacker])
  578.                 SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_sfpistol))
  579.         }
  580.     }
  581. }
  582.  
  583. stock fm_cs_get_current_weapon_ent(id)
  584. {
  585.     return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
  586. }
  587.  
  588. stock fm_cs_get_weapon_ent_owner(ent)
  589. {
  590.     return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
  591. }
  592.  
  593. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
  594. {
  595.     set_pev(Player, pev_weaponanim, Sequence)
  596.    
  597.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  598.     write_byte(Sequence)
  599.     write_byte(pev(Player, pev_body))
  600.     message_end()
  601. }
  602.  
  603. public sfpistol_ItemPostFrame(weapon_entity)
  604. {
  605.      new id = pev(weapon_entity, pev_owner)
  606.      if (!is_user_connected(id))
  607.           return HAM_IGNORED
  608.  
  609.      if (!g_has_sfpistol[id])
  610.           return HAM_IGNORED
  611.  
  612.      static iClipExtra
  613.      
  614.      iClipExtra = get_pcvar_num(cvar_clip_sfpistol)
  615.      new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)
  616.  
  617.      new iBpAmmo = cs_get_user_bpammo(id, CSW_P228);
  618.      new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  619.  
  620.      new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF)
  621.      if( fInReload && flNextAttack <= 0.0 )
  622.      {
  623.          new j = min(iClipExtra - iClip, iBpAmmo)
  624.    
  625.          set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
  626.          cs_set_user_bpammo(id, CSW_P228, iBpAmmo-j)
  627.        
  628.          set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
  629.          fInReload = 0
  630.      }
  631.      return HAM_IGNORED
  632. }
  633.  
  634. public sfpistol_Reload(weapon_entity)
  635. {
  636.      new id = pev(weapon_entity, pev_owner)
  637.      if (!is_user_connected(id))
  638.           return HAM_IGNORED
  639.  
  640.      if (!g_has_sfpistol[id])
  641.           return HAM_IGNORED
  642.  
  643.      static iClipExtra
  644.  
  645.      if(g_has_sfpistol[id])
  646.           iClipExtra = get_pcvar_num(cvar_clip_sfpistol)
  647.  
  648.      g_sfpistol_TmpClip[id] = -1
  649.  
  650.      new iBpAmmo = cs_get_user_bpammo(id, CSW_P228)
  651.      new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  652.  
  653.      if (iBpAmmo <= 0)
  654.           return HAM_SUPERCEDE
  655.  
  656.      if (iClip >= iClipExtra)
  657.           return HAM_SUPERCEDE
  658.  
  659.      g_sfpistol_TmpClip[id] = iClip
  660.  
  661.      return HAM_IGNORED
  662. }
  663.  
  664. public Make_Muzzleflash(id)
  665. {
  666.     static Float:Origin[3], TE_FLAG
  667.     get_position(id, 32.0, 0.0, -18.0, Origin)
  668.    
  669.     TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  670.     TE_FLAG |= TE_EXPLFLAG_NOSOUND
  671.     TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  672.    
  673.     engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, Origin, id)
  674.     write_byte(TE_EXPLOSION)
  675.     engfunc(EngFunc_WriteCoord, Origin[0])
  676.     engfunc(EngFunc_WriteCoord, Origin[1])
  677.     engfunc(EngFunc_WriteCoord, Origin[2])
  678.     write_short(g_MuzzleFlash_SprId)
  679.     write_byte(2)
  680.     write_byte(30)
  681.     write_byte(TE_FLAG)
  682.     message_end()
  683. }
  684.  
  685. public sfpistol_Reload_Post(weapon_entity)
  686. {
  687.     new id = pev(weapon_entity, pev_owner)
  688.     if (!is_user_connected(id))
  689.         return HAM_IGNORED
  690.  
  691.     if (!g_has_sfpistol[id])
  692.         return HAM_IGNORED
  693.  
  694.     if (g_sfpistol_TmpClip[id] == -1)
  695.         return HAM_IGNORED
  696.  
  697.     set_pdata_int(weapon_entity, m_iClip, g_sfpistol_TmpClip[id], WEAP_LINUX_XTRA_OFF)
  698.  
  699.     set_weapons_timeidle(id, CSW_P228, sfpistol_RELOAD_TIME)
  700.     set_player_nextattackx(id, sfpistol_RELOAD_TIME)
  701.     zz[id] = 0
  702.     udah[id] = 0
  703.     set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)
  704.  
  705.     UTIL_PlayWeaponAnimation(id, sfpistol_RELOAD)
  706.  
  707.     return HAM_IGNORED
  708. }
  709.  
  710. stock set_player_nextattackx(id, Float:nexttime)
  711. {
  712.     if(!is_user_alive(id))
  713.         return
  714.        
  715.     set_pdata_float(id, m_flNextAttack, nexttime, 5)
  716. }
  717.  
  718. stock set_weapons_timeidle(id, WeaponId ,Float:TimeIdle)
  719. {
  720.     if(!is_user_alive(id))
  721.         return
  722.        
  723.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
  724.     if(!pev_valid(entwpn))
  725.         return
  726.        
  727.     set_pdata_float(entwpn, 46, TimeIdle, WEAP_LINUX_XTRA_OFF)
  728.     set_pdata_float(entwpn, 47, TimeIdle, WEAP_LINUX_XTRA_OFF)
  729.     set_pdata_float(entwpn, 48, TimeIdle + 0.5, WEAP_LINUX_XTRA_OFF)
  730. }
  731.  
  732. stock fake_smoke(id)
  733. {
  734.     static Float:vecEnd[3], TE_FLAG
  735.    
  736.     fm_get_aim_origin(id, vecEnd)
  737.    
  738.     TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  739.     TE_FLAG |= TE_EXPLFLAG_NOSOUND
  740.     TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  741.    
  742.     engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0)
  743.     write_byte(TE_EXPLOSION)
  744.     engfunc(EngFunc_WriteCoord, vecEnd[0])
  745.     engfunc(EngFunc_WriteCoord, vecEnd[1])
  746.     engfunc(EngFunc_WriteCoord, vecEnd[2]-5)
  747.     write_short(g_smokepuff_id)
  748.     write_byte(2)
  749.     write_byte(50)
  750.     write_byte(TE_FLAG)
  751.     message_end()
  752. }
  753.  
  754. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
  755. {
  756.     static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  757.    
  758.     pev(id, pev_origin, vOrigin)
  759.     pev(id, pev_view_ofs, vUp) //for player
  760.     xs_vec_add(vOrigin, vUp, vOrigin)
  761.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
  762.    
  763.     angle_vector(vAngle, ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
  764.     angle_vector(vAngle, ANGLEVECTOR_RIGHT, vRight)
  765.     angle_vector(vAngle, ANGLEVECTOR_UP, vUp)
  766.    
  767.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  768.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  769.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  770. }
  771.  
  772. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
  773. {
  774.     new Float:vfEnd[3], viEnd[3]
  775.     get_user_origin(id, viEnd, 3)  
  776.     IVecFVec(viEnd, vfEnd)
  777.    
  778.     new Float:fOrigin[3], Float:fAngle[3]
  779.    
  780.     pev(id, pev_origin, fOrigin)
  781.     pev(id, pev_view_ofs, fAngle)
  782.    
  783.     xs_vec_add(fOrigin, fAngle, fOrigin)
  784.    
  785.     new Float:fAttack[3]
  786.    
  787.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  788.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  789.    
  790.     new Float:fRate
  791.    
  792.     fRate = fDis / vector_length(fAttack)
  793.     xs_vec_mul_scalar(fAttack, fRate, fAttack)
  794.    
  795.     xs_vec_add(fOrigin, fAttack, output)
  796. }
  797.  
  798. stock drop_weapons(id, dropwhat)
  799. {
  800.      static weapons[32], num, i, weaponid
  801.      num = 0
  802.      get_user_weapons(id, weapons, num)
  803.      
  804.      for (i = 0; i < num; i++)
  805.      {
  806.           weaponid = weapons[i]
  807.          
  808.           if (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM))
  809.           {
  810.                static wname[32]
  811.                get_weaponname(weaponid, wname, sizeof wname - 1)
  812.                engclient_cmd(id, "drop", wname)
  813.           }
  814.      }
  815. }

Change now from: #define WEAPON_BASE "weapon_ak47"

Re: Cyclone

Posted: 05 Sep 2018, 23:42
by Mark
Raheem wrote: 5 years ago You will need to change weapon_p228 to your new weapon name. EX:

  1. #include <zombie_escape>
  2. #include <engine>
  3. #include <fakemeta_util>
  4. #include <xs>
  5. #include <cstrike>
  6. #include <fun>
  7.  
  8. #define WEAPON_BASE "weapon_ak47"
  9. #define ENG_NULLENT         -1
  10. #define EV_INT_WEAPONKEY    EV_INT_impulse
  11. #define sfpistol_WEAPONKEY  625
  12. #define MAX_PLAYERS         32
  13. #define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
  14.  
  15. const OFFSET_ACTIVE_ITEM = 373
  16. const OFFSET_WEAPONOWNER = 41
  17. const OFFSET_LINUX = 5
  18. const OFFSET_LINUX_WEAPONS = 4
  19.  
  20. #define WEAP_LINUX_XTRA_OFF     4
  21. #define m_fKnown                    44
  22. #define m_flNextPrimaryAttack       46
  23. #define m_flTimeWeaponIdle          48
  24. #define m_iClip                 51
  25. #define m_fInReload             54
  26. #define PLAYER_LINUX_XTRA_OFF   5
  27. #define m_flNextAttack              83
  28.  
  29. #define sfpistol_SHOOT1         1
  30. #define sfpistol_SHOOTEND       2
  31. #define sfpistol_RELOAD         3
  32. #define sfpistol_DRAW           4
  33. #define sfpistol_RELOAD_TIME 2.7
  34. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
  35.  
  36. new const Fire_Sounds[][] = { "weapons/sfpistol_shoot5.wav", "weapons/sfpistol_shoot5.wav" }
  37. new const MuzzleFlash[] = "sprites/muzzleflash27.spr"
  38. new sfpistol_V_MODEL[64] = "models/v_sfpistol.mdl"
  39. new sfpistol_P_MODEL[64] = "models/p_sfpistol.mdl"
  40. new sfpistol_W_MODEL[64] = "models/w_sfpistol.mdl"
  41.  
  42. const m_iShotsFired = 64
  43.  
  44. new cvar_dmg_sfpistol, cvar_clip_sfpistol, cvar_sfpistol_ammo
  45. new g_MaxPlayers, g_orig_event_sfpistol, g_IsInPrimaryAttack, g_iClip, g_smokepuff_id, g_MuzzleFlash_SprId
  46. new Float:cl_pushangle[MAX_PLAYERS + 1][3]
  47. new g_has_sfpistol[33], g_clip_ammo[33], oldweap[33],g_sfpistol_TmpClip[33], zz[33], udah[33]
  48. new gmsgWeaponList, setrum, item_cyclone
  49.  
  50. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
  51. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10", "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550", WEAPON_BASE, "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  52. "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  53. "weapon_ak47", "weapon_knife", "weapon_p90" }
  54.  
  55. public plugin_init()
  56. {
  57.     register_plugin("Cyclone", "1.0", "m4m3ts")
  58.     register_cvar("cyclone_version", "m4m3ts", FCVAR_SERVER|FCVAR_SPONLY)
  59.     register_event("CurWeapon","CurrentWeapon","be","1=1")
  60.     RegisterHam(Ham_Item_AddToPlayer, WEAPON_BASE, "fw_sfpistol_AddToPlayer")
  61.     for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
  62.     if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
  63.     RegisterHam(Ham_Item_PostFrame, WEAPON_BASE, "sfpistol_ItemPostFrame")
  64.     RegisterHam(Ham_Weapon_Reload, WEAPON_BASE, "sfpistol_Reload")
  65.     RegisterHam(Ham_Weapon_Reload, WEAPON_BASE, "sfpistol_Reload_Post", 1)
  66.     RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON_BASE, "fw_sfpistol_PrimaryAttack")
  67.     RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON_BASE, "fw_sfpistol_PrimaryAttack_Post", 1)
  68.     RegisterHam(Ham_Weapon_WeaponIdle, WEAPON_BASE, "fw_cycloneidleanim", 1)
  69.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  70.     RegisterHam(Ham_Spawn, "player", "Player_Spawn", 1)
  71.     register_forward(FM_SetModel, "fw_SetModel")
  72.     register_forward(FM_CmdStart, "fw_CmdStart")
  73.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  74.     register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
  75.    
  76.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
  77.     RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
  78.     RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
  79.     RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
  80.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
  81.     RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
  82.     RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
  83.    
  84.     item_cyclone = ze_register_item("Cyclone", 20, 0)
  85.    
  86.     new const weaponIdentifiers[][] =
  87.     {
  88.         WEAPON_BASE
  89.     }
  90.    
  91.     for( new i = 0; i < sizeof weaponIdentifiers; i++ )
  92.     {
  93.         RegisterHam( Ham_Weapon_PrimaryAttack, weaponIdentifiers[ i ], "Pistols_PrimaryAttack_Pre", false )
  94.     }
  95.  
  96.     cvar_dmg_sfpistol = register_cvar("ze_sfpistol_dmg", "1.0")
  97.     cvar_clip_sfpistol = register_cvar("ze_sfpistol_clip", "50")
  98.     cvar_sfpistol_ammo = register_cvar("ze_sfpistol_ammo", "200")
  99.        
  100.     g_MaxPlayers = get_maxplayers()
  101.     gmsgWeaponList = get_user_msgid("WeaponList")
  102. }
  103.  
  104. public plugin_precache()
  105. {
  106.     precache_model(sfpistol_V_MODEL)
  107.     precache_model(sfpistol_P_MODEL)
  108.     precache_model(sfpistol_W_MODEL)
  109.     for(new i = 0; i < sizeof Fire_Sounds; i++)
  110.     precache_sound(Fire_Sounds[i]) 
  111.     precache_sound("weapons/sfpistol_clipin.wav")
  112.     precache_sound("weapons/sfpistol_clipout.wav")
  113.     precache_sound("weapons/sfpistol_draw.wav")
  114.     precache_sound("weapons/sfpistol_idle.wav")
  115.     precache_sound("weapons/sfpistol_shoot_end.wav")
  116.     precache_generic("sprites/weapon_sfpistol.txt")
  117.     precache_generic("sprites/640hud104.spr")
  118.         precache_generic("sprites/640hud4.spr")
  119.     register_clcmd("weapon_sfpistol", "weapon_hook")
  120.     setrum = precache_model("sprites/laserbeam.spr")
  121.     g_smokepuff_id = engfunc(EngFunc_PrecacheModel, "sprites/ef_smoke_poison.spr")
  122.     g_MuzzleFlash_SprId = engfunc(EngFunc_PrecacheModel, MuzzleFlash)
  123.    
  124.     register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
  125. }
  126.  
  127. public weapon_hook(id)
  128. {
  129.     engclient_cmd(id, WEAPON_BASE)
  130.     return PLUGIN_HANDLED
  131. }
  132.  
  133. public client_putinserver(id)
  134. {  
  135.     new g_Ham_Bot
  136.  
  137.     if(!g_Ham_Bot && is_user_bot(id))
  138.     {
  139.         g_Ham_Bot = 1
  140.         set_task(0.1, "Do_RegisterHam_Bot", id)
  141.     }
  142. }
  143.  
  144. public Do_RegisterHam_Bot(id)
  145. {
  146.     RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage")
  147.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack", 1)
  148. }
  149.  
  150. public Player_Spawn(id)
  151. {
  152.     if (is_user_alive(id))
  153.     {
  154.         g_has_sfpistol[id] = false
  155.         zz[id] = 0
  156.         udah[id] = 0
  157.     }
  158. }
  159.  
  160. public fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  161. {
  162.     if(!is_user_alive(iAttacker))
  163.         return
  164.  
  165.     new g_currentweapon = get_user_weapon(iAttacker)
  166.  
  167.     if(g_currentweapon != CSW_P228) return
  168.    
  169.     if(!g_has_sfpistol[iAttacker]) return
  170.  
  171.     static Float:flEnd[3]
  172.     get_tr2(ptr, TR_vecEndPos, flEnd)
  173. }
  174.  
  175. public Pistols_PrimaryAttack_Pre(weapon)
  176. {
  177.     new Player = get_pdata_cbase(weapon, 41, 4)
  178.    
  179.     if (!g_has_sfpistol[Player])
  180.         return
  181.        
  182.     set_pdata_int( weapon, m_iShotsFired, -1 );
  183. }
  184.  
  185. public ze_user_humanized(id)
  186. {
  187.     g_has_sfpistol[id] = false
  188. }
  189.  
  190. public plugin_natives ()
  191. {
  192.     register_native("give_sfpistol", "native_give_sfpistol", 1)
  193. }
  194. public native_give_sfpistol(id)
  195. {
  196.     give_sfpistol(id)
  197. }
  198.  
  199. public ze_select_item_pre(id, itemid)
  200. {
  201.     // Return Available and we will block it in Post, So it dosen't affect other plugins
  202.     if (itemid != item_cyclone)
  203.         return ZE_ITEM_AVAILABLE
  204.    
  205.     // Available for Humans only, So don't show it for zombies
  206.     if (ze_is_user_zombie(id))
  207.         return ZE_ITEM_DONT_SHOW
  208.    
  209.     return ZE_ITEM_AVAILABLE
  210. }
  211.  
  212. public ze_select_item_post(player, itemid)
  213. {
  214.     if (itemid != item_cyclone)
  215.         return
  216.    
  217.     give_sfpistol(player)
  218. }
  219.  
  220. public fwPrecacheEvent_Post(type, const name[])
  221. {
  222.     if (equal("events/p228.sc", name))
  223.     {
  224.         g_orig_event_sfpistol = get_orig_retval()
  225.         return FMRES_HANDLED
  226.     }
  227.     return FMRES_IGNORED
  228. }
  229.  
  230. public client_connect(id)
  231. {
  232.     g_has_sfpistol[id] = false
  233. }
  234.  
  235. public client_disconnected(id)
  236. {
  237.     g_has_sfpistol[id] = false
  238. }
  239.  
  240. public ze_user_infected(id)
  241. {
  242.     g_has_sfpistol[id] = false
  243.     zz[id] = 0
  244.     udah[id] = 0
  245. }
  246.  
  247. public fw_SetModel(entity, model[])
  248. {
  249.     if(!is_valid_ent(entity))
  250.         return FMRES_IGNORED
  251.    
  252.     static szClassName[33]
  253.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  254.        
  255.     if(!equal(szClassName, "weaponbox"))
  256.         return FMRES_IGNORED
  257.    
  258.     static iOwner
  259.    
  260.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  261.    
  262.     if(equal(model, "models/w_p228.mdl"))
  263.     {
  264.         static iStoredAugID
  265.        
  266.         iStoredAugID = find_ent_by_owner(ENG_NULLENT, WEAPON_BASE, entity)
  267.    
  268.         if(!is_valid_ent(iStoredAugID))
  269.             return FMRES_IGNORED
  270.    
  271.         if(g_has_sfpistol[iOwner])
  272.         {
  273.             entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, sfpistol_WEAPONKEY)
  274.            
  275.             g_has_sfpistol[iOwner] = false
  276.            
  277.             entity_set_model(entity, sfpistol_W_MODEL)
  278.            
  279.             return FMRES_SUPERCEDE
  280.         }
  281.     }
  282.     return FMRES_IGNORED
  283. }
  284.  
  285. public give_sfpistol(id)
  286. {
  287.     drop_weapons(id, 2)
  288.     new iWep2 = fm_give_item(id,WEAPON_BASE)
  289.     if( iWep2 > 0 )
  290.     {
  291.         cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_sfpistol))
  292.         cs_set_user_bpammo (id, CSW_P228, get_pcvar_num(cvar_sfpistol_ammo))   
  293.        
  294.         set_weapons_timeidle(id, CSW_P228, 1.0)
  295.         set_player_nextattackx(id, 1.0)
  296.        
  297.         message_begin(MSG_ONE, gmsgWeaponList, _, id)
  298.         write_string("weapon_sfpistol")
  299.         write_byte(1)
  300.         write_byte(52)
  301.         write_byte(-1)
  302.         write_byte(-1)
  303.         write_byte(1)
  304.         write_byte(3)
  305.         write_byte(CSW_P228)
  306.         message_end()
  307.     }
  308.     g_has_sfpistol[id] = true
  309.     zz[id] = 0
  310.     udah[id] = 0
  311. }
  312.  
  313. public setrums(id)
  314. {
  315.     new Float:flAim[3]
  316.     fm_get_aim_origin(id, flAim)
  317.    
  318.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY )
  319.     write_byte(TE_BEAMENTPOINT)
  320.     write_short(id | 0x1000)
  321.     engfunc(EngFunc_WriteCoord, flAim[0])
  322.     engfunc(EngFunc_WriteCoord, flAim[1])
  323.     engfunc(EngFunc_WriteCoord, flAim[2])
  324.     write_short(setrum)
  325.     write_byte(0) // framerate
  326.     write_byte(0) // framerate
  327.     write_byte(1) // life
  328.     write_byte(12)  // width
  329.     write_byte(0)// noise
  330.     write_byte(120)// r, g, b
  331.     write_byte(238)// r, g, b
  332.     write_byte(3)// r, g, b
  333.     write_byte(255) // brightness
  334.     write_byte(255) // speed
  335.     message_end()
  336. }
  337.  
  338. public fw_CmdStart(id, uc_handle, seed)
  339. {
  340.     if(!is_user_alive(id) || !is_user_connected(id))
  341.         return
  342.     if(get_user_weapon(id) != CSW_P228 || !g_has_sfpistol[id])
  343.         return
  344.    
  345.     static ent; ent = fm_get_user_weapon_entity(id, CSW_P228)
  346.     if(!pev_valid(ent))
  347.         return
  348.     if(get_pdata_float(ent, 46, WEAP_LINUX_XTRA_OFF) > 0.0 || get_pdata_float(ent, 47, WEAP_LINUX_XTRA_OFF) > 0.0)
  349.         return
  350.        
  351.     if(!(pev(id, pev_oldbuttons) & IN_ATTACK))
  352.     {
  353.         if(zz[id] && g_clip_ammo[id])
  354.         {
  355.             zz[id] = 0
  356.             udah[id] = 0
  357.             emit_sound(id, CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  358.             UTIL_PlayWeaponAnimation(id, sfpistol_SHOOTEND)
  359.             set_weapons_timeidle(id, CSW_P228, 0.5)
  360.             set_player_nextattackx(id, 0.5)
  361.         }
  362.     }
  363. }
  364.  
  365. public fw_cycloneidleanim(Weapon)
  366. {
  367.     new id = get_pdata_cbase(Weapon, 41, 4)
  368.  
  369.     if(!is_user_alive(id) || ze_is_user_zombie(id) || !g_has_sfpistol[id] || get_user_weapon(id) != CSW_P228)
  370.         return HAM_IGNORED;
  371.  
  372.     if(get_pdata_float(Weapon, 48, 4) <= 0.25)
  373.     {
  374.         UTIL_PlayWeaponAnimation(id, 0)
  375.         set_pdata_float(Weapon, 48, 20.0, 4)
  376.         return HAM_SUPERCEDE;
  377.     }
  378.  
  379.     return HAM_IGNORED;
  380. }
  381.  
  382. public fw_sfpistol_AddToPlayer(sfpistol, id)
  383. {
  384.     if(!is_valid_ent(sfpistol) || !is_user_connected(id))
  385.         return HAM_IGNORED
  386.    
  387.     if(entity_get_int(sfpistol, EV_INT_WEAPONKEY) == sfpistol_WEAPONKEY)
  388.     {
  389.         g_has_sfpistol[id] = true
  390.        
  391.         entity_set_int(sfpistol, EV_INT_WEAPONKEY, 0)
  392.  
  393.         message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  394.         write_string("weapon_sfpistol")
  395.         write_byte(9)
  396.         write_byte(52)
  397.         write_byte(-1)
  398.         write_byte(-1)
  399.         write_byte(1)  
  400.         write_byte(3)
  401.         write_byte(CSW_P228)
  402.         message_end()
  403.        
  404.         return HAM_HANDLED
  405.     }
  406.     else
  407.     {
  408.         message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  409.         write_string(WEAPON_BASE)
  410.         write_byte(9)
  411.         write_byte(52)
  412.         write_byte(-1)
  413.         write_byte(-1)
  414.         write_byte(1)
  415.         write_byte(3)
  416.         write_byte(CSW_P228)
  417.         message_end()
  418.     }
  419.     return HAM_IGNORED
  420. }
  421.  
  422. public fw_Item_Deploy_Post(weapon_ent)
  423. {
  424.     static owner
  425.     owner = fm_cs_get_weapon_ent_owner(weapon_ent)
  426.    
  427.     static weaponid
  428.     weaponid = cs_get_weapon_id(weapon_ent)
  429.     replace_weapon_models(owner, weaponid)
  430.     zz[owner] = 0
  431.     udah[owner] = 0
  432. }
  433.  
  434. public CurrentWeapon(id)
  435. {
  436.      replace_weapon_models(id, read_data(2))
  437.      
  438.      if(read_data(2) != CSW_P228 || !g_has_sfpistol[id])
  439.           return
  440.      
  441.      static Float:iSpeed
  442.      if(g_has_sfpistol[id])
  443.           iSpeed = 0.075
  444.      
  445.      static weapon[32],Ent
  446.      get_weaponname(read_data(2),weapon,31)
  447.      Ent = find_ent_by_owner(-1,weapon,id)
  448.      if(Ent)
  449.      {
  450.           static Float:Delay
  451.           Delay = get_pdata_float( Ent, 46, 4) * iSpeed
  452.           if (Delay > 0.0)
  453.           {
  454.                set_pdata_float(Ent, 46, Delay, 4)
  455.           }
  456.      }
  457. }
  458.  
  459. replace_weapon_models(id, weaponid)
  460. {
  461.     switch (weaponid)
  462.     {
  463.         case CSW_P228:
  464.         {
  465.             if (ze_is_user_zombie(id))
  466.                 return
  467.            
  468.             if(g_has_sfpistol[id])
  469.             {
  470.                 set_pev(id, pev_viewmodel2, sfpistol_V_MODEL)
  471.                 set_pev(id, pev_weaponmodel2, sfpistol_P_MODEL)
  472.                 if(oldweap[id] != CSW_P228)
  473.                 {
  474.                     UTIL_PlayWeaponAnimation(id, sfpistol_DRAW)
  475.                     set_weapons_timeidle(id, CSW_P228, 1.0)
  476.                     set_player_nextattackx(id, 1.0)
  477.                     message_begin(MSG_ONE, gmsgWeaponList, _, id)
  478.                     write_string("weapon_sfpistol")
  479.                     write_byte(9)
  480.                     write_byte(52)
  481.                     write_byte(-1)
  482.                     write_byte(-1)
  483.                     write_byte(1)
  484.                     write_byte(3)
  485.                     write_byte(CSW_P228)
  486.                     message_end()
  487.                 }
  488.             }
  489.         }
  490.     }
  491.     oldweap[id] = weaponid
  492. }
  493.  
  494. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  495. {
  496.     if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_P228 || !g_has_sfpistol[Player]))
  497.         return FMRES_IGNORED
  498.    
  499.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  500.     return FMRES_HANDLED
  501. }
  502.  
  503. public fw_sfpistol_PrimaryAttack(Weapon)
  504. {
  505.     new Player = get_pdata_cbase(Weapon, 41, 4)
  506.    
  507.     if (!g_has_sfpistol[Player])
  508.         return
  509.    
  510.     g_IsInPrimaryAttack = 1
  511.     pev(Player,pev_punchangle,cl_pushangle[Player])
  512.    
  513.     g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
  514.     g_iClip = cs_get_weapon_ammo(Weapon)
  515. }
  516.  
  517. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  518. {
  519.     if ((eventid != g_orig_event_sfpistol) || !g_IsInPrimaryAttack)
  520.         return FMRES_IGNORED
  521.     if (!(1 <= invoker <= g_MaxPlayers))
  522.     return FMRES_IGNORED
  523.  
  524.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  525.     return FMRES_SUPERCEDE
  526. }
  527.  
  528. public fw_sfpistol_PrimaryAttack_Post(Weapon)
  529. {
  530.     g_IsInPrimaryAttack = 0
  531.     new Player = get_pdata_cbase(Weapon, 41, 4)
  532.    
  533.     new szClip, szAmmo
  534.     get_user_weapon(Player, szClip, szAmmo)
  535.    
  536.     if(!is_user_alive(Player))
  537.         return
  538.  
  539.     if (g_iClip <= cs_get_weapon_ammo(Weapon))
  540.         return
  541.  
  542.     if(g_has_sfpistol[Player])
  543.     {
  544.         if (!g_clip_ammo[Player])
  545.             return
  546.  
  547.         new Float:push[3]
  548.         pev(Player,pev_punchangle,push)
  549.         xs_vec_sub(push,cl_pushangle[Player],push)
  550.        
  551.         xs_vec_mul_scalar(push,0.0,push)
  552.         xs_vec_add(push,cl_pushangle[Player],push)
  553.         set_pev(Player,pev_punchangle,push)
  554.         set_weapons_timeidle(Player, CSW_P228, 0.075)
  555.         set_player_nextattackx(Player, 0.075)
  556.         UTIL_PlayWeaponAnimation(Player, sfpistol_SHOOT1)
  557.         Make_Muzzleflash(Player)
  558.         entity_set_int(Player, EV_INT_sequence, 19)
  559.         zz[Player] = 1
  560.         fake_smoke(Player)
  561.         setrums(Player)
  562.        
  563.         if(!udah[Player])
  564.         {
  565.             emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
  566.             udah[Player] = 1
  567.         }
  568.     }
  569. }
  570.  
  571. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
  572. {
  573.     if (victim != attacker && is_user_connected(attacker))
  574.     {
  575.         if(get_user_weapon(attacker) == CSW_P228)
  576.         {
  577.             if(g_has_sfpistol[attacker])
  578.                 SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_sfpistol))
  579.         }
  580.     }
  581. }
  582.  
  583. stock fm_cs_get_current_weapon_ent(id)
  584. {
  585.     return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
  586. }
  587.  
  588. stock fm_cs_get_weapon_ent_owner(ent)
  589. {
  590.     return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
  591. }
  592.  
  593. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
  594. {
  595.     set_pev(Player, pev_weaponanim, Sequence)
  596.    
  597.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  598.     write_byte(Sequence)
  599.     write_byte(pev(Player, pev_body))
  600.     message_end()
  601. }
  602.  
  603. public sfpistol_ItemPostFrame(weapon_entity)
  604. {
  605.      new id = pev(weapon_entity, pev_owner)
  606.      if (!is_user_connected(id))
  607.           return HAM_IGNORED
  608.  
  609.      if (!g_has_sfpistol[id])
  610.           return HAM_IGNORED
  611.  
  612.      static iClipExtra
  613.      
  614.      iClipExtra = get_pcvar_num(cvar_clip_sfpistol)
  615.      new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)
  616.  
  617.      new iBpAmmo = cs_get_user_bpammo(id, CSW_P228);
  618.      new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  619.  
  620.      new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF)
  621.      if( fInReload && flNextAttack <= 0.0 )
  622.      {
  623.          new j = min(iClipExtra - iClip, iBpAmmo)
  624.    
  625.          set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
  626.          cs_set_user_bpammo(id, CSW_P228, iBpAmmo-j)
  627.        
  628.          set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
  629.          fInReload = 0
  630.      }
  631.      return HAM_IGNORED
  632. }
  633.  
  634. public sfpistol_Reload(weapon_entity)
  635. {
  636.      new id = pev(weapon_entity, pev_owner)
  637.      if (!is_user_connected(id))
  638.           return HAM_IGNORED
  639.  
  640.      if (!g_has_sfpistol[id])
  641.           return HAM_IGNORED
  642.  
  643.      static iClipExtra
  644.  
  645.      if(g_has_sfpistol[id])
  646.           iClipExtra = get_pcvar_num(cvar_clip_sfpistol)
  647.  
  648.      g_sfpistol_TmpClip[id] = -1
  649.  
  650.      new iBpAmmo = cs_get_user_bpammo(id, CSW_P228)
  651.      new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  652.  
  653.      if (iBpAmmo <= 0)
  654.           return HAM_SUPERCEDE
  655.  
  656.      if (iClip >= iClipExtra)
  657.           return HAM_SUPERCEDE
  658.  
  659.      g_sfpistol_TmpClip[id] = iClip
  660.  
  661.      return HAM_IGNORED
  662. }
  663.  
  664. public Make_Muzzleflash(id)
  665. {
  666.     static Float:Origin[3], TE_FLAG
  667.     get_position(id, 32.0, 0.0, -18.0, Origin)
  668.    
  669.     TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  670.     TE_FLAG |= TE_EXPLFLAG_NOSOUND
  671.     TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  672.    
  673.     engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, Origin, id)
  674.     write_byte(TE_EXPLOSION)
  675.     engfunc(EngFunc_WriteCoord, Origin[0])
  676.     engfunc(EngFunc_WriteCoord, Origin[1])
  677.     engfunc(EngFunc_WriteCoord, Origin[2])
  678.     write_short(g_MuzzleFlash_SprId)
  679.     write_byte(2)
  680.     write_byte(30)
  681.     write_byte(TE_FLAG)
  682.     message_end()
  683. }
  684.  
  685. public sfpistol_Reload_Post(weapon_entity)
  686. {
  687.     new id = pev(weapon_entity, pev_owner)
  688.     if (!is_user_connected(id))
  689.         return HAM_IGNORED
  690.  
  691.     if (!g_has_sfpistol[id])
  692.         return HAM_IGNORED
  693.  
  694.     if (g_sfpistol_TmpClip[id] == -1)
  695.         return HAM_IGNORED
  696.  
  697.     set_pdata_int(weapon_entity, m_iClip, g_sfpistol_TmpClip[id], WEAP_LINUX_XTRA_OFF)
  698.  
  699.     set_weapons_timeidle(id, CSW_P228, sfpistol_RELOAD_TIME)
  700.     set_player_nextattackx(id, sfpistol_RELOAD_TIME)
  701.     zz[id] = 0
  702.     udah[id] = 0
  703.     set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)
  704.  
  705.     UTIL_PlayWeaponAnimation(id, sfpistol_RELOAD)
  706.  
  707.     return HAM_IGNORED
  708. }
  709.  
  710. stock set_player_nextattackx(id, Float:nexttime)
  711. {
  712.     if(!is_user_alive(id))
  713.         return
  714.        
  715.     set_pdata_float(id, m_flNextAttack, nexttime, 5)
  716. }
  717.  
  718. stock set_weapons_timeidle(id, WeaponId ,Float:TimeIdle)
  719. {
  720.     if(!is_user_alive(id))
  721.         return
  722.        
  723.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
  724.     if(!pev_valid(entwpn))
  725.         return
  726.        
  727.     set_pdata_float(entwpn, 46, TimeIdle, WEAP_LINUX_XTRA_OFF)
  728.     set_pdata_float(entwpn, 47, TimeIdle, WEAP_LINUX_XTRA_OFF)
  729.     set_pdata_float(entwpn, 48, TimeIdle + 0.5, WEAP_LINUX_XTRA_OFF)
  730. }
  731.  
  732. stock fake_smoke(id)
  733. {
  734.     static Float:vecEnd[3], TE_FLAG
  735.    
  736.     fm_get_aim_origin(id, vecEnd)
  737.    
  738.     TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  739.     TE_FLAG |= TE_EXPLFLAG_NOSOUND
  740.     TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  741.    
  742.     engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0)
  743.     write_byte(TE_EXPLOSION)
  744.     engfunc(EngFunc_WriteCoord, vecEnd[0])
  745.     engfunc(EngFunc_WriteCoord, vecEnd[1])
  746.     engfunc(EngFunc_WriteCoord, vecEnd[2]-5)
  747.     write_short(g_smokepuff_id)
  748.     write_byte(2)
  749.     write_byte(50)
  750.     write_byte(TE_FLAG)
  751.     message_end()
  752. }
  753.  
  754. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
  755. {
  756.     static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  757.    
  758.     pev(id, pev_origin, vOrigin)
  759.     pev(id, pev_view_ofs, vUp) //for player
  760.     xs_vec_add(vOrigin, vUp, vOrigin)
  761.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
  762.    
  763.     angle_vector(vAngle, ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
  764.     angle_vector(vAngle, ANGLEVECTOR_RIGHT, vRight)
  765.     angle_vector(vAngle, ANGLEVECTOR_UP, vUp)
  766.    
  767.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  768.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  769.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  770. }
  771.  
  772. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
  773. {
  774.     new Float:vfEnd[3], viEnd[3]
  775.     get_user_origin(id, viEnd, 3)  
  776.     IVecFVec(viEnd, vfEnd)
  777.    
  778.     new Float:fOrigin[3], Float:fAngle[3]
  779.    
  780.     pev(id, pev_origin, fOrigin)
  781.     pev(id, pev_view_ofs, fAngle)
  782.    
  783.     xs_vec_add(fOrigin, fAngle, fOrigin)
  784.    
  785.     new Float:fAttack[3]
  786.    
  787.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  788.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  789.    
  790.     new Float:fRate
  791.    
  792.     fRate = fDis / vector_length(fAttack)
  793.     xs_vec_mul_scalar(fAttack, fRate, fAttack)
  794.    
  795.     xs_vec_add(fOrigin, fAttack, output)
  796. }
  797.  
  798. stock drop_weapons(id, dropwhat)
  799. {
  800.      static weapons[32], num, i, weaponid
  801.      num = 0
  802.      get_user_weapons(id, weapons, num)
  803.      
  804.      for (i = 0; i < num; i++)
  805.      {
  806.           weaponid = weapons[i]
  807.          
  808.           if (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM))
  809.           {
  810.                static wname[32]
  811.                get_weaponname(weaponid, wname, sizeof wname - 1)
  812.                engclient_cmd(id, "drop", wname)
  813.           }
  814.      }
  815. }

Change now from: #define WEAPON_BASE "weapon_ak47"
Now it seems to work how it should but can't see the BPAMMO
  1. #include <zombie_escape>
  2. #include <engine>
  3. #include <fakemeta_util>
  4. #include <xs>
  5. #include <cstrike>
  6. #include <fun>
  7.  
  8. #define WEAPON_BASE "weapon_galil"
  9. #define ENG_NULLENT         -1
  10. #define EV_INT_WEAPONKEY    EV_INT_impulse
  11. #define sfpistol_WEAPONKEY  625
  12. #define MAX_PLAYERS         32
  13. #define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
  14.  
  15. const OFFSET_ACTIVE_ITEM = 373
  16. const OFFSET_WEAPONOWNER = 41
  17. const OFFSET_LINUX = 5
  18. const OFFSET_LINUX_WEAPONS = 4
  19.  
  20. #define WEAP_LINUX_XTRA_OFF     4
  21. #define m_fKnown                    44
  22. #define m_flNextPrimaryAttack       46
  23. #define m_flTimeWeaponIdle          48
  24. #define m_iClip                 51
  25. #define m_fInReload             54
  26. #define PLAYER_LINUX_XTRA_OFF   5
  27. #define m_flNextAttack              83
  28.  
  29. #define sfpistol_SHOOT1         1
  30. #define sfpistol_SHOOTEND       2
  31. #define sfpistol_RELOAD         3
  32. #define sfpistol_DRAW           4
  33. #define sfpistol_RELOAD_TIME 2.7
  34. #define write_coord_f(%1)   engfunc(EngFunc_WriteCoord,%1)
  35.  
  36. new const Fire_Sounds[][] = { "weapons/sfpistol_shoot5.wav", "weapons/sfpistol_shoot5.wav" }
  37. new const MuzzleFlash[] = "sprites/muzzleflash27.spr"
  38. new sfpistol_V_MODEL[64] = "models/v_sfpistol.mdl"
  39. new sfpistol_P_MODEL[64] = "models/p_sfpistol.mdl"
  40. new sfpistol_W_MODEL[64] = "models/w_sfpistol.mdl"
  41.  
  42. const m_iShotsFired = 64
  43.  
  44. new cvar_dmg_sfpistol, cvar_clip_sfpistol, cvar_sfpistol_ammo
  45. new g_MaxPlayers, g_orig_event_sfpistol, g_IsInPrimaryAttack, g_iClip, g_smokepuff_id, g_MuzzleFlash_SprId
  46. new Float:cl_pushangle[MAX_PLAYERS + 1][3]
  47. new g_has_sfpistol[33], g_clip_ammo[33], oldweap[33],g_sfpistol_TmpClip[33], zz[33], udah[33]
  48. new gmsgWeaponList, setrum, item_cyclone
  49.  
  50. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_GALI)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
  51. new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10", "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550", WEAPON_BASE, "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  52. "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  53. "weapon_ak47", "weapon_knife", "weapon_p90" }
  54.  
  55. public plugin_init()
  56. {
  57.     register_plugin("Cyclone", "1.0", "m4m3ts")
  58.     register_cvar("cyclone_version", "m4m3ts", FCVAR_SERVER|FCVAR_SPONLY)
  59.     register_event("CurWeapon","CurrentWeapon","be","1=1")
  60.     RegisterHam(Ham_Item_AddToPlayer, WEAPON_BASE, "fw_sfpistol_AddToPlayer")
  61.     for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
  62.     if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
  63.     RegisterHam(Ham_Item_PostFrame, WEAPON_BASE, "sfpistol_ItemPostFrame")
  64.     RegisterHam(Ham_Weapon_Reload, WEAPON_BASE, "sfpistol_Reload")
  65.     RegisterHam(Ham_Weapon_Reload, WEAPON_BASE, "sfpistol_Reload_Post", 1)
  66.     RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON_BASE, "fw_sfpistol_PrimaryAttack")
  67.     RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON_BASE, "fw_sfpistol_PrimaryAttack_Post", 1)
  68.     RegisterHam(Ham_Weapon_WeaponIdle, WEAPON_BASE, "fw_cycloneidleanim", 1)
  69.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  70.     RegisterHam(Ham_Spawn, "player", "Player_Spawn", 1)
  71.     register_forward(FM_SetModel, "fw_SetModel")
  72.     register_forward(FM_CmdStart, "fw_CmdStart")
  73.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  74.     register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
  75.    
  76.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
  77.     RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
  78.     RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
  79.     RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
  80.     RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
  81.     RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
  82.     RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
  83.    
  84.     item_cyclone = ze_register_item("Cyclone", 20, 0)
  85.    
  86.     new const weaponIdentifiers[][] =
  87.     {
  88.         WEAPON_BASE
  89.     }
  90.    
  91.     for( new i = 0; i < sizeof weaponIdentifiers; i++ )
  92.     {
  93.         RegisterHam( Ham_Weapon_PrimaryAttack, weaponIdentifiers[ i ], "Pistols_PrimaryAttack_Pre", false )
  94.     }
  95.  
  96.     cvar_dmg_sfpistol = register_cvar("ze_sfpistol_dmg", "1.0")
  97.     cvar_clip_sfpistol = register_cvar("ze_sfpistol_clip", "50")
  98.     cvar_sfpistol_ammo = register_cvar("ze_sfpistol_ammo", "200")
  99.        
  100.     g_MaxPlayers = get_maxplayers()
  101.     gmsgWeaponList = get_user_msgid("WeaponList")
  102. }
  103.  
  104. public plugin_precache()
  105. {
  106.     precache_model(sfpistol_V_MODEL)
  107.     precache_model(sfpistol_P_MODEL)
  108.     precache_model(sfpistol_W_MODEL)
  109.     for(new i = 0; i < sizeof Fire_Sounds; i++)
  110.     precache_sound(Fire_Sounds[i])
  111.     precache_sound("weapons/sfpistol_clipin.wav")
  112.     precache_sound("weapons/sfpistol_clipout.wav")
  113.     precache_sound("weapons/sfpistol_draw.wav")
  114.     precache_sound("weapons/sfpistol_idle.wav")
  115.     precache_sound("weapons/sfpistol_shoot_end.wav")
  116.     precache_generic("sprites/weapon_sfpistol.txt")
  117.     precache_generic("sprites/640hud104.spr")
  118.         precache_generic("sprites/640hud4.spr")
  119.     register_clcmd("weapon_sfpistol", "weapon_hook")
  120.     setrum = precache_model("sprites/laserbeam.spr")
  121.     g_smokepuff_id = engfunc(EngFunc_PrecacheModel, "sprites/ef_smoke_poison.spr")
  122.     g_MuzzleFlash_SprId = engfunc(EngFunc_PrecacheModel, MuzzleFlash)
  123.    
  124.     register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
  125. }
  126.  
  127. public weapon_hook(id)
  128. {
  129.     engclient_cmd(id, WEAPON_BASE)
  130.     return PLUGIN_HANDLED
  131. }
  132.  
  133. public client_putinserver(id)
  134. {  
  135.     new g_Ham_Bot
  136.  
  137.     if(!g_Ham_Bot && is_user_bot(id))
  138.     {
  139.         g_Ham_Bot = 1
  140.         set_task(0.1, "Do_RegisterHam_Bot", id)
  141.     }
  142. }
  143.  
  144. public Do_RegisterHam_Bot(id)
  145. {
  146.     RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage")
  147.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack", 1)
  148. }
  149.  
  150. public Player_Spawn(id)
  151. {
  152.     if (is_user_alive(id))
  153.     {
  154.         g_has_sfpistol[id] = false
  155.         zz[id] = 0
  156.         udah[id] = 0
  157.     }
  158. }
  159.  
  160. public fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  161. {
  162.     if(!is_user_alive(iAttacker))
  163.         return
  164.  
  165.     new g_currentweapon = get_user_weapon(iAttacker)
  166.  
  167.     if(g_currentweapon != CSW_GALI) return
  168.    
  169.     if(!g_has_sfpistol[iAttacker]) return
  170.  
  171.     static Float:flEnd[3]
  172.     get_tr2(ptr, TR_vecEndPos, flEnd)
  173. }
  174.  
  175. public Pistols_PrimaryAttack_Pre(weapon)
  176. {
  177.     new Player = get_pdata_cbase(weapon, 41, 4)
  178.    
  179.     if (!g_has_sfpistol[Player])
  180.         return
  181.        
  182.     set_pdata_int( weapon, m_iShotsFired, -1 );
  183. }
  184.  
  185. public ze_user_humanized(id)
  186. {
  187.     g_has_sfpistol[id] = false
  188. }
  189.  
  190. public plugin_natives ()
  191. {
  192.     register_native("give_sfpistol", "native_give_sfpistol", 1)
  193. }
  194. public native_give_sfpistol(id)
  195. {
  196.     give_sfpistol(id)
  197. }
  198.  
  199. public ze_select_item_pre(id, itemid)
  200. {
  201.     // Return Available and we will block it in Post, So it dosen't affect other plugins
  202.     if (itemid != item_cyclone)
  203.         return ZE_ITEM_AVAILABLE
  204.    
  205.     // Available for Humans only, So don't show it for zombies
  206.     if (ze_is_user_zombie(id))
  207.         return ZE_ITEM_DONT_SHOW
  208.    
  209.     return ZE_ITEM_AVAILABLE
  210. }
  211.  
  212. public ze_select_item_post(player, itemid)
  213. {
  214.     if (itemid != item_cyclone)
  215.         return
  216.    
  217.     give_sfpistol(player)
  218. }
  219.  
  220. public fwPrecacheEvent_Post(type, const name[])
  221. {
  222.     if (equal("events/gali.sc", name))
  223.     {
  224.         g_orig_event_sfpistol = get_orig_retval()
  225.         return FMRES_HANDLED
  226.     }
  227.     return FMRES_IGNORED
  228. }
  229.  
  230. public client_connect(id)
  231. {
  232.     g_has_sfpistol[id] = false
  233. }
  234.  
  235. public client_disconnected(id)
  236. {
  237.     g_has_sfpistol[id] = false
  238. }
  239.  
  240. public ze_user_infected(id)
  241. {
  242.     g_has_sfpistol[id] = false
  243.     zz[id] = 0
  244.     udah[id] = 0
  245. }
  246.  
  247. public fw_SetModel(entity, model[])
  248. {
  249.     if(!is_valid_ent(entity))
  250.         return FMRES_IGNORED
  251.    
  252.     static szClassName[33]
  253.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  254.        
  255.     if(!equal(szClassName, "weaponbox"))
  256.         return FMRES_IGNORED
  257.    
  258.     static iOwner
  259.    
  260.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  261.    
  262.     if(equal(model, "models/w_gali.mdl"))
  263.     {
  264.         static iStoredAugID
  265.        
  266.         iStoredAugID = find_ent_by_owner(ENG_NULLENT, WEAPON_BASE, entity)
  267.    
  268.         if(!is_valid_ent(iStoredAugID))
  269.             return FMRES_IGNORED
  270.    
  271.         if(g_has_sfpistol[iOwner])
  272.         {
  273.             entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, sfpistol_WEAPONKEY)
  274.            
  275.             g_has_sfpistol[iOwner] = false
  276.            
  277.             entity_set_model(entity, sfpistol_W_MODEL)
  278.            
  279.             return FMRES_SUPERCEDE
  280.         }
  281.     }
  282.     return FMRES_IGNORED
  283. }
  284.  
  285. public give_sfpistol(id)
  286. {
  287.     drop_weapons(id, 2)
  288.     new iWep2 = fm_give_item(id,WEAPON_BASE)
  289.     if( iWep2 > 0 )
  290.     {
  291.         cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_sfpistol))
  292.         cs_set_user_bpammo (id, CSW_GALI, get_pcvar_num(cvar_sfpistol_ammo))  
  293.        
  294.         set_weapons_timeidle(id, CSW_GALI, 1.0)
  295.         set_player_nextattackx(id, 1.0)
  296.        
  297.         message_begin(MSG_ONE, gmsgWeaponList, _, id)
  298.         write_string("weapon_sfpistol")
  299.         write_byte(1)
  300.         write_byte(52)
  301.         write_byte(-1)
  302.         write_byte(-1)
  303.         write_byte(1)
  304.         write_byte(3)
  305.         write_byte(CSW_GALI)
  306.         message_end()
  307.     }
  308.     g_has_sfpistol[id] = true
  309.     zz[id] = 0
  310.     udah[id] = 0
  311. }
  312.  
  313. public setrums(id)
  314. {
  315.     new Float:flAim[3]
  316.     fm_get_aim_origin(id, flAim)
  317.    
  318.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY )
  319.     write_byte(TE_BEAMENTPOINT)
  320.     write_short(id | 0x1000)
  321.     engfunc(EngFunc_WriteCoord, flAim[0])
  322.     engfunc(EngFunc_WriteCoord, flAim[1])
  323.     engfunc(EngFunc_WriteCoord, flAim[2])
  324.     write_short(setrum)
  325.     write_byte(0) // framerate
  326.     write_byte(0) // framerate
  327.     write_byte(1) // life
  328.     write_byte(12)  // width
  329.     write_byte(0)// noise
  330.     write_byte(120)// r, g, b
  331.     write_byte(238)// r, g, b
  332.     write_byte(3)// r, g, b
  333.     write_byte(255) // brightness
  334.     write_byte(255) // speed
  335.     message_end()
  336. }
  337.  
  338. public fw_CmdStart(id, uc_handle, seed)
  339. {
  340.     if(!is_user_alive(id) || !is_user_connected(id))
  341.         return
  342.     if(get_user_weapon(id) != CSW_GALI || !g_has_sfpistol[id])
  343.         return
  344.    
  345.     static ent; ent = fm_get_user_weapon_entity(id, CSW_GALI)
  346.     if(!pev_valid(ent))
  347.         return
  348.     if(get_pdata_float(ent, 46, WEAP_LINUX_XTRA_OFF) > 0.0 || get_pdata_float(ent, 47, WEAP_LINUX_XTRA_OFF) > 0.0)
  349.         return
  350.        
  351.     if(!(pev(id, pev_oldbuttons) & IN_ATTACK))
  352.     {
  353.         if(zz[id] && g_clip_ammo[id])
  354.         {
  355.             zz[id] = 0
  356.             udah[id] = 0
  357.             emit_sound(id, CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  358.             UTIL_PlayWeaponAnimation(id, sfpistol_SHOOTEND)
  359.             set_weapons_timeidle(id, CSW_GALI, 0.5)
  360.             set_player_nextattackx(id, 0.5)
  361.         }
  362.     }
  363. }
  364.  
  365. public fw_cycloneidleanim(Weapon)
  366. {
  367.     new id = get_pdata_cbase(Weapon, 41, 4)
  368.  
  369.     if(!is_user_alive(id) || ze_is_user_zombie(id) || !g_has_sfpistol[id] || get_user_weapon(id) != CSW_GALI)
  370.         return HAM_IGNORED;
  371.  
  372.     if(get_pdata_float(Weapon, 48, 4) <= 0.25)
  373.     {
  374.         UTIL_PlayWeaponAnimation(id, 0)
  375.         set_pdata_float(Weapon, 48, 20.0, 4)
  376.         return HAM_SUPERCEDE;
  377.     }
  378.  
  379.     return HAM_IGNORED;
  380. }
  381.  
  382. public fw_sfpistol_AddToPlayer(sfpistol, id)
  383. {
  384.     if(!is_valid_ent(sfpistol) || !is_user_connected(id))
  385.         return HAM_IGNORED
  386.    
  387.     if(entity_get_int(sfpistol, EV_INT_WEAPONKEY) == sfpistol_WEAPONKEY)
  388.     {
  389.         g_has_sfpistol[id] = true
  390.        
  391.         entity_set_int(sfpistol, EV_INT_WEAPONKEY, 0)
  392.  
  393.         message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  394.         write_string("weapon_sfpistol")
  395.         write_byte(9)
  396.         write_byte(52)
  397.         write_byte(-1)
  398.         write_byte(-1)
  399.         write_byte(1)  
  400.         write_byte(3)
  401.         write_byte(CSW_GALI)
  402.         message_end()
  403.        
  404.         return HAM_HANDLED
  405.     }
  406.     else
  407.     {
  408.         message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
  409.         write_string(WEAPON_BASE)
  410.         write_byte(9)
  411.         write_byte(52)
  412.         write_byte(-1)
  413.         write_byte(-1)
  414.         write_byte(1)
  415.         write_byte(3)
  416.         write_byte(CSW_GALI)
  417.         message_end()
  418.     }
  419.     return HAM_IGNORED
  420. }
  421.  
  422. public fw_Item_Deploy_Post(weapon_ent)
  423. {
  424.     static owner
  425.     owner = fm_cs_get_weapon_ent_owner(weapon_ent)
  426.    
  427.     static weaponid
  428.     weaponid = cs_get_weapon_id(weapon_ent)
  429.     replace_weapon_models(owner, weaponid)
  430.     zz[owner] = 0
  431.     udah[owner] = 0
  432. }
  433.  
  434. public CurrentWeapon(id)
  435. {
  436.      replace_weapon_models(id, read_data(2))
  437.      
  438.      if(read_data(2) != CSW_GALI || !g_has_sfpistol[id])
  439.           return
  440.      
  441.      static Float:iSpeed
  442.      if(g_has_sfpistol[id])
  443.           iSpeed = 0.075
  444.      
  445.      static weapon[32],Ent
  446.      get_weaponname(read_data(2),weapon,31)
  447.      Ent = find_ent_by_owner(-1,weapon,id)
  448.      if(Ent)
  449.      {
  450.           static Float:Delay
  451.           Delay = get_pdata_float( Ent, 46, 4) * iSpeed
  452.           if (Delay > 0.0)
  453.           {
  454.                set_pdata_float(Ent, 46, Delay, 4)
  455.           }
  456.      }
  457. }
  458.  
  459. replace_weapon_models(id, weaponid)
  460. {
  461.     switch (weaponid)
  462.     {
  463.         case CSW_GALI:
  464.         {
  465.             if (ze_is_user_zombie(id))
  466.                 return
  467.            
  468.             if(g_has_sfpistol[id])
  469.             {
  470.                 set_pev(id, pev_viewmodel2, sfpistol_V_MODEL)
  471.                 set_pev(id, pev_weaponmodel2, sfpistol_P_MODEL)
  472.                 if(oldweap[id] != CSW_GALI)
  473.                 {
  474.                     UTIL_PlayWeaponAnimation(id, sfpistol_DRAW)
  475.                     set_weapons_timeidle(id, CSW_GALI, 1.0)
  476.                     set_player_nextattackx(id, 1.0)
  477.                     message_begin(MSG_ONE, gmsgWeaponList, _, id)
  478.                     write_string("weapon_sfpistol")
  479.                     write_byte(9)
  480.                     write_byte(52)
  481.                     write_byte(-1)
  482.                     write_byte(-1)
  483.                     write_byte(1)
  484.                     write_byte(3)
  485.                     write_byte(CSW_GALI)
  486.                     message_end()
  487.                 }
  488.             }
  489.         }
  490.     }
  491.     oldweap[id] = weaponid
  492. }
  493.  
  494. public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  495. {
  496.     if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_GALI || !g_has_sfpistol[Player]))
  497.         return FMRES_IGNORED
  498.    
  499.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  500.     return FMRES_HANDLED
  501. }
  502.  
  503. public fw_sfpistol_PrimaryAttack(Weapon)
  504. {
  505.     new Player = get_pdata_cbase(Weapon, 41, 4)
  506.    
  507.     if (!g_has_sfpistol[Player])
  508.         return
  509.    
  510.     g_IsInPrimaryAttack = 1
  511.     pev(Player,pev_punchangle,cl_pushangle[Player])
  512.    
  513.     g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
  514.     g_iClip = cs_get_weapon_ammo(Weapon)
  515. }
  516.  
  517. public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  518. {
  519.     if ((eventid != g_orig_event_sfpistol) || !g_IsInPrimaryAttack)
  520.         return FMRES_IGNORED
  521.     if (!(1 <= invoker <= g_MaxPlayers))
  522.     return FMRES_IGNORED
  523.  
  524.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  525.     return FMRES_SUPERCEDE
  526. }
  527.  
  528. public fw_sfpistol_PrimaryAttack_Post(Weapon)
  529. {
  530.     g_IsInPrimaryAttack = 0
  531.     new Player = get_pdata_cbase(Weapon, 41, 4)
  532.    
  533.     new szClip, szAmmo
  534.     get_user_weapon(Player, szClip, szAmmo)
  535.    
  536.     if(!is_user_alive(Player))
  537.         return
  538.  
  539.     if (g_iClip <= cs_get_weapon_ammo(Weapon))
  540.         return
  541.  
  542.     if(g_has_sfpistol[Player])
  543.     {
  544.         if (!g_clip_ammo[Player])
  545.             return
  546.  
  547.         new Float:push[3]
  548.         pev(Player,pev_punchangle,push)
  549.         xs_vec_sub(push,cl_pushangle[Player],push)
  550.        
  551.         xs_vec_mul_scalar(push,0.0,push)
  552.         xs_vec_add(push,cl_pushangle[Player],push)
  553.         set_pev(Player,pev_punchangle,push)
  554.         set_weapons_timeidle(Player, CSW_GALI, 0.075)
  555.         set_player_nextattackx(Player, 0.075)
  556.         UTIL_PlayWeaponAnimation(Player, sfpistol_SHOOT1)
  557.         Make_Muzzleflash(Player)
  558.         entity_set_int(Player, EV_INT_sequence, 19)
  559.         zz[Player] = 1
  560.         fake_smoke(Player)
  561.         setrums(Player)
  562.        
  563.         if(!udah[Player])
  564.         {
  565.             emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
  566.             udah[Player] = 1
  567.         }
  568.     }
  569. }
  570.  
  571. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
  572. {
  573.     if (victim != attacker && is_user_connected(attacker))
  574.     {
  575.         if(get_user_weapon(attacker) == CSW_GALI)
  576.         {
  577.             if(g_has_sfpistol[attacker])
  578.                 SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_sfpistol))
  579.         }
  580.     }
  581. }
  582.  
  583. stock fm_cs_get_current_weapon_ent(id)
  584. {
  585.     return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
  586. }
  587.  
  588. stock fm_cs_get_weapon_ent_owner(ent)
  589. {
  590.     return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
  591. }
  592.  
  593. stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
  594. {
  595.     set_pev(Player, pev_weaponanim, Sequence)
  596.    
  597.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  598.     write_byte(Sequence)
  599.     write_byte(pev(Player, pev_body))
  600.     message_end()
  601. }
  602.  
  603. public sfpistol_ItemPostFrame(weapon_entity)
  604. {
  605.      new id = pev(weapon_entity, pev_owner)
  606.      if (!is_user_connected(id))
  607.           return HAM_IGNORED
  608.  
  609.      if (!g_has_sfpistol[id])
  610.           return HAM_IGNORED
  611.  
  612.      static iClipExtra
  613.      
  614.      iClipExtra = get_pcvar_num(cvar_clip_sfpistol)
  615.      new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)
  616.  
  617.      new iBpAmmo = cs_get_user_bpammo(id, CSW_GALI);
  618.      new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  619.  
  620.      new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF)
  621.      if( fInReload && flNextAttack <= 0.0 )
  622.      {
  623.          new j = min(iClipExtra - iClip, iBpAmmo)
  624.    
  625.          set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
  626.          cs_set_user_bpammo(id, CSW_GALI, iBpAmmo - j)
  627.        
  628.          set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
  629.          fInReload = 0
  630.      }
  631.      return HAM_IGNORED
  632. }
  633.  
  634. public sfpistol_Reload(weapon_entity)
  635. {
  636.      new id = pev(weapon_entity, pev_owner)
  637.      if (!is_user_connected(id))
  638.           return HAM_IGNORED
  639.  
  640.      if (!g_has_sfpistol[id])
  641.           return HAM_IGNORED
  642.  
  643.      static iClipExtra
  644.  
  645.      if(g_has_sfpistol[id])
  646.           iClipExtra = get_pcvar_num(cvar_clip_sfpistol)
  647.  
  648.      g_sfpistol_TmpClip[id] = -1
  649.  
  650.      new iBpAmmo = cs_get_user_bpammo(id, CSW_GALI)
  651.      new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
  652.  
  653.      if (iBpAmmo <= 0)
  654.           return HAM_SUPERCEDE
  655.  
  656.      if (iClip >= iClipExtra)
  657.           return HAM_SUPERCEDE
  658.  
  659.      g_sfpistol_TmpClip[id] = iClip
  660.  
  661.      return HAM_IGNORED
  662. }
  663.  
  664. public Make_Muzzleflash(id)
  665. {
  666.     static Float:Origin[3], TE_FLAG
  667.     get_position(id, 32.0, 0.0, -18.0, Origin)
  668.    
  669.     TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  670.     TE_FLAG |= TE_EXPLFLAG_NOSOUND
  671.     TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  672.    
  673.     engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, Origin, id)
  674.     write_byte(TE_EXPLOSION)
  675.     engfunc(EngFunc_WriteCoord, Origin[0])
  676.     engfunc(EngFunc_WriteCoord, Origin[1])
  677.     engfunc(EngFunc_WriteCoord, Origin[2])
  678.     write_short(g_MuzzleFlash_SprId)
  679.     write_byte(2)
  680.     write_byte(30)
  681.     write_byte(TE_FLAG)
  682.     message_end()
  683. }
  684.  
  685. public sfpistol_Reload_Post(weapon_entity)
  686. {
  687.     new id = pev(weapon_entity, pev_owner)
  688.     if (!is_user_connected(id))
  689.         return HAM_IGNORED
  690.  
  691.     if (!g_has_sfpistol[id])
  692.         return HAM_IGNORED
  693.  
  694.     if (g_sfpistol_TmpClip[id] == -1)
  695.         return HAM_IGNORED
  696.  
  697.     set_pdata_int(weapon_entity, m_iClip, g_sfpistol_TmpClip[id], WEAP_LINUX_XTRA_OFF)
  698.  
  699.     set_weapons_timeidle(id, CSW_GALI, sfpistol_RELOAD_TIME)
  700.     set_player_nextattackx(id, sfpistol_RELOAD_TIME)
  701.     zz[id] = 0
  702.     udah[id] = 0
  703.     set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)
  704.  
  705.     UTIL_PlayWeaponAnimation(id, sfpistol_RELOAD)
  706.  
  707.     return HAM_IGNORED
  708. }
  709.  
  710. stock set_player_nextattackx(id, Float:nexttime)
  711. {
  712.     if(!is_user_alive(id))
  713.         return
  714.        
  715.     set_pdata_float(id, m_flNextAttack, nexttime, 5)
  716. }
  717.  
  718. stock set_weapons_timeidle(id, WeaponId ,Float:TimeIdle)
  719. {
  720.     if(!is_user_alive(id))
  721.         return
  722.        
  723.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
  724.     if(!pev_valid(entwpn))
  725.         return
  726.        
  727.     set_pdata_float(entwpn, 46, TimeIdle, WEAP_LINUX_XTRA_OFF)
  728.     set_pdata_float(entwpn, 47, TimeIdle, WEAP_LINUX_XTRA_OFF)
  729.     set_pdata_float(entwpn, 48, TimeIdle + 0.5, WEAP_LINUX_XTRA_OFF)
  730. }
  731.  
  732. stock fake_smoke(id)
  733. {
  734.     static Float:vecEnd[3], TE_FLAG
  735.    
  736.     fm_get_aim_origin(id, vecEnd)
  737.    
  738.     TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  739.     TE_FLAG |= TE_EXPLFLAG_NOSOUND
  740.     TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  741.    
  742.     engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0)
  743.     write_byte(TE_EXPLOSION)
  744.     engfunc(EngFunc_WriteCoord, vecEnd[0])
  745.     engfunc(EngFunc_WriteCoord, vecEnd[1])
  746.     engfunc(EngFunc_WriteCoord, vecEnd[2]-5)
  747.     write_short(g_smokepuff_id)
  748.     write_byte(2)
  749.     write_byte(50)
  750.     write_byte(TE_FLAG)
  751.     message_end()
  752. }
  753.  
  754. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
  755. {
  756.     static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  757.    
  758.     pev(id, pev_origin, vOrigin)
  759.     pev(id, pev_view_ofs, vUp) //for player
  760.     xs_vec_add(vOrigin, vUp, vOrigin)
  761.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
  762.    
  763.     angle_vector(vAngle, ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
  764.     angle_vector(vAngle, ANGLEVECTOR_RIGHT, vRight)
  765.     angle_vector(vAngle, ANGLEVECTOR_UP, vUp)
  766.    
  767.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  768.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  769.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  770. }
  771.  
  772. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
  773. {
  774.     new Float:vfEnd[3], viEnd[3]
  775.     get_user_origin(id, viEnd, 3)  
  776.     IVecFVec(viEnd, vfEnd)
  777.    
  778.     new Float:fOrigin[3], Float:fAngle[3]
  779.    
  780.     pev(id, pev_origin, fOrigin)
  781.     pev(id, pev_view_ofs, fAngle)
  782.    
  783.     xs_vec_add(fOrigin, fAngle, fOrigin)
  784.    
  785.     new Float:fAttack[3]
  786.    
  787.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  788.     xs_vec_sub(vfEnd, fOrigin, fAttack)
  789.    
  790.     new Float:fRate
  791.    
  792.     fRate = fDis / vector_length(fAttack)
  793.     xs_vec_mul_scalar(fAttack, fRate, fAttack)
  794.    
  795.     xs_vec_add(fOrigin, fAttack, output)
  796. }
  797.  
  798. stock drop_weapons(id, dropwhat)
  799. {
  800.      static weapons[32], num, i, weaponid
  801.      num = 0
  802.      get_user_weapons(id, weapons, num)
  803.      
  804.      for (i = 0; i < num; i++)
  805.      {
  806.           weaponid = weapons[i]
  807.          
  808.           if (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM))
  809.           {
  810.                static wname[32]
  811.                get_weaponname(weaponid, wname, sizeof wname - 1)
  812.                engclient_cmd(id, "drop", wname)
  813.           }
  814.      }
  815. }

Re: Cyclone

Posted: 06 Sep 2018, 09:08
by Raheem
  1. public give_sfpistol(id)
  2. {
  3.     drop_weapons(id, 2)
  4.     new iWep2 = fm_give_item(id,WEAPON_BASE)
  5.     if( iWep2 > 0 )
  6.     {
  7.         cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_sfpistol))
  8.         cs_set_user_bpammo (id, CSW_P228, get_pcvar_num(cvar_sfpistol_ammo))  
  9.        
  10.         set_weapons_timeidle(id, CSW_P228, 1.0)
  11.         set_player_nextattackx(id, 1.0)
  12.        
  13.         message_begin(MSG_ONE, gmsgWeaponList, _, id)
  14.         write_string("weapon_sfpistol")
  15.         write_byte(1)
  16.         write_byte(52)
  17.         write_byte(-1)
  18.         write_byte(-1)
  19.         write_byte(1)
  20.         write_byte(3)
  21.         write_byte(CSW_P228)
  22.         message_end()
  23.     }
  24.     g_has_sfpistol[id] = true
  25.     zz[id] = 0
  26.     udah[id] = 0
  27. }
  1. public give_sfpistol(id)
  2. {
  3.     drop_weapons(id, 2)
  4.     new iWep2 = fm_give_item(id,WEAPON_BASE)
  5.     if( iWep2 > 0 )
  6.     {
  7.         cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_sfpistol))
  8.         cs_set_user_bpammo (id, CSW_AK47, get_pcvar_num(cvar_sfpistol_ammo))  
  9.        
  10.         set_weapons_timeidle(id, CSW_AK47, 1.0)
  11.         set_player_nextattackx(id, 1.0)
  12.        
  13.         message_begin(MSG_ONE, gmsgWeaponList, _, id)
  14.         write_string("weapon_sfpistol")
  15.         write_byte(1)
  16.         write_byte(52)
  17.         write_byte(-1)
  18.         write_byte(-1)
  19.         write_byte(1)
  20.         write_byte(3)
  21.         write_byte(CSW_AK47)
  22.         message_end()
  23.     }
  24.     g_has_sfpistol[id] = true
  25.     zz[id] = 0
  26.     udah[id] = 0
  27. }

Re: Cyclone

Posted: 06 Sep 2018, 14:53
by Mark
Raheem wrote: 5 years ago
  1. public give_sfpistol(id)
  2. {
  3.     drop_weapons(id, 2)
  4.     new iWep2 = fm_give_item(id,WEAPON_BASE)
  5.     if( iWep2 > 0 )
  6.     {
  7.         cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_sfpistol))
  8.         cs_set_user_bpammo (id, CSW_P228, get_pcvar_num(cvar_sfpistol_ammo))  
  9.        
  10.         set_weapons_timeidle(id, CSW_P228, 1.0)
  11.         set_player_nextattackx(id, 1.0)
  12.        
  13.         message_begin(MSG_ONE, gmsgWeaponList, _, id)
  14.         write_string("weapon_sfpistol")
  15.         write_byte(1)
  16.         write_byte(52)
  17.         write_byte(-1)
  18.         write_byte(-1)
  19.         write_byte(1)
  20.         write_byte(3)
  21.         write_byte(CSW_P228)
  22.         message_end()
  23.     }
  24.     g_has_sfpistol[id] = true
  25.     zz[id] = 0
  26.     udah[id] = 0
  27. }
  1. public give_sfpistol(id)
  2. {
  3.     drop_weapons(id, 2)
  4.     new iWep2 = fm_give_item(id,WEAPON_BASE)
  5.     if( iWep2 > 0 )
  6.     {
  7.         cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_sfpistol))
  8.         cs_set_user_bpammo (id, CSW_AK47, get_pcvar_num(cvar_sfpistol_ammo))  
  9.        
  10.         set_weapons_timeidle(id, CSW_AK47, 1.0)
  11.         set_player_nextattackx(id, 1.0)
  12.        
  13.         message_begin(MSG_ONE, gmsgWeaponList, _, id)
  14.         write_string("weapon_sfpistol")
  15.         write_byte(1)
  16.         write_byte(52)
  17.         write_byte(-1)
  18.         write_byte(-1)
  19.         write_byte(1)
  20.         write_byte(3)
  21.         write_byte(CSW_AK47)
  22.         message_end()
  23.     }
  24.     g_has_sfpistol[id] = true
  25.     zz[id] = 0
  26.     udah[id] = 0
  27. }
I’m sure I did that I’ll check again when I get off work

Re: Cyclone

Posted: 07 Sep 2018, 20:19
by Mark
Dark Shadow wrote: 6 years agooh
Fixed to be Automatic

Also working as it should!
cyclone_fixed.zip
(1.04 MiB) Downloaded 365 times
cyclone_fixed.zip
(1.04 MiB) Downloaded 365 times

Re: Cyclone

Posted: 07 Sep 2018, 20:27
by karan
oh thats nice will try it asap

Re: Cyclone

Posted: 07 Sep 2018, 20:29
by karan
Dark Shadow is my old account

Re: Cyclone

Posted: 07 Oct 2018, 16:27
by shady101852
Mark wrote: 5 years ago
Dark Shadow wrote: 6 years agooh
Fixed to be Automatic

Also working as it should!

cyclone_fixed.zip
thanks a lot!