Page 1 of 1

Weapons Menu over write extra items on new round.

Posted: 09 Oct 2018, 00:54
by Mark
Not sure where to start with this one.

Problem : If a player selects a gun from the weapon menu and saves the selections but then buys a extra item weapon the next round it is over written by the weapon menu. {I have it setup that if they are not infected they will have any weapon they bought untill they get infected.}

So what i want is if they select an extra item the weapon menu will not over write it on new round.

Hope this make sense.

Re: Weapons Menu over write extra items on new round.

Posted: 09 Oct 2018, 08:20
by Raheem
In weapons menu source you will find something like: rg_give_item(id, szWeaponName, GT_REPLACE) so instead of GT_REPLACE you will need to use GT_APPEND.

  1. /**
  2. * Use with rg_give_item
  3. */
  4. enum GiveType
  5. {
  6.     GT_APPEND,          // Just give item
  7.     GT_REPLACE,         // Give the item and remove all other weapons from the slot
  8.     GT_DROP_AND_REPLACE // Give the item and drop all other weapons from the slot
  9. };

Re: Weapons Menu over write extra items on new round.

Posted: 10 Oct 2018, 00:59
by Mark
Raheem wrote: 5 years ago In weapons menu source you will find something like: rg_give_item(id, szWeaponName, GT_REPLACE) so instead of GT_REPLACE you will need to use GT_APPEND.

  1. /**
  2. * Use with rg_give_item
  3. */
  4. enum GiveType
  5. {
  6.     GT_APPEND,          // Just give item
  7.     GT_REPLACE,         // Give the item and remove all other weapons from the slot
  8.     GT_DROP_AND_REPLACE // Give the item and drop all other weapons from the slot
  9. };
Now everytime i select a new weapon i have more then one.

20181009195641_1.jpg
20181009195640_1.jpg
What i want is if i save the gun selection then pick a extra item weapon it will drop the normal weapon but next round it will keep the extra item weapon....


So in this case if the player gets infected they will lose all weapons and next round they will get the saved selected weapon menu guns untill they select a extra item gun then if they are not infected this round next round they will still have extra item gun.

Re: Weapons Menu over write extra items on new round.

Posted: 10 Oct 2018, 08:18
by Night Fury
Check on round start if the player has another weapon than knife to not to give weapons, otherwise give.

Re: Weapons Menu over write extra items on new round.

Posted: 10 Oct 2018, 15:37
by Mark
Jack GamePlay wrote: 5 years ago Check on round start if the player has another weapon than knife to not to give weapons, otherwise give.
Can you give me example pls :)

Re: Weapons Menu over write extra items on new round.

Posted: 11 Oct 2018, 02:56
by Mark
lol

Re: Weapons Menu over write extra items on new round.

Posted: 11 Oct 2018, 04:23
by Raheem
You will need to introduce new natives on these extra weapons and this native like: user have item
this mean he have it. Then in weapons menu u check if player has one of them then you append the item give. If he does not have extra item just give item with replace.

How many weapons that should be not replaced?

Re: Weapons Menu over write extra items on new round.

Posted: 11 Oct 2018, 11:56
by Mark
Raheem wrote: 5 years ago You will need to introduce new natives on these extra weapons and this native like: user have item
this mean he have it. Then in weapons menu u check if player has one of them then you append the item give. If he does not have extra item just give item with replace.

How many weapons that should be not replaced?
16

Re: Weapons Menu over write extra items on new round.

Posted: 12 Oct 2018, 09:04
by Raheem
Post 1 item of them, i'll show you how to do it.

Re: Weapons Menu over write extra items on new round.

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

Re: Weapons Menu over write extra items on new round.

Posted: 12 Oct 2018, 15:20
by Raheem
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.

Re: Weapons Menu over write extra items on new round.

Posted: 12 Oct 2018, 16:57
by Mark
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

Re: Weapons Menu over write extra items on new round.

Posted: 13 Oct 2018, 22:21
by Mark
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. }

Re: Weapons Menu over write extra items on new round.

Posted: 13 Oct 2018, 22:56
by Mark
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. }

Re: Weapons Menu over write extra items on new round.

Posted: 14 Oct 2018, 03:46
by Mark
I think i got this figured out ill let you know in a few days i had to add more code...

Re: Weapons Menu over write extra items on new round.

Posted: 16 Oct 2018, 13:32
by Raheem
My method failed in what? viewtopic.php?p=8966#p8966
Let me know how my idea working for you.

Re: Weapons Menu over write extra items on new round.

Posted: 09 Jan 2022, 09:27
by evanorah00
Good to share