Страница 1 от 1

Help fixing an Gunxp Unlock Model Problem

Публикувано на: 08 Юли 2019, 20:05
от Infamous2018
Hello, i have an problem. I dont get errors but the Modelchanging after Upgrade dont work. Any Idea ?

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <engine>
#include <gxm_shop>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>

#define IsPlayer(%1) (1 <= %1 <= g_maxplayers)
new ItemIndex
new cvar_knock;
const m_flNextSecondaryAttack = 47;
const m_pPlayer	= 41
const m_flPrimaryAttack = 46;
static bool:Knife[33]

new const KNIFE_MDL[] = "models/gunxp/v_baseball.mdl";	

new g_maxplayers, damage_knife, bool:g_KNIFE[33];

public plugin_precache()
	engfunc(EngFunc_PrecacheModel, KNIFE_MDL);

public plugin_init()
{
	register_plugin("TEST KNIFE BASEBAT" , "1.0" , "Invis");
	
	RegisterHam(Ham_TakeDamage, "player", "Ham_Damage");

	register_event("CurWeapon",	"Event_CurWeaponKNIFE", "be", "1=1")
	register_event("Damage" , "event_Damage" , "b" , "2>0");

	ItemIndex = gxm_register_knife("Base", 1000, 0, 1, 0, "KNIFE")
	
	damage_knife = register_cvar("gxm_knife_damage", "2.0");
	cvar_knock = register_cvar("gxm_knife_knocks" , "50");
	
	g_maxplayers = get_maxplayers();
}

public gxm_knife_selected(id, itemid)
{
	if(ItemIndex == itemid)
	{
		Knife[id] = true
	}
}

public client_connect(id)
	g_KNIFE[id] = false;

public Event_CurWeaponKNIFE(id) 
{
	if (!g_KNIFE[id] || cs_get_user_team(id) == CS_TEAM_T)
		return PLUGIN_CONTINUE;

	new Gun = read_data(2);
	
	if(Gun == CSW_KNIFE)
		set_pev(id, pev_viewmodel2, KNIFE_MDL);
	
	return PLUGIN_CONTINUE;
}

public event_Damage(id)
{
	if(!is_user_alive(id))
		return PLUGIN_CONTINUE;

	new weapon, attacker = get_user_attacker(id, weapon);

	if(!is_user_alive(attacker))
		return PLUGIN_CONTINUE;

	if (!g_KNIFE[attacker])
		return PLUGIN_CONTINUE;

	if(weapon == CSW_KNIFE && cs_get_user_team(attacker) == CS_TEAM_CT)
	{
		new Float:vec[3];
		new Float:oldvelo[3];
		get_user_velocity(id, oldvelo);
		create_velocity_vector(id , attacker , vec);
		vec[0] += oldvelo[0];
		vec[1] += oldvelo[1];
		set_user_velocity(id , vec);
	}

	return PLUGIN_CONTINUE;
}

public Ham_Damage(id, inflictor, attacker, Float:damage, damagebits) 
{
	if ( !(1 <= attacker <= g_maxplayers) || !g_KNIFE[attacker] || cs_get_user_team(attacker) == CS_TEAM_T || damagebits == 16777216)
		return HAM_IGNORED; 

	new weaponx = get_user_weapon(attacker, _, _);
	if(weaponx == CSW_KNIFE && damagebits != 16777216)
	{
		SetHamParamFloat(4, damage * get_pcvar_float(damage_knife));
		return HAM_HANDLED;
	}
	return HAM_IGNORED;
}

// Stock by the one and only, Chronic :P
stock create_velocity_vector(victim,attacker,Float:velocity[3])
{
	if(!is_user_alive(attacker))
		return 0;

	new Float:vicorigin[3];
	new Float:attorigin[3];
	entity_get_vector(victim   , EV_VEC_origin , vicorigin);
	entity_get_vector(attacker , EV_VEC_origin , attorigin);

	new Float:origin2[3]
	origin2[0] = vicorigin[0] - attorigin[0];
	origin2[1] = vicorigin[1] - attorigin[1];

	new Float:largestnum = 0.0;

	if(floatabs(origin2[0])>largestnum) largestnum = floatabs(origin2[0]);
	if(floatabs(origin2[1])>largestnum) largestnum = floatabs(origin2[1]);

	origin2[0] /= largestnum;
	origin2[1] /= largestnum;

	velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knock) * 3000) ) / get_entity_distance(victim , attacker);
	velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knock) * 3000) ) / get_entity_distance(victim , attacker);
	if(velocity[0] <= 20.0 || velocity[1] <= 20.0)
		velocity[2] = random_float(200.0 , 275.0);

	return 1;
}

Inc File for Unlocks:

Код за потвърждение: Избери целия код

#if defined _gxm_shop_included
    #endinput
#endif

#define _gxm_shop_included

native gxm_register_gun( const Name[ ], const XP, const Level = 0, const VIP = 0, const Round = 0, const Type[ ] = 0);
native gxm_register_item( const Name[ ], const XP, const Level = 0, const VIP = 0, const Round = 0, const Type[ ] = 0);
native gxm_register_pistol( const Name[ ], const XP, const Level = 0, const VIP = 0, const Round = 0, const Type[ ] = 0);
native gxm_register_knife( const Name[ ], const XP, const Level = 0, const VIP = 0, const Round = 0, const Type[ ] = 0);
native gxm_register_grenade( const Name[ ], const XP, const Level = 0, const VIP = 0, const Round = 0, const Type[ ] = 0);



forward gxm_gun_selected( Player, ItemIndex);
forward gxm_item_selected( Player, ItemIndex);
forward gxm_pistol_selected( Player, ItemIndex);
forward gxm_knife_selected( Player, ItemIndex);
forward gxm_grenade_selected( Player, ItemIndex);

Help fixing an Gunxp Unlock Model Problem

Публикувано на: 09 Юли 2019, 15:52
от OciXCrom

Код за потвърждение: Избери целия код

public Event_CurWeaponKNIFE(id) 
{
	if (!g_KNIFE[id] || cs_get_user_team(id) == CS_TEAM_T)
		return PLUGIN_CONTINUE;

	new Gun = read_data(2);
	
	if(Gun == CSW_KNIFE)
		set_pev(id, pev_viewmodel2, KNIFE_MDL);
	
	return PLUGIN_CONTINUE;
}
The variable g_iKNIFE is never set to true in the code, so the entire function won't even run. In fact, the variable is only created and checked, but never set to anything, so it's always false. I don't know what the author was thinking, but I'll assume that he mixed up the variable names, as there is already another variable called Knife. See if changing the variable name will work:

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <engine>
#include <gxm_shop>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>

#define IsPlayer(%1) (1 <= %1 <= g_maxplayers)
new ItemIndex
new cvar_knock;
const m_flNextSecondaryAttack = 47;
const m_pPlayer	= 41
const m_flPrimaryAttack = 46;
static bool:Knife[33]

new const KNIFE_MDL[] = "models/gunxp/v_baseball.mdl";	

new g_maxplayers, damage_knife;

public plugin_precache()
	engfunc(EngFunc_PrecacheModel, KNIFE_MDL);

public plugin_init()
{
	register_plugin("TEST KNIFE BASEBAT" , "1.0" , "Invis");
	
	RegisterHam(Ham_TakeDamage, "player", "Ham_Damage");

	register_event("CurWeapon",	"Event_CurWeaponKNIFE", "be", "1=1")
	register_event("Damage" , "event_Damage" , "b" , "2>0");

	ItemIndex = gxm_register_knife("Base", 1000, 0, 1, 0, "KNIFE")
	
	damage_knife = register_cvar("gxm_knife_damage", "2.0");
	cvar_knock = register_cvar("gxm_knife_knocks" , "50");
	
	g_maxplayers = get_maxplayers();
}

public gxm_knife_selected(id, itemid)
{
	if(ItemIndex == itemid)
	{
		Knife[id] = true
	}
}

public client_connect(id)
	Knife[id] = false;

public Event_CurWeaponKNIFE(id) 
{
	if (!Knife[id] || cs_get_user_team(id) == CS_TEAM_T)
		return PLUGIN_CONTINUE;

	new Gun = read_data(2);
	
	if(Gun == CSW_KNIFE)
		set_pev(id, pev_viewmodel2, KNIFE_MDL);
	
	return PLUGIN_CONTINUE;
}

public event_Damage(id)
{
	if(!is_user_alive(id))
		return PLUGIN_CONTINUE;

	new weapon, attacker = get_user_attacker(id, weapon);

	if(!is_user_alive(attacker))
		return PLUGIN_CONTINUE;

	if (!Knife[attacker])
		return PLUGIN_CONTINUE;

	if(weapon == CSW_KNIFE && cs_get_user_team(attacker) == CS_TEAM_CT)
	{
		new Float:vec[3];
		new Float:oldvelo[3];
		get_user_velocity(id, oldvelo);
		create_velocity_vector(id , attacker , vec);
		vec[0] += oldvelo[0];
		vec[1] += oldvelo[1];
		set_user_velocity(id , vec);
	}

	return PLUGIN_CONTINUE;
}

public Ham_Damage(id, inflictor, attacker, Float:damage, damagebits) 
{
	if ( !(1 <= attacker <= g_maxplayers) || !Knife[attacker] || cs_get_user_team(attacker) == CS_TEAM_T || damagebits == 16777216)
		return HAM_IGNORED; 

	new weaponx = get_user_weapon(attacker, _, _);
	if(weaponx == CSW_KNIFE && damagebits != 16777216)
	{
		SetHamParamFloat(4, damage * get_pcvar_float(damage_knife));
		return HAM_HANDLED;
	}
	return HAM_IGNORED;
}

// Stock by the one and only, Chronic :P
stock create_velocity_vector(victim,attacker,Float:velocity[3])
{
	if(!is_user_alive(attacker))
		return 0;

	new Float:vicorigin[3];
	new Float:attorigin[3];
	entity_get_vector(victim   , EV_VEC_origin , vicorigin);
	entity_get_vector(attacker , EV_VEC_origin , attorigin);

	new Float:origin2[3]
	origin2[0] = vicorigin[0] - attorigin[0];
	origin2[1] = vicorigin[1] - attorigin[1];

	new Float:largestnum = 0.0;

	if(floatabs(origin2[0])>largestnum) largestnum = floatabs(origin2[0]);
	if(floatabs(origin2[1])>largestnum) largestnum = floatabs(origin2[1]);

	origin2[0] /= largestnum;
	origin2[1] /= largestnum;

	velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_knock) * 3000) ) / get_entity_distance(victim , attacker);
	velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knock) * 3000) ) / get_entity_distance(victim , attacker);
	if(velocity[0] <= 20.0 || velocity[1] <= 20.0)
		velocity[2] = random_float(200.0 , 275.0);

	return 1;
}

Help fixing an Gunxp Unlock Model Problem

Публикувано на: 09 Юли 2019, 18:07
от Infamous2018
You are the best one. It works. can u tell me exactly what u did? Maybe i can learn how to fix my other problems, i have more problems with other unlocks with the self problem...

Help fixing an Gunxp Unlock Model Problem

Публикувано на: 09 Юли 2019, 20:12
от OciXCrom
I just changed the g_iKNIFE variable to Knife - the author created 2 different variables instead of using only the one.

Help fixing an Gunxp Unlock Model Problem

Публикувано на: 09 Юли 2019, 21:08
от Infamous2018
mhhh its possible that it was me xD I tried to fix more things , there was also an bug about upgrade the item and block rest upgrade unlocks from Rest of Knifes. Its possible that i added this without to know what i am doing there.