[ZP] Constructor Soldier

Descarcari de pluginuri si discutii despre acestea.

Moderators: Moderatori ajutători, Scripteri TheXForce

Post Reply
User avatar
Rainq
Fost administrator
Fost administrator
Posts: 381
Joined: Mon Jan 18, 2021 7:25 am
Status: Citesc forumul TheXForce.RO...!
Detinator Steam: Da
SteamID: mrainq
Gaming experience: Nu spun..
Reputatie: Fost administrator
Nume anterior: Light
Fost detinator zm.thexforce.ro
Fost detinator dr.thexforce.ro
Location: Bucureşti
Has thanked: 2 times
Been thanked: 1 time
Contact:

[ZP] Constructor Soldier

Post by Rainq »

Descriere: Inspiratia mea cu aceasta clasa de human este de la fostul zm.oldones.ro ,eu aveam fixuri pe zp 4.3 ,zm.oldones.ro fiind 5.0 si nu puteam folosi clasa de acolo asa a aparut aceasta clasa,ideea e ca sa puteti utiliza human class trebuie sa aveti xp-ul activat ori deja pregatit human class in addons

Descarcare:

Code: Select all

#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#include <zombiexp>
#include <xs>

enum _:Coord_t 
{ 
	Float:x, 
	Float:y,
	Float:z 
}

#define VectorMA(%0,%1,%2,%3) ( %3[ x ] = %0[ x ] + %1 * %2[ x ], %3[ y ] = %0[ y ] + %1 * %2[ y ], %3[ z ] = %0[ z ] + %1 * %2[ z ] )

#define PLUGIN  "[ZP] Constructor Human"
#define VERSION "1.0"
#define AUTHOR  "Shadows Adi edited Rainq"

/* NU LE MODIFICA */
#define BAR_MINS Float:{ -6.430000, -53.943878, -0.527283 }
#define BAR_MAXS Float:{ 1.900000, 50.996113, 122.572678 }
/* NU LE MODIFICA */

#define ENT_DISTANCE 		100.0
#define TASK_CONSTRUCT 		28372
#define TASK_SOLID 			23928

enum _:Cvars
{
	Float:BARRICADE_HEALTH
}

// Human Attributes
new const hclass_name[] = { "Constructor Soldier" } // name 
new const hclass_info[] = { "[E] \w- \r[FREE]" } // description
new const hclass_model[] = { "" } // model
new const hclass_weapons[] = { "" } // weapons
const hclass_health = 230 // health
const hclass_speed = 240 // speed
const Float:hclass_gravity = 1.00 // gravity
const hclass_level = 0 // level required to use

new const g_szModel[] = "models/zp/f3barricade.mdl"
new const g_szClassName[] = "barricade"

new g_iConstructorClass
new g_iConstructorEnt[MAX_PLAYERS + 1]

new g_iMsgBarTime

new bool:g_bIsConstructing[MAX_PLAYERS + 1]
new g_iCvars[Cvars]
new g_iBarricades[MAX_PLAYERS + 1]

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	g_iConstructorClass =  zpxp_register_human_class(hclass_name, hclass_info, hclass_model, hclass_weapons, hclass_health, hclass_speed, hclass_gravity, hclass_level)
	g_iMsgBarTime = get_user_msgid("BarTime");
	new pcvar = register_cvar("construct_hp", "300")
	g_iCvars[BARRICADE_HEALTH] = get_pcvar_float(pcvar)
	register_event("HLTV", "ev_NewRound", "a", "1=0", "2=0");
	register_forward(FM_Touch, "FM_TouchPre")
	RegisterHam(Ham_Think, "info_target", "barricade_ThinkPre")
	RegisterHam(Ham_TakeDamage, "info_target", "barricade_TakeDamage_Pre", 0)
	RegisterHam(Ham_TakeDamage, "info_target", "barricade_TakeDamage_Post", 1)
	RegisterHam(Ham_Killed, "player", "Ham_PlayerKilled_Post", 1)
}

public plugin_precache()
{
	precache_model(g_szModel)
}

public client_PostThink(id)
{
	if(CheckConditions(id))
	{
		static button
		button = get_user_button(id)
		if(button & IN_USE)
		{
			ConstructPre(id)
		}
		else 
		{
			if(g_bIsConstructing[id])
			{
				StopConstruct(id)
			}
		}
	}
}

public ConstructPre(id)
{
	if(CheckConditions(id) && !g_bIsConstructing[id])
	{
		if(g_iBarricades[id] == 3) // rainq
		{
			//client_print(id, print_chat, "Max Barricades")
			return PLUGIN_HANDLED
		}

		new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))

		set_pev(iEnt, pev_classname, g_szClassName)

		engfunc(EngFunc_SetModel, iEnt, g_szModel)

		static Float:flOrigin[3], iOrigin[3]

		if(engfunc(EngFunc_PointContents, flOrigin) == CONTENTS_SKY)
		{
			return PLUGIN_HANDLED
		}

		g_bIsConstructing[id] = true

		get_user_origin(id, iOrigin, 0)
		IVecFVec(iOrigin, flOrigin)

		engfunc(EngFunc_SetSize, iEnt, BAR_MINS, BAR_MAXS)

		get_user_viewpoint(id, iEnt, flOrigin)
		new Float:flAngles[3]
		entity_get_vector(id, EV_VEC_angles, flAngles)
		flAngles[0] = 0.0
		//flAngles[1] -= 90.0
		flAngles[2] = 0.0

		SetEntityAngles(iEnt, flAngles)

		set_pev(iEnt, pev_mins, BAR_MINS)
		set_pev(iEnt, pev_maxs, BAR_MAXS )
		set_pev(iEnt, pev_absmin, BAR_MINS)
		set_pev(iEnt, pev_absmax, BAR_MAXS )
	
		set_pev(iEnt, pev_movetype, MOVETYPE_PUSHSTEP)

		set_pev(iEnt, pev_solid, SOLID_NOT)
		set_pev(iEnt, pev_health, g_iCvars[BARRICADE_HEALTH])
		set_pev(iEnt, pev_takedamage, DAMAGE_YES)
		set_pev(iEnt, pev_rendermode, kRenderTransAdd)
		set_pev(iEnt, pev_renderfx, kRenderFxHologram)
		set_pev(iEnt, pev_renderamt, 255.0)
		set_pev(iEnt, pev_rendercolor, {255.0,255.0,255.0})
		set_pev(iEnt, pev_nextthink, get_gametime() + 0.01)

		set_pev(iEnt, pev_owner, id)

		engfunc(EngFunc_DropToFloor, iEnt)

		ShowBarricadeBar(id, floatround(3.0)) // rainq

		g_iConstructorEnt[id] = iEnt
		set_task(3.0, "task_construct_post", id + TASK_CONSTRUCT)
	}

	return PLUGIN_HANDLED
}

public task_construct_post(id)
{
	id -= TASK_CONSTRUCT

	new iEnt = g_iConstructorEnt[id]

	if(!pev_valid(iEnt))
	{
		return
	}

	set_pev(iEnt, pev_nextthink, 0)

	set_pev(iEnt, pev_movetype, MOVETYPE_TOSS)

	set_pev(iEnt, pev_solid, SOLID_BBOX)

	set_pev(iEnt, pev_rendermode, kRenderNormal);
	set_pev(iEnt, pev_renderfx,	kRenderFxNone);

	engfunc(EngFunc_SetSize, iEnt, BAR_MINS, BAR_MAXS)
	engfunc(EngFunc_DropToFloor, iEnt)

	g_bIsConstructing[id] = false
	g_iBarricades[id] += 1
	client_print(id, print_center, "You have %d barricades left!", 3 - g_iBarricades[id]) // rainq
}

public StopConstruct(id)
{
	if(task_exists(id + TASK_CONSTRUCT))
	{
		remove_task(id + TASK_CONSTRUCT)
	}
	if(g_bIsConstructing[id])
	{
		new iEnt = g_iConstructorEnt[id]
		HideBarricadeBar(id)
		if(pev_valid(iEnt))
		{
			new flags
			pev(iEnt, pev_flags, flags);
			set_pev(iEnt, pev_flags, flags | FL_KILLME);
		}
		g_bIsConstructing[id] = false
	}
}

public ev_NewRound()
{
	remove_entity_name(g_szClassName)
	arrayset(g_iBarricades, 0, charsmax(g_iBarricades))
}

public FM_TouchPre(iToucher, iEnt)
{
	if(is_user_alive(iToucher) && pev_valid(iEnt))
	{
		static szClass[32]	
		pev(iEnt, pev_classname, szClass, charsmax(szClass))
		if (!equal(szClass, g_szClassName))
			return FMRES_IGNORED

		if(!zp_get_user_zombie(iToucher))
		{
			set_pev(iEnt, pev_solid, SOLID_NOT)
			set_pev(iEnt, pev_rendermode, kRenderTransAdd)
			set_pev(iEnt, pev_rendercolor, {255.0,255.0,255.0})
			set_task(0.3, "task_make_solid", iEnt + TASK_SOLID)
		}
	}

	return FMRES_IGNORED
}

public task_make_solid(iEnt)
{
	iEnt -= TASK_SOLID

	if(!pev_valid(iEnt))
		return FMRES_IGNORED

	static szClassName[32];
	pev(iEnt, pev_classname, szClassName, charsmax(szClassName)) 
	if(!equal(szClassName, g_szClassName)) 
		return FMRES_IGNORED;

	set_pev(iEnt, pev_solid, SOLID_BBOX)
	set_pev(iEnt, pev_rendermode, kRenderNormal)

	return FMRES_IGNORED
}

public barricade_ThinkPre(iEnt)
{
	if(!pev_valid(iEnt))
		return

	static className[32]
	pev(iEnt, pev_classname, className, charsmax(className))

	if(!equali(className, g_szClassName)) 
	{
		return
	}

	new id = pev(iEnt, pev_owner)

	if(is_user_alive(id))
	{
		new button = get_user_button(id)
		new Float:fStartPos[3], Float:fvOFS[3], Float:fAngles[3]
		pev(id, pev_origin, fStartPos)
		pev(id, pev_view_ofs, fvOFS)
		pev(id, pev_angles, fAngles)
		fAngles[0] = 0.0
		/*if(!(pev(id, pev_flags) & FL_DUCKING))
		{
			fStartPos[2] -= fvOFS[2]
		}*/
		set_pev(iEnt, pev_origin, fStartPos)
		set_pev(iEnt, pev_angles, fAngles)
		if(button & IN_FORWARD)
		{
			entity_set_aim(iEnt, id, true);
		}
		else
		{
			entity_set_aim(iEnt, id);
		}

		shift_entity_position(iEnt, 100.0, 0.0, -(fvOFS[2] + 4.0))
		engfunc(EngFunc_DropToFloor, iEnt)
		set_pev(iEnt, pev_nextthink, get_gametime() + 0.01)
	}
}

public barricade_TakeDamage_Pre(iEnt, iInflictor, iAttacker, Float:flDamage, damagebits)
{
    if(!pev_valid(iEnt))
        return HAM_IGNORED

    static className[32]
    pev(iEnt, pev_classname, className, charsmax(className))

    if(!equali(className, g_szClassName) || !is_user_connected(iAttacker)) 
    {
        return HAM_IGNORED
    }

    if(!zp_get_user_zombie(iAttacker))
    {
        return HAM_SUPERCEDE
    }

    return HAM_IGNORED
}

public barricade_TakeDamage_Post(iEnt, iInflictor, iAttacker, Float:flDamage, damagebits)
{
	if(!pev_valid(iEnt))
		return

	static className[32]
	pev(iEnt, pev_classname, className, charsmax(className))

	if(!equali(className, g_szClassName)) 
		return

	new Float:health;
	pev(iEnt, pev_health, health);

	if(is_user_connected(iAttacker) && health > 0)
	{
		client_print(iAttacker, print_center, "Barricade HP: %1.f", health)
	}
}

public Ham_PlayerKilled_Post(id)
{
	if(!pev_valid(id))
		return HAM_IGNORED

	new iEnt
	while((iEnt = find_ent_by_owner(-1, g_szClassName, id)) > 0 && is_valid_ent(iEnt))
	{
		remove_entity(iEnt)
		g_iBarricades[id] -= 1
	}

	return HAM_IGNORED
}

public zp_user_infected_post(id, infector, nemesis)
{
	new iEnt
	while((iEnt = find_ent_by_owner(-1, g_szClassName, id)) > 0 && is_valid_ent(iEnt))
	{
		remove_entity(iEnt)
	}
}

stock get_user_viewpoint(player, iEnt, Float:flOrigin[3])
{
	const Float:LENGTH = ENT_DISTANCE;

	new Float:dirForward[ 3 ];
	new Float:viewAngles[ 3 ];
	pev( player, pev_v_angle, viewAngles );
    
	engfunc( EngFunc_MakeVectors, viewAngles );
	global_get( glb_v_forward, dirForward );
    
	VectorMA( flOrigin, LENGTH, dirForward, flOrigin );
	engfunc(EngFunc_SetOrigin, iEnt, flOrigin)
}

stock entity_set_aim(ent, player, bool:bBackWards = false) 
{ 
	static Float:origin[3], Float:ent_origin[3], Float:angles[3] 
	pev(player, pev_origin, origin)
	pev(ent, pev_origin, ent_origin) 
	 
	xs_vec_sub(origin, ent_origin, origin) 
	xs_vec_normalize(origin, origin) 
	vector_to_angle(origin, angles) 
	 
	angles[0] = 0.0 
	if(entity_range(ent, player) > ENT_DISTANCE)
	{
		set_velocity(ent, angles, bBackWards)
		//angles[1] -= 90.0
		set_pev(ent, pev_angles, angles)
	}
} 

stock set_velocity(ent, Float:angles[3], bool:bBackWards = false)
{
	new Float: Direction[3] 
	angle_vector(angles, ANGLEVECTOR_FORWARD, Direction) 
	xs_vec_mul_scalar(Direction, bBackWards ? float(-hclass_speed) : float(hclass_speed), Direction)
	set_pev(ent, pev_velocity, Direction)
}

stock shift_entity_position(ent, Float:forw, Float:right, Float:up)
{
    static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vEnd[3];
    
    pev(ent, pev_origin, vOrigin);
    pev(ent, pev_angles, vAngle);
    
    angle_vector(vAngle,ANGLEVECTOR_FORWARD, vForward);
    angle_vector(vAngle,ANGLEVECTOR_RIGHT, vRight);
    
    vEnd[0] = vOrigin[0] + (vForward[0] * forw) + (vRight[0] * right);
    vEnd[1] = vOrigin[1] + (vForward[1] * forw) + (vRight[1] * right);
    vEnd[2] = vOrigin[2] + up;

    static iTr2; iTr2 = create_tr2();
    engfunc(EngFunc_TraceLine, vOrigin, vEnd, DONT_IGNORE_MONSTERS, ent, iTr2);
    get_tr2(iTr2, TR_vecEndPos, vEnd);
    free_tr2(iTr2);

    set_pev(ent, pev_origin, vEnd);
}

stock SetEntityAngles(ent, const Float:angles[3]) {
    new Float:origin[3];
    origin = GetEntityOrigin(ent);
    
    set_pev(ent, pev_angles, angles);
    set_pev(ent, pev_origin, Float:{0.0, 0.0, 0.0});
    
    new Float:newOrigin[3];
    newOrigin = GetEntityOrigin(ent);
    
    origin[0] -= newOrigin[0];
    origin[1] -= newOrigin[1];
    origin[2] -= newOrigin[2];
    
    engfunc(EngFunc_SetOrigin, ent, origin);
}

stock Float:GetEntityOrigin(ent) {
    new Float:origin[3];
    pev(ent, pev_origin, origin);
    
    new Float:center[3];
    {
        new Float:mins[3], Float:maxs[3];
        pev(ent, pev_mins, mins);
        pev(ent, pev_maxs, maxs);
        center[0] = (mins[0] + maxs[0])/2;
        center[1] = (mins[1] + maxs[1])/2;
        center[2] = (mins[2] + maxs[2])/2;
    }
    
    new Float:rotatedCenter[3];
    {
        new Float:angles[3];
        pev(ent, pev_angles, angles);
        
        engfunc(EngFunc_MakeVectors, angles);
        new Float:fwd[3], Float:left[3], Float:up[3];
        global_get(glb_v_forward, fwd);
        {
            new Float:right[3];
            global_get(glb_v_right, right);
            left[0] = -right[0];
            left[1] = -right[1];
            left[2] = -right[2];
        }
        global_get(glb_v_up, up);
        
        rotatedCenter[0] = fwd[0]*center[0] + left[0]*center[1] + up[0]*center[2];
        rotatedCenter[1] = fwd[1]*center[0] + left[1]*center[1] + up[1]*center[2];
        rotatedCenter[2] = fwd[2]*center[0] + left[2]*center[1] + up[2]*center[2];
    }
    
    origin[0] += rotatedCenter[0];
    origin[1] += rotatedCenter[1];
    origin[2] += rotatedCenter[2];
    
    return origin;
}

stock ShowBarricadeBar(id, iTime)
{
	if (pev_valid(id))
	{
		message_begin(MSG_ONE_UNRELIABLE, g_iMsgBarTime, .player=id);
		write_short(iTime);
		message_end();
	}
}

stock HideBarricadeBar(id)
{
	if (pev_valid(id))
	{
		message_begin(MSG_ONE_UNRELIABLE, g_iMsgBarTime, .player=id);
		write_short(0);
		message_end();
	}
}

stock CheckConditions(iPlayer)
{
	if(zp_is_survivor_round() || is_user_alive(iPlayer) && zp_get_user_human_class(iPlayer) == g_iConstructorClass && !zp_get_user_zombie(iPlayer))
	{
		return true
	}
	return false
}
Nume: Constructor Soldier
Versiune: 1.0
Link oficial: cspower / thexforce

Instalare:
1. Fisierul soldier_class_constructor.sma il puneti in addons/amxmodx/scripting
2. Fisierul soldier_class_constructor.amxx il puneti in addons/amxmodx/plugins
3. Intrati in fisierul addons/amxmodx/configs/plugins.ini si adaugati la urma:

Code: Select all

soldier_class_constructor.amxx
4. Alti pasi necesari....

Cvar-uri (se adauga in fisierul amxmodx\configs\amxx.cfg):

Code: Select all

construct_hp - viata la baricada
Video: -
Image
Post Reply

Return to “Pluginuri”