Weapons Menu over write extra items on new round.

Coding Help/Re-API Supported
Post Reply
User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#11

Post by Raheem » 5 years ago

Here i added the native:

  1. #include <zombie_escape>
  2. #include <engine>
  3.  
  4. #define ITEM_NAME "Paintball Gun"
  5. #define ITEM_COST 50
  6.  
  7. new PAINTBALL_V_MODEL[64] = "models/zombie_escape/v_paintballgun.mdl"
  8. new PAINTBALL_P_MODEL[64] = "models/zombie_escape/p_paintballgun.mdl"
  9. new PAINTBALL_W_MODEL[64] = "models/zombie_escape/w_paintballgun.mdl"
  10.  
  11. new g_paintSprite[2][] = {"sprites/bhit.spr", "sprites/richo1.spr"}
  12. new lastammo[33], g_paintball_gun[33], g_ballsnum = 0
  13.  
  14. const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_AK47)|(1<<CSW_M4A1)|(1<<CSW_FAMAS)|(1<<CSW_GALIL)|(1<<CSW_SCOUT)|(1<<CSW_AWP)|(1<<CSW_M249)|(1<<CSW_MP5NAVY)|(1<<CSW_P90)|(1<<CSW_MAC10)|(1<<CSW_TMP)|(1<<CSW_XM1014)|(1<<CSW_M3)|(1<<CSW_G3SG1)|(1<<CSW_SG550)|(1<<CSW_SG552)|(1<<CSW_AUG)|(1<<CSW_UMP45);
  15.  
  16.  
  17. // Cvars //
  18. new paintball_lifetime, paintball_maxballs, paintball_dmg_multi, paintball_unlimited_clip, g_iItemID
  19.  
  20. public plugin_natives()
  21. {
  22.     register_native("is_has_paint_ball_gun", "native_is_has_paint_ball_gun", 1)
  23. }
  24.  
  25. public plugin_init()
  26. {
  27.     register_plugin("[ZE] Extra Item: Paint Ball Gun", "1.1", "KRoTaL | [P]erfec[T] [S]cr[@]s[H] | Mark")
  28.     register_cvar("ze_paintballgun", "1.1", FCVAR_SERVER|FCVAR_UNLOGGED);
  29.    
  30.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  31.     RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_AddToPlayer")
  32.     register_forward(FM_SetModel, "fw_SetModel")
  33.     register_event("CurWeapon", "make_paint", "be", "3>0")
  34.     register_event("WeapPickup","checkModel","b","1=19")
  35.     register_event("CurWeapon","checkWeapon","be","1=1")
  36.     register_event("HLTV", "new_round", "a", "1=0", "2=0")
  37.    
  38.     paintball_maxballs = register_cvar("ze_paintball_maxballs", "200")
  39.     paintball_lifetime = register_cvar("ze_paintball_lifetime", "10")
  40.     paintball_dmg_multi = register_cvar("ze_paintball_dmg_multi", "4")
  41.     paintball_unlimited_clip = register_cvar("ze_paintball_unlimited_clip", "0")
  42.    
  43.     g_iItemID = ze_register_item(ITEM_NAME, ITEM_COST, 0)
  44. }
  45.  
  46. public plugin_precache()
  47. {
  48.     precache_model("sprites/bhit.spr")
  49.     precache_model("sprites/richo1.spr")
  50.     precache_model(PAINTBALL_V_MODEL)
  51.     precache_model(PAINTBALL_P_MODEL)
  52.     precache_model(PAINTBALL_W_MODEL)
  53. }
  54.  
  55. public native_is_has_paint_ball_gun(id)
  56. {
  57.     return g_paintball_gun[id];
  58. }
  59.  
  60. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
  61. {
  62.     if (is_user_alive(attacker) && get_user_weapon(attacker) == CSW_MP5NAVY && g_paintball_gun[attacker] && !ze_is_user_zombie(attacker))
  63.     {
  64.         SetHamParamFloat(4, damage * get_pcvar_float(paintball_dmg_multi ))
  65.        
  66.         set_rendering(victim, kRenderFxGlowShell, random_num(0,255), random_num(0,255), random_num(0,255), kRenderNormal, 16);
  67.         set_task(5.0, "remove_glow", victim)
  68.     }
  69. }
  70.  
  71. public ze_user_humanized(id)
  72. {
  73.     g_paintball_gun[id] = false
  74.     remove_glow(id)
  75. }
  76.  
  77. public ze_user_infected(iVictim)
  78. {
  79.     g_paintball_gun[iVictim] = false
  80.     remove_glow(iVictim)  
  81. }
  82.  
  83. public ze_select_item_pre(id, itemid)
  84. {
  85.     if (itemid != g_iItemID)
  86.         return ZE_ITEM_AVAILABLE
  87.    
  88.     if (ze_is_user_zombie(id))
  89.         return ZE_ITEM_DONT_SHOW
  90.        
  91.     return ZE_ITEM_AVAILABLE
  92. }
  93.  
  94.  
  95. public ze_select_item_post(id, itemid)
  96. {
  97.     if (itemid != g_iItemID)
  98.         return
  99.        
  100.     ze_colored_print(id, "Congrats! You have bought a Paintball Gun! :D")
  101.    
  102.     Get_MyWeapon(id)
  103. }
  104.  
  105. public Get_MyWeapon(id)
  106. {
  107.     drop_weapons(id, 1);
  108.     g_paintball_gun[id] = true
  109.     give_item(id, "weapon_mp5navy")
  110. }
  111.  
  112. public remove_glow(id)
  113. {
  114.     set_rendering(id);
  115. }
  116.  
  117. public checkWeapon(id)
  118. {
  119.     new plrClip, plrAmmo, plrWeap[32], plrWeapId
  120.    
  121.     plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
  122.    
  123.     if (plrWeapId == CSW_MP5NAVY && g_paintball_gun[id])
  124.         checkModel(id)
  125.  
  126.     else return PLUGIN_CONTINUE;
  127.    
  128.     if (plrClip == 0 && get_pcvar_num(paintball_unlimited_clip))
  129.     {
  130.         // If the user is out of ammo..
  131.         get_weaponname(plrWeapId, plrWeap, 31)
  132.         // Get the name of their weapon
  133.         give_item(id, plrWeap)
  134.         engclient_cmd(id, plrWeap)
  135.         engclient_cmd(id, plrWeap)
  136.         engclient_cmd(id, plrWeap)
  137.     }
  138.     return PLUGIN_HANDLED
  139. }
  140.  
  141. public checkModel(id)
  142. {
  143.     if (ze_is_user_zombie(id)) return PLUGIN_HANDLED;
  144.    
  145.     new szWeapID = read_data(2)
  146.    
  147.     if ( szWeapID == CSW_MP5NAVY && g_paintball_gun[id])
  148.     {
  149.         entity_set_string(id, EV_SZ_viewmodel, PAINTBALL_V_MODEL)
  150.         entity_set_string(id, EV_SZ_weaponmodel, PAINTBALL_P_MODEL)
  151.     }
  152.     return PLUGIN_HANDLED
  153. }
  154.  
  155. public make_paint(id)
  156. {
  157.     new ammo = read_data(3)
  158.    
  159.     if(get_user_weapon(id) == CSW_MP5NAVY  && lastammo[id] > ammo && g_paintball_gun[id])
  160.     {
  161.         new iOrigin[3]
  162.         get_user_origin(id, iOrigin, 4)
  163.         new Float:fOrigin[3]
  164.         IVecFVec(iOrigin, fOrigin)
  165.        
  166.         if(g_ballsnum < get_pcvar_num(paintball_maxballs) && worldInVicinity(fOrigin))
  167.         {
  168.             new ent = create_entity("info_target")
  169.             if(ent > 0)
  170.             {
  171.                 entity_set_string(ent, EV_SZ_classname, "paint_ent")
  172.                 entity_set_int(ent, EV_INT_movetype, 0)
  173.                 entity_set_int(ent, EV_INT_solid, 0)
  174.                 entity_set_model(ent, g_paintSprite[random_num(0,1)])
  175.                 new r, g, b
  176.  
  177.                 r = random_num(64,255)
  178.                 g = random_num(64,255)
  179.                 b = random_num(64,255)
  180.                
  181.                 set_rendering(ent, kRenderFxNoDissipation, r, g, b, kRenderGlow, 255)
  182.                 entity_set_origin(ent, fOrigin)
  183.                 entity_set_int(ent, EV_INT_flags, FL_ALWAYSTHINK)
  184.                 entity_set_float(ent, EV_FL_nextthink, get_gametime() + get_pcvar_float(paintball_lifetime))
  185.                 ++g_ballsnum
  186.             }
  187.         }
  188.     }
  189.     lastammo[id] = ammo
  190. }
  191.  
  192. public pfn_think(entity)
  193. {
  194.     if(!is_valid_ent(entity))
  195.         return
  196.    
  197.     new class[32]; entity_get_string(entity, EV_SZ_classname, class, 31)
  198.     if(entity > 0 && equal(class, "paint_ent"))
  199.     {
  200.         remove_entity(entity)
  201.         --g_ballsnum
  202.     }
  203. }
  204.  
  205. public new_round()
  206. {
  207.     for(new id = 1; id <= get_maxplayers(); id++) g_paintball_gun[id] = false
  208.    
  209.     remove_entity_name("paint_ent")
  210.     g_ballsnum = 0
  211. }
  212.  
  213. stock worldInVicinity(Float:origin[3])
  214. {
  215.     new ent = find_ent_in_sphere(-1, origin, 4.0)
  216.     while(ent > 0)
  217.     {
  218.         if(entity_get_float(ent, EV_FL_health) > 0 || entity_get_float(ent, EV_FL_takedamage) > 0.0) return 0;
  219.         ent = find_ent_in_sphere(ent, origin, 4.0)
  220.     }
  221.    
  222.     new Float:traceEnds[8][3], Float:traceHit[3], hitEnt
  223.    
  224.     traceEnds[0][0] = origin[0] - 2.0; traceEnds[0][1] = origin[1] - 2.0; traceEnds[0][2] = origin[2] - 2.0
  225.     traceEnds[1][0] = origin[0] - 2.0; traceEnds[1][1] = origin[1] - 2.0; traceEnds[1][2] = origin[2] + 2.0
  226.     traceEnds[2][0] = origin[0] + 2.0; traceEnds[2][1] = origin[1] - 2.0; traceEnds[2][2] = origin[2] + 2.0
  227.     traceEnds[3][0] = origin[0] + 2.0; traceEnds[3][1] = origin[1] - 2.0; traceEnds[3][2] = origin[2] - 2.0
  228.     traceEnds[4][0] = origin[0] - 2.0; traceEnds[4][1] = origin[1] + 2.0; traceEnds[4][2] = origin[2] - 2.0
  229.     traceEnds[5][0] = origin[0] - 2.0; traceEnds[5][1] = origin[1] + 2.0; traceEnds[5][2] = origin[2] + 2.0
  230.     traceEnds[6][0] = origin[0] + 2.0; traceEnds[6][1] = origin[1] + 2.0; traceEnds[6][2] = origin[2] + 2.0
  231.     traceEnds[7][0] = origin[0] + 2.0; traceEnds[7][1] = origin[1] + 2.0; traceEnds[7][2] = origin[2] - 2.0
  232.    
  233.     for (new i = 0; i < 8; i++)
  234.     {
  235.         if (PointContents(traceEnds[i]) != CONTENTS_EMPTY) return 1;
  236.    
  237.         hitEnt = trace_line(0, origin, traceEnds[i], traceHit)
  238.         if (hitEnt != -1) return 1;
  239.        
  240.         for (new j = 0; j < 3; j++) if (traceEnds[i][j] != traceHit[j]) return 1;
  241.     }
  242.     return 0
  243. }
  244.  
  245. public fw_SetModel(entity, model[])
  246. {
  247.     if(!is_valid_ent(entity))
  248.         return FMRES_IGNORED;
  249.  
  250.     if(!equal(model, "models/w_mp5.mdl"))
  251.         return FMRES_IGNORED;
  252.  
  253.     static szClassName[33]
  254.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  255.     if(!equal(szClassName, "weaponbox")) return FMRES_IGNORED
  256.  
  257.     static iOwner, iStoredMp5ID
  258.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  259.     iStoredMp5ID = find_ent_by_owner(-1, "weapon_mp5navy", entity)
  260.  
  261.     if(g_paintball_gun[iOwner] && is_valid_ent(iStoredMp5ID))
  262.     {
  263.         g_paintball_gun[iOwner] = false
  264.         entity_set_int(iStoredMp5ID, EV_INT_impulse, 1664656581)
  265.         entity_set_model(entity, PAINTBALL_W_MODEL)
  266.  
  267.         return FMRES_SUPERCEDE
  268.     }
  269.     return FMRES_IGNORED
  270. }
  271.  
  272. public fw_AddToPlayer(wpn, id)
  273. {
  274.     if(is_valid_ent(wpn) && is_user_connected(id) && entity_get_int(wpn, EV_INT_impulse) == 1664656581)
  275.     {
  276.         g_paintball_gun[id] = true
  277.         entity_set_int(wpn, EV_INT_impulse, 0)
  278.  
  279.         return HAM_HANDLED
  280.     }
  281.     return HAM_IGNORED
  282. }
  283.  
  284. stock give_item(index, const item[]) {
  285.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
  286.         return 0;
  287.  
  288.     new ent = create_entity(item);
  289.     if (!pev_valid(ent))
  290.         return 0;
  291.  
  292.     new Float:origin[3];
  293.     pev(index, pev_origin, origin);
  294.     set_pev(ent, pev_origin, origin);
  295.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
  296.     dllfunc(DLLFunc_Spawn, ent);
  297.  
  298.     new save = pev(ent, pev_solid);
  299.     dllfunc(DLLFunc_Touch, ent, index);
  300.     if (pev(ent, pev_solid) != save)
  301.         return ent;
  302.  
  303.     engfunc(EngFunc_RemoveEntity, ent);
  304.  
  305.     return -1;
  306. }
  307.  
  308. stock drop_weapons(id, dropwhat)
  309. {
  310.     static weapons[32], num, i, weaponid
  311.     num = 0
  312.     get_user_weapons(id, weapons, num)
  313.    
  314.     for (i = 0; i < num; i++)
  315.     {
  316.         weaponid = weapons[i]
  317.        
  318.         if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
  319.         {
  320.             static wname[32]
  321.             get_weaponname(weaponid, wname, sizeof wname - 1)
  322.            
  323.             engclient_cmd(id, "drop", wname)
  324.         }
  325.     }
  326.    
  327. }
  328.  
  329. stock client_printcolor(const id,const input[], any:...)
  330. {
  331.     new msg[191], players[32], count = 1
  332.     vformat(msg,190,input,3);
  333.     replace_all(msg,190,"!g","^4");    // green
  334.     replace_all(msg,190,"!y","^1");    // normal
  335.     replace_all(msg,190,"!t","^3");    // team
  336.        
  337.     if (id) players[0] = id; else get_players(players,count,"ch");
  338.        
  339.     for (new i=0;i<count;i++)
  340.     {
  341.         if (is_user_connected(players[i]))
  342.         {
  343.             message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("SayText"),_,players[i]);
  344.             write_byte(players[i]);
  345.             write_string(msg);
  346.             message_end();
  347.         }
  348.     }
  349. }

You can use it in main menu like:

  1. public Buy_Primary_Weapon(id, selection)
  2. {
  3.     static szWeaponName[32]
  4.     ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
  5.     new iWeaponId = get_weaponid(szWeaponName)
  6.    
  7.     // Strip and Give Full Weapon
  8.     if (is_has_paint_ball_gun(id) /*|| Anything here*/)
  9.     {
  10.         rg_give_item(id, szWeaponName, GT_APPEND)
  11.     }
  12.     else
  13.     {
  14.         rg_give_item(id, szWeaponName, GT_REPLACE)
  15.     }
  16.    
  17.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
  18.    
  19.     // Primary bought
  20.     g_bBoughtPrimary[id] = true
  21. }

Make same for all weapons.
He who fails to plan is planning to fail

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#12

Post by Mark » 5 years ago

Raheem wrote: 5 years ago Here i added the native:

  1. #include <zombie_escape>
  2. #include <engine>
  3.  
  4. #define ITEM_NAME "Paintball Gun"
  5. #define ITEM_COST 50
  6.  
  7. new PAINTBALL_V_MODEL[64] = "models/zombie_escape/v_paintballgun.mdl"
  8. new PAINTBALL_P_MODEL[64] = "models/zombie_escape/p_paintballgun.mdl"
  9. new PAINTBALL_W_MODEL[64] = "models/zombie_escape/w_paintballgun.mdl"
  10.  
  11. new g_paintSprite[2][] = {"sprites/bhit.spr", "sprites/richo1.spr"}
  12. new lastammo[33], g_paintball_gun[33], g_ballsnum = 0
  13.  
  14. const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_AK47)|(1<<CSW_M4A1)|(1<<CSW_FAMAS)|(1<<CSW_GALIL)|(1<<CSW_SCOUT)|(1<<CSW_AWP)|(1<<CSW_M249)|(1<<CSW_MP5NAVY)|(1<<CSW_P90)|(1<<CSW_MAC10)|(1<<CSW_TMP)|(1<<CSW_XM1014)|(1<<CSW_M3)|(1<<CSW_G3SG1)|(1<<CSW_SG550)|(1<<CSW_SG552)|(1<<CSW_AUG)|(1<<CSW_UMP45);
  15.  
  16.  
  17. // Cvars //
  18. new paintball_lifetime, paintball_maxballs, paintball_dmg_multi, paintball_unlimited_clip, g_iItemID
  19.  
  20. public plugin_natives()
  21. {
  22.     register_native("is_has_paint_ball_gun", "native_is_has_paint_ball_gun", 1)
  23. }
  24.  
  25. public plugin_init()
  26. {
  27.     register_plugin("[ZE] Extra Item: Paint Ball Gun", "1.1", "KRoTaL | [P]erfec[T] [S]cr[@]s[H] | Mark")
  28.     register_cvar("ze_paintballgun", "1.1", FCVAR_SERVER|FCVAR_UNLOGGED);
  29.    
  30.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  31.     RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_AddToPlayer")
  32.     register_forward(FM_SetModel, "fw_SetModel")
  33.     register_event("CurWeapon", "make_paint", "be", "3>0")
  34.     register_event("WeapPickup","checkModel","b","1=19")
  35.     register_event("CurWeapon","checkWeapon","be","1=1")
  36.     register_event("HLTV", "new_round", "a", "1=0", "2=0")
  37.    
  38.     paintball_maxballs = register_cvar("ze_paintball_maxballs", "200")
  39.     paintball_lifetime = register_cvar("ze_paintball_lifetime", "10")
  40.     paintball_dmg_multi = register_cvar("ze_paintball_dmg_multi", "4")
  41.     paintball_unlimited_clip = register_cvar("ze_paintball_unlimited_clip", "0")
  42.    
  43.     g_iItemID = ze_register_item(ITEM_NAME, ITEM_COST, 0)
  44. }
  45.  
  46. public plugin_precache()
  47. {
  48.     precache_model("sprites/bhit.spr")
  49.     precache_model("sprites/richo1.spr")
  50.     precache_model(PAINTBALL_V_MODEL)
  51.     precache_model(PAINTBALL_P_MODEL)
  52.     precache_model(PAINTBALL_W_MODEL)
  53. }
  54.  
  55. public native_is_has_paint_ball_gun(id)
  56. {
  57.     return g_paintball_gun[id];
  58. }
  59.  
  60. public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
  61. {
  62.     if (is_user_alive(attacker) && get_user_weapon(attacker) == CSW_MP5NAVY && g_paintball_gun[attacker] && !ze_is_user_zombie(attacker))
  63.     {
  64.         SetHamParamFloat(4, damage * get_pcvar_float(paintball_dmg_multi ))
  65.        
  66.         set_rendering(victim, kRenderFxGlowShell, random_num(0,255), random_num(0,255), random_num(0,255), kRenderNormal, 16);
  67.         set_task(5.0, "remove_glow", victim)
  68.     }
  69. }
  70.  
  71. public ze_user_humanized(id)
  72. {
  73.     g_paintball_gun[id] = false
  74.     remove_glow(id)
  75. }
  76.  
  77. public ze_user_infected(iVictim)
  78. {
  79.     g_paintball_gun[iVictim] = false
  80.     remove_glow(iVictim)  
  81. }
  82.  
  83. public ze_select_item_pre(id, itemid)
  84. {
  85.     if (itemid != g_iItemID)
  86.         return ZE_ITEM_AVAILABLE
  87.    
  88.     if (ze_is_user_zombie(id))
  89.         return ZE_ITEM_DONT_SHOW
  90.        
  91.     return ZE_ITEM_AVAILABLE
  92. }
  93.  
  94.  
  95. public ze_select_item_post(id, itemid)
  96. {
  97.     if (itemid != g_iItemID)
  98.         return
  99.        
  100.     ze_colored_print(id, "Congrats! You have bought a Paintball Gun! :D")
  101.    
  102.     Get_MyWeapon(id)
  103. }
  104.  
  105. public Get_MyWeapon(id)
  106. {
  107.     drop_weapons(id, 1);
  108.     g_paintball_gun[id] = true
  109.     give_item(id, "weapon_mp5navy")
  110. }
  111.  
  112. public remove_glow(id)
  113. {
  114.     set_rendering(id);
  115. }
  116.  
  117. public checkWeapon(id)
  118. {
  119.     new plrClip, plrAmmo, plrWeap[32], plrWeapId
  120.    
  121.     plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
  122.    
  123.     if (plrWeapId == CSW_MP5NAVY && g_paintball_gun[id])
  124.         checkModel(id)
  125.  
  126.     else return PLUGIN_CONTINUE;
  127.    
  128.     if (plrClip == 0 && get_pcvar_num(paintball_unlimited_clip))
  129.     {
  130.         // If the user is out of ammo..
  131.         get_weaponname(plrWeapId, plrWeap, 31)
  132.         // Get the name of their weapon
  133.         give_item(id, plrWeap)
  134.         engclient_cmd(id, plrWeap)
  135.         engclient_cmd(id, plrWeap)
  136.         engclient_cmd(id, plrWeap)
  137.     }
  138.     return PLUGIN_HANDLED
  139. }
  140.  
  141. public checkModel(id)
  142. {
  143.     if (ze_is_user_zombie(id)) return PLUGIN_HANDLED;
  144.    
  145.     new szWeapID = read_data(2)
  146.    
  147.     if ( szWeapID == CSW_MP5NAVY && g_paintball_gun[id])
  148.     {
  149.         entity_set_string(id, EV_SZ_viewmodel, PAINTBALL_V_MODEL)
  150.         entity_set_string(id, EV_SZ_weaponmodel, PAINTBALL_P_MODEL)
  151.     }
  152.     return PLUGIN_HANDLED
  153. }
  154.  
  155. public make_paint(id)
  156. {
  157.     new ammo = read_data(3)
  158.    
  159.     if(get_user_weapon(id) == CSW_MP5NAVY  && lastammo[id] > ammo && g_paintball_gun[id])
  160.     {
  161.         new iOrigin[3]
  162.         get_user_origin(id, iOrigin, 4)
  163.         new Float:fOrigin[3]
  164.         IVecFVec(iOrigin, fOrigin)
  165.        
  166.         if(g_ballsnum < get_pcvar_num(paintball_maxballs) && worldInVicinity(fOrigin))
  167.         {
  168.             new ent = create_entity("info_target")
  169.             if(ent > 0)
  170.             {
  171.                 entity_set_string(ent, EV_SZ_classname, "paint_ent")
  172.                 entity_set_int(ent, EV_INT_movetype, 0)
  173.                 entity_set_int(ent, EV_INT_solid, 0)
  174.                 entity_set_model(ent, g_paintSprite[random_num(0,1)])
  175.                 new r, g, b
  176.  
  177.                 r = random_num(64,255)
  178.                 g = random_num(64,255)
  179.                 b = random_num(64,255)
  180.                
  181.                 set_rendering(ent, kRenderFxNoDissipation, r, g, b, kRenderGlow, 255)
  182.                 entity_set_origin(ent, fOrigin)
  183.                 entity_set_int(ent, EV_INT_flags, FL_ALWAYSTHINK)
  184.                 entity_set_float(ent, EV_FL_nextthink, get_gametime() + get_pcvar_float(paintball_lifetime))
  185.                 ++g_ballsnum
  186.             }
  187.         }
  188.     }
  189.     lastammo[id] = ammo
  190. }
  191.  
  192. public pfn_think(entity)
  193. {
  194.     if(!is_valid_ent(entity))
  195.         return
  196.    
  197.     new class[32]; entity_get_string(entity, EV_SZ_classname, class, 31)
  198.     if(entity > 0 && equal(class, "paint_ent"))
  199.     {
  200.         remove_entity(entity)
  201.         --g_ballsnum
  202.     }
  203. }
  204.  
  205. public new_round()
  206. {
  207.     for(new id = 1; id <= get_maxplayers(); id++) g_paintball_gun[id] = false
  208.    
  209.     remove_entity_name("paint_ent")
  210.     g_ballsnum = 0
  211. }
  212.  
  213. stock worldInVicinity(Float:origin[3])
  214. {
  215.     new ent = find_ent_in_sphere(-1, origin, 4.0)
  216.     while(ent > 0)
  217.     {
  218.         if(entity_get_float(ent, EV_FL_health) > 0 || entity_get_float(ent, EV_FL_takedamage) > 0.0) return 0;
  219.         ent = find_ent_in_sphere(ent, origin, 4.0)
  220.     }
  221.    
  222.     new Float:traceEnds[8][3], Float:traceHit[3], hitEnt
  223.    
  224.     traceEnds[0][0] = origin[0] - 2.0; traceEnds[0][1] = origin[1] - 2.0; traceEnds[0][2] = origin[2] - 2.0
  225.     traceEnds[1][0] = origin[0] - 2.0; traceEnds[1][1] = origin[1] - 2.0; traceEnds[1][2] = origin[2] + 2.0
  226.     traceEnds[2][0] = origin[0] + 2.0; traceEnds[2][1] = origin[1] - 2.0; traceEnds[2][2] = origin[2] + 2.0
  227.     traceEnds[3][0] = origin[0] + 2.0; traceEnds[3][1] = origin[1] - 2.0; traceEnds[3][2] = origin[2] - 2.0
  228.     traceEnds[4][0] = origin[0] - 2.0; traceEnds[4][1] = origin[1] + 2.0; traceEnds[4][2] = origin[2] - 2.0
  229.     traceEnds[5][0] = origin[0] - 2.0; traceEnds[5][1] = origin[1] + 2.0; traceEnds[5][2] = origin[2] + 2.0
  230.     traceEnds[6][0] = origin[0] + 2.0; traceEnds[6][1] = origin[1] + 2.0; traceEnds[6][2] = origin[2] + 2.0
  231.     traceEnds[7][0] = origin[0] + 2.0; traceEnds[7][1] = origin[1] + 2.0; traceEnds[7][2] = origin[2] - 2.0
  232.    
  233.     for (new i = 0; i < 8; i++)
  234.     {
  235.         if (PointContents(traceEnds[i]) != CONTENTS_EMPTY) return 1;
  236.    
  237.         hitEnt = trace_line(0, origin, traceEnds[i], traceHit)
  238.         if (hitEnt != -1) return 1;
  239.        
  240.         for (new j = 0; j < 3; j++) if (traceEnds[i][j] != traceHit[j]) return 1;
  241.     }
  242.     return 0
  243. }
  244.  
  245. public fw_SetModel(entity, model[])
  246. {
  247.     if(!is_valid_ent(entity))
  248.         return FMRES_IGNORED;
  249.  
  250.     if(!equal(model, "models/w_mp5.mdl"))
  251.         return FMRES_IGNORED;
  252.  
  253.     static szClassName[33]
  254.     entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  255.     if(!equal(szClassName, "weaponbox")) return FMRES_IGNORED
  256.  
  257.     static iOwner, iStoredMp5ID
  258.     iOwner = entity_get_edict(entity, EV_ENT_owner)
  259.     iStoredMp5ID = find_ent_by_owner(-1, "weapon_mp5navy", entity)
  260.  
  261.     if(g_paintball_gun[iOwner] && is_valid_ent(iStoredMp5ID))
  262.     {
  263.         g_paintball_gun[iOwner] = false
  264.         entity_set_int(iStoredMp5ID, EV_INT_impulse, 1664656581)
  265.         entity_set_model(entity, PAINTBALL_W_MODEL)
  266.  
  267.         return FMRES_SUPERCEDE
  268.     }
  269.     return FMRES_IGNORED
  270. }
  271.  
  272. public fw_AddToPlayer(wpn, id)
  273. {
  274.     if(is_valid_ent(wpn) && is_user_connected(id) && entity_get_int(wpn, EV_INT_impulse) == 1664656581)
  275.     {
  276.         g_paintball_gun[id] = true
  277.         entity_set_int(wpn, EV_INT_impulse, 0)
  278.  
  279.         return HAM_HANDLED
  280.     }
  281.     return HAM_IGNORED
  282. }
  283.  
  284. stock give_item(index, const item[]) {
  285.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
  286.         return 0;
  287.  
  288.     new ent = create_entity(item);
  289.     if (!pev_valid(ent))
  290.         return 0;
  291.  
  292.     new Float:origin[3];
  293.     pev(index, pev_origin, origin);
  294.     set_pev(ent, pev_origin, origin);
  295.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
  296.     dllfunc(DLLFunc_Spawn, ent);
  297.  
  298.     new save = pev(ent, pev_solid);
  299.     dllfunc(DLLFunc_Touch, ent, index);
  300.     if (pev(ent, pev_solid) != save)
  301.         return ent;
  302.  
  303.     engfunc(EngFunc_RemoveEntity, ent);
  304.  
  305.     return -1;
  306. }
  307.  
  308. stock drop_weapons(id, dropwhat)
  309. {
  310.     static weapons[32], num, i, weaponid
  311.     num = 0
  312.     get_user_weapons(id, weapons, num)
  313.    
  314.     for (i = 0; i < num; i++)
  315.     {
  316.         weaponid = weapons[i]
  317.        
  318.         if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
  319.         {
  320.             static wname[32]
  321.             get_weaponname(weaponid, wname, sizeof wname - 1)
  322.            
  323.             engclient_cmd(id, "drop", wname)
  324.         }
  325.     }
  326.    
  327. }
  328.  
  329. stock client_printcolor(const id,const input[], any:...)
  330. {
  331.     new msg[191], players[32], count = 1
  332.     vformat(msg,190,input,3);
  333.     replace_all(msg,190,"!g","^4");    // green
  334.     replace_all(msg,190,"!y","^1");    // normal
  335.     replace_all(msg,190,"!t","^3");    // team
  336.        
  337.     if (id) players[0] = id; else get_players(players,count,"ch");
  338.        
  339.     for (new i=0;i<count;i++)
  340.     {
  341.         if (is_user_connected(players[i]))
  342.         {
  343.             message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("SayText"),_,players[i]);
  344.             write_byte(players[i]);
  345.             write_string(msg);
  346.             message_end();
  347.         }
  348.     }
  349. }

You can use it in main menu like:

  1. public Buy_Primary_Weapon(id, selection)
  2. {
  3.     static szWeaponName[32]
  4.     ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
  5.     new iWeaponId = get_weaponid(szWeaponName)
  6.    
  7.     // Strip and Give Full Weapon
  8.     if (is_has_paint_ball_gun(id) /*|| Anything here*/)
  9.     {
  10.         rg_give_item(id, szWeaponName, GT_APPEND)
  11.     }
  12.     else
  13.     {
  14.         rg_give_item(id, szWeaponName, GT_REPLACE)
  15.     }
  16.    
  17.     rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
  18.    
  19.     // Primary bought
  20.     g_bBoughtPrimary[id] = true
  21. }

Make same for all weapons.
Well shit that did not work!

with the current code you made for me with the native i have both weapons 1 from extra items and 1 from weapon menu.


I want if i buy an extra item it does not give the weapon menu weapon.


Image
20181013131617_1.jpg

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#13

Post by Mark » 5 years ago

Put code back to normal and tryed this works alittle better. But if i buy the extra item and drop it the next round i have no guns lol



  1. public ze_user_humanized(id)
  2. {
  3.     // Static Values
  4.     switch (ze_get_user_level(id))
  5.     {
  6.         case 0..4: WPN_MAXIDS[id] = 2
  7.         case 5..9: WPN_MAXIDS[id] = 4
  8.         case 10..14: WPN_MAXIDS[id] = 6
  9.         case 15..19: WPN_MAXIDS[id] = 8
  10.         case 20..24: WPN_MAXIDS[id] = 10
  11.         case 25..29: WPN_MAXIDS[id] = 12
  12.         case 30: WPN_MAXIDS[id] = 14
  13.     }
  14.    
  15.     if (ze_get_user_level(id) > 30)
  16.     {
  17.         WPN_MAXIDS[id] = 14
  18.     }
  19.  
  20.     // Buyzone time starts when player is set to human
  21.     g_flBuyTimeStart[id] = get_gametime()
  22.    
  23.     g_bBoughtPrimary[id] = false
  24.     g_bBoughtSecondary[id] = false
  25.    
  26.     // Player dead or zombie
  27.     if (!is_user_alive(id) || ze_is_user_zombie(id))
  28.         return
  29.    
  30.     if (WPN_AUTO_ON)
  31.     {
  32.         if (is_has_paint_ball_gun(id) /*|| Anything here*/)
  33.             return
  34.            
  35.         ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
  36.         Buy_Primary_Weapon(id, WPN_AUTO_PRI)
  37.         Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
  38.     }
  39.    
  40.     // Open available buy menus
  41.     Show_Available_Buy_Menus(id)
  42.    
  43.     // Give HE Grenade
  44.     if (get_pcvar_num(g_pCvarHEGrenade) != 0)
  45.         rg_give_item(id, "weapon_hegrenade")
  46.    
  47.     // Give Smoke Grenade
  48.     if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
  49.         rg_give_item(id, "weapon_smokegrenade")
  50.    
  51.     // Give Flashbang Grenade
  52.     if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
  53.         rg_give_item(id, "weapon_flashbang")
  54. }

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#14

Post by Mark » 5 years ago

Ok here is the working code with the only changes i made to the org file seems to be working....


  1. public ze_user_humanized(id)
  2. {
  3.     // Static Values
  4.     switch (ze_get_user_level(id))
  5.     {
  6.         case 0..4: WPN_MAXIDS[id] = 2
  7.         case 5..9: WPN_MAXIDS[id] = 4
  8.         case 10..14: WPN_MAXIDS[id] = 6
  9.         case 15..19: WPN_MAXIDS[id] = 8
  10.         case 20..24: WPN_MAXIDS[id] = 10
  11.         case 25..29: WPN_MAXIDS[id] = 12
  12.         case 30: WPN_MAXIDS[id] = 14
  13.     }
  14.    
  15.     if (ze_get_user_level(id) > 30)
  16.     {
  17.         WPN_MAXIDS[id] = 14
  18.     }
  19.  
  20.     // Buyzone time starts when player is set to human
  21.     g_flBuyTimeStart[id] = get_gametime()
  22.    
  23.     g_bBoughtPrimary[id] = false
  24.     g_bBoughtSecondary[id] = false
  25.    
  26.     // Player dead or zombie
  27.     if (!is_user_alive(id) || ze_is_user_zombie(id))
  28.         return
  29.    
  30.     if (WPN_AUTO_ON)
  31.     {
  32.         if (is_has_paint_ball_gun(id) /*|| Anything here*/)
  33.             return
  34.  
  35.         ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
  36.         Buy_Primary_Weapon(id, WPN_AUTO_PRI)
  37.         Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
  38.     }
  39.    
  40.     // Open available buy menus
  41.     Show_Available_Buy_Menus(id)
  42.    
  43.     // Give HE Grenade
  44.     if (get_pcvar_num(g_pCvarHEGrenade) != 0)
  45.         rg_give_item(id, "weapon_hegrenade")
  46.    
  47.     // Give Smoke Grenade
  48.     if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
  49.         rg_give_item(id, "weapon_smokegrenade")
  50.    
  51.     // Give Flashbang Grenade
  52.     if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
  53.         rg_give_item(id, "weapon_flashbang")
  54. }

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#15

Post by Mark » 5 years ago

I think i got this figured out ill let you know in a few days i had to add more code...

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

#16

Post by Raheem » 5 years ago

My method failed in what? viewtopic.php?p=8966#p8966
Let me know how my idea working for you.
He who fails to plan is planning to fail

evanorah00
Member
Member
Posts: 2
Joined: 2 years ago
Contact:

#17

Post by evanorah00 » 2 years ago

Good to share

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