Post by launcherr on Jun 14, 2016 19:17:06 GMT
When buy this item no drop current weapon and player have 2 weapons lol. I want to drop current weapons and give ak47 only.
Another bug is when give ak47 have only 30 bullets (using gunxp plugin and zp special 3.5)
Can you fix the ammo and optimize code?
Another bug is when give ak47 have only 30 bullets (using gunxp plugin and zp special 3.5)
Can you fix the ammo and optimize code?
#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <cstrike>
#include <colorchat>
#include <zombie_plague_special>
#define is_valid_player(%1) (1 <= %1 <= 32)
new AK_V_MODEL[64] = "models/launcherr/v_ak47.mdl"
new AK_P_MODEL[64] = "models/launcherr/p_ak47.mdl"
new cvar_dmgmultiplier, cvar_custommodel, cvar_uclip
new g_itemid
new bool:g_HasAk[33]
const Wep_ak47 = ((1<<CSW_AK47))
public plugin_init()
{
cvar_dmgmultiplier = register_cvar("zp_goldenak_dmg_multiplier", "3")
cvar_custommodel = register_cvar("zp_goldenak_custom_model", "1")
cvar_uclip = register_cvar("zp_goldenak_unlimited_clip", "0")
register_plugin("Extra item silver ak47","1.1","AlejandroSk")
g_itemid = zp_register_extra_item("Silver ak47", 30, ZP_TEAM_HUMAN)
register_event("DeathMsg", "Death", "a")
register_event("WeapPickup","checkModel","b","1=19")
register_event("CurWeapon","checkWeapon","be","1=1")
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
}
public client_connect(id)
{
g_HasAk[id] = false
}
public client_disconnect(id)
{
g_HasAk[id] = false
}
public Death()
{
g_HasAk[read_data(2)] = false
}
public fwHamPlayerSpawnPost(id)
{
g_HasAk[id] = false
}
public plugin_precache()
{
precache_model(AK_V_MODEL)
precache_model(AK_P_MODEL)
}
public zp_user_infected_post(id)
{
if (zp_get_user_zombie(id))
{
g_HasAk[id] = false
}
}
public checkModel(id)
{
if ( zp_get_user_zombie(id) )
return PLUGIN_HANDLED
new szWeapID = read_data(2)
if ( szWeapID == CSW_AK47 && g_HasAk[id] == true && get_pcvar_num(cvar_custommodel) )
{
set_pev(id, pev_viewmodel2, AK_V_MODEL)
set_pev(id, pev_weaponmodel2, AK_P_MODEL)
}
return PLUGIN_HANDLED
}
public checkWeapon(id)
{
new plrClip, plrAmmo, plrWeap[32]
new plrWeapId
plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
if (plrWeapId == CSW_AK47 && g_HasAk[id])
{
checkModel(id)
}
else
{
return PLUGIN_CONTINUE
}
if (plrClip == 0 && get_pcvar_num(cvar_uclip))
{
get_weaponname(plrWeapId, plrWeap, 31)
give_item(id, plrWeap)
engclient_cmd(id, plrWeap)
engclient_cmd(id, plrWeap)
engclient_cmd(id, plrWeap)
}
return PLUGIN_HANDLED
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
if(is_user_connected(attacker))
{
if(get_user_weapon(attacker) == CSW_AK47 && g_HasAk[attacker])
{
SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmgmultiplier))
}
}
}
public zp_extra_item_selected(player, itemid)
{
if ( itemid == g_itemid )
{
if ( user_has_weapon(player, CSW_AK47 & CSW_M4A1) )
{
drop_prim(player)
}
give_item(player, "weapon_ak47")
ColorChat( player, GREEN, "[Gameplay-BG]^1 You bought ^3Silver ak47" )
g_HasAk[player] = true;
}
}
stock drop_prim(id)
{
new weapons[32], num
get_user_weapons(id, weapons, num)
for (new i = 0; i < num; i++) {
if (Wep_ak47 & (1<<weapons[i]))
{
static wname[32]
get_weaponname(weapons[i], wname, sizeof wname - 1)
engclient_cmd(id, "drop", wname)
}
}
}