Raised This Month: $51 Target: $400
 12% 

Border unlock Gunxpmod Question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 03-17-2018 , 09:47   Border unlock Gunxpmod Question
Reply With Quote #1

I have a question, maybe someone can tell me how to set a limit, for example, if someone upgrades a weapon, that he can only use this upgrade if the server has 20 players. But when Server have 19 Players the upgrade get auto disabled. Is that even possible?

Could someone show me this with the help of this example sma?

Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#include <gxm_shop>
#include <engine>
#include <cstrike>

new PLUGIN_NAME[] 	    = "Ginklas P228"
new PLUGIN_AUTHOR[] 	= "Invis"
new PLUGIN_VERSION[] 	= "1.0"

new const WEAPON_V_MDL[] = "models/gunxp/v_p228_golden.mdl";
new const WEAPON_W_MDL[] = "models/w_p228.mdl";
#define WEAPON_CSW CSW_P228
new const weapon_n[] = "weapon_p228";

const m_pPlayer	= 41;
const m_flPrimaryAttack = 46;

#define IsPlayer(%1)  ( 1 <= %1 <= g_maxplayers )

new damage_weapon, weapon_recoil;
new g_maxplayers;	
new bool:g_Weapon[33]; 
new Float:cl_pushangle[33][3];
new item_pistol
public plugin_init() 
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

	item_pistol = gxm_register_pistol("P228 Golden", 100, 2, 0, 0, "P228")

	damage_weapon = register_cvar("gxm_damage_p228","1.9"); 
	weapon_recoil = register_cvar( "p228_recoil", "1.0" );  

	register_event("CurWeapon", "Event_CurWeapon", "be", "1=1");
	
	RegisterHam( Ham_Weapon_PrimaryAttack, weapon_n, "Fwd_AttackSpeedPost" , 1 );
	RegisterHam(Ham_Weapon_PrimaryAttack, weapon_n, "Fwd_AttackSpeedPre");

	RegisterHam( Ham_Item_Deploy , weapon_n, "Fwd_AttackSpeedPost", 1);

	RegisterHam(Ham_TakeDamage, "player", "Ham_DamageWeapon");

	register_forward( FM_CmdStart, "Fwd_CmdStart" );

	g_maxplayers = get_maxplayers();

}
public gxm_pistol_selected(id, itemid) 
{
	if(item_pistol == itemid)
	{
		g_Weapon[id] = true
	}
}
public client_connect(id) 
{
	g_Weapon[id] = false;
}
public plugin_precache()  
{
	engfunc(EngFunc_PrecacheModel, WEAPON_V_MDL);
        engfunc(EngFunc_PrecacheModel, WEAPON_W_MDL);
}

public Fwd_AttackSpeedPre(Ent)
{
	new id = pev(Ent,pev_owner);
	entity_get_vector( id, EV_VEC_punchangle, cl_pushangle[id]);
}
public Fwd_AttackSpeedPost( const Entity )
{
	static id ; id = get_pdata_cbase(Entity, m_pPlayer, 4)
	if (g_Weapon[id] && IsPlayer(id) )
	{

		new Float:push[3];
		entity_get_vector( id, EV_VEC_punchangle, cl_pushangle[id]);
		xs_vec_sub( push, cl_pushangle[id], push);
		xs_vec_mul_scalar( push, get_pcvar_float( weapon_recoil ), push);
		xs_vec_add( push, cl_pushangle[id], push);
		entity_set_vector( id, EV_VEC_punchangle, push);
	}
}

public Ham_DamageWeapon(id, inflictor, attacker, Float:damage, damagebits) 
{
	if ( !IsPlayer(attacker) || !g_Weapon[attacker] )
        	return HAM_IGNORED; 

	new weapon2 = get_user_weapon(attacker, _, _);
	if( weapon2 == WEAPON_CSW)
	{
		SetHamParamFloat(4, damage * get_pcvar_float(damage_weapon));
		return HAM_HANDLED;
	}

	return HAM_IGNORED;
}

public Event_CurWeapon(id) 
{
	if ( !g_Weapon[id] || !is_user_alive(id) )
	return PLUGIN_CONTINUE;

	new Gun = read_data(2) 

	if( Gun == WEAPON_CSW)
	{
		entity_set_string(id, EV_SZ_viewmodel, WEAPON_V_MDL)
	}

	return PLUGIN_CONTINUE;
}
Godofwar is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 03-17-2018 , 10:49   Re: Border unlock Gunxpmod Question
Reply With Quote #2

Code:
    new Y[32], X;
    get_players(Y, X);
   
    if (X == 20)
    {
         //  Add code here
    }

Last edited by raizo11; 03-17-2018 at 10:52.
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 03-17-2018 , 15:21   Re: Border unlock Gunxpmod Question
Reply With Quote #3

Could u edit the sma and tell me what u added/edited... ?!
Godofwar is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:02.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode