Custom Weapons menu

Unpaid Requests, Public Plugins
Post Reply
BandiT
Member
Member
Romania
Posts: 59
Joined: 4 years ago
Contact:

Custom Weapons menu

#1

Post by BandiT » 4 years ago

Hello everyone i have a request if someone cand help me, i put his plugin viewtopic.php?f=15&t=3331 in my sv and it-s working very good i like it, but i want to add more extra guns for level, can somne one help me to make it for me?, because i try to make by myself but is not work.
I want to add 4 more guns

For level 35 M4A1 Dark Knight - viewtopic.php?f=14&t=268
For level 40 Ak47 Paladin - viewtopic.php?f=14&t=267
For level 45 - Tornado laserGun
For level 50 - RPG 7 - viewtopic.php?f=14&t=248

If someone can help me, pleaso post here, Thank you.

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

#2

Post by Night Fury » 4 years ago

Post what you have tried and we will help you to fix it.
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

BandiT
Member
Member
Romania
Posts: 59
Joined: 4 years ago
Contact:

#3

Post by BandiT » 4 years ago

I just try to modify some lines, i-m not to good to edit this plugin, i don-t know how and what i need to edit, that was the reason why i ask here

BandiT
Member
Member
Romania
Posts: 59
Joined: 4 years ago
Contact:

#4

Post by BandiT » 4 years ago

Soory for double post, nobody can help me ?

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

#5

Post by Raheem » 4 years ago

Added DarkNight M4A1, you can add the other same as it, just let me know if it works or not as I did not test it.
  • DarkNight M4A1:
    1. #include <zombie_escape>
    2. #include <fakemeta_util>
    3. #include <cstrike>
    4. #include <xs>
    5. #include <fun>
    6.  
    7. #define PLUGIN "[CSO] M4A1 Dark Knight"
    8. #define VERSION "1.0"
    9. #define AUTHOR "Dias Pendragon"
    10.  
    11. // Data Config
    12. #define MODEL_V "models/v_buffm4.mdl"
    13. #define MODEL_P "models/p_buffm4.mdl"
    14. #define MODEL_W "models/w_buffm4.mdl"
    15. #define MODEL_W_OLD "models/w_m4a1.mdl"
    16.  
    17. #define CSW_BASE CSW_M4A1
    18. #define weapon_base "weapon_m4a1"
    19.  
    20. #define SUBMODEL -1 // can -1
    21. #define WEAPON_CODE 2692015
    22. #define WEAPON_EVENT "events/m4a1.sc"
    23.  
    24. #define ANIME_SHOOT 3
    25. #define ANIME_RELOAD 1 // can -1
    26. #define ANIME_DRAW 2 // can -1
    27. #define ANIME_IDLE 0 // can -1
    28.  
    29. new const WeaponSounds[6][] =
    30. {
    31.     "weapons/m4a1buff-1.wav",
    32.     "weapons/m4a1buff-2.wav",
    33.     "weapons/m4a1buff_idle.wav",
    34.     "weapons/m4a1buff_clipin1.wav",
    35.     "weapons/m4a1buff_clipin2.wav",
    36.     "weapons/m4a1buff_clipout.wav"
    37. }
    38.  
    39. // Weapon Config
    40. #define DAMAGE_A 30 // 60 for Zombie
    41. #define DAMAGE_B 43 // 200 for Zombie
    42. #define ACCURACY 70 // 0 - 100 ; -1 Default
    43. #define CLIP 50
    44. #define BPAMMO 250
    45. #define SPEED_A 0.0875
    46. #define SPEED_B 0.25
    47. #define RECOIL 0.75
    48. #define RELOAD_TIME 2.0
    49.  
    50. // Muzzleflash
    51. #define MUZZLEFLASH1 "sprites/muzzleflash43.spr"
    52. #define MUZZLEFLASH2 "sprites/muzzleflash44.spr"
    53.  
    54. // MACROS
    55. #define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
    56. #define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
    57. #define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))
    58.  
    59. //new g_Base
    60. new g_Had_Base, g_Clip[33], g_OldWeapon[33], Float:g_Recoil[33][3]
    61. new g_Event_Base, g_SmokePuff_SprId, g_MsgCurWeapon, m_spriteTexture
    62. new g_Muzzleflash_Ent, g_Muzzleflash
    63. new g_Muzzleflash_Ent2, g_Muzzleflash2
    64.  
    65. // Safety
    66. new g_HamBot
    67. new g_IsConnected, g_IsAlive, g_PlayerWeapon[33]
    68.  
    69. public plugin_init()
    70. {
    71.     register_plugin(PLUGIN, VERSION, AUTHOR)
    72.    
    73.     // Safety
    74.     Register_SafetyFunc()
    75.    
    76.     // Event
    77.     register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
    78.    
    79.     // Forward
    80.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
    81.     register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
    82.     register_forward(FM_SetModel, "fw_SetModel")   
    83.     register_forward(FM_CmdStart, "fw_CmdStart")
    84.     register_forward(FM_AddToFullPack, "fw_AddToFullPack_Post", 1)
    85.     register_forward(FM_CheckVisibility, "fw_CheckVisibility")
    86.    
    87.     // Ham
    88.     RegisterHam(Ham_Item_Deploy, weapon_base, "fw_Item_Deploy_Post", 1)
    89.     RegisterHam(Ham_Item_AddToPlayer, weapon_base, "fw_Item_AddToPlayer_Post", 1)
    90.     RegisterHam(Ham_Weapon_WeaponIdle, weapon_base, "fw_Weapon_WeaponIdle_Post", 1)
    91.     RegisterHam(Ham_Item_PostFrame, weapon_base, "fw_Item_PostFrame")  
    92.     RegisterHam(Ham_Weapon_Reload, weapon_base, "fw_Weapon_Reload")
    93.     RegisterHam(Ham_Weapon_Reload, weapon_base, "fw_Weapon_Reload_Post", 1)
    94.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_base, "fw_Weapon_PrimaryAttack")
    95.     RegisterHam(Ham_Weapon_PrimaryAttack, weapon_base, "fw_Weapon_PrimaryAttack_Post", 1)
    96.    
    97.     RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_World")
    98.     RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack_Player")
    99.    
    100.     // Cache
    101.     g_MsgCurWeapon = get_user_msgid("CurWeapon")
    102. }
    103.  
    104. public plugin_natives()
    105. {
    106.     register_native("give_darknight_m4a1", "native_give_darknight_m4a1", 1)
    107. }
    108.  
    109. public native_give_darknight_m4a1(id)
    110. {
    111.     Get_Base(id)
    112. }
    113.  
    114. public plugin_precache()
    115. {
    116.     precache_model(MODEL_V)
    117.     precache_model(MODEL_P)
    118.     precache_model(MODEL_W)
    119.    
    120.     for(new i = 0; i < sizeof(WeaponSounds); i++)
    121.         precache_sound(WeaponSounds[i])
    122.    
    123.     m_spriteTexture = precache_model( "sprites/lgtning.spr" )
    124.     g_SmokePuff_SprId = engfunc(EngFunc_PrecacheModel, "sprites/wall_puff1.spr")
    125.     register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
    126.    
    127.     // Muzzleflash
    128.     g_Muzzleflash_Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
    129.     g_Muzzleflash_Ent2 = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
    130.    
    131.     precache_model(MUZZLEFLASH1)
    132.     precache_model(MUZZLEFLASH2)
    133.    
    134.     engfunc(EngFunc_SetModel, g_Muzzleflash_Ent, MUZZLEFLASH1)
    135.     engfunc(EngFunc_SetModel, g_Muzzleflash_Ent2, MUZZLEFLASH2)
    136.    
    137.     set_pev(g_Muzzleflash_Ent, pev_scale, 0.075)
    138.     set_pev(g_Muzzleflash_Ent2, pev_scale, 0.1)
    139.    
    140.     set_pev(g_Muzzleflash_Ent, pev_rendermode, kRenderTransTexture)
    141.     set_pev(g_Muzzleflash_Ent, pev_renderamt, 0.0)
    142.     set_pev(g_Muzzleflash_Ent2, pev_rendermode, kRenderTransTexture)
    143.     set_pev(g_Muzzleflash_Ent2, pev_renderamt, 0.0)
    144. }
    145.  
    146. public fw_PrecacheEvent_Post(type, const name[])
    147. {
    148.     if(equal(WEAPON_EVENT, name)) g_Event_Base = get_orig_retval()     
    149. }
    150.  
    151. public client_putinserver(id)
    152. {
    153.         Safety_Connected(id)
    154.    
    155.     if(!g_HamBot && is_user_bot(id))
    156.     {
    157.         g_HamBot = 1
    158.         set_task(0.1, "Register_HamBot", id)
    159.     }
    160. }
    161.  
    162. public Register_HamBot(id)
    163. {
    164.     Register_SafetyFuncBot(id)
    165.     RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack_Player")
    166. }
    167.  
    168. public client_disconnected(id)
    169. {
    170.         Safety_Disconnected(id)
    171. }
    172. /*
    173. public Mileage_WeaponGet(id, ItemID)
    174. {
    175.     if(ItemID == g_Base) Get_Base(id)
    176. }
    177.  
    178. public Mileage_WeaponRefillAmmo(id, ItemID)
    179. {
    180.     if(ItemID == g_Base) cs_set_user_bpammo(id, CSW_BASE, BPAMMO)
    181. }
    182.  
    183. public Mileage_WeaponRemove(id, ItemID)
    184. {
    185.     if(ItemID == g_Base) Remove_Base(id)
    186. }*/
    187.  
    188. public Get_Base(id)
    189. {
    190.     Set_BitVar(g_Had_Base, id)
    191.     give_item(id, weapon_base)
    192.    
    193.     // Clip & Ammo
    194.     static Ent; Ent = fm_get_user_weapon_entity(id, CSW_BASE)
    195.     if(!pev_valid(Ent)) return
    196.    
    197.     cs_set_weapon_ammo(Ent, CLIP)
    198.     cs_set_user_bpammo(id, CSW_BASE, BPAMMO)
    199.    
    200.     message_begin(MSG_ONE_UNRELIABLE, g_MsgCurWeapon, _, id)
    201.     write_byte(1)
    202.     write_byte(CSW_BASE)
    203.     write_byte(CLIP)
    204.     message_end()
    205.    
    206.     cs_set_weapon_silen(Ent, 0, 0)
    207. }
    208.  
    209. public ze_user_infected(id)
    210. {
    211.     Remove_Base(id)
    212. }
    213.  
    214. public ze_user_humanized(id)
    215. {
    216.     Remove_Base(id)
    217. }
    218.  
    219. public Remove_Base(id)
    220. {
    221.     UnSet_BitVar(g_Had_Base, id)
    222. }
    223.  
    224. public Event_CurWeapon(id)
    225. {
    226.     static CSWID; CSWID = read_data(2)
    227.     static SubModel; SubModel = SUBMODEL
    228.    
    229.     if((CSWID == CSW_BASE && g_OldWeapon[id] != CSW_BASE) && Get_BitVar(g_Had_Base, id))
    230.     {
    231.         if(SubModel != -1) Draw_NewWeapon(id, CSWID)
    232.     } else if((CSWID == CSW_BASE && g_OldWeapon[id] == CSW_BASE) && Get_BitVar(g_Had_Base, id)) {
    233.         static Ent; Ent = fm_get_user_weapon_entity(id, CSW_BASE)
    234.         if(!pev_valid(Ent))
    235.         {
    236.             g_OldWeapon[id] = get_user_weapon(id)
    237.             return
    238.         }
    239.        
    240.         static Float:Speed
    241.         if(cs_get_user_zoom(id) != CS_SET_AUGSG552_ZOOM) Speed = SPEED_A
    242.         else Speed = SPEED_B
    243.        
    244.         set_pdata_float(Ent, 46, Speed, 4)
    245.         set_pdata_float(Ent, 47, Speed, 4)
    246.     } else if(CSWID != CSW_BASE && g_OldWeapon[id] == CSW_BASE) {
    247.         if(SubModel != -1) Draw_NewWeapon(id, CSWID)
    248.     }
    249.    
    250.     g_OldWeapon[id] = get_user_weapon(id)
    251. }
    252.  
    253. public Draw_NewWeapon(id, CSW_ID)
    254. {
    255.     if(CSW_ID == CSW_BASE)
    256.     {
    257.         static ent
    258.         ent = fm_get_user_weapon_entity(id, CSW_BASE)
    259.        
    260.         if(pev_valid(ent) && Get_BitVar(g_Had_Base, id))
    261.         {
    262.             set_pev(ent, pev_effects, pev(ent, pev_effects) &~ EF_NODRAW)
    263.             engfunc(EngFunc_SetModel, ent, MODEL_P)
    264.             set_pev(ent, pev_body, SUBMODEL)
    265.         }
    266.     } else {
    267.         static ent
    268.         ent = fm_get_user_weapon_entity(id, CSW_BASE)
    269.        
    270.         if(pev_valid(ent)) set_pev(ent, pev_effects, pev(ent, pev_effects) | EF_NODRAW)            
    271.     }
    272. }
    273.  
    274. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
    275. {
    276.     if(!is_alive(id))
    277.         return FMRES_IGNORED   
    278.     if(get_user_weapon(id) == CSW_BASE && Get_BitVar(g_Had_Base, id))
    279.         set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
    280.    
    281.     return FMRES_HANDLED
    282. }
    283.  
    284. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
    285. {
    286.     if (!is_connected(invoker))
    287.         return FMRES_IGNORED   
    288.     if(get_player_weapon(invoker) != CSW_BASE || !Get_BitVar(g_Had_Base, invoker))
    289.         return FMRES_IGNORED
    290.     if(eventid != g_Event_Base)
    291.         return FMRES_IGNORED
    292.    
    293.     engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
    294.  
    295.     Set_WeaponAnim(invoker, ANIME_SHOOT)
    296.     if(cs_get_user_zoom(invoker) != CS_SET_AUGSG552_ZOOM) emit_sound(invoker, CHAN_WEAPON, WeaponSounds[0], 1.0, 0.4, 0, 94 + random_num(0, 15))
    297.     else emit_sound(invoker, CHAN_WEAPON, WeaponSounds[1], 1.0, 0.4, 0, 94 + random_num(0, 15))
    298.    
    299.     return FMRES_SUPERCEDE
    300. }
    301.  
    302. public fw_SetModel(entity, model[])
    303. {
    304.     if(!pev_valid(entity))
    305.         return FMRES_IGNORED
    306.    
    307.     static Classname[32]
    308.     pev(entity, pev_classname, Classname, sizeof(Classname))
    309.    
    310.     if(!equal(Classname, "weaponbox"))
    311.         return FMRES_IGNORED
    312.    
    313.     static iOwner
    314.     iOwner = pev(entity, pev_owner)
    315.    
    316.     if(equal(model, MODEL_W_OLD))
    317.     {
    318.         static weapon; weapon = find_ent_by_owner(-1, weapon_base, entity)
    319.        
    320.         if(!pev_valid(weapon))
    321.             return FMRES_IGNORED;
    322.        
    323.         if(Get_BitVar(g_Had_Base, iOwner))
    324.         {
    325.             set_pev(weapon, pev_impulse, WEAPON_CODE)
    326.             engfunc(EngFunc_SetModel, entity, MODEL_W)
    327.             set_pev(entity, pev_body, SUBMODEL)
    328.        
    329.             Remove_Base(iOwner)
    330.            
    331.             return FMRES_SUPERCEDE
    332.         }
    333.     }
    334.  
    335.     return FMRES_IGNORED;
    336. }
    337.  
    338. public fw_CmdStart(id, uc_handle, seed)
    339. {
    340.     if (!is_alive(id))
    341.         return FMRES_IGNORED   
    342.     if(get_player_weapon(id) != CSW_BASE || !Get_BitVar(g_Had_Base, id))
    343.         return FMRES_IGNORED
    344.        
    345.     static Button; Button = get_uc(uc_handle, UC_Buttons)  
    346.    
    347.     if(Button & IN_ATTACK2)
    348.     {
    349.         static Float:Time; Time = get_pdata_float(id, 83, 5)
    350.         if(Time > 0.0) return FMRES_IGNORED
    351.        
    352.         if(cs_get_user_zoom(id) != CS_SET_AUGSG552_ZOOM) cs_set_user_zoom(id, CS_SET_AUGSG552_ZOOM, 1)
    353.         else cs_set_user_zoom(id, CS_RESET_ZOOM, 0)
    354.        
    355.         Time = 0.25
    356.         set_pdata_float(id, 83, Time, 5)
    357.     }
    358.    
    359.     return FMRES_IGNORED
    360. }
    361.  
    362. public fw_AddToFullPack_Post(esState, iE, iEnt, iHost, iHostFlags, iPlayer, pSet)
    363. {
    364.     if(iEnt == g_Muzzleflash_Ent)
    365.     {
    366.         if(Get_BitVar(g_Muzzleflash, iHost))
    367.         {
    368.             set_es(esState, ES_Frame, float(random_num(0, 2)))
    369.                
    370.             set_es(esState, ES_RenderMode, kRenderTransAdd)
    371.             set_es(esState, ES_RenderAmt, 255.0)
    372.            
    373.             UnSet_BitVar(g_Muzzleflash, iHost)
    374.             //remove_task(iHost+WEAPON_CODE)
    375.             set_task(0.001, "Set_NextMuzzleflash", iHost+WEAPON_CODE)
    376.         }
    377.            
    378.         set_es(esState, ES_Skin, iHost)
    379.         set_es(esState, ES_Body, 1)
    380.         set_es(esState, ES_AimEnt, iHost)
    381.         set_es(esState, ES_MoveType, MOVETYPE_FOLLOW)
    382.     } else if(iEnt == g_Muzzleflash_Ent2) {
    383.         if(Get_BitVar(g_Muzzleflash2, iHost))
    384.         {
    385.             set_es(esState, ES_Frame, float(random_num(0, 2)))
    386.                
    387.             set_es(esState, ES_RenderMode, kRenderTransAdd)
    388.             set_es(esState, ES_RenderAmt, 255.0)
    389.            
    390.             UnSet_BitVar(g_Muzzleflash2, iHost)
    391.         }
    392.            
    393.         set_es(esState, ES_Skin, iHost)
    394.         set_es(esState, ES_Body, 1)
    395.         set_es(esState, ES_AimEnt, iHost)
    396.         set_es(esState, ES_MoveType, MOVETYPE_FOLLOW)
    397.     }
    398. }
    399.  
    400. public Set_NextMuzzleflash(id) Set_BitVar(g_Muzzleflash2, id-WEAPON_CODE)
    401.  
    402. public fw_CheckVisibility(iEntity, pSet)
    403. {
    404.     if(iEntity == g_Muzzleflash_Ent || iEntity == g_Muzzleflash_Ent2)
    405.     {
    406.         forward_return(FMV_CELL, 1)
    407.         return FMRES_SUPERCEDE
    408.     }
    409.    
    410.     return FMRES_IGNORED
    411. }
    412.  
    413. public fw_Item_Deploy_Post(Ent)
    414. {
    415.     if(pev_valid(Ent) != 2)
    416.         return
    417.     static Id; Id = get_pdata_cbase(Ent, 41, 4)
    418.     if(get_pdata_cbase(Id, 373) != Ent)
    419.         return
    420.     if(!Get_BitVar(g_Had_Base, Id))
    421.         return
    422.        
    423.     static SubModel; SubModel = SUBMODEL
    424.    
    425.     set_pev(Id, pev_viewmodel2, MODEL_V)
    426.     set_pev(Id, pev_weaponmodel2, SubModel != -1 ? "" : MODEL_P)
    427.    
    428.     static Draw; Draw = ANIME_DRAW
    429.     if(Draw != -1) Set_WeaponAnim(Id, ANIME_DRAW)
    430. }
    431.  
    432. public fw_Item_AddToPlayer_Post(Ent, id)
    433. {
    434.     if(!pev_valid(Ent))
    435.         return HAM_IGNORED
    436.        
    437.     if(pev(Ent, pev_impulse) == WEAPON_CODE)
    438.     {
    439.         Set_BitVar(g_Had_Base, id)
    440.         set_pev(Ent, pev_impulse, 0)
    441.     }
    442.    
    443.     return HAM_HANDLED 
    444. }
    445.  
    446. public fw_Item_PostFrame(ent)
    447. {
    448.     static id; id = pev(ent, pev_owner)
    449.     if(!is_user_alive(id))
    450.         return HAM_IGNORED
    451.     if(!Get_BitVar(g_Had_Base, id))
    452.         return HAM_IGNORED 
    453.    
    454.     static Float:flNextAttack; flNextAttack = get_pdata_float(id, 83, 5)
    455.     static bpammo; bpammo = cs_get_user_bpammo(id, CSW_BASE)
    456.    
    457.     static iClip; iClip = get_pdata_int(ent, 51, 4)
    458.     static fInReload; fInReload = get_pdata_int(ent, 54, 4)
    459.    
    460.     if(fInReload && flNextAttack <= 0.0)
    461.     {
    462.         static temp1
    463.         temp1 = min(CLIP - iClip, bpammo)
    464.  
    465.         set_pdata_int(ent, 51, iClip + temp1, 4)
    466.         cs_set_user_bpammo(id, CSW_BASE, bpammo - temp1)       
    467.        
    468.         set_pdata_int(ent, 54, 0, 4)
    469.        
    470.         fInReload = 0
    471.     }      
    472.    
    473.     return HAM_IGNORED
    474. }
    475.  
    476. public fw_Weapon_Reload(ent)
    477. {
    478.     static id; id = pev(ent, pev_owner)
    479.     if(!is_user_alive(id))
    480.         return HAM_IGNORED
    481.     if(!Get_BitVar(g_Had_Base, id))
    482.         return HAM_IGNORED 
    483.  
    484.     g_Clip[id] = -1
    485.        
    486.     static BPAmmo; BPAmmo = cs_get_user_bpammo(id, CSW_BASE)
    487.     static iClip; iClip = get_pdata_int(ent, 51, 4)
    488.        
    489.     if(BPAmmo <= 0)
    490.         return HAM_SUPERCEDE
    491.     if(iClip >= CLIP)
    492.         return HAM_SUPERCEDE       
    493.            
    494.     g_Clip[id] = iClip 
    495.    
    496.     return HAM_HANDLED
    497. }
    498.  
    499. public fw_Weapon_Reload_Post(ent)
    500. {
    501.     static id; id = pev(ent, pev_owner)
    502.     if(!is_user_alive(id))
    503.         return HAM_IGNORED
    504.     if(!Get_BitVar(g_Had_Base, id))
    505.         return HAM_IGNORED 
    506.    
    507.     if((get_pdata_int(ent, 54, 4) == 1))
    508.     { // Reload
    509.         if(g_Clip[id] == -1)
    510.             return HAM_IGNORED
    511.        
    512.         set_pdata_int(ent, 51, g_Clip[id], 4)
    513.        
    514.         static Reload; Reload = ANIME_RELOAD
    515.         if(Reload != -1) Set_WeaponAnim(id, ANIME_RELOAD)
    516.         Set_PlayerNextAttack(id, RELOAD_TIME)
    517.     }
    518.    
    519.     return HAM_HANDLED
    520. }
    521.  
    522. public fw_Weapon_WeaponIdle_Post( iEnt )
    523. {
    524.     if(pev_valid(iEnt) != 2)
    525.         return
    526.     static Id; Id = get_pdata_cbase(iEnt, 41, 4)
    527.     if(get_pdata_cbase(Id, 373) != iEnt)
    528.         return
    529.     if(!Get_BitVar(g_Had_Base, Id))
    530.         return
    531.        
    532.     static Idle; Idle = ANIME_IDLE
    533.    
    534.     if(Idle != -1 && get_pdata_float(iEnt, 48, 4) <= 0.25)
    535.     {
    536.         Set_WeaponAnim(Id, ANIME_IDLE)
    537.         set_pdata_float(iEnt, 48, 20.0, 4)
    538.     }  
    539. }
    540.  
    541. public fw_TraceAttack_World(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
    542. {
    543.     if(!is_connected(Attacker))
    544.         return HAM_IGNORED 
    545.     if(get_player_weapon(Attacker) != CSW_BASE || !Get_BitVar(g_Had_Base, Attacker))
    546.         return HAM_IGNORED
    547.        
    548.     static Float:flEnd[3], Float:vecPlane[3]
    549.        
    550.     get_tr2(Ptr, TR_vecEndPos, flEnd)
    551.     get_tr2(Ptr, TR_vecPlaneNormal, vecPlane)      
    552.            
    553.     Make_BulletHole(Attacker, flEnd, Damage)
    554.     Make_BulletSmoke(Attacker, Ptr)
    555.  
    556.     if(cs_get_user_zoom(Attacker) != CS_SET_AUGSG552_ZOOM) SetHamParamFloat(3, float(DAMAGE_A))
    557.     else {
    558.         SetHamParamFloat(3, float(DAMAGE_B))
    559.         Create_Tracer(Attacker, flEnd)
    560.     }
    561.    
    562.     return HAM_HANDLED
    563. }
    564.  
    565. public fw_TraceAttack_Player(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
    566. {
    567.     if(!is_connected(Attacker))
    568.         return HAM_IGNORED 
    569.     if(get_player_weapon(Attacker) != CSW_BASE || !Get_BitVar(g_Had_Base, Attacker))
    570.         return HAM_IGNORED
    571.  
    572.     static Float:flEnd[3]
    573.     get_tr2(Ptr, TR_vecEndPos, flEnd)  
    574.        
    575.     if(cs_get_user_zoom(Attacker) != CS_SET_AUGSG552_ZOOM) SetHamParamFloat(3, float(DAMAGE_A))
    576.     else {
    577.         SetHamParamFloat(3, float(DAMAGE_B))
    578.         Create_Tracer(Attacker, flEnd)
    579.     }
    580.    
    581.     return HAM_HANDLED
    582. }
    583.  
    584. public Create_Tracer(id, Float:Target[3])
    585. {
    586.     static Float:Start[3];
    587.     Get_Position(id, 48.0, 6.0, -6.0, Start)
    588.    
    589.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    590.     write_byte(TE_BEAMPOINTS)
    591.     write_coord(Start[0])
    592.     write_coord(Start[1])
    593.     write_coord(Start[2])
    594.     write_coord(Target[0])
    595.     write_coord(Target[1])
    596.     write_coord(Target[2])
    597.     write_short(m_spriteTexture)
    598.     write_byte(0) // framerate
    599.     write_byte(0) // framerate
    600.     write_byte(5) // life
    601.     write_byte(2)  // width
    602.     write_byte(0)   // noise
    603.     write_byte(255)   // r, g, b
    604.     write_byte(255)   // r, g, b
    605.     write_byte(255)   // r, g, b
    606.     write_byte(175) // brightness
    607.     write_byte(1)       // speed
    608.     message_end()
    609. }
    610.  
    611. public fw_Weapon_PrimaryAttack(Ent)
    612. {
    613.     static id; id = pev(Ent, pev_owner)
    614.     if(!is_alive(id))
    615.         return
    616.     if(!Get_BitVar(g_Had_Base, id))
    617.         return
    618.  
    619.     pev(id, pev_punchangle, g_Recoil[id])
    620. }
    621.  
    622. public fw_Weapon_PrimaryAttack_Post(Ent)
    623. {
    624.     static id; id = pev(Ent, pev_owner)
    625.     if(!is_alive(id))
    626.         return
    627.     if(!Get_BitVar(g_Had_Base, id))
    628.         return
    629.  
    630.     static Float:Push[3]
    631.     pev(id, pev_punchangle, Push)
    632.     xs_vec_sub(Push, g_Recoil[id], Push)
    633.    
    634.     xs_vec_mul_scalar(Push, RECOIL, Push)
    635.     xs_vec_add(Push, g_Recoil[id], Push)
    636.    
    637.     set_pev(id, pev_punchangle, Push)
    638.     Set_BitVar(g_Muzzleflash, id)
    639.    
    640.     // Acc
    641.     static Accena; Accena = ACCURACY
    642.     if(Accena != -1)
    643.     {
    644.         static Float:Accuracy
    645.         Accuracy = (float(100 - ACCURACY) * 1.5) / 100.0
    646.  
    647.         set_pdata_float(Ent, 62, Accuracy, 4);
    648.     }
    649. }
    650.  
    651. /* ===============================
    652. ------------- SAFETY -------------
    653. =================================*/
    654. public Register_SafetyFunc()
    655. {
    656.     register_event("CurWeapon", "Safety_CurWeapon", "be", "1=1")
    657.    
    658.     RegisterHam(Ham_Spawn, "player", "fw_Safety_Spawn_Post", 1)
    659.     RegisterHam(Ham_Killed, "player", "fw_Safety_Killed_Post", 1)
    660. }
    661.  
    662. public Register_SafetyFuncBot(id)
    663. {
    664.     RegisterHamFromEntity(Ham_Spawn, id, "fw_Safety_Spawn_Post", 1)
    665.     RegisterHamFromEntity(Ham_Killed, id, "fw_Safety_Killed_Post", 1)
    666. }
    667.  
    668. public Safety_Connected(id)
    669. {
    670.     Set_BitVar(g_IsConnected, id)
    671.     UnSet_BitVar(g_IsAlive, id)
    672.    
    673.     g_PlayerWeapon[id] = 0
    674. }
    675.  
    676. public Safety_Disconnected(id)
    677. {
    678.     UnSet_BitVar(g_IsConnected, id)
    679.     UnSet_BitVar(g_IsAlive, id)
    680.    
    681.     g_PlayerWeapon[id] = 0
    682. }
    683.  
    684. public Safety_CurWeapon(id)
    685. {
    686.     if(!is_alive(id))
    687.         return
    688.        
    689.     static CSW; CSW = read_data(2)
    690.     if(g_PlayerWeapon[id] != CSW) g_PlayerWeapon[id] = CSW
    691. }
    692.  
    693. public fw_Safety_Spawn_Post(id)
    694. {
    695.     if(!is_user_alive(id))
    696.         return
    697.        
    698.     Set_BitVar(g_IsAlive, id)
    699. }
    700.  
    701. public fw_Safety_Killed_Post(id)
    702. {
    703.     UnSet_BitVar(g_IsAlive, id)
    704. }
    705.  
    706. public is_connected(id)
    707. {
    708.     if(!(1 <= id <= 32))
    709.         return 0
    710.     if(!Get_BitVar(g_IsConnected, id))
    711.         return 0
    712.  
    713.     return 1
    714. }
    715.  
    716. public is_alive(id)
    717. {
    718.     if(!is_connected(id))
    719.         return 0
    720.     if(!Get_BitVar(g_IsAlive, id))
    721.         return 0
    722.        
    723.     return 1
    724. }
    725.  
    726. public get_player_weapon(id)
    727. {
    728.     if(!is_alive(id))
    729.         return 0
    730.    
    731.     return g_PlayerWeapon[id]
    732. }
    733.  
    734. /* ===============================
    735. --------- END OF SAFETY  ---------
    736. =================================*/
    737.  
    738. stock Set_WeaponAnim(id, anim)
    739. {
    740.     set_pev(id, pev_weaponanim, anim)
    741.    
    742.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
    743.     write_byte(anim)
    744.     write_byte(pev(id, pev_body))
    745.     message_end()
    746. }
    747.  
    748. stock Make_BulletHole(id, Float:Origin[3], Float:Damage)
    749. {
    750.     // Find target
    751.     static Decal; Decal = random_num(41, 45)
    752.     static LoopTime;
    753.    
    754.     if(Damage > 100.0) LoopTime = 2
    755.     else LoopTime = 1
    756.    
    757.     for(new i = 0; i < LoopTime; i++)
    758.     {
    759.         // Put decal on "world" (a wall)
    760.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    761.         write_byte(TE_WORLDDECAL)
    762.         engfunc(EngFunc_WriteCoord, Origin[0])
    763.         engfunc(EngFunc_WriteCoord, Origin[1])
    764.         engfunc(EngFunc_WriteCoord, Origin[2])
    765.         write_byte(Decal)
    766.         message_end()
    767.        
    768.         // Show sparcles
    769.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    770.         write_byte(TE_GUNSHOTDECAL)
    771.         engfunc(EngFunc_WriteCoord, Origin[0])
    772.         engfunc(EngFunc_WriteCoord, Origin[1])
    773.         engfunc(EngFunc_WriteCoord, Origin[2])
    774.         write_short(id)
    775.         write_byte(Decal)
    776.         message_end()
    777.     }
    778. }
    779.  
    780. stock Make_BulletSmoke(id, TrResult)
    781. {
    782.     static Float:vecSrc[3], Float:vecEnd[3], TE_FLAG
    783.    
    784.     get_weapon_attachment(id, vecSrc)
    785.     global_get(glb_v_forward, vecEnd)
    786.    
    787.     xs_vec_mul_scalar(vecEnd, 8192.0, vecEnd)
    788.     xs_vec_add(vecSrc, vecEnd, vecEnd)
    789.  
    790.     get_tr2(TrResult, TR_vecEndPos, vecSrc)
    791.     get_tr2(TrResult, TR_vecPlaneNormal, vecEnd)
    792.    
    793.     xs_vec_mul_scalar(vecEnd, 2.5, vecEnd)
    794.     xs_vec_add(vecSrc, vecEnd, vecEnd)
    795.    
    796.     TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
    797.     TE_FLAG |= TE_EXPLFLAG_NOSOUND
    798.     TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
    799.    
    800.     engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, vecEnd, 0)
    801.     write_byte(TE_EXPLOSION)
    802.     engfunc(EngFunc_WriteCoord, vecEnd[0])
    803.     engfunc(EngFunc_WriteCoord, vecEnd[1])
    804.     engfunc(EngFunc_WriteCoord, vecEnd[2] - 10.0)
    805.     write_short(g_SmokePuff_SprId)
    806.     write_byte(2)
    807.     write_byte(50)
    808.     write_byte(TE_FLAG)
    809.     message_end()
    810. }
    811.  
    812. stock get_weapon_attachment(id, Float:output[3], Float:fDis = 40.0)
    813. {
    814.     static Float:vfEnd[3], viEnd[3]
    815.     get_user_origin(id, viEnd, 3)  
    816.     IVecFVec(viEnd, vfEnd)
    817.    
    818.     static Float:fOrigin[3], Float:fAngle[3]
    819.    
    820.     pev(id, pev_origin, fOrigin)
    821.     pev(id, pev_view_ofs, fAngle)
    822.    
    823.     xs_vec_add(fOrigin, fAngle, fOrigin)
    824.    
    825.     static Float:fAttack[3]
    826.    
    827.     xs_vec_sub(vfEnd, fOrigin, fAttack)
    828.     xs_vec_sub(vfEnd, fOrigin, fAttack)
    829.    
    830.     static Float:fRate
    831.    
    832.     fRate = fDis / vector_length(fAttack)
    833.     xs_vec_mul_scalar(fAttack, fRate, fAttack)
    834.    
    835.     xs_vec_add(fOrigin, fAttack, output)
    836. }
    837.  
    838. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
    839. {
    840.     new Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
    841.    
    842.     pev(id, pev_origin, vOrigin)
    843.     pev(id, pev_view_ofs,vUp) //for player
    844.     xs_vec_add(vOrigin,vUp,vOrigin)
    845.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
    846.    
    847.     angle_vector(vAngle,ANGLEVECTOR_FORWARD,vForward) //or use EngFunc_AngleVectors
    848.     angle_vector(vAngle,ANGLEVECTOR_RIGHT,vRight)
    849.     angle_vector(vAngle,ANGLEVECTOR_UP,vUp)
    850.    
    851.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
    852.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
    853.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
    854. }
    855.  
    856. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
    857. {
    858.     new_velocity[0] = origin2[0] - origin1[0]
    859.     new_velocity[1] = origin2[1] - origin1[1]
    860.     new_velocity[2] = origin2[2] - origin1[2]
    861.     new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
    862.     new_velocity[0] *= num
    863.     new_velocity[1] *= num
    864.     new_velocity[2] *= num
    865.    
    866.     return 1;
    867. }
    868.  
    869. stock Set_WeaponIdleTime(id, WeaponId ,Float:TimeIdle)
    870. {
    871.     static entwpn; entwpn = fm_get_user_weapon_entity(id, WeaponId)
    872.     if(!pev_valid(entwpn))
    873.         return
    874.        
    875.     set_pdata_float(entwpn, 46, TimeIdle, 4)
    876.     set_pdata_float(entwpn, 47, TimeIdle, 4)
    877.     set_pdata_float(entwpn, 48, TimeIdle + 0.5, 4)
    878. }
    879.  
    880. stock Set_PlayerNextAttack(id, Float:nexttime)
    881. {
    882.     set_pdata_float(id, 83, nexttime, 5)
    883. }
    884.  
    885. stock Get_Position(id,Float:forw, Float:right, Float:up, Float:vStart[])
    886. {
    887.     static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
    888.    
    889.     pev(id, pev_origin, vOrigin)
    890.     pev(id, pev_view_ofs,vUp) //for player
    891.     xs_vec_add(vOrigin,vUp,vOrigin)
    892.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
    893.    
    894.     angle_vector(vAngle,ANGLEVECTOR_FORWARD,vForward) //or use EngFunc_AngleVectors
    895.     angle_vector(vAngle,ANGLEVECTOR_RIGHT,vRight)
    896.     angle_vector(vAngle,ANGLEVECTOR_UP,vUp)
    897.    
    898.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
    899.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
    900.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
    901. }
    902. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
    903. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1042\\ f0\\ fs16 \n\\ par }
    904. */
  • Weapons Menu:
    1. #include <zombie_escape>
    2. #include <ze_levels>
    3.  
    4. native give_golden_m3(id);
    5. native give_golden_mp5(id);
    6. native give_golden_m4a1(id);
    7. native give_golden_ak47(id);
    8. native give_darknight_m4a1(id);
    9.  
    10. // Setting File
    11. new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
    12.  
    13. // Keys
    14. const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
    15. const OFFSET_CSMENUCODE = 205
    16.  
    17. // Primary Weapons Entities [Default Values]
    18. new const szPrimaryWeaponEnt[][] =
    19. {
    20.     "weapon_xm1014",  // Level 0
    21.     "weapon_ump45",   // Level 0
    22.     "weapon_m3",      // Level 1
    23.     "weapon_mp5navy", // Level 2
    24.     "weapon_p90",     // Level 3
    25.     "weapon_galil",   // Level 4
    26.     "weapon_famas",   // Level 5
    27.     "weapon_sg550",   // Level 6
    28.     "weapon_g3sg1",   // Level 7
    29.     "weapon_m249",    // Level 8
    30.     "weapon_sg552",   // Level 9
    31.     "weapon_aug",     // Level 10
    32.     "weapon_m4a1",    // Level 11
    33.     "weapon_ak47"     // Level 12
    34. }
    35.  
    36. // Secondary Weapons Entities [Default Values]
    37. new const szSecondaryWeaponEnt[][]=
    38. {
    39.     "weapon_usp",         // Level 0
    40.     "weapon_p228",        // Level 0
    41.     "weapon_glock18",     // Level 1
    42.     "weapon_fiveseven",   // Level 2
    43.     "weapon_deagle",      // Level 3
    44.     "weapon_elite"        // Level 4
    45. }
    46.  
    47. // Primary and Secondary Weapons Names [Default Values]
    48. new const szWeaponNames[][] =
    49. {
    50.     "",
    51.     "P228",
    52.     "",
    53.     "Scout",
    54.     "HE Grenade",
    55.     "XM1014",
    56.     "",
    57.     "MAC-10",
    58.     "AUG",
    59.     "Smoke Grenade",
    60.     "Dual Elite",
    61.     "Five Seven",
    62.     "UMP 45",
    63.     "SG-550",
    64.     "Galil",
    65.     "Famas",
    66.     "USP",
    67.     "Glock",
    68.     "AWP",
    69.     "MP5",
    70.     "M249",
    71.     "M3",
    72.     "M4A1",
    73.     "TMP",
    74.     "G3SG1",
    75.     "Flashbang",
    76.     "Desert Eagle",
    77.     "SG-552",
    78.     "AK-47",
    79.     "",
    80.     "P90"
    81. }
    82.  
    83. // Max Back Clip Ammo (Change it From here if you need)
    84. new const szMaxBPAmmo[] =
    85. {
    86.     -1,
    87.     52,
    88.     -1,
    89.     90,
    90.     1,
    91.     32,
    92.     1,
    93.     100,
    94.     90,
    95.     1,
    96.     120,
    97.     100,
    98.     100,
    99.     90,
    100.     90,
    101.     90,
    102.     100,
    103.     120,
    104.     30,
    105.     120,
    106.     200,
    107.     32,
    108.     90,
    109.     120,
    110.     90,
    111.     2,
    112.     35,
    113.     90,
    114.     90,
    115.     -1,
    116.     100
    117. }
    118.  
    119. // Menu selections
    120. const MENU_KEY_AUTOSELECT = 7
    121. const MENU_KEY_BACK = 7
    122. const MENU_KEY_NEXT = 8
    123. const MENU_KEY_EXIT = 9
    124.  
    125. // Variables
    126. new Array:g_szPrimaryWeapons, Array:g_szSecondaryWeapons
    127.  
    128. new g_iMenuData[33][4],
    129.     Float:g_fBuyTimeStart[33],
    130.     bool:g_bBoughtPrimary[33],
    131.     bool:g_bBoughtSecondary[33],
    132.     WPN_MAXIDS[33]
    133.  
    134. // Define
    135. #define WPN_STARTID g_iMenuData[id][0]
    136. #define WPN_SELECTION (g_iMenuData[id][0]+key)
    137. #define WPN_AUTO_ON g_iMenuData[id][1]
    138. #define WPN_AUTO_PRI g_iMenuData[id][2]
    139. #define WPN_AUTO_SEC g_iMenuData[id][3]
    140.  
    141. // Cvars
    142. new g_pCvarBuyTime,
    143.     g_pCvarHeGrenade,
    144.     g_pCvarSmokeGrenade,
    145.     g_pCvarFlashGrenade,
    146.     g_pCvarBlockWeapLowLevel
    147.  
    148. public plugin_natives()
    149. {
    150.     register_native("ze_show_weapon_menu", "native_ze_show_weapon_menu", 1)
    151.     register_native("ze_is_auto_buy_enabled", "native_ze_is_auto_buy_enabled", 1)
    152.     register_native("ze_disable_auto_buy", "native_ze_disable_auto_buy", 1)
    153. }
    154.  
    155. public plugin_precache()
    156. {
    157.     // Initialize arrays (32 is the max length of Weapon Entity like: weapon_ak47)
    158.     g_szPrimaryWeapons = ArrayCreate(32, 1)
    159.     g_szSecondaryWeapons = ArrayCreate(32, 1)
    160.    
    161.     // Load from external file
    162.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    163.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    164.    
    165.     // If we couldn't load from file, use and save default ones
    166.    
    167.     new iIndex
    168.    
    169.     if (ArraySize(g_szPrimaryWeapons) == 0)
    170.     {
    171.         for (iIndex = 0; iIndex < sizeof szPrimaryWeaponEnt; iIndex++)
    172.             ArrayPushString(g_szPrimaryWeapons, szPrimaryWeaponEnt[iIndex])
    173.        
    174.         // If not found .ini File Create it and save default values in it
    175.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    176.     }
    177.    
    178.     if (ArraySize(g_szSecondaryWeapons) == 0)
    179.     {
    180.         for (iIndex = 0; iIndex < sizeof szSecondaryWeaponEnt; iIndex++)
    181.             ArrayPushString(g_szSecondaryWeapons, szSecondaryWeaponEnt[iIndex])
    182.        
    183.         // If not found .ini File Create it and save default values in it
    184.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    185.     }
    186. }
    187.  
    188. public plugin_init()
    189. {
    190.     register_plugin("[ZE] Levels Weapons Menu", "1.1", "Raheem")
    191.    
    192.     // Commands
    193.     register_clcmd("guns", "Cmd_Buy")
    194.     register_clcmd("say /enable", "Cmd_Enable")
    195.     register_clcmd("say_team /enable", "Cmd_Enable")
    196.    
    197.     // Cvars
    198.     g_pCvarBuyTime = register_cvar("ze_buy_time", "60")
    199.     g_pCvarHeGrenade = register_cvar("ze_give_HE_nade", "1") // 0 Nothing || 1 Give HE
    200.     g_pCvarSmokeGrenade = register_cvar("ze_give_SM_nade", "1")
    201.     g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "1")
    202.     g_pCvarBlockWeapLowLevel = register_cvar("ze_block_weapons_lowlvl", "1")
    203.    
    204.     // Menus
    205.     register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
    206.     register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
    207.    
    208.     // Hams
    209.     RegisterHam(Ham_Touch, "weaponbox", "Fw_TouchWeapon_Pre", 0)
    210.     RegisterHam(Ham_Touch, "armoury_entity", "Fw_TouchWeapon_Pre", 0)
    211. }
    212.  
    213. public client_disconnected(id)
    214. {
    215.     WPN_AUTO_ON = 0
    216.     WPN_STARTID = 0
    217. }
    218.  
    219. public Cmd_Enable(id)
    220. {
    221.     if (WPN_AUTO_ON)
    222.     {
    223.         ze_colored_print(id, "%L", LANG_PLAYER, "BUY_ENABLED")
    224.         WPN_AUTO_ON = 0
    225.     }
    226. }
    227.  
    228. public Cmd_Buy(id)
    229. {
    230.     // Player Zombie
    231.     if (ze_is_user_zombie(id))
    232.     {
    233.         ze_colored_print(id, "%L", LANG_PLAYER, "NO_BUY_ZOMBIE")
    234.         return
    235.     }
    236.    
    237.     // Player Dead
    238.     if (!is_user_alive(id))
    239.     {
    240.         ze_colored_print(id, "%L", LANG_PLAYER, "DEAD_CANT_BUY_WEAPON")
    241.         return
    242.     }
    243.    
    244.     // Already bought
    245.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    246.     {
    247.         ze_colored_print(id, "%L", LANG_PLAYER, "ALREADY_BOUGHT")
    248.     }
    249.    
    250.     Show_Available_Buy_Menus(id)
    251. }
    252.  
    253. public ze_user_humanized(id)
    254. {
    255.     // Static Values
    256.     switch (ze_get_user_level(id))
    257.     {
    258.         case 0: WPN_MAXIDS[id] = 2
    259.         case 1: WPN_MAXIDS[id] = 3
    260.         case 2: WPN_MAXIDS[id] = 4
    261.         case 3: WPN_MAXIDS[id] = 5
    262.         case 4: WPN_MAXIDS[id] = 6
    263.         case 5: WPN_MAXIDS[id] = 7
    264.         case 6: WPN_MAXIDS[id] = 8
    265.         case 7: WPN_MAXIDS[id] = 9
    266.         case 8: WPN_MAXIDS[id] = 10
    267.         case 9: WPN_MAXIDS[id] = 11
    268.         case 10: WPN_MAXIDS[id] = 12
    269.         case 11: WPN_MAXIDS[id] = 13
    270.         case 12..14: WPN_MAXIDS[id] = 14
    271.         case 15..19: WPN_MAXIDS[id] = 15 // Golden m3
    272.         case 20..24: WPN_MAXIDS[id] = 16 // Golden MP5
    273.         case 25..29: WPN_MAXIDS[id] = 17 // Golden M4A1
    274.         case 30..34: WPN_MAXIDS[id] = 18 // Golden AK47
    275.         case 35: WPN_MAXIDS[id] = 19     // DarkNight M4A1
    276.     }
    277.    
    278.     if (ze_get_user_level(id) > 35)
    279.     {
    280.         WPN_MAXIDS[id] = 19
    281.     }
    282.  
    283.     // Buyzone time starts when player is set to human
    284.     g_fBuyTimeStart[id] = get_gametime()
    285.    
    286.     g_bBoughtPrimary[id] = false
    287.     g_bBoughtSecondary[id] = false
    288.    
    289.     // Player dead or zombie
    290.     if (!is_user_alive(id) || ze_is_user_zombie(id))
    291.         return
    292.    
    293.     if (WPN_AUTO_ON)
    294.     {
    295.         ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
    296.         Buy_Primary_Weapon(id, WPN_AUTO_PRI)
    297.         Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
    298.     }
    299.    
    300.     // Open available buy menus
    301.     Show_Available_Buy_Menus(id)
    302.    
    303.     // Give HE Grenade
    304.     if (get_pcvar_num(g_pCvarHeGrenade) != 0)
    305.         rg_give_item(id, "weapon_hegrenade")
    306.    
    307.     // Give Smoke Grenade
    308.     if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
    309.         rg_give_item(id, "weapon_smokegrenade")
    310.    
    311.     // Give Flashbang Grenade
    312.     if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
    313.         rg_give_item(id, "weapon_flashbang")
    314. }
    315.  
    316. public Show_Available_Buy_Menus(id)
    317. {
    318.     // Already Bought
    319.     if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    320.         return
    321.    
    322.     // Here we use if and else if so we make sure that Primary weapon come first then secondary
    323.     if (!g_bBoughtPrimary[id])
    324.     {
    325.         // Primary     
    326.         Show_Menu_Buy_Primary(id)
    327.     }
    328.     else if (!g_bBoughtSecondary[id])
    329.     {
    330.         // Secondary
    331.         Show_Menu_Buy_Secondary(id)
    332.     }
    333. }
    334.  
    335. public Show_Menu_Buy_Primary(id)
    336. {
    337.     new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
    338.    
    339.     if (iMenuTime <= 0)
    340.     {
    341.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
    342.         return
    343.     }
    344.    
    345.     static szMenu[300], szWeaponName[32]
    346.     new iLen, iIndex, iMaxLoops = min(WPN_STARTID+7, WPN_MAXIDS[id])
    347.    
    348.     // Title
    349.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L \w[\r%d\w-\r%d\w]^n^n", id, "MENU_PRIMARY_TITLE", WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS[id]))
    350.    
    351.     // 1-7. Weapon List
    352.     for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
    353.     {
    354.         if (ze_get_user_level(id) == 0 && iIndex >= 2||
    355.         ze_get_user_level(id) == 1 && iIndex >= 3 ||
    356.         ze_get_user_level(id) == 2 && iIndex >= 4 ||
    357.         ze_get_user_level(id) == 3 && iIndex >= 5 ||
    358.         ze_get_user_level(id) == 4 && iIndex >= 6 ||
    359.         ze_get_user_level(id) == 5 && iIndex >= 7 ||
    360.         ze_get_user_level(id) == 6 && iIndex >= 8 ||
    361.         ze_get_user_level(id) == 7 && iIndex >= 9 ||
    362.         ze_get_user_level(id) == 8 && iIndex >= 10 ||
    363.         ze_get_user_level(id) == 9 && iIndex >= 11 ||
    364.         ze_get_user_level(id) == 10 && iIndex >= 12 ||
    365.         ze_get_user_level(id) == 11 && iIndex >= 13 ||
    366.         ze_get_user_level(id) == 12 && iIndex >= 14)
    367.         {
    368.             break
    369.         }
    370.        
    371.         /*
    372.         *  Note that WPN_MAXIDS start from 1 but iIndex start from 0.
    373.         */
    374.        
    375.         // Golden M3
    376.         if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20)
    377.         {
    378.             if (iIndex == 14)
    379.             {
    380.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
    381.                 break;
    382.             }
    383.         }
    384.        
    385.         // Golden MP5
    386.         if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25)
    387.         {
    388.             if (iIndex == 14)
    389.             {
    390.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
    391.             }
    392.            
    393.             if (iIndex == 15)
    394.             {
    395.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
    396.                 break;
    397.             }
    398.         }
    399.        
    400.         // Golden M4A1
    401.         if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30)
    402.         {
    403.             if (iIndex == 14)
    404.             {
    405.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
    406.             }
    407.            
    408.             if (iIndex == 15)
    409.             {
    410.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
    411.             }
    412.            
    413.             if (iIndex == 16)
    414.             {
    415.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
    416.                 break;
    417.             }
    418.         }
    419.        
    420.         // Golden AK47
    421.         if (ze_get_user_level(id) >= 30)
    422.         {
    423.             if (iIndex == 14)
    424.             {
    425.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
    426.             }
    427.            
    428.             if (iIndex == 15)
    429.             {
    430.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
    431.             }
    432.            
    433.             if (iIndex == 16)
    434.             {
    435.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
    436.             }
    437.            
    438.             if (iIndex == 17)
    439.             {
    440.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
    441.                 break;
    442.             }
    443.         }
    444.        
    445.         if (ze_get_user_level(id) >= 35)
    446.         {
    447.             if (iIndex == 14)
    448.             {
    449.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M3")
    450.             }
    451.            
    452.             if (iIndex == 15)
    453.             {
    454.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
    455.             }
    456.            
    457.             if (iIndex == 16)
    458.             {
    459.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
    460.             }
    461.            
    462.             if (iIndex == 17)
    463.             {
    464.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden AK-47")
    465.             }
    466.            
    467.             if (iIndex == 18)
    468.             {
    469.                 iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "DarkNight M4A1")
    470.                 break;
    471.             }
    472.         }
    473.        
    474.         // Must check if iIndex < 14 means max is AK47
    475.         if (iIndex < 14)
    476.         {
    477.             ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    478.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
    479.         }
    480.     }
    481.    
    482.     if (iIndex < 7)
    483.     {
    484.         ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    485.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    486.     }
    487.    
    488.     if (ze_get_user_level(id) == 5)
    489.     {
    490.         ArrayGetString(g_szPrimaryWeapons, 7, szWeaponName, charsmax(szWeaponName))
    491.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    492.     }
    493.     else if (ze_get_user_level(id) == 6)
    494.     {
    495.         ArrayGetString(g_szPrimaryWeapons, 8, szWeaponName, charsmax(szWeaponName))
    496.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    497.     }
    498.     else if (ze_get_user_level(id) == 7)
    499.     {
    500.         ArrayGetString(g_szPrimaryWeapons, 9, szWeaponName, charsmax(szWeaponName))
    501.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    502.     }
    503.     else if (ze_get_user_level(id) == 8)
    504.     {
    505.         ArrayGetString(g_szPrimaryWeapons, 10, szWeaponName, charsmax(szWeaponName))
    506.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    507.     }
    508.     else if (ze_get_user_level(id) == 9)
    509.     {
    510.         ArrayGetString(g_szPrimaryWeapons, 11, szWeaponName, charsmax(szWeaponName))
    511.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    512.     }
    513.     else if (ze_get_user_level(id) == 10)
    514.     {
    515.         ArrayGetString(g_szPrimaryWeapons, 12, szWeaponName, charsmax(szWeaponName))
    516.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    517.     }
    518.     else if (ze_get_user_level(id) == 11)
    519.     {
    520.         ArrayGetString(g_szPrimaryWeapons, 13, szWeaponName, charsmax(szWeaponName))
    521.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    522.     }
    523.     else if (ze_get_user_level(id) >= 12 && ze_get_user_level(id) < 15) // Golden M3
    524.     {
    525.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yGolden M3^n")
    526.     }
    527.     else if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20) // Golden MP5
    528.     {
    529.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 20 Unlock\w: \yGolden MP5^n")
    530.     }
    531.     else if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25) // Golden M4A1
    532.     {
    533.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 25 Unlock\w: \yGolden M4A1^n")
    534.     }
    535.     else if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30) // Golden Ak-47
    536.     {
    537.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yGolden AK-47^n")
    538.     }
    539.     else if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 35) // DarkNight M4A1
    540.     {
    541.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yDarkNight M4A1^n")
    542.     }
    543.  
    544.     // 8. Auto Select
    545.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w8.\y %L \w[\r%L\w]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
    546.    
    547.     // 9. Next/Back - 0. Exit
    548.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\y9.\r %L \w/ \r%L^n^n\w0.\y %L", id, "NEXT", id, "BACK", id, "EXIT")
    549.    
    550.     // Fix for AMXX custom menus
    551.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    552.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
    553. }
    554.  
    555. public Show_Menu_Buy_Secondary(id)
    556. {
    557.     new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
    558.    
    559.     if (iMenuTime <= 0)
    560.     {
    561.         ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
    562.         return
    563.     }
    564.    
    565.     static szMenu[250], szWeaponName[32]
    566.     new iLen, iIndex, iMaxLoops = ArraySize(g_szSecondaryWeapons)
    567.    
    568.     // Title
    569.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L^n", id, "MENU_SECONDARY_TITLE")
    570.    
    571.     // 1-6. Weapon List
    572.     for (iIndex = 0; iIndex < iMaxLoops; iIndex++)
    573.     {
    574.         if (ze_get_user_level(id) == 0 && iIndex >= 2 ||
    575.         ze_get_user_level(id) == 1 && iIndex >= 3 ||
    576.         ze_get_user_level(id) == 2 && iIndex >= 4 ||
    577.         ze_get_user_level(id) == 3 && iIndex >= 5 ||
    578.         ze_get_user_level(id) == 4 && iIndex >= 6)
    579.         {
    580.             break
    581.         }
    582.        
    583.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    584.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w%d.\y %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
    585.     }
    586.    
    587.     if (iIndex < ArraySize(g_szSecondaryWeapons))
    588.     {
    589.         ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
    590.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r Next Level Unlock\w: \y%s", szWeaponNames[get_weaponid(szWeaponName)])
    591.     }
    592.    
    593.     // 8. Auto Select
    594.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w8.\y %L \w[\r%L\w]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
    595.    
    596.     // 0. Exit
    597.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\y %L", id, "EXIT")
    598.    
    599.     // Fix for AMXX custom menus
    600.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    601.     show_menu(id, KEYSMENU, szMenu, iMenuTime, "Secondary Weapons")
    602. }
    603.  
    604. public Menu_Buy_Primary(id, key)
    605. {
    606.     // Player dead or zombie or already bought primary
    607.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtPrimary[id])
    608.         return PLUGIN_HANDLED
    609.    
    610.     // Special keys / weapon list exceeded
    611.     if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS[id])
    612.     {
    613.         switch (key)
    614.         {
    615.             case MENU_KEY_AUTOSELECT: // toggle auto select
    616.             {
    617.                 WPN_AUTO_ON = 1 - WPN_AUTO_ON
    618.             }
    619.             case MENU_KEY_NEXT: // next/back
    620.             {
    621.                 if (WPN_STARTID+7 < WPN_MAXIDS[id])
    622.                     WPN_STARTID += 7
    623.                 else
    624.                     WPN_STARTID = 0
    625.             }
    626.             case MENU_KEY_EXIT: // exit
    627.             {
    628.                 return PLUGIN_HANDLED
    629.             }
    630.         }
    631.        
    632.         // Show buy menu again
    633.         Show_Menu_Buy_Primary(id)
    634.         return PLUGIN_HANDLED
    635.     }
    636.    
    637.     // Store selected weapon id
    638.     WPN_AUTO_PRI = WPN_SELECTION
    639.    
    640.     // Buy primary weapon
    641.     Buy_Primary_Weapon(id, WPN_AUTO_PRI)
    642.    
    643.     // Show Secondary Weapons
    644.     Show_Available_Buy_Menus(id)
    645.    
    646.     return PLUGIN_HANDLED
    647. }
    648.  
    649. public Buy_Primary_Weapon(id, selection)
    650. {
    651.     if (selection == 14) // Golden M3
    652.     {
    653.         give_golden_m3(id)
    654.         g_bBoughtPrimary[id] = true
    655.         return true;
    656.     }
    657.     else if (selection == 15) // Golden MP5
    658.     {
    659.         give_golden_mp5(id)
    660.         g_bBoughtPrimary[id] = true
    661.         return true;
    662.     }
    663.     else if (selection == 16) // Golden M4A1
    664.     {
    665.         give_golden_m4a1(id)
    666.         g_bBoughtPrimary[id] = true
    667.         return true;
    668.     }
    669.     else if (selection == 17) // Golden AK47
    670.     {
    671.         give_golden_ak47(id)
    672.         g_bBoughtPrimary[id] = true
    673.         return true;
    674.     }
    675.     else if (selection == 18) // Golden AK47
    676.     {
    677.         give_darknight_m4a1(id)
    678.         g_bBoughtPrimary[id] = true
    679.         return true;
    680.     }
    681.    
    682.     static szWeaponName[32]
    683.     ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    684.     new iWeaponId = get_weaponid(szWeaponName)
    685.    
    686.     // Strip and Give Full Weapon
    687.     rg_give_item(id, szWeaponName, GT_REPLACE)
    688.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    689.    
    690.     // Primary bought
    691.     g_bBoughtPrimary[id] = true
    692.     return true;
    693. }
    694.  
    695. public Menu_Buy_Secondary(id, key)
    696. {
    697.     // Player dead or zombie or already bought secondary
    698.     if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
    699.         return PLUGIN_HANDLED
    700.    
    701.     // Special keys / weapon list exceeded
    702.     if (key >= ArraySize(g_szSecondaryWeapons))
    703.     {
    704.         // Toggle autoselect
    705.         if (key == MENU_KEY_AUTOSELECT)
    706.             WPN_AUTO_ON = 1 - WPN_AUTO_ON
    707.        
    708.         // Reshow menu unless user exited
    709.         if (key != MENU_KEY_EXIT)
    710.             Show_Menu_Buy_Secondary(id)
    711.        
    712.         return PLUGIN_HANDLED
    713.     }
    714.    
    715.     // Store selected weapon id
    716.     WPN_AUTO_SEC = key
    717.    
    718.     // Buy secondary weapon
    719.     Buy_Secondary_Weapon(id, key)
    720.    
    721.     return PLUGIN_HANDLED
    722. }
    723.  
    724. public Buy_Secondary_Weapon(id, selection)
    725. {
    726.     if ( ((selection == 2) && (ze_get_user_level(id) < 1)) ||
    727.     ((selection == 3) && (ze_get_user_level(id) < 2)) ||
    728.     ((selection == 4) && (ze_get_user_level(id) < 3)) ||
    729.     ((selection == 5) && (ze_get_user_level(id) < 4)) )
    730.     {
    731.         Show_Menu_Buy_Secondary(id)
    732.         return;
    733.     }
    734.  
    735.     static szWeaponName[32]
    736.     ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    737.     new iWeaponId = get_weaponid(szWeaponName)
    738.    
    739.     // Strip and Give Full Weapon
    740.     rg_give_item(id, szWeaponName, GT_REPLACE)
    741.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    742.    
    743.     // Secondary bought
    744.     g_bBoughtSecondary[id] = true
    745. }
    746.  
    747. public Fw_TouchWeapon_Pre(iEnt, id)
    748. {
    749.     if (get_pcvar_num(g_pCvarBlockWeapLowLevel) == 0)
    750.         return HAM_IGNORED;
    751.    
    752.     // Not alive or Not Valid Weapon?
    753.     if(!is_user_alive(id) || !pev_valid(iEnt))
    754.         return HAM_IGNORED;
    755.    
    756.     // Get Weapon Model
    757.     new szWeapModel[32]
    758.     pev(iEnt, pev_model, szWeapModel, charsmax(szWeapModel))
    759.    
    760.     // Remove "models/w_" and ".mdl"
    761.     copyc(szWeapModel, charsmax(szWeapModel), szWeapModel[contain(szWeapModel, "_" ) + 1], '.')
    762.    
    763.     // Set for mp5 to be same as "weapon_mp5navy"
    764.     if(szWeapModel[1] == 'p' && szWeapModel[2] == '5')
    765.         szWeapModel = "mp5navy"
    766.    
    767.     // Add "weapon_" to all model names
    768.     static szWeaponEnt[32]
    769.     formatex(szWeaponEnt, charsmax(szWeaponEnt), "weapon_%s", szWeapModel)
    770.  
    771.     // Get it's index in Weapon Array
    772.     new iIndex, i
    773.    
    774.     // I won't explain the blew code if you need to understand ask me in Escapers-Zone.XYZ
    775.     for (i = 0; i < ArraySize(g_szPrimaryWeapons); i++)
    776.     {
    777.         new szPrimaryWeapon[32]
    778.         ArrayGetString(g_szPrimaryWeapons, i, szPrimaryWeapon, charsmax(szPrimaryWeapon))
    779.        
    780.         if (equali(szWeaponEnt, szPrimaryWeapon))
    781.             iIndex = i
    782.     }
    783.    
    784.     if (ze_get_user_level(id) == 0 && iIndex > 1)
    785.     {
    786.         return HAM_SUPERCEDE;
    787.     }
    788.    
    789.     for (i = 1; i <= 11; i++)
    790.     {
    791.         if ((ze_get_user_level(id) == i) && iIndex > i+1)
    792.         {
    793.             return HAM_SUPERCEDE;
    794.         }
    795.     }
    796.    
    797.     return HAM_IGNORED;
    798. }
    799.  
    800. // Natives
    801. public native_ze_show_weapon_menu(id)
    802. {
    803.     if (!is_user_connected(id))
    804.     {
    805.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    806.         return false
    807.     }
    808.    
    809.     Cmd_Buy(id)
    810.     return true
    811. }
    812.  
    813. public native_ze_is_auto_buy_enabled(id)
    814. {
    815.     if (!is_user_connected(id))
    816.     {
    817.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    818.         return -1;
    819.     }
    820.    
    821.     return WPN_AUTO_ON;
    822. }
    823.  
    824. public native_ze_disable_auto_buy(id)
    825. {
    826.     if (!is_user_connected(id))
    827.     {
    828.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    829.         return false
    830.     }
    831.    
    832.     WPN_AUTO_ON = 0;
    833.     return true
    834. }
He who fails to plan is planning to fail

BandiT
Member
Member
Romania
Posts: 59
Joined: 4 years ago
Contact:

#6

Post by BandiT » 4 years ago

I already make IT thank you anyway :)

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

#7

Post by Luxurious » 4 years ago

BandiT wrote: 4 years ago I already make IT thank you anyway :)
can u send it ?
DRK Zombie-Escape V1.6
IP : 81.169.153.129:27015

Post Reply

Create an account or sign in to join the discussion

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

Create an account

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

Register

Sign in

Who is online

Users browsing this forum: No registered users and 6 guests