Weapons Menu over write extra items on new round.
Weapons Menu over write extra items on new round.
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.
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.
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
.- /**
- * Use with rg_give_item
- */
- enum GiveType
- {
- GT_APPEND, // Just give item
- GT_REPLACE, // Give the item and remove all other weapons from the slot
- GT_DROP_AND_REPLACE // Give the item and drop all other weapons from the slot
- };
He who fails to plan is planning to fail
Now everytime i select a new weapon i have more then one.Raheem wrote: ↑5 years ago In weapons menu source you will find something like:rg_give_item(id, szWeaponName, GT_REPLACE)
so instead ofGT_REPLACE
you will need to useGT_APPEND
.
/** * Use with rg_give_item */ enum GiveType { GT_APPEND, // Just give item GT_REPLACE, // Give the item and remove all other weapons from the slot GT_DROP_AND_REPLACE // Give the item and drop all other weapons from the slot };
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.
- Night Fury
- Mod Developer
- Posts: 677
- Joined: 7 years ago
- Contact:
Check on round start if the player has another weapon than knife to not to give weapons, otherwise give.
Can you give me example plsJack GamePlay wrote: ↑5 years ago Check on round start if the player has another weapon than knife to not to give weapons, otherwise give.
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?
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?
He who fails to plan is planning to fail
16Raheem 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?
Post 1 item of them, i'll show you how to do it.
He who fails to plan is planning to fail
- #include <zombie_escape>
- #include <engine>
- #define ITEM_NAME "Paintball Gun"
- #define ITEM_COST 50
- new PAINTBALL_V_MODEL[64] = "models/zombie_escape/v_paintballgun.mdl"
- new PAINTBALL_P_MODEL[64] = "models/zombie_escape/p_paintballgun.mdl"
- new PAINTBALL_W_MODEL[64] = "models/zombie_escape/w_paintballgun.mdl"
- new g_paintSprite[2][] = {"sprites/bhit.spr", "sprites/richo1.spr"}
- new lastammo[33], g_paintball_gun[33], g_ballsnum = 0
- 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);
- // Cvars //
- new paintball_lifetime, paintball_maxballs, paintball_dmg_multi, paintball_unlimited_clip, g_iItemID
- public plugin_init()
- {
- register_plugin("[ZE] Extra Item: Paint Ball Gun", "1.1", "KRoTaL | [P]erfec[T] [S]cr[@]s[H] | Mark")
- register_cvar("ze_paintballgun", "1.1", FCVAR_SERVER|FCVAR_UNLOGGED);
- RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
- RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_AddToPlayer")
- register_forward(FM_SetModel, "fw_SetModel")
- register_event("CurWeapon", "make_paint", "be", "3>0")
- register_event("WeapPickup","checkModel","b","1=19")
- register_event("CurWeapon","checkWeapon","be","1=1")
- register_event("HLTV", "new_round", "a", "1=0", "2=0")
- paintball_maxballs = register_cvar("ze_paintball_maxballs", "200")
- paintball_lifetime = register_cvar("ze_paintball_lifetime", "10")
- paintball_dmg_multi = register_cvar("ze_paintball_dmg_multi", "4")
- paintball_unlimited_clip = register_cvar("ze_paintball_unlimited_clip", "0")
- g_iItemID = ze_register_item(ITEM_NAME, ITEM_COST, 0)
- }
- public plugin_precache()
- {
- precache_model("sprites/bhit.spr")
- precache_model("sprites/richo1.spr")
- precache_model(PAINTBALL_V_MODEL)
- precache_model(PAINTBALL_P_MODEL)
- precache_model(PAINTBALL_W_MODEL)
- }
- public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
- {
- if (is_user_alive(attacker) && get_user_weapon(attacker) == CSW_MP5NAVY && g_paintball_gun[attacker] && !ze_is_user_zombie(attacker))
- {
- SetHamParamFloat(4, damage * get_pcvar_float(paintball_dmg_multi ))
- set_rendering(victim, kRenderFxGlowShell, random_num(0,255), random_num(0,255), random_num(0,255), kRenderNormal, 16);
- set_task(5.0, "remove_glow", victim)
- }
- }
- public ze_user_humanized(id)
- {
- g_paintball_gun[id] = false
- remove_glow(id)
- }
- public ze_user_infected(iVictim)
- {
- g_paintball_gun[iVictim] = false
- remove_glow(iVictim)
- }
- public ze_select_item_pre(id, itemid)
- {
- if (itemid != g_iItemID)
- return ZE_ITEM_AVAILABLE
- if (ze_is_user_zombie(id))
- return ZE_ITEM_DONT_SHOW
- return ZE_ITEM_AVAILABLE
- }
- public ze_select_item_post(id, itemid)
- {
- if (itemid != g_iItemID)
- return
- ze_colored_print(id, "Congrats! You have bought a Paintball Gun! :D")
- Get_MyWeapon(id)
- }
- public Get_MyWeapon(id)
- {
- drop_weapons(id, 1);
- g_paintball_gun[id] = true
- give_item(id, "weapon_mp5navy")
- }
- public remove_glow(id)
- {
- set_rendering(id);
- }
- public checkWeapon(id)
- {
- new plrClip, plrAmmo, plrWeap[32], plrWeapId
- plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
- if (plrWeapId == CSW_MP5NAVY && g_paintball_gun[id])
- checkModel(id)
- else return PLUGIN_CONTINUE;
- if (plrClip == 0 && get_pcvar_num(paintball_unlimited_clip))
- {
- // If the user is out of ammo..
- get_weaponname(plrWeapId, plrWeap, 31)
- // Get the name of their weapon
- give_item(id, plrWeap)
- engclient_cmd(id, plrWeap)
- engclient_cmd(id, plrWeap)
- engclient_cmd(id, plrWeap)
- }
- return PLUGIN_HANDLED
- }
- public checkModel(id)
- {
- if (ze_is_user_zombie(id)) return PLUGIN_HANDLED;
- new szWeapID = read_data(2)
- if ( szWeapID == CSW_MP5NAVY && g_paintball_gun[id])
- {
- entity_set_string(id, EV_SZ_viewmodel, PAINTBALL_V_MODEL)
- entity_set_string(id, EV_SZ_weaponmodel, PAINTBALL_P_MODEL)
- }
- return PLUGIN_HANDLED
- }
- public make_paint(id)
- {
- new ammo = read_data(3)
- if(get_user_weapon(id) == CSW_MP5NAVY && lastammo[id] > ammo && g_paintball_gun[id])
- {
- new iOrigin[3]
- get_user_origin(id, iOrigin, 4)
- new Float:fOrigin[3]
- IVecFVec(iOrigin, fOrigin)
- if(g_ballsnum < get_pcvar_num(paintball_maxballs) && worldInVicinity(fOrigin))
- {
- new ent = create_entity("info_target")
- if(ent > 0)
- {
- entity_set_string(ent, EV_SZ_classname, "paint_ent")
- entity_set_int(ent, EV_INT_movetype, 0)
- entity_set_int(ent, EV_INT_solid, 0)
- entity_set_model(ent, g_paintSprite[random_num(0,1)])
- new r, g, b
- r = random_num(64,255)
- g = random_num(64,255)
- b = random_num(64,255)
- set_rendering(ent, kRenderFxNoDissipation, r, g, b, kRenderGlow, 255)
- entity_set_origin(ent, fOrigin)
- entity_set_int(ent, EV_INT_flags, FL_ALWAYSTHINK)
- entity_set_float(ent, EV_FL_nextthink, get_gametime() + get_pcvar_float(paintball_lifetime))
- ++g_ballsnum
- }
- }
- }
- lastammo[id] = ammo
- }
- public pfn_think(entity)
- {
- if(!is_valid_ent(entity))
- return
- new class[32]; entity_get_string(entity, EV_SZ_classname, class, 31)
- if(entity > 0 && equal(class, "paint_ent"))
- {
- remove_entity(entity)
- --g_ballsnum
- }
- }
- public new_round()
- {
- for(new id = 1; id <= get_maxplayers(); id++) g_paintball_gun[id] = false
- remove_entity_name("paint_ent")
- g_ballsnum = 0
- }
- stock worldInVicinity(Float:origin[3])
- {
- new ent = find_ent_in_sphere(-1, origin, 4.0)
- while(ent > 0)
- {
- if(entity_get_float(ent, EV_FL_health) > 0 || entity_get_float(ent, EV_FL_takedamage) > 0.0) return 0;
- ent = find_ent_in_sphere(ent, origin, 4.0)
- }
- new Float:traceEnds[8][3], Float:traceHit[3], hitEnt
- traceEnds[0][0] = origin[0] - 2.0; traceEnds[0][1] = origin[1] - 2.0; traceEnds[0][2] = origin[2] - 2.0
- traceEnds[1][0] = origin[0] - 2.0; traceEnds[1][1] = origin[1] - 2.0; traceEnds[1][2] = origin[2] + 2.0
- traceEnds[2][0] = origin[0] + 2.0; traceEnds[2][1] = origin[1] - 2.0; traceEnds[2][2] = origin[2] + 2.0
- traceEnds[3][0] = origin[0] + 2.0; traceEnds[3][1] = origin[1] - 2.0; traceEnds[3][2] = origin[2] - 2.0
- traceEnds[4][0] = origin[0] - 2.0; traceEnds[4][1] = origin[1] + 2.0; traceEnds[4][2] = origin[2] - 2.0
- traceEnds[5][0] = origin[0] - 2.0; traceEnds[5][1] = origin[1] + 2.0; traceEnds[5][2] = origin[2] + 2.0
- traceEnds[6][0] = origin[0] + 2.0; traceEnds[6][1] = origin[1] + 2.0; traceEnds[6][2] = origin[2] + 2.0
- traceEnds[7][0] = origin[0] + 2.0; traceEnds[7][1] = origin[1] + 2.0; traceEnds[7][2] = origin[2] - 2.0
- for (new i = 0; i < 8; i++)
- {
- if (PointContents(traceEnds[i]) != CONTENTS_EMPTY) return 1;
- hitEnt = trace_line(0, origin, traceEnds[i], traceHit)
- if (hitEnt != -1) return 1;
- for (new j = 0; j < 3; j++) if (traceEnds[i][j] != traceHit[j]) return 1;
- }
- return 0
- }
- public fw_SetModel(entity, model[])
- {
- if(!is_valid_ent(entity))
- return FMRES_IGNORED;
- if(!equal(model, "models/w_mp5.mdl"))
- return FMRES_IGNORED;
- static szClassName[33]
- entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
- if(!equal(szClassName, "weaponbox")) return FMRES_IGNORED
- static iOwner, iStoredMp5ID
- iOwner = entity_get_edict(entity, EV_ENT_owner)
- iStoredMp5ID = find_ent_by_owner(-1, "weapon_mp5navy", entity)
- if(g_paintball_gun[iOwner] && is_valid_ent(iStoredMp5ID))
- {
- g_paintball_gun[iOwner] = false
- entity_set_int(iStoredMp5ID, EV_INT_impulse, 1664656581)
- entity_set_model(entity, PAINTBALL_W_MODEL)
- return FMRES_SUPERCEDE
- }
- return FMRES_IGNORED
- }
- public fw_AddToPlayer(wpn, id)
- {
- if(is_valid_ent(wpn) && is_user_connected(id) && entity_get_int(wpn, EV_INT_impulse) == 1664656581)
- {
- g_paintball_gun[id] = true
- entity_set_int(wpn, EV_INT_impulse, 0)
- return HAM_HANDLED
- }
- return HAM_IGNORED
- }
- stock give_item(index, const item[]) {
- if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
- return 0;
- new ent = create_entity(item);
- if (!pev_valid(ent))
- return 0;
- new Float:origin[3];
- pev(index, pev_origin, origin);
- set_pev(ent, pev_origin, origin);
- set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
- dllfunc(DLLFunc_Spawn, ent);
- new save = pev(ent, pev_solid);
- dllfunc(DLLFunc_Touch, ent, index);
- if (pev(ent, pev_solid) != save)
- return ent;
- engfunc(EngFunc_RemoveEntity, ent);
- return -1;
- }
- stock drop_weapons(id, dropwhat)
- {
- static weapons[32], num, i, weaponid
- num = 0
- get_user_weapons(id, weapons, num)
- for (i = 0; i < num; i++)
- {
- weaponid = weapons[i]
- if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
- {
- static wname[32]
- get_weaponname(weaponid, wname, sizeof wname - 1)
- engclient_cmd(id, "drop", wname)
- }
- }
- }
- stock client_printcolor(const id,const input[], any:...)
- {
- new msg[191], players[32], count = 1
- vformat(msg,190,input,3);
- replace_all(msg,190,"!g","^4"); // green
- replace_all(msg,190,"!y","^1"); // normal
- replace_all(msg,190,"!t","^3"); // team
- if (id) players[0] = id; else get_players(players,count,"ch");
- for (new i=0;i<count;i++)
- {
- if (is_user_connected(players[i]))
- {
- message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("SayText"),_,players[i]);
- write_byte(players[i]);
- write_string(msg);
- message_end();
- }
- }
- }
Here i added the native:
You can use it in main menu like:
Make same for all weapons.
- #include <zombie_escape>
- #include <engine>
- #define ITEM_NAME "Paintball Gun"
- #define ITEM_COST 50
- new PAINTBALL_V_MODEL[64] = "models/zombie_escape/v_paintballgun.mdl"
- new PAINTBALL_P_MODEL[64] = "models/zombie_escape/p_paintballgun.mdl"
- new PAINTBALL_W_MODEL[64] = "models/zombie_escape/w_paintballgun.mdl"
- new g_paintSprite[2][] = {"sprites/bhit.spr", "sprites/richo1.spr"}
- new lastammo[33], g_paintball_gun[33], g_ballsnum = 0
- 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);
- // Cvars //
- new paintball_lifetime, paintball_maxballs, paintball_dmg_multi, paintball_unlimited_clip, g_iItemID
- public plugin_natives()
- {
- register_native("is_has_paint_ball_gun", "native_is_has_paint_ball_gun", 1)
- }
- public plugin_init()
- {
- register_plugin("[ZE] Extra Item: Paint Ball Gun", "1.1", "KRoTaL | [P]erfec[T] [S]cr[@]s[H] | Mark")
- register_cvar("ze_paintballgun", "1.1", FCVAR_SERVER|FCVAR_UNLOGGED);
- RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
- RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_AddToPlayer")
- register_forward(FM_SetModel, "fw_SetModel")
- register_event("CurWeapon", "make_paint", "be", "3>0")
- register_event("WeapPickup","checkModel","b","1=19")
- register_event("CurWeapon","checkWeapon","be","1=1")
- register_event("HLTV", "new_round", "a", "1=0", "2=0")
- paintball_maxballs = register_cvar("ze_paintball_maxballs", "200")
- paintball_lifetime = register_cvar("ze_paintball_lifetime", "10")
- paintball_dmg_multi = register_cvar("ze_paintball_dmg_multi", "4")
- paintball_unlimited_clip = register_cvar("ze_paintball_unlimited_clip", "0")
- g_iItemID = ze_register_item(ITEM_NAME, ITEM_COST, 0)
- }
- public plugin_precache()
- {
- precache_model("sprites/bhit.spr")
- precache_model("sprites/richo1.spr")
- precache_model(PAINTBALL_V_MODEL)
- precache_model(PAINTBALL_P_MODEL)
- precache_model(PAINTBALL_W_MODEL)
- }
- public native_is_has_paint_ball_gun(id)
- {
- return g_paintball_gun[id];
- }
- public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
- {
- if (is_user_alive(attacker) && get_user_weapon(attacker) == CSW_MP5NAVY && g_paintball_gun[attacker] && !ze_is_user_zombie(attacker))
- {
- SetHamParamFloat(4, damage * get_pcvar_float(paintball_dmg_multi ))
- set_rendering(victim, kRenderFxGlowShell, random_num(0,255), random_num(0,255), random_num(0,255), kRenderNormal, 16);
- set_task(5.0, "remove_glow", victim)
- }
- }
- public ze_user_humanized(id)
- {
- g_paintball_gun[id] = false
- remove_glow(id)
- }
- public ze_user_infected(iVictim)
- {
- g_paintball_gun[iVictim] = false
- remove_glow(iVictim)
- }
- public ze_select_item_pre(id, itemid)
- {
- if (itemid != g_iItemID)
- return ZE_ITEM_AVAILABLE
- if (ze_is_user_zombie(id))
- return ZE_ITEM_DONT_SHOW
- return ZE_ITEM_AVAILABLE
- }
- public ze_select_item_post(id, itemid)
- {
- if (itemid != g_iItemID)
- return
- ze_colored_print(id, "Congrats! You have bought a Paintball Gun! :D")
- Get_MyWeapon(id)
- }
- public Get_MyWeapon(id)
- {
- drop_weapons(id, 1);
- g_paintball_gun[id] = true
- give_item(id, "weapon_mp5navy")
- }
- public remove_glow(id)
- {
- set_rendering(id);
- }
- public checkWeapon(id)
- {
- new plrClip, plrAmmo, plrWeap[32], plrWeapId
- plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
- if (plrWeapId == CSW_MP5NAVY && g_paintball_gun[id])
- checkModel(id)
- else return PLUGIN_CONTINUE;
- if (plrClip == 0 && get_pcvar_num(paintball_unlimited_clip))
- {
- // If the user is out of ammo..
- get_weaponname(plrWeapId, plrWeap, 31)
- // Get the name of their weapon
- give_item(id, plrWeap)
- engclient_cmd(id, plrWeap)
- engclient_cmd(id, plrWeap)
- engclient_cmd(id, plrWeap)
- }
- return PLUGIN_HANDLED
- }
- public checkModel(id)
- {
- if (ze_is_user_zombie(id)) return PLUGIN_HANDLED;
- new szWeapID = read_data(2)
- if ( szWeapID == CSW_MP5NAVY && g_paintball_gun[id])
- {
- entity_set_string(id, EV_SZ_viewmodel, PAINTBALL_V_MODEL)
- entity_set_string(id, EV_SZ_weaponmodel, PAINTBALL_P_MODEL)
- }
- return PLUGIN_HANDLED
- }
- public make_paint(id)
- {
- new ammo = read_data(3)
- if(get_user_weapon(id) == CSW_MP5NAVY && lastammo[id] > ammo && g_paintball_gun[id])
- {
- new iOrigin[3]
- get_user_origin(id, iOrigin, 4)
- new Float:fOrigin[3]
- IVecFVec(iOrigin, fOrigin)
- if(g_ballsnum < get_pcvar_num(paintball_maxballs) && worldInVicinity(fOrigin))
- {
- new ent = create_entity("info_target")
- if(ent > 0)
- {
- entity_set_string(ent, EV_SZ_classname, "paint_ent")
- entity_set_int(ent, EV_INT_movetype, 0)
- entity_set_int(ent, EV_INT_solid, 0)
- entity_set_model(ent, g_paintSprite[random_num(0,1)])
- new r, g, b
- r = random_num(64,255)
- g = random_num(64,255)
- b = random_num(64,255)
- set_rendering(ent, kRenderFxNoDissipation, r, g, b, kRenderGlow, 255)
- entity_set_origin(ent, fOrigin)
- entity_set_int(ent, EV_INT_flags, FL_ALWAYSTHINK)
- entity_set_float(ent, EV_FL_nextthink, get_gametime() + get_pcvar_float(paintball_lifetime))
- ++g_ballsnum
- }
- }
- }
- lastammo[id] = ammo
- }
- public pfn_think(entity)
- {
- if(!is_valid_ent(entity))
- return
- new class[32]; entity_get_string(entity, EV_SZ_classname, class, 31)
- if(entity > 0 && equal(class, "paint_ent"))
- {
- remove_entity(entity)
- --g_ballsnum
- }
- }
- public new_round()
- {
- for(new id = 1; id <= get_maxplayers(); id++) g_paintball_gun[id] = false
- remove_entity_name("paint_ent")
- g_ballsnum = 0
- }
- stock worldInVicinity(Float:origin[3])
- {
- new ent = find_ent_in_sphere(-1, origin, 4.0)
- while(ent > 0)
- {
- if(entity_get_float(ent, EV_FL_health) > 0 || entity_get_float(ent, EV_FL_takedamage) > 0.0) return 0;
- ent = find_ent_in_sphere(ent, origin, 4.0)
- }
- new Float:traceEnds[8][3], Float:traceHit[3], hitEnt
- traceEnds[0][0] = origin[0] - 2.0; traceEnds[0][1] = origin[1] - 2.0; traceEnds[0][2] = origin[2] - 2.0
- traceEnds[1][0] = origin[0] - 2.0; traceEnds[1][1] = origin[1] - 2.0; traceEnds[1][2] = origin[2] + 2.0
- traceEnds[2][0] = origin[0] + 2.0; traceEnds[2][1] = origin[1] - 2.0; traceEnds[2][2] = origin[2] + 2.0
- traceEnds[3][0] = origin[0] + 2.0; traceEnds[3][1] = origin[1] - 2.0; traceEnds[3][2] = origin[2] - 2.0
- traceEnds[4][0] = origin[0] - 2.0; traceEnds[4][1] = origin[1] + 2.0; traceEnds[4][2] = origin[2] - 2.0
- traceEnds[5][0] = origin[0] - 2.0; traceEnds[5][1] = origin[1] + 2.0; traceEnds[5][2] = origin[2] + 2.0
- traceEnds[6][0] = origin[0] + 2.0; traceEnds[6][1] = origin[1] + 2.0; traceEnds[6][2] = origin[2] + 2.0
- traceEnds[7][0] = origin[0] + 2.0; traceEnds[7][1] = origin[1] + 2.0; traceEnds[7][2] = origin[2] - 2.0
- for (new i = 0; i < 8; i++)
- {
- if (PointContents(traceEnds[i]) != CONTENTS_EMPTY) return 1;
- hitEnt = trace_line(0, origin, traceEnds[i], traceHit)
- if (hitEnt != -1) return 1;
- for (new j = 0; j < 3; j++) if (traceEnds[i][j] != traceHit[j]) return 1;
- }
- return 0
- }
- public fw_SetModel(entity, model[])
- {
- if(!is_valid_ent(entity))
- return FMRES_IGNORED;
- if(!equal(model, "models/w_mp5.mdl"))
- return FMRES_IGNORED;
- static szClassName[33]
- entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
- if(!equal(szClassName, "weaponbox")) return FMRES_IGNORED
- static iOwner, iStoredMp5ID
- iOwner = entity_get_edict(entity, EV_ENT_owner)
- iStoredMp5ID = find_ent_by_owner(-1, "weapon_mp5navy", entity)
- if(g_paintball_gun[iOwner] && is_valid_ent(iStoredMp5ID))
- {
- g_paintball_gun[iOwner] = false
- entity_set_int(iStoredMp5ID, EV_INT_impulse, 1664656581)
- entity_set_model(entity, PAINTBALL_W_MODEL)
- return FMRES_SUPERCEDE
- }
- return FMRES_IGNORED
- }
- public fw_AddToPlayer(wpn, id)
- {
- if(is_valid_ent(wpn) && is_user_connected(id) && entity_get_int(wpn, EV_INT_impulse) == 1664656581)
- {
- g_paintball_gun[id] = true
- entity_set_int(wpn, EV_INT_impulse, 0)
- return HAM_HANDLED
- }
- return HAM_IGNORED
- }
- stock give_item(index, const item[]) {
- if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
- return 0;
- new ent = create_entity(item);
- if (!pev_valid(ent))
- return 0;
- new Float:origin[3];
- pev(index, pev_origin, origin);
- set_pev(ent, pev_origin, origin);
- set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
- dllfunc(DLLFunc_Spawn, ent);
- new save = pev(ent, pev_solid);
- dllfunc(DLLFunc_Touch, ent, index);
- if (pev(ent, pev_solid) != save)
- return ent;
- engfunc(EngFunc_RemoveEntity, ent);
- return -1;
- }
- stock drop_weapons(id, dropwhat)
- {
- static weapons[32], num, i, weaponid
- num = 0
- get_user_weapons(id, weapons, num)
- for (i = 0; i < num; i++)
- {
- weaponid = weapons[i]
- if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
- {
- static wname[32]
- get_weaponname(weaponid, wname, sizeof wname - 1)
- engclient_cmd(id, "drop", wname)
- }
- }
- }
- stock client_printcolor(const id,const input[], any:...)
- {
- new msg[191], players[32], count = 1
- vformat(msg,190,input,3);
- replace_all(msg,190,"!g","^4"); // green
- replace_all(msg,190,"!y","^1"); // normal
- replace_all(msg,190,"!t","^3"); // team
- if (id) players[0] = id; else get_players(players,count,"ch");
- for (new i=0;i<count;i++)
- {
- if (is_user_connected(players[i]))
- {
- message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("SayText"),_,players[i]);
- write_byte(players[i]);
- write_string(msg);
- message_end();
- }
- }
- }
You can use it in main menu like:
- public Buy_Primary_Weapon(id, selection)
- {
- static szWeaponName[32]
- ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
- new iWeaponId = get_weaponid(szWeaponName)
- // Strip and Give Full Weapon
- if (is_has_paint_ball_gun(id) /*|| Anything here*/)
- {
- rg_give_item(id, szWeaponName, GT_APPEND)
- }
- else
- {
- rg_give_item(id, szWeaponName, GT_REPLACE)
- }
- rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
- // Primary bought
- g_bBoughtPrimary[id] = true
- }
Make same for all weapons.
He who fails to plan is planning to fail
Well shit that did not work!Raheem wrote: ↑5 years ago Here i added the native:
#include <zombie_escape> #include <engine> #define ITEM_NAME "Paintball Gun" #define ITEM_COST 50 new PAINTBALL_V_MODEL[64] = "models/zombie_escape/v_paintballgun.mdl" new PAINTBALL_P_MODEL[64] = "models/zombie_escape/p_paintballgun.mdl" new PAINTBALL_W_MODEL[64] = "models/zombie_escape/w_paintballgun.mdl" new g_paintSprite[2][] = {"sprites/bhit.spr", "sprites/richo1.spr"} new lastammo[33], g_paintball_gun[33], g_ballsnum = 0 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); // Cvars // new paintball_lifetime, paintball_maxballs, paintball_dmg_multi, paintball_unlimited_clip, g_iItemID public plugin_natives() { register_native("is_has_paint_ball_gun", "native_is_has_paint_ball_gun", 1) } public plugin_init() { register_plugin("[ZE] Extra Item: Paint Ball Gun", "1.1", "KRoTaL | [P]erfec[T] [S]cr[@]s[H] | Mark") register_cvar("ze_paintballgun", "1.1", FCVAR_SERVER|FCVAR_UNLOGGED); RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage") RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_AddToPlayer") register_forward(FM_SetModel, "fw_SetModel") register_event("CurWeapon", "make_paint", "be", "3>0") register_event("WeapPickup","checkModel","b","1=19") register_event("CurWeapon","checkWeapon","be","1=1") register_event("HLTV", "new_round", "a", "1=0", "2=0") paintball_maxballs = register_cvar("ze_paintball_maxballs", "200") paintball_lifetime = register_cvar("ze_paintball_lifetime", "10") paintball_dmg_multi = register_cvar("ze_paintball_dmg_multi", "4") paintball_unlimited_clip = register_cvar("ze_paintball_unlimited_clip", "0") g_iItemID = ze_register_item(ITEM_NAME, ITEM_COST, 0) } public plugin_precache() { precache_model("sprites/bhit.spr") precache_model("sprites/richo1.spr") precache_model(PAINTBALL_V_MODEL) precache_model(PAINTBALL_P_MODEL) precache_model(PAINTBALL_W_MODEL) } public native_is_has_paint_ball_gun(id) { return g_paintball_gun[id]; } public fw_TakeDamage(victim, inflictor, attacker, Float:damage) { if (is_user_alive(attacker) && get_user_weapon(attacker) == CSW_MP5NAVY && g_paintball_gun[attacker] && !ze_is_user_zombie(attacker)) { SetHamParamFloat(4, damage * get_pcvar_float(paintball_dmg_multi )) set_rendering(victim, kRenderFxGlowShell, random_num(0,255), random_num(0,255), random_num(0,255), kRenderNormal, 16); set_task(5.0, "remove_glow", victim) } } public ze_user_humanized(id) { g_paintball_gun[id] = false remove_glow(id) } public ze_user_infected(iVictim) { g_paintball_gun[iVictim] = false remove_glow(iVictim) } public ze_select_item_pre(id, itemid) { if (itemid != g_iItemID) return ZE_ITEM_AVAILABLE if (ze_is_user_zombie(id)) return ZE_ITEM_DONT_SHOW return ZE_ITEM_AVAILABLE } public ze_select_item_post(id, itemid) { if (itemid != g_iItemID) return ze_colored_print(id, "Congrats! You have bought a Paintball Gun! :D") Get_MyWeapon(id) } public Get_MyWeapon(id) { drop_weapons(id, 1); g_paintball_gun[id] = true give_item(id, "weapon_mp5navy") } public remove_glow(id) { set_rendering(id); } public checkWeapon(id) { new plrClip, plrAmmo, plrWeap[32], plrWeapId plrWeapId = get_user_weapon(id, plrClip , plrAmmo) if (plrWeapId == CSW_MP5NAVY && g_paintball_gun[id]) checkModel(id) else return PLUGIN_CONTINUE; if (plrClip == 0 && get_pcvar_num(paintball_unlimited_clip)) { // If the user is out of ammo.. get_weaponname(plrWeapId, plrWeap, 31) // Get the name of their weapon give_item(id, plrWeap) engclient_cmd(id, plrWeap) engclient_cmd(id, plrWeap) engclient_cmd(id, plrWeap) } return PLUGIN_HANDLED } public checkModel(id) { if (ze_is_user_zombie(id)) return PLUGIN_HANDLED; new szWeapID = read_data(2) if ( szWeapID == CSW_MP5NAVY && g_paintball_gun[id]) { entity_set_string(id, EV_SZ_viewmodel, PAINTBALL_V_MODEL) entity_set_string(id, EV_SZ_weaponmodel, PAINTBALL_P_MODEL) } return PLUGIN_HANDLED } public make_paint(id) { new ammo = read_data(3) if(get_user_weapon(id) == CSW_MP5NAVY && lastammo[id] > ammo && g_paintball_gun[id]) { new iOrigin[3] get_user_origin(id, iOrigin, 4) new Float:fOrigin[3] IVecFVec(iOrigin, fOrigin) if(g_ballsnum < get_pcvar_num(paintball_maxballs) && worldInVicinity(fOrigin)) { new ent = create_entity("info_target") if(ent > 0) { entity_set_string(ent, EV_SZ_classname, "paint_ent") entity_set_int(ent, EV_INT_movetype, 0) entity_set_int(ent, EV_INT_solid, 0) entity_set_model(ent, g_paintSprite[random_num(0,1)]) new r, g, b r = random_num(64,255) g = random_num(64,255) b = random_num(64,255) set_rendering(ent, kRenderFxNoDissipation, r, g, b, kRenderGlow, 255) entity_set_origin(ent, fOrigin) entity_set_int(ent, EV_INT_flags, FL_ALWAYSTHINK) entity_set_float(ent, EV_FL_nextthink, get_gametime() + get_pcvar_float(paintball_lifetime)) ++g_ballsnum } } } lastammo[id] = ammo } public pfn_think(entity) { if(!is_valid_ent(entity)) return new class[32]; entity_get_string(entity, EV_SZ_classname, class, 31) if(entity > 0 && equal(class, "paint_ent")) { remove_entity(entity) --g_ballsnum } } public new_round() { for(new id = 1; id <= get_maxplayers(); id++) g_paintball_gun[id] = false remove_entity_name("paint_ent") g_ballsnum = 0 } stock worldInVicinity(Float:origin[3]) { new ent = find_ent_in_sphere(-1, origin, 4.0) while(ent > 0) { if(entity_get_float(ent, EV_FL_health) > 0 || entity_get_float(ent, EV_FL_takedamage) > 0.0) return 0; ent = find_ent_in_sphere(ent, origin, 4.0) } new Float:traceEnds[8][3], Float:traceHit[3], hitEnt traceEnds[0][0] = origin[0] - 2.0; traceEnds[0][1] = origin[1] - 2.0; traceEnds[0][2] = origin[2] - 2.0 traceEnds[1][0] = origin[0] - 2.0; traceEnds[1][1] = origin[1] - 2.0; traceEnds[1][2] = origin[2] + 2.0 traceEnds[2][0] = origin[0] + 2.0; traceEnds[2][1] = origin[1] - 2.0; traceEnds[2][2] = origin[2] + 2.0 traceEnds[3][0] = origin[0] + 2.0; traceEnds[3][1] = origin[1] - 2.0; traceEnds[3][2] = origin[2] - 2.0 traceEnds[4][0] = origin[0] - 2.0; traceEnds[4][1] = origin[1] + 2.0; traceEnds[4][2] = origin[2] - 2.0 traceEnds[5][0] = origin[0] - 2.0; traceEnds[5][1] = origin[1] + 2.0; traceEnds[5][2] = origin[2] + 2.0 traceEnds[6][0] = origin[0] + 2.0; traceEnds[6][1] = origin[1] + 2.0; traceEnds[6][2] = origin[2] + 2.0 traceEnds[7][0] = origin[0] + 2.0; traceEnds[7][1] = origin[1] + 2.0; traceEnds[7][2] = origin[2] - 2.0 for (new i = 0; i < 8; i++) { if (PointContents(traceEnds[i]) != CONTENTS_EMPTY) return 1; hitEnt = trace_line(0, origin, traceEnds[i], traceHit) if (hitEnt != -1) return 1; for (new j = 0; j < 3; j++) if (traceEnds[i][j] != traceHit[j]) return 1; } return 0 } public fw_SetModel(entity, model[]) { if(!is_valid_ent(entity)) return FMRES_IGNORED; if(!equal(model, "models/w_mp5.mdl")) return FMRES_IGNORED; static szClassName[33] entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName)) if(!equal(szClassName, "weaponbox")) return FMRES_IGNORED static iOwner, iStoredMp5ID iOwner = entity_get_edict(entity, EV_ENT_owner) iStoredMp5ID = find_ent_by_owner(-1, "weapon_mp5navy", entity) if(g_paintball_gun[iOwner] && is_valid_ent(iStoredMp5ID)) { g_paintball_gun[iOwner] = false entity_set_int(iStoredMp5ID, EV_INT_impulse, 1664656581) entity_set_model(entity, PAINTBALL_W_MODEL) return FMRES_SUPERCEDE } return FMRES_IGNORED } public fw_AddToPlayer(wpn, id) { if(is_valid_ent(wpn) && is_user_connected(id) && entity_get_int(wpn, EV_INT_impulse) == 1664656581) { g_paintball_gun[id] = true entity_set_int(wpn, EV_INT_impulse, 0) return HAM_HANDLED } return HAM_IGNORED } stock give_item(index, const item[]) { if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10)) return 0; new ent = create_entity(item); if (!pev_valid(ent)) return 0; new Float:origin[3]; pev(index, pev_origin, origin); set_pev(ent, pev_origin, origin); set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN); dllfunc(DLLFunc_Spawn, ent); new save = pev(ent, pev_solid); dllfunc(DLLFunc_Touch, ent, index); if (pev(ent, pev_solid) != save) return ent; engfunc(EngFunc_RemoveEntity, ent); return -1; } stock drop_weapons(id, dropwhat) { static weapons[32], num, i, weaponid num = 0 get_user_weapons(id, weapons, num) for (i = 0; i < num; i++) { weaponid = weapons[i] if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) { static wname[32] get_weaponname(weaponid, wname, sizeof wname - 1) engclient_cmd(id, "drop", wname) } } } stock client_printcolor(const id,const input[], any:...) { new msg[191], players[32], count = 1 vformat(msg,190,input,3); replace_all(msg,190,"!g","^4"); // green replace_all(msg,190,"!y","^1"); // normal replace_all(msg,190,"!t","^3"); // team if (id) players[0] = id; else get_players(players,count,"ch"); for (new i=0;i<count;i++) { if (is_user_connected(players[i])) { message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("SayText"),_,players[i]); write_byte(players[i]); write_string(msg); message_end(); } } }
You can use it in main menu like:
public Buy_Primary_Weapon(id, selection) { static szWeaponName[32] ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName)) new iWeaponId = get_weaponid(szWeaponName) // Strip and Give Full Weapon if (is_has_paint_ball_gun(id) /*|| Anything here*/) { rg_give_item(id, szWeaponName, GT_APPEND) } else { rg_give_item(id, szWeaponName, GT_REPLACE) } rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId]) // Primary bought g_bBoughtPrimary[id] = true }
Make same for all weapons.
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
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
- public ze_user_humanized(id)
- {
- // Static Values
- switch (ze_get_user_level(id))
- {
- case 0..4: WPN_MAXIDS[id] = 2
- case 5..9: WPN_MAXIDS[id] = 4
- case 10..14: WPN_MAXIDS[id] = 6
- case 15..19: WPN_MAXIDS[id] = 8
- case 20..24: WPN_MAXIDS[id] = 10
- case 25..29: WPN_MAXIDS[id] = 12
- case 30: WPN_MAXIDS[id] = 14
- }
- if (ze_get_user_level(id) > 30)
- {
- WPN_MAXIDS[id] = 14
- }
- // Buyzone time starts when player is set to human
- g_flBuyTimeStart[id] = get_gametime()
- g_bBoughtPrimary[id] = false
- g_bBoughtSecondary[id] = false
- // Player dead or zombie
- if (!is_user_alive(id) || ze_is_user_zombie(id))
- return
- if (WPN_AUTO_ON)
- {
- if (is_has_paint_ball_gun(id) /*|| Anything here*/)
- return
- ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
- Buy_Primary_Weapon(id, WPN_AUTO_PRI)
- Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
- }
- // Open available buy menus
- Show_Available_Buy_Menus(id)
- // Give HE Grenade
- if (get_pcvar_num(g_pCvarHEGrenade) != 0)
- rg_give_item(id, "weapon_hegrenade")
- // Give Smoke Grenade
- if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
- rg_give_item(id, "weapon_smokegrenade")
- // Give Flashbang Grenade
- if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
- rg_give_item(id, "weapon_flashbang")
- }
Ok here is the working code with the only changes i made to the org file seems to be working....
- public ze_user_humanized(id)
- {
- // Static Values
- switch (ze_get_user_level(id))
- {
- case 0..4: WPN_MAXIDS[id] = 2
- case 5..9: WPN_MAXIDS[id] = 4
- case 10..14: WPN_MAXIDS[id] = 6
- case 15..19: WPN_MAXIDS[id] = 8
- case 20..24: WPN_MAXIDS[id] = 10
- case 25..29: WPN_MAXIDS[id] = 12
- case 30: WPN_MAXIDS[id] = 14
- }
- if (ze_get_user_level(id) > 30)
- {
- WPN_MAXIDS[id] = 14
- }
- // Buyzone time starts when player is set to human
- g_flBuyTimeStart[id] = get_gametime()
- g_bBoughtPrimary[id] = false
- g_bBoughtSecondary[id] = false
- // Player dead or zombie
- if (!is_user_alive(id) || ze_is_user_zombie(id))
- return
- if (WPN_AUTO_ON)
- {
- if (is_has_paint_ball_gun(id) /*|| Anything here*/)
- return
- ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
- Buy_Primary_Weapon(id, WPN_AUTO_PRI)
- Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
- }
- // Open available buy menus
- Show_Available_Buy_Menus(id)
- // Give HE Grenade
- if (get_pcvar_num(g_pCvarHEGrenade) != 0)
- rg_give_item(id, "weapon_hegrenade")
- // Give Smoke Grenade
- if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
- rg_give_item(id, "weapon_smokegrenade")
- // Give Flashbang Grenade
- if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
- rg_give_item(id, "weapon_flashbang")
- }
I think i got this figured out ill let you know in a few days i had to add more code...
My method failed in what? viewtopic.php?p=8966#p8966
Let me know how my idea working for you.
Let me know how my idea working for you.
He who fails to plan is planning to fail
-
- Member
- Posts: 2
- Joined: 2 years ago
- Contact:
Good to share
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
Sign in
Who is online
Users browsing this forum: No registered users and 5 guests