Gente é o seguinte, quando eu compro este item a munição dele fica 10/0 em vez de ficar 10/30:
Agradeço desde já!
- Código:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include < fun >
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#define PLUGIN "[ZP] Sniper"
#define VERSION "1.0"
#define AUTHOR "Vechta"
new cvar_health, cvar_armor, cvar_speed, cvar_damage, cvar_glow, cvar_gravity
new g_sniper[33], g_hassniper[33]
new g_item_sniper
new const g_item_name[] = "Sniper" // Item name
new const g_item_cost = 10 // Item cost
new const g_item_team = ZP_TEAM_HUMAN // Item team
new const SNIPER_AWP[] = "models/zombie_plague/v_awp.mdl" // here you can change to your awp model
#define is_valid_player(%1) (1 <= %1 <= 32) // Check player
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_item_sniper = zp_register_extra_item(g_item_name, g_item_cost, g_item_team) // Register Sniper as Item
cvar_health = register_cvar("zp_sniper_health", "500") // Default - 100
cvar_armor = register_cvar("zp_sniper_armor", "500") // Default - 100
cvar_speed = register_cvar("zp_sniper_speed", "300.0") // Default - 240.0
cvar_gravity = register_cvar("zp_sniper_gravity", "0.8") // Default - 0.5 (Half gravity)
cvar_damage = register_cvar("zp_sniper_awp_damage", "1000") // Default - 1000
cvar_glow = register_cvar("zp_sniper_glow", "0 255 0") // Default - 0 255 0
register_event("CurWeapon", "Event_CurWeapon", "be", "1=1"); // Awp model
RegisterHam(Ham_TakeDamage, "player", "Fw_PlayerDamaged", 1) // Register sniper damage
register_forward(FM_PlayerPreThink, "fm_PlayerPreThink") // Replace speed?
}
public plugin_precache()
precache_model(SNIPER_AWP) // Precache Awp model
public zp_round_ended(win)
{
arrayset(g_sniper, false, 32)
arrayset(g_hassniper, false, 32)
}
public zp_extra_item_selected(player, itemid)
{
if (itemid == g_item_sniper)
{
if (!g_hassniper[player])
{
// Set the player to Sniper
g_sniper[player] = true
g_hassniper[player] = true
// Change users: health, armor, speed, gravity
set_user_health(player, get_user_health(player) + get_pcvar_num(cvar_health))
set_user_armor(player, get_user_armor(player) + get_pcvar_num(cvar_armor))
set_pev(player, pev_speed, get_pcvar_float(cvar_speed))
set_pev(player, pev_gravity, get_pcvar_float(cvar_gravity))
// Strip first users weapon to give Awp
strip_user_weapons(player)
// Give weapon awp
give_item(player, "weapon_knife")
give_item(player, "weapon_awp")
}
else
{
client_print(player, print_chat, "[ZP] You are already a Sniper!")
return ZP_PLUGIN_HANDLED;
}
}
return PLUGIN_HANDLED;
}
public Fw_PlayerDamaged(id, inflictor, attacker, damage, damagebits)
{
if ( is_valid_player(attacker) && get_user_weapon(attacker) == CSW_AWP && g_hassniper[attacker] )
SetHamParamFloat(4, damage *= get_pcvar_float(cvar_damage))
}
public Event_CurWeapon(id)
{
if (get_user_weapon(id) == CSW_AWP && g_hassniper[id])
set_pev(id, pev_viewmodel2, SNIPER_AWP)
}
public fm_PlayerPreThink(id)
{
if (!is_user_alive(id)) return;
if (g_hassniper[id])
set_pev(id, pev_speed, get_pcvar_float(cvar_speed))
}
public SetUserGlow(id)
{
if (!is_user_alive(id) || zp_get_user_zombie(id) || zp_get_user_nemesis(id)) return;
if (g_hassniper[id])
{
// Glow part
new szColors[16]
get_pcvar_string(cvar_glow, szColors, 15)
new gRed[4], gGreen[4], gBlue[4], iRed, iGreen, iBlue
parse(szColors, gRed, 3, gGreen, 3, gBlue, 3)
iRed = clamp(str_to_num(gRed), 0, 255)
iGreen = clamp(str_to_num(gGreen), 0, 255)
iBlue = clamp(str_to_num(gBlue), 0, 255)
set_user_rendering(id, kRenderFxGlowShell, iRed, iGreen, iBlue, kRenderNormal, 20)
}
}
Agradeço desde já!