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

Unreal Vehicle Fixer [0.2]


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Admin Commands       
karaulov
Senior Member
Join Date: Jul 2018
Old 03-17-2022 , 23:32   Unreal Vehicle Fixer [0.2]
Reply With Quote #1

This plugin can try to fix func_vehicle:

* No teamkills
* Now frags shows when kill enemy
* Handle hostage kills
* Some stuff for unstuck players

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

#define is_user_valid(%1)			(1 <= %1 <= MAX_PLAYERS)

new g_pCarDriver[MAX_PLAYERS + 1]= {0,...};
new Float:g_fLastAttacked[MAX_PLAYERS + 1] = {0.0,...};

public plugin_init() 
{
	register_plugin("UNREAL VEHICLE FIXER", "0.2", "KARAULOV");
	register_cvar("car_fixer", "0.2", FCVAR_SPONLY|FCVAR_UNLOGGED)
	
	if (cvar_exists("mp_legacy_vehicle_block"))
	{
                //https://github.com/s1lentq/ReGameDLL_CS/actions/runs/1987302279
		log_amx("This plugin can be disabled, because mp_legacy_vehicle_block cvar is exists!");
	}
	
	register_forward(FM_Blocked, "fw_Blocked", false)
	RegisterHam( Ham_OnControls, "func_vehicle", "FuncButtonVehicle", 1 ); 
}

public FuncButtonVehicle(pCar, pBlocker)
{
	if (is_user_valid(pBlocker))
	{
		g_pCarDriver[pBlocker] = pCar;
	}
}

public get_pDriver(pCar)
{
	for(new i = 1; i <= MAX_PLAYERS;i++)
	{
		if (g_pCarDriver[i] == pCar)
			return i;
	}
	return 0;
}

public client_disconnected(id)
{
	if (task_exists(id))
		remove_task(id);
}

public check_if_stuck(pStucker)
{
	if (!(pev(pStucker,pev_flags) & FL_ONGROUND))
	{
		new Float:fCurOrg[3];
		pev(pStucker,pev_origin,fCurOrg);
		fCurOrg[2]+=2.0;
		set_pev(pStucker,pev_origin,fCurOrg);
	}
}

public fw_Blocked(pCar, pBlocker)
{
	if (!is_valid_ent(pCar))
		return FMRES_IGNORED;
		
	if (!is_valid_ent(pBlocker))
		return FMRES_IGNORED;
		
	if (pev(pBlocker,pev_groundentity) == pCar)
	{
		new Float:v_fCarVel[3];
		pev(pCar,pev_velocity,v_fCarVel)
		set_pev(pBlocker, pev_velocity,v_fCarVel);
		if (!(pev(pBlocker,pev_flags) & FL_ONGROUND))
		{
			new Float:fCurOrg[3];
			pev(pBlocker,pev_origin,fCurOrg);
			fCurOrg[2]+=5.0;
			set_pev(pBlocker,pev_origin,fCurOrg);
		}
		return FMRES_SUPERCEDE;
	}
	
	if (is_user_valid(pBlocker) && !task_exists(pBlocker) && !(pev(pBlocker,pev_flags) & FL_ONGROUND))
	{
		set_task(0.1,"check_if_stuck",pBlocker);
	}
	
	new pDriver = get_pDriver(pCar);
	new classname[32];
	pev(pBlocker, pev_classname, classname,charsmax(classname));
	if (!is_user_valid(pBlocker) && !equal(classname,"hostage_entity"))
		return FMRES_IGNORED;
	pev(pCar, pev_classname, classname,charsmax(classname));
	if (!equal(classname,"func_vehicle"))
		return FMRES_IGNORED;
	
	new Float:v_fCarVel[3];
	pev(pCar,pev_velocity,v_fCarVel)
	
	new Float:fpCarSpeed;
	pev(pCar, pev_speed, fpCarSpeed);
	
	if (fpCarSpeed > 100.0 || fpCarSpeed < -100)
	{
		if (pDriver && pDriver != pBlocker)
		{
			set_pev(pCar,pev_speed,0.0);
			set_pev(pCar,pev_velocity,Float:{ 0.0, 0.0, 0.0 });
			set_pev(pCar,pev_avelocity,Float:{ 0.0, 0.0, 0.0 });
			if (!is_user_valid(pBlocker) || cs_get_user_team(pBlocker) != cs_get_user_team(pDriver))
			{
				if (get_gametime() - g_fLastAttacked[pDriver] > 1.0)
				{
					emit_sound(pDriver, CHAN_ITEM, "weapons/knife_slash1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
					ExecuteHam(Ham_TakeDamage, pBlocker, pCar, pDriver, 50.0, DMG_CRUSH);
				}
				g_fLastAttacked[pDriver] = get_gametime();
			}
		}
	}
	
	v_fCarVel[0]*=1.5;
	v_fCarVel[1]*=1.5;
	v_fCarVel[2] = floatclamp(floatabs(fpCarSpeed),200.0,600.0);
	
	set_pev(pBlocker, pev_velocity,v_fCarVel);
	set_pev(pBlocker, pev_gaitsequence, 6)
	
	return FMRES_SUPERCEDE;
}

Now possible to play maps like big_city2, etc.

Last edited by karaulov; 03-17-2022 at 23:33.
karaulov is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 03-18-2022 , 06:47   Re: Unreal Vehicle Fixer [0.2]
Reply With Quote #2

Reaction:
Glad to see there is still func_vehicle interest out there.

Critique:
This plugin looks conflicting with my Jeep Nitros plugin as well as other unsticking scripts that people might use. Only CVAR is for purpose of tracking? A bit hard-coded. Make them to let admin decide if they want unsticking or if they want the other parameters or not such as the speed adjustment, team kills, or even to have the plugin active or not.

Summary: Good to know it fixes some specific maps.
__________________
DJEarthQuake 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 16:57.


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