Page 1 of 1

ZP Extra Item: Bhop

Posted: 29 Jun 2019, 09:09
by Rainq
Image
Descriere: Faci bunnyhop printre zombi/oameni


Descarcare:

Code: Select all

#include <amxmodx>
#include <fakemeta>
#include <zombieplague>

#pragma tabsize 0

new g_Bhop, g_cvar_bhop_cost

new g_hasBhop[ 33 ]
new pcvar_enabled, pcvar_autojump

new bool:g_restorevel[33]
new Float:g_velocity[33][3]

public plugin_init()
{
    register_plugin("[ZP] Extra Item : Bhop", "1.1", "")
	g_cvar_bhop_cost = register_cvar("zp_bhop_cost", "15")
	register_event( "DeathMsg", "event_player_death", "a" )
	register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
	pcvar_enabled = register_cvar( "zp_bhop_enabled", "1" )
	pcvar_autojump = register_cvar( "zp_bhop_autojump", "1" )
	register_clcmd("say /bhop", "buy_bannyhop")
	register_forward( FM_PlayerPreThink, "forward_prethink" )
	
	g_Bhop = zp_register_extra_item("Bhop", 10, ZP_TEAM_HUMAN|ZP_TEAM_ZOMBIE)
	
	register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
	register_forward(FM_PlayerPreThink, "fw_PlayerPreThink_Post", 1)
}

public zp_extra_item_selected(player, itemid)
{
	if (itemid == g_Bhop)
	{
		g_hasBhop[player] = true
		client_print(player, print_chat, "Ai cumparat BannyHop!")
		
		pev(player, pev_velocity, g_velocity[player])
	}
}

public client_connect( id )
{
	g_hasBhop[ id ] = false
}

public event_player_death()
{
	g_hasBhop[ read_data( 2 ) ] = false
}

public buy_bannyhop(id)
{
	if( !is_user_alive(id) )
	{
		client_print(id, print_chat, "Zombie nu pot cumpara BannyHop!")
		return PLUGIN_HANDLED
	}
	
	new iMoney = zp_get_user_ammo_packs(id)
	new iCost = get_pcvar_num(g_cvar_bhop_cost)
	if(iMoney >= iCost)
	{
		zp_set_user_ammo_packs(id, iMoney - iCost)	
		client_print(id, print_chat, "Ai cumparat BannyHop pentru %i ???? packs", iCost)
		g_hasBhop[id] = true
		return PLUGIN_HANDLED
	}
	else
	{
		client_print(id, print_chat, "Nu aveti ammo suficienti! Costul pentru %i ammo packs !", iCost)
	}
	return PLUGIN_HANDLED
}

public forward_prethink( id )
{
	if(!is_user_alive(id) || !g_hasBhop[id])
		return PLUGIN_CONTINUE
	
	if( get_pcvar_num( pcvar_enabled ) )
	{
		set_pev( id, pev_fuser2, 0.0 )
		
		if( get_pcvar_num( pcvar_autojump ) && pev( id, pev_button ) & IN_JUMP )
		{
			new szFlags = pev( id, pev_flags )
			if( !( szFlags & FL_WATERJUMP ) && pev( id, pev_waterlevel ) < 2 && szFlags & FL_ONGROUND )
			{
				new Float: szVelocity[ 3 ]
				pev( id, pev_velocity, szVelocity)
				szVelocity[ 2 ] += 250.0
				set_pev( id, pev_velocity, szVelocity )
				set_pev( id, pev_gaitsequence, 6 )
			}
		}
	}
	return FMRES_IGNORED
}

public fw_PlayerPreThink(id)
{	
	if ( !is_user_alive(id) ||!g_hasBhop[id] )
		return FMRES_IGNORED
	
	if (pev(id, pev_flags) & FL_ONGROUND)
	{
		pev(id, pev_velocity, g_velocity[id])
		
		g_restorevel[id] = true
	}
	return FMRES_IGNORED
}

public fw_PlayerPreThink_Post(id)
{	
	if (g_restorevel[id])
	{
		g_restorevel[id] = false
		
		if (!(pev(id, pev_flags) & FL_ONTRAIN))
		{
			new groundent = pev(id, pev_groundentity)
			
			if (pev_valid(groundent) && (pev(groundent, pev_flags) & FL_CONVEYOR))
			{	
				static Float:vecTemp[3]
				
				pev(id, pev_basevelocity, vecTemp)
				
				g_velocity[id][0] += vecTemp[0]
				g_velocity[id][1] += vecTemp[1]
				g_velocity[id][2] += vecTemp[2]
			} 
			
			set_pev(id, pev_velocity, g_velocity[id])
			
			return FMRES_HANDLED
		}
	}
	return FMRES_IGNORED
}

public event_round_start()
{
	for (new id; id <= 32; id++) g_hasBhop[id] = false;
}
Nume: ZP Extra Bhop
Versiune: 1.1
Link oficial: -


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

Code: Select all

zp_extra_bhop.amxx
4. Alti pasi necesari....

Cvar-uri (se adauga in fisierul amxmodx\configs\amxx.cfg):
zp_bhop_cost 15 (costul)
zp_bhop_enabled 1 (activezi 1 / dezactivezi 0 )
zp_bhop_autojump 1 (activezi autojump 1 / dezactivezi 0)

Versiunea pentru VIP:

Code: Select all

#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
#include <zmvip>

#pragma tabsize 0

new g_Bhop, g_cvar_bhop_cost

new g_hasBhop[ 33 ]
new pcvar_enabled, pcvar_autojump

new bool:g_restorevel[33]
new Float:g_velocity[33][3]

public plugin_init()
{
    register_plugin("[ZP] Extra Item : Bhop", "1.1", "")
	g_cvar_bhop_cost = register_cvar("zp_bhop_cost", "15")
	register_event( "DeathMsg", "event_player_death", "a" )
	register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
	pcvar_enabled = register_cvar( "zp_bhop_enabled", "1" )
	pcvar_autojump = register_cvar( "zp_bhop_autojump", "1" )
	register_clcmd("say /bhop", "buy_bannyhop")
	register_forward( FM_PlayerPreThink, "forward_prethink" )
	
	g_Bhop = zv_register_extra_item("Bhop","Bhop VIP", 10, ZV_TEAM_HUMAN|ZV_TEAM_ZOMBIE)
	
	register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
	register_forward(FM_PlayerPreThink, "fw_PlayerPreThink_Post", 1)
}

public zv_extra_item_selected(player, itemid)
{
	if (itemid == g_Bhop)
	{
		g_hasBhop[player] = true
		client_print(player, print_chat, "Ai cumparat BannyHop!")
		
		pev(player, pev_velocity, g_velocity[player])
	}
}

public client_connect( id )
{
	g_hasBhop[ id ] = false
}

public event_player_death()
{
	g_hasBhop[ read_data( 2 ) ] = false
}

public buy_bannyhop(id)
{
	if( !is_user_alive(id) )
	{
		client_print(id, print_chat, "Zombie nu pot cumpara BannyHop!")
		return PLUGIN_HANDLED
	}
	
	new iMoney = zp_get_user_ammo_packs(id)
	new iCost = get_pcvar_num(g_cvar_bhop_cost)
	if(iMoney >= iCost)
	{
		zp_set_user_ammo_packs(id, iMoney - iCost)	
		client_print(id, print_chat, "Ai cumparat BannyHop pentru %i ???? packs", iCost)
		g_hasBhop[id] = true
		return PLUGIN_HANDLED
	}
	else
	{
		client_print(id, print_chat, "Nu aveti ammo suficienti! Costul pentru %i ammo packs !", iCost)
	}
	return PLUGIN_HANDLED
}

public forward_prethink( id )
{
	if(!is_user_alive(id) || !g_hasBhop[id])
		return PLUGIN_CONTINUE
	
	if( get_pcvar_num( pcvar_enabled ) )
	{
		set_pev( id, pev_fuser2, 0.0 )
		
		if( get_pcvar_num( pcvar_autojump ) && pev( id, pev_button ) & IN_JUMP )
		{
			new szFlags = pev( id, pev_flags )
			if( !( szFlags & FL_WATERJUMP ) && pev( id, pev_waterlevel ) < 2 && szFlags & FL_ONGROUND )
			{
				new Float: szVelocity[ 3 ]
				pev( id, pev_velocity, szVelocity)
				szVelocity[ 2 ] += 250.0
				set_pev( id, pev_velocity, szVelocity )
				set_pev( id, pev_gaitsequence, 6 )
			}
		}
	}
	return FMRES_IGNORED
}

public fw_PlayerPreThink(id)
{	
	if ( !is_user_alive(id) ||!g_hasBhop[id] )
		return FMRES_IGNORED
	
	if (pev(id, pev_flags) & FL_ONGROUND)
	{
		pev(id, pev_velocity, g_velocity[id])
		
		g_restorevel[id] = true
	}
	return FMRES_IGNORED
}

public fw_PlayerPreThink_Post(id)
{	
	if (g_restorevel[id])
	{
		g_restorevel[id] = false
		
		if (!(pev(id, pev_flags) & FL_ONTRAIN))
		{
			new groundent = pev(id, pev_groundentity)
			
			if (pev_valid(groundent) && (pev(groundent, pev_flags) & FL_CONVEYOR))
			{	
				static Float:vecTemp[3]
				
				pev(id, pev_basevelocity, vecTemp)
				
				g_velocity[id][0] += vecTemp[0]
				g_velocity[id][1] += vecTemp[1]
				g_velocity[id][2] += vecTemp[2]
			} 
			
			set_pev(id, pev_velocity, g_velocity[id])
			
			return FMRES_HANDLED
		}
	}
	return FMRES_IGNORED
}

public event_round_start()
{
	for (new id; id <= 32; id++) g_hasBhop[id] = false;
}

Imagini: -