AUG Guardian problem

Coding Help/Re-API Supported
Post Reply
Templaso
Senior Member
Senior Member
Romania
Posts: 119
Joined: 5 years ago
Location: Bucharest
Contact:

AUG Guardian problem

#1

Post by Templaso » 4 years ago

  1. /*
  2. AUG GUARDIAN v1.0a by YunusReyiz
  3. Fixed situations:
  4. -The previous version of the gun was adapted to Galil and appeared as hud AUG.
  5. For this reason it caused some errors.
  6. The cause is that the AUG is not fully steady in zoom at speed settings.
  7. Now their speeds are set to true AUG with completely fixed.
  8. -While in Galil, there were some redundancy codes, although they were obligatory.
  9. After the AUG, some nonsense code was removed.
  10. (POSTSCRIPT: If v1.1 comes it is probably possible to add muzzleflash. It's also likely to be free.
  11. But it comes late because I'm bored and lazy.)
  12. Good game.
  13. */
  14. #include <amxmodx>
  15. #include <engine>
  16. #include <fakemeta>
  17. #include <fakemeta_util>
  18. #include <fun>
  19. #include <hamsandwich>
  20. #include <xs>
  21. #include <cstrike>
  22. #include <zombie_escape>
  23.  
  24. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
  25.  
  26. new g_event, g_has[33], g_clip[33], oldweap[33], Float:recoil[33]
  27.  
  28. new zoom[33], Float:g_flNextUseTime[33]
  29. new g_iItemID
  30.  
  31. public plugin_init()
  32. {
  33.     register_plugin("[Weapon]: AUG Guardian", "1.0a", "YunusReyiz")
  34.     register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
  35.     register_event("CurWeapon","CurrentWeapon","be","1=1")
  36.    
  37.     register_forward(FM_SetModel, "SetModel")
  38.     register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
  39.     register_forward(FM_PlaybackEvent, "PlaybackEvent")
  40.  
  41.     RegisterHam(Ham_TraceAttack, "worldspawn", "TraceAttack", 1)
  42.     RegisterHam(Ham_TraceAttack, "player", "TraceAttack")
  43.     RegisterHam(Ham_Item_AddToPlayer, "weapon_aug", "AddToPlayer")
  44.     RegisterHam(Ham_Item_PostFrame, "weapon_aug", "ItemPostFrame")
  45.     //RegisterHam(Ham_Item_Deploy, "weapon_aug", "ItemDeploy_Post", 1)
  46.  
  47.     RegisterHam(Ham_Weapon_Reload, "weapon_aug", "Reload")
  48.     RegisterHam(Ham_Weapon_Reload, "weapon_aug", "Reload_Post", 1) 
  49.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_aug", "PrimaryAttack")
  50.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_aug", "PrimaryAttack_Post", 1)
  51.  
  52.    
  53.     //register_clcmd("say aug", "give_weapon")
  54.         g_iItemID = ze_register_item("AUG Guardian", 300, 0)
  55. }
  56. public plugin_precache()
  57. {  
  58.     precache_model("models/Legolas/v_buffaug2.mdl")
  59.     precache_model("models/Legolas/p_buffaug.mdl")
  60.     precache_model("models/Legolas/w_buffaug.mdl")
  61.     precache_sound("weapons/buffaug-1.wav")
  62.  
  63.     //precache_generic("sprites/weapon_augx.txt")
  64.  
  65.     //register_clcmd("weapon_aug", "weapon_hook")  
  66. }
  67.  
  68. /*public weapon_hook(id)
  69. {
  70.         engclient_cmd(id, "weapon_aug")
  71.         return PLUGIN_HANDLED
  72. }*/
  73.  
  74. public TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  75. {
  76.     if(!is_user_alive(iAttacker))
  77.         return
  78.  
  79.     new g_currentweapon = get_user_weapon(iAttacker)
  80.  
  81.     if(g_currentweapon != CSW_AUG) return
  82.    
  83.     if(!g_has[iAttacker]) return
  84.  
  85.     static Float:flEnd[3]
  86.     get_tr2(ptr, TR_vecEndPos, flEnd)
  87.    
  88.     if(iEnt)
  89.     {
  90.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  91.         write_byte(TE_DECAL)
  92.         engfunc(EngFunc_WriteCoord,flEnd[0])
  93.         engfunc(EngFunc_WriteCoord,flEnd[1])
  94.         engfunc(EngFunc_WriteCoord,flEnd[2])
  95.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  96.         write_short(iEnt)
  97.         message_end()
  98.     }
  99.     else
  100.     {
  101.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  102.         write_byte(TE_WORLDDECAL)
  103.         engfunc(EngFunc_WriteCoord,flEnd[0])
  104.         engfunc(EngFunc_WriteCoord,flEnd[1])
  105.         engfunc(EngFunc_WriteCoord,flEnd[2])
  106.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  107.         message_end()
  108.     }
  109.     SetHamParamFloat(3, float(41))
  110.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  111.     write_byte(TE_GUNSHOTDECAL)
  112.     engfunc(EngFunc_WriteCoord,flEnd[0])
  113.     engfunc(EngFunc_WriteCoord,flEnd[1])
  114.     engfunc(EngFunc_WriteCoord,flEnd[2])   
  115.     write_short(iAttacker)
  116.     write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  117.     message_end()
  118. }
  119.  
  120. public PrecacheEvent_Post(type, const name[]) if(equal("events/aug.sc", name)) g_event = get_orig_retval()
  121.  
  122. public client_disconnect(id) g_has[id] = false
  123.  
  124. public SetModel(ent, model[])
  125. {
  126.     if(!is_valid_ent(ent))
  127.         return FMRES_IGNORED
  128.    
  129.     static szClassName[33]
  130.     entity_get_string(ent, EV_SZ_classname, szClassName, charsmax(szClassName))
  131.        
  132.     if(!equal(szClassName, "weaponbox"))
  133.         return FMRES_IGNORED
  134.        
  135.     if(equal(model, "models/w_aug.mdl"))
  136.     {
  137.    
  138.         if(!is_valid_ent(find_ent_by_owner(-1, "weapon_aug", ent)))
  139.             return FMRES_IGNORED
  140.    
  141.         if(g_has[entity_get_edict(ent, EV_ENT_owner)])
  142.         {
  143.             entity_set_int(find_ent_by_owner(-1, "weapon_aug", ent), EV_INT_impulse, 45488)
  144.            
  145.             g_has[entity_get_edict(ent, EV_ENT_owner)] = false
  146.            
  147.             entity_set_model(ent, "models/w_buffaug.mdl")
  148.            
  149.             return FMRES_SUPERCEDE
  150.         }
  151.     }
  152.     return FMRES_IGNORED
  153. }
  154.  
  155. public give_weapon(id)
  156. {
  157.     new iWep2 = give_item(id,"weapon_aug")
  158.     if( iWep2 > 0 )
  159.     {
  160.         cs_set_weapon_ammo(iWep2, 30)
  161.         cs_set_user_bpammo (id, CSW_AUG, 700)  
  162.         set_anim(id, 2)
  163.         set_pdata_float(id, 83, 1.0, 5)
  164.     }
  165.     g_has[id] = true
  166. }
  167.  
  168. public ze_select_item_pre(id, itemid)
  169. {  
  170.     if (itemid != g_iItemID)
  171.         return ZE_ITEM_AVAILABLE
  172.            
  173.     if (ze_is_user_zombie(id))
  174.         return ZE_ITEM_DONT_SHOW
  175.  
  176.     return ZE_ITEM_AVAILABLE
  177. }
  178.  
  179. public ze_select_item_post(id, itemid)
  180. {
  181.     if (itemid != g_iItemID)
  182.         return
  183.  
  184.     give_weapon(id)
  185. }
  186.  
  187. /*public ItemDeploy_Post(id)
  188. {
  189.     static owner
  190.     owner = fm_cs_get_weapon_ent_owner(id)
  191.    
  192.     static weaponid
  193.     weaponid = cs_get_weapon_id(id)
  194.    
  195.     replace_weapon_models(owner, weaponid)
  196. }*/
  197.  
  198. /*stock fm_cs_get_weapon_ent_owner(ent)
  199. {
  200.     return get_pdata_cbase(ent, 41, 4)
  201. }*/
  202.  
  203. public AddToPlayer(wpn, id)
  204. {
  205.     if(!is_valid_ent(wpn) || !is_user_connected(id))
  206.         return HAM_IGNORED
  207.    
  208.     if(entity_get_int(wpn, EV_INT_impulse) == 45488)
  209.     {
  210.         g_has[id] = true
  211.        
  212.         entity_set_int(wpn, EV_INT_impulse, 0)
  213.                        
  214.     }
  215.     return HAM_IGNORED
  216. }
  217.  
  218. public CurrentWeapon(id)
  219. {
  220.     replace_weapon_models(id, read_data(2))
  221.     if(read_data(2) != CSW_AUG || !g_has[id]) return
  222.    
  223.     /*static Float:iSpeed
  224.     if(g_has[id]) iSpeed = 0.8
  225.        
  226.     static weapon[32],Ent
  227.     get_weaponname(read_data(2),weapon,31)
  228.     Ent = find_ent_by_owner(-1,weapon,id)
  229.     if(Ent)
  230.     {
  231.         static Float:Delay
  232.         Delay = get_pdata_float( Ent, 46, 4) * iSpeed
  233.         if (Delay > 0.0)
  234.         {
  235.             set_pdata_float(Ent, 46, Delay, 4)
  236.         }
  237.     }*/
  238.     static Ent; Ent = fm_get_user_weapon_entity(id, CSW_AUG)
  239.     if(!pev_valid(Ent)) return
  240.    
  241.     set_pdata_float(Ent, 46, 0.065, 4)
  242.     set_pdata_float(Ent, 47, 0.065, 4)
  243.  
  244.  
  245. }
  246.  
  247. replace_weapon_models(id, wpnid)
  248. {
  249.     switch (wpnid)
  250.     {
  251.         case CSW_AUG:
  252.         {          
  253.             if(g_has[id])
  254.             {
  255.                 set_pev(id, pev_viewmodel2, "models/Legolas/v_buffaug2.mdl")
  256.                 set_pev(id, pev_weaponmodel2, "models/Legolas/p_buffaug.mdl")
  257.                 if(oldweap[id] != CSW_AUG)
  258.                 {
  259.                     set_anim(id, 2)
  260.                     set_pdata_float(id, 83, 1.0, 5)
  261.                     //set_weapon_list(id, "weapon_aug", CSW_AUG)
  262.                 }
  263.             }
  264.         }
  265.     }
  266.     oldweap[id] = wpnid
  267. }
  268.  
  269. public UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  270. {
  271.     if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_AUG || !g_has[Player]))
  272.         return FMRES_IGNORED
  273.    
  274.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  275.     return FMRES_HANDLED
  276. }
  277.  
  278. public PrimaryAttack(wpn)
  279. {
  280.     new id = get_pdata_cbase(wpn, 41, 4)
  281.     if (!g_has[id]) return
  282. }
  283.  
  284. public PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  285. {
  286.     if ((eventid != g_event))
  287.         return FMRES_IGNORED
  288.     if (!(1 <= invoker <= get_maxplayers()))
  289.     return FMRES_IGNORED
  290.  
  291.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  292.     return FMRES_SUPERCEDE
  293. }
  294.  
  295. public PrimaryAttack_Post(wpn)
  296. {
  297.     new id = get_pdata_cbase(wpn, 41, 4)
  298.    
  299.     if(!is_user_alive(id) || !g_has[id] || cs_get_weapon_ammo(wpn) <= 0)
  300.         return
  301.    
  302.     static Float:Push[3]
  303.     pev(id, pev_punchangle, Push)
  304.     xs_vec_sub(Push, recoil[id], Push)
  305.  
  306.     xs_vec_mul_scalar(Push, 0.5, Push)
  307.     xs_vec_add(Push, recoil[id], Push)
  308.     set_pev(id,pev_punchangle,Push)
  309.     emit_sound(id, CHAN_WEAPON, "weapons/buffaug-1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  310.     set_anim(id, random_num(3,5))
  311. }
  312.  
  313. stock set_anim(const Player, const Sequence)
  314. {
  315.     set_pev(Player, pev_weaponanim, Sequence)
  316.    
  317.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  318.     write_byte(Sequence)
  319.     write_byte(pev(Player, pev_body))
  320.     message_end()
  321. }
  322.  
  323. public message_DeathMsg(msg_id, msg_dest, id)
  324. {
  325.     static szTruncatedWeapon[33], iAttacker, iVictim
  326.    
  327.     get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  328.    
  329.     iAttacker = get_msg_arg_int(1)
  330.     iVictim = get_msg_arg_int(2)
  331.    
  332.     if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  333.         return PLUGIN_CONTINUE
  334.    
  335.     if(equal(szTruncatedWeapon, "aug") && get_user_weapon(iAttacker) == CSW_AUG)
  336.     {
  337.         if(g_has[iAttacker])
  338.             set_msg_arg_string(4, "aug")
  339.     }
  340.     return PLUGIN_CONTINUE
  341. }
  342.  
  343. public ItemPostFrame(wpn)
  344. {
  345.     new id = pev(wpn, pev_owner)
  346.     if (!is_user_connected(id)) return HAM_IGNORED
  347.  
  348.     if (!g_has[id])return HAM_IGNORED
  349.  
  350.     static iClipExtra
  351.      
  352.     iClipExtra = 50
  353.     new Float:flNextAttack = get_pdata_float(id, 83, 5)
  354.  
  355.     new iBpAmmo = cs_get_user_bpammo(id, CSW_AUG)
  356.     new iClip = get_pdata_int(wpn, 51, 4)
  357.  
  358.     new fInReload = get_pdata_int(wpn, 54, 4)
  359.  
  360.     if( fInReload && flNextAttack <= 0.0 )
  361.     {
  362.         new j = min(iClipExtra - iClip, iBpAmmo)
  363.    
  364.         set_pdata_int(wpn, 51, iClip + j, 4)
  365.         cs_set_user_bpammo(id, CSW_AUG, iBpAmmo-j)
  366.        
  367.         set_pdata_int(wpn, 54, 0, 4)
  368.         fInReload = 0
  369.     }
  370.     return HAM_IGNORED
  371. }
  372.  
  373. public Reload(wpn)
  374. {
  375.     new id = pev(wpn, pev_owner)
  376.     if(!is_user_connected(id)) return HAM_IGNORED
  377.  
  378.     if(!g_has[id]) return HAM_IGNORED
  379.  
  380.     static iClipExtra
  381.  
  382.     //if(g_has[id])
  383.     iClipExtra = 50
  384.  
  385.     g_clip[id] = -1
  386.  
  387.     new iBpAmmo = cs_get_user_bpammo(id, CSW_AUG)
  388.     new iClip = get_pdata_int(wpn, 51, 4)
  389.  
  390.     if (iBpAmmo <= 0)
  391.         return HAM_SUPERCEDE
  392.  
  393.     if (iClip >= iClipExtra)
  394.         return HAM_SUPERCEDE
  395.  
  396.     g_clip[id] = iClip
  397.  
  398.     return HAM_IGNORED
  399. }
  400.  
  401. public Reload_Post(wpn)
  402. {
  403.     new id = pev(wpn, pev_owner)
  404.     if (!is_user_connected(id))
  405.         return HAM_IGNORED
  406.  
  407.     if (!g_has[id])
  408.         return HAM_IGNORED
  409.  
  410.     if (g_clip[id] == -1)
  411.         return HAM_IGNORED
  412.  
  413.        
  414.     //zoom[id] = 0
  415.     //cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
  416.     set_pdata_int(wpn, 51, g_clip[id], 4)
  417.  
  418.     set_pdata_int(wpn, 54, 1, 4)
  419.    
  420.     set_pdata_float(wpn, 48, 2.0, 4)
  421.  
  422.     set_pdata_float(id, 83, 2.0, 5)
  423.  
  424.     set_anim(id, 1)
  425.  
  426.     return HAM_IGNORED
  427. }
  428.  
  429. /*public Holster_Post(wpn)
  430. {
  431.     static id
  432.     id = get_pdata_cbase(wpn, 41, 4)
  433.    
  434.     g_flNextUseTime[id] = 0.0
  435.  
  436.     if(g_has[id])
  437.     {
  438.         zoom[id] = false
  439.         cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
  440.     }
  441. }*/
  442.  
  443. /*public CmdStart(id, uc_handle, seed)
  444. {
  445.     if (!is_user_alive(id) || !g_has[id])
  446.         return FMRES_IGNORED
  447.    
  448.     if((get_uc(uc_handle, UC_Buttons) & IN_ATTACK2) && !(pev(id, pev_oldbuttons) & IN_ATTACK2))
  449.     {
  450.         new szClip, szAmmo
  451.         new szWeapID = get_user_weapon(id, szClip, szAmmo)
  452.  
  453.         if(szWeapID == CSW_AUG && g_has[id] && !zoom[id] == true)
  454.         {
  455.             zoom[id] = 1
  456.             cs_set_user_zoom(id, CS_SET_AUGSG552_ZOOM, 1)
  457.             emit_sound(id, CHAN_ITEM, "weapons/zoom.wav", 0.20, 2.40, 0, 100)
  458.         }
  459.         else if(szWeapID == CSW_AUG && g_has[id] && zoom[id])
  460.         {
  461.             zoom[id] = false
  462.             cs_set_user_zoom(id, CS_RESET_ZOOM, 0) 
  463.         }
  464.     }
  465.     return FMRES_IGNORED
  466. }*/
  467.  
  468. /*stock set_weapon_list(id, const weapon_namee[], const CSW_NAMEE)
  469. {
  470.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0,0,0}, id)
  471.     write_string(weapon_namee)
  472.     write_byte(4)
  473.     write_byte(90)
  474.     write_byte(-1)
  475.     write_byte(-1)
  476.     write_byte(0)
  477.     write_byte(14)
  478.     write_byte(CSW_NAMEE)
  479.     message_end()
  480. }*/
When i drop the weapon the server is shutting down because of model. I mean when i drop the weapons the server kicked me and said reason for shut down for set model or something like that idk

Muhammet20
Veteran Member
Veteran Member
Posts: 408
Joined: 5 years ago
Contact:

#2

Post by Muhammet20 » 4 years ago

Mystic Viper wrote: 4 years ago
  1. /*
  2. AUG GUARDIAN v1.0a by YunusReyiz
  3. Fixed situations:
  4. -The previous version of the gun was adapted to Galil and appeared as hud AUG.
  5. For this reason it caused some errors.
  6. The cause is that the AUG is not fully steady in zoom at speed settings.
  7. Now their speeds are set to true AUG with completely fixed.
  8. -While in Galil, there were some redundancy codes, although they were obligatory.
  9. After the AUG, some nonsense code was removed.
  10. (POSTSCRIPT: If v1.1 comes it is probably possible to add muzzleflash. It's also likely to be free.
  11. But it comes late because I'm bored and lazy.)
  12. Good game.
  13. */
  14. #include <amxmodx>
  15. #include <engine>
  16. #include <fakemeta>
  17. #include <fakemeta_util>
  18. #include <fun>
  19. #include <hamsandwich>
  20. #include <xs>
  21. #include <cstrike>
  22. #include <zombie_escape>
  23.  
  24. new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
  25.  
  26. new g_event, g_has[33], g_clip[33], oldweap[33], Float:recoil[33]
  27.  
  28. new zoom[33], Float:g_flNextUseTime[33]
  29. new g_iItemID
  30.  
  31. public plugin_init()
  32. {
  33.     register_plugin("[Weapon]: AUG Guardian", "1.0a", "YunusReyiz")
  34.     register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
  35.     register_event("CurWeapon","CurrentWeapon","be","1=1")
  36.    
  37.     register_forward(FM_SetModel, "SetModel")
  38.     register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
  39.     register_forward(FM_PlaybackEvent, "PlaybackEvent")
  40.  
  41.     RegisterHam(Ham_TraceAttack, "worldspawn", "TraceAttack", 1)
  42.     RegisterHam(Ham_TraceAttack, "player", "TraceAttack")
  43.     RegisterHam(Ham_Item_AddToPlayer, "weapon_aug", "AddToPlayer")
  44.     RegisterHam(Ham_Item_PostFrame, "weapon_aug", "ItemPostFrame")
  45.     //RegisterHam(Ham_Item_Deploy, "weapon_aug", "ItemDeploy_Post", 1)
  46.  
  47.     RegisterHam(Ham_Weapon_Reload, "weapon_aug", "Reload")
  48.     RegisterHam(Ham_Weapon_Reload, "weapon_aug", "Reload_Post", 1) 
  49.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_aug", "PrimaryAttack")
  50.     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_aug", "PrimaryAttack_Post", 1)
  51.  
  52.    
  53.     //register_clcmd("say aug", "give_weapon")
  54.         g_iItemID = ze_register_item("AUG Guardian", 300, 0)
  55. }
  56. public plugin_precache()
  57. {  
  58.     precache_model("models/Legolas/v_buffaug2.mdl")
  59.     precache_model("models/Legolas/p_buffaug.mdl")
  60.     precache_model("models/Legolas/w_buffaug.mdl")
  61.     precache_sound("weapons/buffaug-1.wav")
  62.  
  63.     //precache_generic("sprites/weapon_augx.txt")
  64.  
  65.     //register_clcmd("weapon_aug", "weapon_hook")  
  66. }
  67.  
  68. /*public weapon_hook(id)
  69. {
  70.         engclient_cmd(id, "weapon_aug")
  71.         return PLUGIN_HANDLED
  72. }*/
  73.  
  74. public TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
  75. {
  76.     if(!is_user_alive(iAttacker))
  77.         return
  78.  
  79.     new g_currentweapon = get_user_weapon(iAttacker)
  80.  
  81.     if(g_currentweapon != CSW_AUG) return
  82.    
  83.     if(!g_has[iAttacker]) return
  84.  
  85.     static Float:flEnd[3]
  86.     get_tr2(ptr, TR_vecEndPos, flEnd)
  87.    
  88.     if(iEnt)
  89.     {
  90.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  91.         write_byte(TE_DECAL)
  92.         engfunc(EngFunc_WriteCoord,flEnd[0])
  93.         engfunc(EngFunc_WriteCoord,flEnd[1])
  94.         engfunc(EngFunc_WriteCoord,flEnd[2])
  95.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  96.         write_short(iEnt)
  97.         message_end()
  98.     }
  99.     else
  100.     {
  101.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  102.         write_byte(TE_WORLDDECAL)
  103.         engfunc(EngFunc_WriteCoord,flEnd[0])
  104.         engfunc(EngFunc_WriteCoord,flEnd[1])
  105.         engfunc(EngFunc_WriteCoord,flEnd[2])
  106.         write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  107.         message_end()
  108.     }
  109.     SetHamParamFloat(3, float(41))
  110.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  111.     write_byte(TE_GUNSHOTDECAL)
  112.     engfunc(EngFunc_WriteCoord,flEnd[0])
  113.     engfunc(EngFunc_WriteCoord,flEnd[1])
  114.     engfunc(EngFunc_WriteCoord,flEnd[2])   
  115.     write_short(iAttacker)
  116.     write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
  117.     message_end()
  118. }
  119.  
  120. public PrecacheEvent_Post(type, const name[]) if(equal("events/aug.sc", name)) g_event = get_orig_retval()
  121.  
  122. public client_disconnect(id) g_has[id] = false
  123.  
  124. public SetModel(ent, model[])
  125. {
  126.     if(!is_valid_ent(ent))
  127.         return FMRES_IGNORED
  128.    
  129.     static szClassName[33]
  130.     entity_get_string(ent, EV_SZ_classname, szClassName, charsmax(szClassName))
  131.        
  132.     if(!equal(szClassName, "weaponbox"))
  133.         return FMRES_IGNORED
  134.        
  135.     if(equal(model, "models/w_aug.mdl"))
  136.     {
  137.    
  138.         if(!is_valid_ent(find_ent_by_owner(-1, "weapon_aug", ent)))
  139.             return FMRES_IGNORED
  140.    
  141.         if(g_has[entity_get_edict(ent, EV_ENT_owner)])
  142.         {
  143.             entity_set_int(find_ent_by_owner(-1, "weapon_aug", ent), EV_INT_impulse, 45488)
  144.            
  145.             g_has[entity_get_edict(ent, EV_ENT_owner)] = false
  146.            
  147.             entity_set_model(ent, "models/w_buffaug.mdl")
  148.            
  149.             return FMRES_SUPERCEDE
  150.         }
  151.     }
  152.     return FMRES_IGNORED
  153. }
  154.  
  155. public give_weapon(id)
  156. {
  157.     new iWep2 = give_item(id,"weapon_aug")
  158.     if( iWep2 > 0 )
  159.     {
  160.         cs_set_weapon_ammo(iWep2, 30)
  161.         cs_set_user_bpammo (id, CSW_AUG, 700)  
  162.         set_anim(id, 2)
  163.         set_pdata_float(id, 83, 1.0, 5)
  164.     }
  165.     g_has[id] = true
  166. }
  167.  
  168. public ze_select_item_pre(id, itemid)
  169. {  
  170.     if (itemid != g_iItemID)
  171.         return ZE_ITEM_AVAILABLE
  172.            
  173.     if (ze_is_user_zombie(id))
  174.         return ZE_ITEM_DONT_SHOW
  175.  
  176.     return ZE_ITEM_AVAILABLE
  177. }
  178.  
  179. public ze_select_item_post(id, itemid)
  180. {
  181.     if (itemid != g_iItemID)
  182.         return
  183.  
  184.     give_weapon(id)
  185. }
  186.  
  187. /*public ItemDeploy_Post(id)
  188. {
  189.     static owner
  190.     owner = fm_cs_get_weapon_ent_owner(id)
  191.    
  192.     static weaponid
  193.     weaponid = cs_get_weapon_id(id)
  194.    
  195.     replace_weapon_models(owner, weaponid)
  196. }*/
  197.  
  198. /*stock fm_cs_get_weapon_ent_owner(ent)
  199. {
  200.     return get_pdata_cbase(ent, 41, 4)
  201. }*/
  202.  
  203. public AddToPlayer(wpn, id)
  204. {
  205.     if(!is_valid_ent(wpn) || !is_user_connected(id))
  206.         return HAM_IGNORED
  207.    
  208.     if(entity_get_int(wpn, EV_INT_impulse) == 45488)
  209.     {
  210.         g_has[id] = true
  211.        
  212.         entity_set_int(wpn, EV_INT_impulse, 0)
  213.                        
  214.     }
  215.     return HAM_IGNORED
  216. }
  217.  
  218. public CurrentWeapon(id)
  219. {
  220.     replace_weapon_models(id, read_data(2))
  221.     if(read_data(2) != CSW_AUG || !g_has[id]) return
  222.    
  223.     /*static Float:iSpeed
  224.     if(g_has[id]) iSpeed = 0.8
  225.        
  226.     static weapon[32],Ent
  227.     get_weaponname(read_data(2),weapon,31)
  228.     Ent = find_ent_by_owner(-1,weapon,id)
  229.     if(Ent)
  230.     {
  231.         static Float:Delay
  232.         Delay = get_pdata_float( Ent, 46, 4) * iSpeed
  233.         if (Delay > 0.0)
  234.         {
  235.             set_pdata_float(Ent, 46, Delay, 4)
  236.         }
  237.     }*/
  238.     static Ent; Ent = fm_get_user_weapon_entity(id, CSW_AUG)
  239.     if(!pev_valid(Ent)) return
  240.    
  241.     set_pdata_float(Ent, 46, 0.065, 4)
  242.     set_pdata_float(Ent, 47, 0.065, 4)
  243.  
  244.  
  245. }
  246.  
  247. replace_weapon_models(id, wpnid)
  248. {
  249.     switch (wpnid)
  250.     {
  251.         case CSW_AUG:
  252.         {          
  253.             if(g_has[id])
  254.             {
  255.                 set_pev(id, pev_viewmodel2, "models/Legolas/v_buffaug2.mdl")
  256.                 set_pev(id, pev_weaponmodel2, "models/Legolas/p_buffaug.mdl")
  257.                 if(oldweap[id] != CSW_AUG)
  258.                 {
  259.                     set_anim(id, 2)
  260.                     set_pdata_float(id, 83, 1.0, 5)
  261.                     //set_weapon_list(id, "weapon_aug", CSW_AUG)
  262.                 }
  263.             }
  264.         }
  265.     }
  266.     oldweap[id] = wpnid
  267. }
  268.  
  269. public UpdateClientData_Post(Player, SendWeapons, CD_Handle)
  270. {
  271.     if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_AUG || !g_has[Player]))
  272.         return FMRES_IGNORED
  273.    
  274.     set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
  275.     return FMRES_HANDLED
  276. }
  277.  
  278. public PrimaryAttack(wpn)
  279. {
  280.     new id = get_pdata_cbase(wpn, 41, 4)
  281.     if (!g_has[id]) return
  282. }
  283.  
  284. public PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  285. {
  286.     if ((eventid != g_event))
  287.         return FMRES_IGNORED
  288.     if (!(1 <= invoker <= get_maxplayers()))
  289.     return FMRES_IGNORED
  290.  
  291.     playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  292.     return FMRES_SUPERCEDE
  293. }
  294.  
  295. public PrimaryAttack_Post(wpn)
  296. {
  297.     new id = get_pdata_cbase(wpn, 41, 4)
  298.    
  299.     if(!is_user_alive(id) || !g_has[id] || cs_get_weapon_ammo(wpn) <= 0)
  300.         return
  301.    
  302.     static Float:Push[3]
  303.     pev(id, pev_punchangle, Push)
  304.     xs_vec_sub(Push, recoil[id], Push)
  305.  
  306.     xs_vec_mul_scalar(Push, 0.5, Push)
  307.     xs_vec_add(Push, recoil[id], Push)
  308.     set_pev(id,pev_punchangle,Push)
  309.     emit_sound(id, CHAN_WEAPON, "weapons/buffaug-1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  310.     set_anim(id, random_num(3,5))
  311. }
  312.  
  313. stock set_anim(const Player, const Sequence)
  314. {
  315.     set_pev(Player, pev_weaponanim, Sequence)
  316.    
  317.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
  318.     write_byte(Sequence)
  319.     write_byte(pev(Player, pev_body))
  320.     message_end()
  321. }
  322.  
  323. public message_DeathMsg(msg_id, msg_dest, id)
  324. {
  325.     static szTruncatedWeapon[33], iAttacker, iVictim
  326.    
  327.     get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
  328.    
  329.     iAttacker = get_msg_arg_int(1)
  330.     iVictim = get_msg_arg_int(2)
  331.    
  332.     if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  333.         return PLUGIN_CONTINUE
  334.    
  335.     if(equal(szTruncatedWeapon, "aug") && get_user_weapon(iAttacker) == CSW_AUG)
  336.     {
  337.         if(g_has[iAttacker])
  338.             set_msg_arg_string(4, "aug")
  339.     }
  340.     return PLUGIN_CONTINUE
  341. }
  342.  
  343. public ItemPostFrame(wpn)
  344. {
  345.     new id = pev(wpn, pev_owner)
  346.     if (!is_user_connected(id)) return HAM_IGNORED
  347.  
  348.     if (!g_has[id])return HAM_IGNORED
  349.  
  350.     static iClipExtra
  351.      
  352.     iClipExtra = 50
  353.     new Float:flNextAttack = get_pdata_float(id, 83, 5)
  354.  
  355.     new iBpAmmo = cs_get_user_bpammo(id, CSW_AUG)
  356.     new iClip = get_pdata_int(wpn, 51, 4)
  357.  
  358.     new fInReload = get_pdata_int(wpn, 54, 4)
  359.  
  360.     if( fInReload && flNextAttack <= 0.0 )
  361.     {
  362.         new j = min(iClipExtra - iClip, iBpAmmo)
  363.    
  364.         set_pdata_int(wpn, 51, iClip + j, 4)
  365.         cs_set_user_bpammo(id, CSW_AUG, iBpAmmo-j)
  366.        
  367.         set_pdata_int(wpn, 54, 0, 4)
  368.         fInReload = 0
  369.     }
  370.     return HAM_IGNORED
  371. }
  372.  
  373. public Reload(wpn)
  374. {
  375.     new id = pev(wpn, pev_owner)
  376.     if(!is_user_connected(id)) return HAM_IGNORED
  377.  
  378.     if(!g_has[id]) return HAM_IGNORED
  379.  
  380.     static iClipExtra
  381.  
  382.     //if(g_has[id])
  383.     iClipExtra = 50
  384.  
  385.     g_clip[id] = -1
  386.  
  387.     new iBpAmmo = cs_get_user_bpammo(id, CSW_AUG)
  388.     new iClip = get_pdata_int(wpn, 51, 4)
  389.  
  390.     if (iBpAmmo <= 0)
  391.         return HAM_SUPERCEDE
  392.  
  393.     if (iClip >= iClipExtra)
  394.         return HAM_SUPERCEDE
  395.  
  396.     g_clip[id] = iClip
  397.  
  398.     return HAM_IGNORED
  399. }
  400.  
  401. public Reload_Post(wpn)
  402. {
  403.     new id = pev(wpn, pev_owner)
  404.     if (!is_user_connected(id))
  405.         return HAM_IGNORED
  406.  
  407.     if (!g_has[id])
  408.         return HAM_IGNORED
  409.  
  410.     if (g_clip[id] == -1)
  411.         return HAM_IGNORED
  412.  
  413.        
  414.     //zoom[id] = 0
  415.     //cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
  416.     set_pdata_int(wpn, 51, g_clip[id], 4)
  417.  
  418.     set_pdata_int(wpn, 54, 1, 4)
  419.    
  420.     set_pdata_float(wpn, 48, 2.0, 4)
  421.  
  422.     set_pdata_float(id, 83, 2.0, 5)
  423.  
  424.     set_anim(id, 1)
  425.  
  426.     return HAM_IGNORED
  427. }
  428.  
  429. /*public Holster_Post(wpn)
  430. {
  431.     static id
  432.     id = get_pdata_cbase(wpn, 41, 4)
  433.    
  434.     g_flNextUseTime[id] = 0.0
  435.  
  436.     if(g_has[id])
  437.     {
  438.         zoom[id] = false
  439.         cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
  440.     }
  441. }*/
  442.  
  443. /*public CmdStart(id, uc_handle, seed)
  444. {
  445.     if (!is_user_alive(id) || !g_has[id])
  446.         return FMRES_IGNORED
  447.    
  448.     if((get_uc(uc_handle, UC_Buttons) & IN_ATTACK2) && !(pev(id, pev_oldbuttons) & IN_ATTACK2))
  449.     {
  450.         new szClip, szAmmo
  451.         new szWeapID = get_user_weapon(id, szClip, szAmmo)
  452.  
  453.         if(szWeapID == CSW_AUG && g_has[id] && !zoom[id] == true)
  454.         {
  455.             zoom[id] = 1
  456.             cs_set_user_zoom(id, CS_SET_AUGSG552_ZOOM, 1)
  457.             emit_sound(id, CHAN_ITEM, "weapons/zoom.wav", 0.20, 2.40, 0, 100)
  458.         }
  459.         else if(szWeapID == CSW_AUG && g_has[id] && zoom[id])
  460.         {
  461.             zoom[id] = false
  462.             cs_set_user_zoom(id, CS_RESET_ZOOM, 0) 
  463.         }
  464.     }
  465.     return FMRES_IGNORED
  466. }*/
  467.  
  468. /*stock set_weapon_list(id, const weapon_namee[], const CSW_NAMEE)
  469. {
  470.     message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0,0,0}, id)
  471.     write_string(weapon_namee)
  472.     write_byte(4)
  473.     write_byte(90)
  474.     write_byte(-1)
  475.     write_byte(-1)
  476.     write_byte(0)
  477.     write_byte(14)
  478.     write_byte(CSW_NAMEE)
  479.     message_end()
  480. }*/
When i drop the weapon the server is shutting down because of model. I mean when i drop the weapons the server kicked me and said reason for shut down for set model or something like that idk


not sure , but try this :

Code: Select all

/*
AUG GUARDIAN v1.0a by YunusReyiz
Fixed situations:
-The previous version of the gun was adapted to Galil and appeared as hud AUG.
For this reason it caused some errors.
The cause is that the AUG is not fully steady in zoom at speed settings.
Now their speeds are set to true AUG with completely fixed.
-While in Galil, there were some redundancy codes, although they were obligatory.
After the AUG, some nonsense code was removed.
(POSTSCRIPT: If v1.1 comes it is probably possible to add muzzleflash. It's also likely to be free.
But it comes late because I'm bored and lazy.)
Good game.
*/
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <fun>
#include <hamsandwich>
#include <xs>
#include <cstrike>
#include <zombie_escape>
 
new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
 
new g_event, g_has[33], g_clip[33], oldweap[33], Float:recoil[33]
 
new zoom[33], Float:g_flNextUseTime[33]
new g_iItemID
 
public plugin_init()
{
    register_plugin("[Weapon]: AUG Guardian", "1.0a", "YunusReyiz")
    register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
    register_event("CurWeapon","CurrentWeapon","be","1=1")
   
    register_forward(FM_SetModel, "SetModel")
    register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
    register_forward(FM_PlaybackEvent, "PlaybackEvent")
 
    RegisterHam(Ham_TraceAttack, "worldspawn", "TraceAttack", 1)
    RegisterHam(Ham_TraceAttack, "player", "TraceAttack")
    RegisterHam(Ham_Item_AddToPlayer, "weapon_aug", "AddToPlayer")
    RegisterHam(Ham_Item_PostFrame, "weapon_aug", "ItemPostFrame")
    RegisterHam(Ham_Item_Deploy, "weapon_aug", "ItemDeploy_Post", 1)
 
    RegisterHam(Ham_Weapon_Reload, "weapon_aug", "Reload")
    RegisterHam(Ham_Weapon_Reload, "weapon_aug", "Reload_Post", 1) 
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_aug", "PrimaryAttack")
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_aug", "PrimaryAttack_Post", 1)
 
   
    //register_clcmd("say aug", "give_weapon")
        g_iItemID = ze_register_item("AUG Guardian", 300, 0)
}
public plugin_precache()
{  
    precache_model("models/Legolas/v_buffaug2.mdl")
    precache_model("models/Legolas/p_buffaug.mdl")
    precache_model("models/Legolas/w_buffaug.mdl")
    precache_sound("weapons/buffaug-1.wav")
 
    //precache_generic("sprites/weapon_augx.txt")
 
    //register_clcmd("weapon_aug", "weapon_hook")  
}
 
/*public weapon_hook(id)
{
        engclient_cmd(id, "weapon_aug")
        return PLUGIN_HANDLED
}*/
 
public TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
{
    if(!is_user_alive(iAttacker))
        return
 
    new g_currentweapon = get_user_weapon(iAttacker)
 
    if(g_currentweapon != CSW_AUG) return
   
    if(!g_has[iAttacker]) return
 
    static Float:flEnd[3]
    get_tr2(ptr, TR_vecEndPos, flEnd)
   
    if(iEnt)
    {
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
        write_byte(TE_DECAL)
        engfunc(EngFunc_WriteCoord,flEnd[0])
        engfunc(EngFunc_WriteCoord,flEnd[1])
        engfunc(EngFunc_WriteCoord,flEnd[2])
        write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
        write_short(iEnt)
        message_end()
    }
    else
    {
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
        write_byte(TE_WORLDDECAL)
        engfunc(EngFunc_WriteCoord,flEnd[0])
        engfunc(EngFunc_WriteCoord,flEnd[1])
        engfunc(EngFunc_WriteCoord,flEnd[2])
        write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
        message_end()
    }
    SetHamParamFloat(3, float(41))
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(TE_GUNSHOTDECAL)
    engfunc(EngFunc_WriteCoord,flEnd[0])
    engfunc(EngFunc_WriteCoord,flEnd[1])
    engfunc(EngFunc_WriteCoord,flEnd[2])   
    write_short(iAttacker)
    write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
    message_end()
}
 
public PrecacheEvent_Post(type, const name[]) if(equal("events/aug.sc", name)) g_event = get_orig_retval()
 
public client_disconnect(id) g_has[id] = false
 
public SetModel(ent, model[])
{
    if(!is_valid_ent(ent))
        return FMRES_IGNORED
   
    static szClassName[33]
    entity_get_string(ent, EV_SZ_classname, szClassName, charsmax(szClassName))
       
    if(!equal(szClassName, "weaponbox"))
        return FMRES_IGNORED
       
    if(equal(model, "models/w_aug.mdl"))
    {
   
        if(!is_valid_ent(find_ent_by_owner(-1, "weapon_aug", ent)))
            return FMRES_IGNORED
   
        if(g_has[entity_get_edict(ent, EV_ENT_owner)])
        {
            entity_set_int(find_ent_by_owner(-1, "weapon_aug", ent), EV_INT_impulse, 45488)
           
            g_has[entity_get_edict(ent, EV_ENT_owner)] = false
           
            entity_set_model(ent, "models/w_buffaug.mdl")
           
            return FMRES_SUPERCEDE
        }
    }
    return FMRES_IGNORED
}
 
public give_weapon(id)
{
    new iWep2 = give_item(id,"weapon_aug")
    if( iWep2 > 0 )
    {
        cs_set_weapon_ammo(iWep2, 30)
        cs_set_user_bpammo (id, CSW_AUG, 700)  
        set_anim(id, 2)
        set_pdata_float(id, 83, 1.0, 5)
    }
    g_has[id] = true
}
 
public ze_select_item_pre(id, itemid)
{  
    if (itemid != g_iItemID)
        return ZE_ITEM_AVAILABLE
           
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
 
    return ZE_ITEM_AVAILABLE
}
 
public ze_select_item_post(id, itemid)
{
    if (itemid != g_iItemID)
        return
 
    give_weapon(id)
}
 
/*public ItemDeploy_Post(id)
{
    static owner
    owner = fm_cs_get_weapon_ent_owner(id)
   
    static weaponid
    weaponid = cs_get_weapon_id(id)
   
    replace_weapon_models(owner, weaponid)
}*/
 
/*stock fm_cs_get_weapon_ent_owner(ent)
{
    return get_pdata_cbase(ent, 41, 4)
}*/
 
public AddToPlayer(wpn, id)
{
    if(!is_valid_ent(wpn) || !is_user_connected(id))
        return HAM_IGNORED
   
    if(entity_get_int(wpn, EV_INT_impulse) == 45488)
    {
        g_has[id] = true
       
        entity_set_int(wpn, EV_INT_impulse, 0)
                       
    }
    return HAM_IGNORED
}
 
public CurrentWeapon(id)
{
    replace_weapon_models(id, read_data(2))
    if(read_data(2) != CSW_AUG || !g_has[id]) return
   
    /*static Float:iSpeed
    if(g_has[id]) iSpeed = 0.8
       
    static weapon[32],Ent
    get_weaponname(read_data(2),weapon,31)
    Ent = find_ent_by_owner(-1,weapon,id)
    if(Ent)
    {
        static Float:Delay
        Delay = get_pdata_float( Ent, 46, 4) * iSpeed
        if (Delay > 0.0)
        {
            set_pdata_float(Ent, 46, Delay, 4)
        }
    }*/
    static Ent; Ent = fm_get_user_weapon_entity(id, CSW_AUG)
    if(!pev_valid(Ent)) return
   
    set_pdata_float(Ent, 46, 0.065, 4)
    set_pdata_float(Ent, 47, 0.065, 4)
 
 
}
 
replace_weapon_models(id, wpnid)
{
    switch (wpnid)
    {
        case CSW_AUG:
        {          
            if(g_has[id])
            {
                set_pev(id, pev_viewmodel2, "models/Legolas/v_buffaug2.mdl")
                set_pev(id, pev_weaponmodel2, "models/Legolas/p_buffaug.mdl")
                if(oldweap[id] != CSW_AUG)
                {
                    set_anim(id, 2)
                    set_pdata_float(id, 83, 1.0, 5)
                    //set_weapon_list(id, "weapon_aug", CSW_AUG)
                }
            }
        }
    }
    oldweap[id] = wpnid
}
 
public UpdateClientData_Post(Player, SendWeapons, CD_Handle)
{
    if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_AUG || !g_has[Player]))
        return FMRES_IGNORED
   
    set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
    return FMRES_HANDLED
}
 
public PrimaryAttack(wpn)
{
    new id = get_pdata_cbase(wpn, 41, 4)
    if (!g_has[id]) return
}
 
public PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
    if ((eventid != g_event))
        return FMRES_IGNORED
    if (!(1 <= invoker <= get_maxplayers()))
    return FMRES_IGNORED
 
    playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
    return FMRES_SUPERCEDE
}
 
public PrimaryAttack_Post(wpn)
{
    new id = get_pdata_cbase(wpn, 41, 4)
   
    if(!is_user_alive(id) || !g_has[id] || cs_get_weapon_ammo(wpn) <= 0)
        return
   
    static Float:Push[3]
    pev(id, pev_punchangle, Push)
    xs_vec_sub(Push, recoil[id], Push)
 
    xs_vec_mul_scalar(Push, 0.5, Push)
    xs_vec_add(Push, recoil[id], Push)
    set_pev(id,pev_punchangle,Push)
    emit_sound(id, CHAN_WEAPON, "weapons/buffaug-1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    set_anim(id, random_num(3,5))
}
 
stock set_anim(const Player, const Sequence)
{
    set_pev(Player, pev_weaponanim, Sequence)
   
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
    write_byte(Sequence)
    write_byte(pev(Player, pev_body))
    message_end()
}
 
public message_DeathMsg(msg_id, msg_dest, id)
{
    static szTruncatedWeapon[33], iAttacker, iVictim
   
    get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
   
    iAttacker = get_msg_arg_int(1)
    iVictim = get_msg_arg_int(2)
   
    if(!is_user_connected(iAttacker) || iAttacker == iVictim)
        return PLUGIN_CONTINUE
   
    if(equal(szTruncatedWeapon, "aug") && get_user_weapon(iAttacker) == CSW_AUG)
    {
        if(g_has[iAttacker])
            set_msg_arg_string(4, "aug")
    }
    return PLUGIN_CONTINUE
}
 
public ItemPostFrame(wpn)
{
    new id = pev(wpn, pev_owner)
    if (!is_user_connected(id)) return HAM_IGNORED
 
    if (!g_has[id])return HAM_IGNORED
 
    static iClipExtra
     
    iClipExtra = 50
    new Float:flNextAttack = get_pdata_float(id, 83, 5)
 
    new iBpAmmo = cs_get_user_bpammo(id, CSW_AUG)
    new iClip = get_pdata_int(wpn, 51, 4)
 
    new fInReload = get_pdata_int(wpn, 54, 4)
 
    if( fInReload && flNextAttack <= 0.0 )
    {
        new j = min(iClipExtra - iClip, iBpAmmo)
   
        set_pdata_int(wpn, 51, iClip + j, 4)
        cs_set_user_bpammo(id, CSW_AUG, iBpAmmo-j)
       
        set_pdata_int(wpn, 54, 0, 4)
        fInReload = 0
    }
    return HAM_IGNORED
}
 
public Reload(wpn)
{
    new id = pev(wpn, pev_owner)
    if(!is_user_connected(id)) return HAM_IGNORED
 
    if(!g_has[id]) return HAM_IGNORED
 
    static iClipExtra
 
    //if(g_has[id])
    iClipExtra = 50
 
    g_clip[id] = -1
 
    new iBpAmmo = cs_get_user_bpammo(id, CSW_AUG)
    new iClip = get_pdata_int(wpn, 51, 4)
 
    if (iBpAmmo <= 0)
        return HAM_SUPERCEDE
 
    if (iClip >= iClipExtra)
        return HAM_SUPERCEDE
 
    g_clip[id] = iClip
 
    return HAM_IGNORED
}
 
public Reload_Post(wpn)
{
    new id = pev(wpn, pev_owner)
    if (!is_user_connected(id))
        return HAM_IGNORED
 
    if (!g_has[id])
        return HAM_IGNORED
 
    if (g_clip[id] == -1)
        return HAM_IGNORED
 
       
    //zoom[id] = 0
    //cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
    set_pdata_int(wpn, 51, g_clip[id], 4)
 
    set_pdata_int(wpn, 54, 1, 4)
   
    set_pdata_float(wpn, 48, 2.0, 4)
 
    set_pdata_float(id, 83, 2.0, 5)
 
    set_anim(id, 1)
 
    return HAM_IGNORED
}
 
/*public Holster_Post(wpn)
{
    static id
    id = get_pdata_cbase(wpn, 41, 4)
   
    g_flNextUseTime[id] = 0.0
 
    if(g_has[id])
    {
        zoom[id] = false
        cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
    }
}*/
 
/*public CmdStart(id, uc_handle, seed)
{
    if (!is_user_alive(id) || !g_has[id])
        return FMRES_IGNORED
   
    if((get_uc(uc_handle, UC_Buttons) & IN_ATTACK2) && !(pev(id, pev_oldbuttons) & IN_ATTACK2))
    {
        new szClip, szAmmo
        new szWeapID = get_user_weapon(id, szClip, szAmmo)
 
        if(szWeapID == CSW_AUG && g_has[id] && !zoom[id] == true)
        {
            zoom[id] = 1
            cs_set_user_zoom(id, CS_SET_AUGSG552_ZOOM, 1)
            emit_sound(id, CHAN_ITEM, "weapons/zoom.wav", 0.20, 2.40, 0, 100)
        }
        else if(szWeapID == CSW_AUG && g_has[id] && zoom[id])
        {
            zoom[id] = false
            cs_set_user_zoom(id, CS_RESET_ZOOM, 0) 
        }
    }
    return FMRES_IGNORED
}*/
 
/*stock set_weapon_list(id, const weapon_namee[], const CSW_NAMEE)
{
    message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0,0,0}, id)
    write_string(weapon_namee)
    write_byte(4)
    write_byte(90)
    write_byte(-1)
    write_byte(-1)
    write_byte(0)
    write_byte(14)
    write_byte(CSW_NAMEE)
    message_end()
}*/

Templaso
Senior Member
Senior Member
Romania
Posts: 119
Joined: 5 years ago
Location: Bucharest
Contact:

#3

Post by Templaso » 4 years ago

not working...it s not showing the weapon on shop

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

#4

Post by Night Fury » 4 years ago

What is the full error?
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

Post Reply

Create an account or sign in to join the discussion

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

Create an account

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

Register

Sign in

Who is online

Users browsing this forum: No registered users and 5 guests