Available Backweapons BUG!

Unpaid Requests, Public Plugins
Post Reply
Templaso
Senior Member
Senior Member
Romania
Posts: 119
Joined: 5 years ago
Location: Bucharest
Contact:

Backweapons BUG!

#1

Post by Templaso » 5 years ago

when the round begins, the gun remains behind at the zm and just humans should to have the weapons!
Attachments
2844172.5000000442_20181017170202_1.jpg
2202716.400000034_20181017170423_1.jpg

Rain1153
Senior Member
Senior Member
India
Posts: 278
Joined: 6 years ago
Contact:

#2

Post by Rain1153 » 5 years ago

Post your code
LOL

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

#3

Post by Templaso » 5 years ago

  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <hamsandwich>
  4.  
  5. #define PLUGIN  "Back Weapons"
  6. #define AUTHOR  "hoboman313/cheap_suit"
  7. #define VERSION "1.87"
  8.  
  9. #define MAX_PLAYERS         32
  10. #define OFFSET_PRIMARYWEAPON    116
  11. #define OFFSET_WEAPONTYPE   43
  12. #define EXTRAOFFSET_WEAPONS     4
  13. #define OFFSET_AUTOSWITCH   509
  14. #define OFFSET_SHIELD       510
  15. #define HAS_SHIELD      (1<<24)
  16.  
  17. #define PRIMARY_WEAPONS (1<<CSW_SCOUT | 1<<CSW_XM1014 | 1<<CSW_MAC10 | 1<<CSW_AUG | 1<<CSW_UMP45 | 1<<CSW_SG550 | 1<<CSW_GALIL | 1<<CSW_FAMAS | 1<<CSW_AWP | 1<<CSW_MP5NAVY | 1<<CSW_M249 | 1<<CSW_M3 | 1<<CSW_M4A1 | 1<<CSW_TMP | 1<<CSW_G3SG1 | 1<<CSW_SG552 | 1<<CSW_AK47 | 1<<CSW_P90)
  18.  
  19. #define is_weapon_primary(%1)      (PRIMARY_WEAPONS & (1<<%1))
  20. #define cs_get_weapon_type(%1)     get_pdata_int(%1, OFFSET_WEAPONTYPE, EXTRAOFFSET_WEAPONS)
  21. #define cs_get_user_hasprim(%1)    get_pdata_int(%1, OFFSET_PRIMARYWEAPON)
  22. #define cs_get_user_autoswitch(%1) get_pdata_int(%1, OFFSET_AUTOSWITCH)
  23. #define cs_get_user_shield(%1)     (get_pdata_int(%1, OFFSET_SHIELD) & HAS_SHIELD) ? 1 : 0
  24.  
  25. enum
  26. {
  27.     MODEL_NULL    = 0,
  28.     MODEL_AUG     = 1,
  29.     MODEL_AK47    = 2,
  30.     MODEL_AWP     = 3,
  31.     MODEL_MP5NAVY = 4,
  32.     MODEL_P90     = 5,
  33.     MODEL_GALIL   = 6,
  34.     MODEL_M4A1    = 7,
  35.     MODEL_SG550   = 8,
  36.     MODEL_SG552   = 9,
  37.     MODEL_SCOUT   = 10,
  38.     MODEL_XM1014  = 11,
  39.     MODEL_M3      = 12,
  40.     MODEL_G3SG1   = 13,
  41.     MODEL_M249    = 14,
  42.     MODEL_FAMAS   = 15,
  43.     MODEL_UMP45   = 16
  44. }
  45.  
  46. new g_weapons[][] =
  47. {  
  48.     "weapon_p228",
  49.     "weapon_scout",
  50.     "weapon_hegrenade",
  51.     "weapon_xm1014",
  52.     "weapon_c4",
  53.     "weapon_mac10",
  54.     "weapon_aug",
  55.     "weapon_smokegrenade",
  56.     "weapon_elite",
  57.     "weapon_fiveseven",
  58.     "weapon_ump45",
  59.     "weapon_sg550",
  60.     "weapon_galil",
  61.     "weapon_famas",
  62.     "weapon_usp",
  63.     "weapon_glock18",
  64.     "weapon_awp",
  65.     "weapon_mp5navy",
  66.     "weapon_m249",
  67.     "weapon_m3",
  68.     "weapon_m4a1",
  69.     "weapon_tmp",
  70.     "weapon_g3sg1",
  71.     "weapon_flashbang",
  72.     "weapon_deagle",
  73.     "weapon_sg552",
  74.     "weapon_ak47",
  75.     "weapon_knife",
  76.     "weapon_p90"
  77. }
  78.  
  79. new g_weaponclass[] = "backweapon"
  80. new g_weaponmodel[] = "models/backweapons.mdl"
  81.  
  82. new g_weaponent[MAX_PLAYERS+1]
  83.  
  84. public plugin_init()
  85. {
  86.     register_plugin(PLUGIN, VERSION, AUTHOR)
  87.     register_cvar(PLUGIN, VERSION, FCVAR_SPONLY|FCVAR_SERVER)
  88.    
  89.     RegisterHam(Ham_Killed,           "player", "bacon_killed")
  90.     RegisterHam(Ham_Spawn,            "player", "bacon_spawn_post", 1)
  91.     RegisterHam(Ham_AddPlayerItem,    "player", "bacon_addplayeritem")
  92.     RegisterHam(Ham_RemovePlayerItem, "player", "bacon_removeplayeritem")
  93.    
  94.     for(new i = 0; i < sizeof g_weapons; i++)
  95.     {
  96.         RegisterHam(Ham_Item_AttachToPlayer, g_weapons[i], "bacon_item_attachtoplayer_post", 1)
  97.         RegisterHam(Ham_Item_Deploy,         g_weapons[i], "bacon_item_deploy_post",         1)
  98.     }
  99. }
  100.  
  101. public plugin_precache()
  102.     precache_model(g_weaponmodel)
  103.  
  104. public client_putinserver(id)
  105. {
  106.     static infotarget
  107.     if(!infotarget) infotarget = engfunc(EngFunc_AllocString, "info_target")
  108.    
  109.     g_weaponent[id] = engfunc(EngFunc_CreateNamedEntity, infotarget)
  110.     if(pev_valid(g_weaponent[id]))
  111.     {
  112.         engfunc(EngFunc_SetModel, g_weaponent[id], g_weaponmodel)
  113.         set_pev(g_weaponent[id], pev_classname, g_weaponclass)
  114.         set_pev(g_weaponent[id], pev_movetype, MOVETYPE_FOLLOW)
  115.         set_pev(g_weaponent[id], pev_effects, EF_NODRAW)
  116.         set_pev(g_weaponent[id], pev_aiment, id)
  117.     }
  118. }
  119.  
  120. public client_disconnect(id)
  121. {
  122.     if(g_weaponent[id] > 0 && pev_valid(g_weaponent[id]))
  123.         engfunc(EngFunc_RemoveEntity, g_weaponent[id])
  124.    
  125.     g_weaponent[id] = 0
  126. }
  127.  
  128. public bacon_killed(id, idattacker, shouldgib)
  129.     fm_set_entity_visibility(g_weaponent[id], 0)
  130.  
  131. public bacon_addplayeritem(id, ent)
  132. {
  133.     static weaponid; weaponid = cs_get_weapon_type(ent)
  134.     if(is_weapon_primary(weaponid) && pev_valid(g_weaponent[id]))
  135.     {
  136.         fm_set_entity_visibility(g_weaponent[id], 0)
  137.         set_pev(g_weaponent[id], pev_body, get_weapon_model(weaponid))
  138.     }
  139. }
  140.  
  141. public bacon_removeplayeritem(id, ent)
  142. {
  143.     if(is_weapon_primary(cs_get_weapon_type(ent)) && pev_valid(g_weaponent[id]))
  144.         fm_set_entity_visibility(g_weaponent[id], 0)
  145. }
  146.  
  147. public bacon_spawn_post(id) if(is_user_alive(id))
  148. {
  149.     if(!cs_get_user_hasprim(id))
  150.         fm_set_entity_visibility(g_weaponent[id], 0)
  151. }
  152.  
  153. public bacon_item_attachtoplayer_post(ent, id) if(is_user_alive(id) && !cs_get_user_autoswitch(id))
  154. {
  155.     if(is_weapon_primary(cs_get_weapon_type(ent)) && pev_valid(g_weaponent[id]))
  156.         fm_set_entity_visibility(g_weaponent[id], 1)
  157. }
  158.  
  159. public bacon_item_deploy_post(ent)
  160. {
  161.     static id; id = pev(ent, pev_owner)
  162.     if(is_user_alive(id))
  163.     {
  164.         static weapon; weapon = cs_get_weapon_type(ent)
  165.         if(is_weapon_primary(weapon) || cs_get_user_shield(id))
  166.             fm_set_entity_visibility(g_weaponent[id], 0)
  167.        
  168.         else if(cs_get_user_hasprim(id))
  169.             fm_set_entity_visibility(g_weaponent[id], 1)
  170.     }
  171. }
  172.  
  173. stock get_weapon_model(weapon)
  174. {
  175.     switch(weapon)
  176.     {
  177.         case CSW_SCOUT:   return MODEL_SCOUT
  178.         case CSW_XM1014:  return MODEL_XM1014
  179.         case CSW_AUG:     return MODEL_AUG
  180.         case CSW_UMP45:   return MODEL_UMP45
  181.         case CSW_SG550:   return MODEL_SG550
  182.         case CSW_GALIL:   return MODEL_GALIL
  183.         case CSW_FAMAS:   return MODEL_FAMAS
  184.         case CSW_AWP:     return MODEL_AWP
  185.         case CSW_MP5NAVY: return MODEL_MP5NAVY
  186.         case CSW_M249:    return MODEL_M249
  187.         case CSW_M3:      return MODEL_M3
  188.         case CSW_M4A1:    return MODEL_M4A1
  189.         case CSW_G3SG1:   return MODEL_G3SG1
  190.         case CSW_SG552:   return MODEL_SG552
  191.         case CSW_AK47:    return MODEL_AK47
  192.         case CSW_P90:     return MODEL_P90
  193.     }
  194.     return 0
  195. }
  196.  
  197. stock fm_set_entity_visibility(index, visible = 1)
  198.     set_pev(index, pev_effects, visible == 1 ? pev(index, pev_effects) & ~EF_NODRAW : pev(index, pev_effects) | EF_NODRAW)

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

#4

Post by Raheem » 5 years ago

He who fails to plan is planning to fail

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: Bing [Bot] and 0 guests