Cerere plugin /pet

Categoria cu cereri de pluginuri si nu numai.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Forum rules
Accesează link-ul pentru a putea vedea regulile forumului

Daca doriti sa vi se modifice un plugin, va rugam postati aici .
Post Reply
User avatar
Sokar
Membru, skill +1
Membru, skill +1
Posts: 452
Joined: 13 Jan 2018, 21:18
Detinator Steam: Da
CS Status: connect relax.kript.ro:27015
Detinator server CS: RELAX.KRIPT.RO
Fond eXtream: 0
Location: Constanța
Has thanked: 5 times
Been thanked: 3 times

17 Nov 2019, 18:54

Plugin Cerut: pet (liliac)
Descriere (adica ce face el mai exact): când scrii /pet să îți dea liliacul (știți despre ce vorbesc) iar acesta să coste 3000$ (până mori și să fie doar pentru antifurien) aș vrea și mesaje în chat, ex: !g[FR] !nNu ai suficienți bani pentru a cumpăra un liliac. & !g[FR] !nJucătorul !t%nume !nși-a cumpărat liliac!
Serverul ruleaza (HLDS/ReHLDS): rehlds
Versiune AMX Mod X: 1.8.2
Modul Serverului: furien
eXtreamSHOP
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2551
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 37 times
Been thanked: 387 times
Contact:

17 Nov 2019, 19:24

Code: Select all

/* Plugin generated by AMXX-Studio */

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

#define PLUGIN "ZP: Bat"
#define VERSION "1.0"
#define AUTHOR "Sn!ff3r"

#define fm_precache_model(%1) 		engfunc(EngFunc_PrecacheModel,%1)
#define fm_precache_sound(%1) 		engfunc(EngFunc_PrecacheSound,%1)
#define fm_remove_entity(%1) 		engfunc(EngFunc_RemoveEntity, %1)
#define fm_drop_to_floor(%1) 		engfunc(EngFunc_DropToFloor,%1)
#define fm_find_ent_by_class(%1,%2) 	engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
#define fm_set_user_gravity(%1,%2) 	set_pev(%1,pev_gravity,%2)

#define PET_FLAG 			pev_flTimeStepSound
#define PET_KILLED 			389

static const pet_model[] = "models/stukabat.mdl"
static const pet_sounds[][] = { "bullchicken/bc_die1.wav", "bullchicken/bc_die2.wav", "bullchicken/bc_die3.wav", "bullchicken/bc_idle1.wav", "bullchicken/bc_pain3.wav" }
static const pet_idle = 13
static const pet_run = 13
static const pet_die = 5
static const PET_COST = 3000
static const Float:pet_idle_speed = 0.5
static const Float:pet_run_speed = 13.0
static const Float:player_gravity = 0.8

new item_pet[33]
new item_have[33]
new item_at_spawn[33]
new Float:item_leaptime[33]

new maxplayers

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_event("DeathMsg","DeathMsg","a")
	register_event("HLTV","HLTV", "a","1=0", "2=0")
	
	register_forward(FM_Think,"FM_Think_hook")
	register_forward(FM_PlayerPreThink, "FM_PlayerPreThink_hook")
	
	RegisterHam(Ham_Spawn, "player", "player_spawn", 1)	
	RegisterHam(Ham_Touch, "info_target", "player_touch")
	
	maxplayers = get_maxplayers()

	register_clcmd("say /pet","BP")
	register_clcmd("say_team /pet","BP")
}

public BP(player)
{
	if(!is_user_alive(player)||cs_get_user_team(player)!=CS_TEAM_CT)	return
	if(cs_get_user_money(player)<PET_COST)
	{
		print_cc(player,"!g[FR]!n Nu ai suficienți bani pentru a cumpăra un liliac.")
		return
	}
	create_pet(player)
	cs_set_user_money(player,cs_get_user_money(player)-PET_COST,1)
	new name[32];
	print_cc(player,"!g[FR]!n Jucătorul!t %s!n și-a cumpărat liliac!",get_user_name(player,name,charsmax(name)))
}

public plugin_precache()
{
	new i = 0
	for(i = 0; i < sizeof pet_sounds; i++)	fm_precache_sound(pet_sounds[i])
	
	fm_precache_model(pet_model)	
}

public HLTV()
{
	new entid = -1
	while((entid = fm_find_ent_by_class(entid, "zp_bat")))	if(pev(entid,PET_FLAG) == PET_KILLED)	fm_remove_entity(entid)		
}

public DeathMsg() 
{
	new id = read_data(2)
	if(item_have[id])	kill_pet(id)
}

public kill_pet(id)
{
	if(pev_valid(item_pet[id]))
	{
		set_pev(item_pet[id],pev_sequence,pet_die)
		set_pev(item_pet[id],pev_gaitsequence,pet_die)
		set_pev(item_pet[id],pev_framerate,1.0)
		
		set_pev(item_pet[id],PET_FLAG,PET_KILLED)
		
		fm_drop_to_floor(item_pet[id])
		
		item_have[id] = 0
	}	
	item_pet[id] = 0
}

public player_spawn(player)
{
	if(is_user_alive(player))
	{
		if(item_have[player])	set_task(get_cvar_float("zp_delay") + 1.0,"new_round_gravity",player)
		else if(item_at_spawn[player])
		{
			create_pet(player)
			item_at_spawn[player] = 0
		}
	}	
}
public new_round_gravity(id)	fm_set_user_gravity(id,player_gravity)

public player_touch(this,idother)
{	
	if(!this || !idother)	return HAM_IGNORED
	
	new classname[32]
	pev(this,pev_classname,classname,31)
	if(equal(classname,"zp_bat") && is_a_player(idother) && !item_have[idother] && cs_get_user_team(idother)==CS_TEAM_CT)
	{
		if(pev(this,PET_FLAG) == PET_KILLED)
		{
			remove_pet(this)
			create_pet(idother)				
		}
	}	
	return HAM_IGNORED
}

public create_pet(id)
{
	if(item_have[id])
	{
		client_print(id,print_chat,"[ZP] Tu deja ai un liliac.")
		return PLUGIN_HANDLED
	}
	else if(!is_user_alive(id))
	{
		client_print(id,print_chat,"[ZP] Iti vei primi propriul liliac la urmatoarea runda.")
		item_at_spawn[id] = 1
		return PLUGIN_HANDLED
	}	
	else
	{
		item_pet[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"))
		set_pev(item_pet[id],pev_classname,"zp_bat")
		
		engfunc(EngFunc_SetModel,item_pet[id],pet_model)
		
		new Float:origin[3]
		pev(id,pev_origin,origin)			
		
		set_pev(item_pet[id],pev_origin,origin)
		set_pev(item_pet[id],pev_solid,SOLID_TRIGGER)
		set_pev(item_pet[id],pev_movetype,MOVETYPE_FLY)
		set_pev(item_pet[id],pev_owner,33)
		set_pev(item_pet[id],pev_nextthink,1.0)
		set_pev(item_pet[id],pev_sequence,0)
		set_pev(item_pet[id],pev_gaitsequence,0)
		set_pev(item_pet[id],pev_framerate,1.0)
		
		fm_set_user_gravity(id,player_gravity)		
		
		engfunc(EngFunc_EmitSound,item_pet[id],CHAN_AUTO,pet_sounds[random_num(0,sizeof pet_sounds - 1)],1.0, 1.2, 0, PITCH_NORM)	
		
		client_print(id,print_chat,"[ZP] Acum ai un liliac ! [ saritura lunga / gravitatie scazuta / animal prietenos ]")		
		
		item_have[id] = 1
	}
	return PLUGIN_HANDLED
}

public FM_Think_hook(ent)
{
	for(new i = 0; i <= maxplayers; i++)
	{
		if(ent == item_pet[i])
		{
			static Float:origin[3]
			static Float:origin2[3]
			static Float:velocity[3]
			pev(ent,pev_origin,origin2)
			get_offset_origin_body(i,Float:{50.0,0.0,0.0},origin)
			
			if(get_distance_f(origin,origin2) > 300.0)
			{
				set_pev(ent,pev_origin,origin)
			}
			
			else if(get_distance_f(origin,origin2) > 80.0)
			{
				get_speed_vector(origin2,origin,250.0,velocity)
				set_pev(ent,pev_velocity,velocity)
				if(pev(ent,pev_sequence) != pet_run || pev(ent,pev_framerate) != pet_run_speed)
				{
					set_pev(ent,pev_sequence,pet_run)
					set_pev(ent,pev_gaitsequence,pet_run)
					set_pev(ent,pev_framerate,pet_run_speed)
				}
			}
			
			else if(get_distance_f(origin,origin2) < 75.0)
			{
				if(pev(ent,pev_sequence) != pet_idle || pev(ent,pev_framerate) != pet_idle_speed)
				{
					set_pev(ent,pev_sequence,pet_idle)
					set_pev(ent,pev_gaitsequence,pet_idle)
					set_pev(ent,pev_framerate,pet_idle_speed)
				}
				set_pev(ent,pev_velocity,Float:{0.0,0.0,0.0})
			}
			pev(i,pev_origin,origin)
			origin[2] = origin2[2]
			entity_set_aim(ent,origin)			
			set_pev(ent,pev_nextthink,1.0)
			break
		}
	}
}

public FM_PlayerPreThink_hook(id)
{
	if (!is_user_alive(id))
		return
	
	if(allowed_leap(id))
	{
		static Float:velocity[3]
		velocity_by_aim(id, get_cvar_num("zp_leap_force"), velocity)
		
		velocity[2] = get_cvar_float("zp_leap_height")
		
		set_pev(id, pev_velocity, velocity)
		
		item_leaptime[id] = get_gametime()
	}
}

public allowed_leap(id)
{	
	if(cs_get_user_team(id)==CS_TEAM_T)	return false
	
	if(!item_have[id])	return false
	
	if (!(pev(id, pev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)	return false
	
	static buttons
	buttons = pev(id, pev_button)
	if (!is_user_bot(id) && (!(buttons & IN_JUMP) || !(buttons & IN_DUCK)))	return false
	
	if (get_gametime() - item_leaptime[id] < get_cvar_float("zp_leap_cooldown"))	return false
	
	return true
}

public is_a_player(ent)
{
	if(ent > 0 && ent < 33)	return true
	
	return false
}

public remove_pet(ent) 	if(pev_valid(ent)) 	fm_remove_entity(ent)

// Get entity's speed (from fakemeta_util)
stock fm_get_speed(entity)
{
	static Float:velocity[3]
	pev(entity, pev_velocity, velocity)
	
	return floatround(vector_length(velocity));
}
stock get_offset_origin_body(ent,const Float:offset[3],Float:origin[3])
{
	if(!pev_valid(ent))	return 0;
	
	new Float:angle[3]
	pev(ent,pev_angles,angle)
	
	pev(ent,pev_origin,origin)
	
	origin[0] += floatcos(angle[1],degrees) * offset[0]
	origin[1] += floatsin(angle[1],degrees) * offset[0]
	
	origin[1] += floatcos(angle[1],degrees) * offset[1]
	origin[0] += floatsin(angle[1],degrees) * offset[1]
	
	return 1;
}

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
{
	new_velocity[0] = origin2[0] - origin1[0]
	new_velocity[1] = origin2[1] - origin1[1]
	new_velocity[2] = origin2[2] - origin1[2]
	new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
	new_velocity[0] *= num
	new_velocity[1] *= num
	new_velocity[2] *= num
	
	return 1;
}

stock entity_set_aim(ent,const Float:origin2[3],bone=0)
{
	if(!pev_valid(ent))	return 0;
	
	static Float:origin[3]
	origin[0] = origin2[0]
	origin[1] = origin2[1]
	origin[2] = origin2[2]
	
	static Float:ent_origin[3], Float:angles[3]
	
	if(bone)	engfunc(EngFunc_GetBonePosition,ent,bone,ent_origin,angles)
	else	pev(ent,pev_origin,ent_origin)
	
	origin[0] -= ent_origin[0]
	origin[1] -= ent_origin[1]
	origin[2] -= ent_origin[2]
	
	static Float:v_length
	v_length = vector_length(origin)
	
	static Float:aim_vector[3]
	aim_vector[0] = origin[0] / v_length
	aim_vector[1] = origin[1] / v_length
	aim_vector[2] = origin[2] / v_length
	
	static Float:new_angles[3]
	vector_to_angle(aim_vector,new_angles)
	
	new_angles[0] *= -1
	
	if(new_angles[1]>180.0) new_angles[1] -= 360
	if(new_angles[1]<-180.0) new_angles[1] += 360
	if(new_angles[1]==180.0 || new_angles[1]==-180.0) new_angles[1]=-179.999999
	
	set_pev(ent,pev_angles,new_angles)
	set_pev(ent,pev_fixangle,1)
	
	return 1;
}

print_cc(id, fmt[], any:...)
{
	static saytext = 0, fake_user;
	if (!saytext)
	{
		saytext = get_user_msgid("SayText");
		fake_user = get_maxplayers() + 1;
	}
	new msg[192];
	vformat(msg, charsmax(msg), fmt, 3)
	replace_all(msg, sizeof(msg) - 1, "!g", "^x04");
	replace_all(msg, sizeof(msg) - 1, "!n", "^x01");
	replace_all(msg, sizeof(msg) - 1, "!t", "^x03");
	message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, saytext, _, id);
	write_byte(id ? id : fake_user);
	write_string(msg);
	message_end();
}
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
User avatar
Sokar
Membru, skill +1
Membru, skill +1
Posts: 452
Joined: 13 Jan 2018, 21:18
Detinator Steam: Da
CS Status: connect relax.kript.ro:27015
Detinator server CS: RELAX.KRIPT.RO
Fond eXtream: 0
Location: Constanța
Has thanked: 5 times
Been thanked: 3 times

17 Nov 2019, 19:30

mersi mult, îmi poți da și resursele?
User avatar
Rainq
Fost moderator
Fost moderator
Posts: 2553
Joined: 21 Jul 2015, 18:50
Detinator Steam: Da
CS Status: Busy
Detinator server CS: ---
Reputatie: Fost super moderator
Fost detinator ZM.eXtreamCS.COM
Fost Membru Club eXtreamCS (trei luni)
Fond eXtream: 0
Location: Bucuresti
Has thanked: 5 times
Been thanked: 24 times
Contact:

18 Nov 2019, 18:50

Sokar wrote:
17 Nov 2019, 19:30
mersi mult, îmi poți da și resursele?
amxmodx/extra-item-pet-bat-t361755.html
Image
Leul si tigru sunt mai puternici ca lupul,dar lupul la circ nu participa.
User avatar
Sokar
Membru, skill +1
Membru, skill +1
Posts: 452
Joined: 13 Jan 2018, 21:18
Detinator Steam: Da
CS Status: connect relax.kript.ro:27015
Detinator server CS: RELAX.KRIPT.RO
Fond eXtream: 0
Location: Constanța
Has thanked: 5 times
Been thanked: 3 times

18 Nov 2019, 19:03

Rainq wrote:
18 Nov 2019, 18:50
Sokar wrote:
17 Nov 2019, 19:30
mersi mult, îmi poți da și resursele?
amxmodx/extra-item-pet-bat-t361755.html
mersi
L E V I N wrote:
17 Nov 2019, 19:24

Code: Select all

/* Plugin generated by AMXX-Studio */

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

#define PLUGIN "ZP: Bat"
#define VERSION "1.0"
#define AUTHOR "Sn!ff3r"

#define fm_precache_model(%1) 		engfunc(EngFunc_PrecacheModel,%1)
#define fm_precache_sound(%1) 		engfunc(EngFunc_PrecacheSound,%1)
#define fm_remove_entity(%1) 		engfunc(EngFunc_RemoveEntity, %1)
#define fm_drop_to_floor(%1) 		engfunc(EngFunc_DropToFloor,%1)
#define fm_find_ent_by_class(%1,%2) 	engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
#define fm_set_user_gravity(%1,%2) 	set_pev(%1,pev_gravity,%2)

#define PET_FLAG 			pev_flTimeStepSound
#define PET_KILLED 			389

static const pet_model[] = "models/stukabat.mdl"
static const pet_sounds[][] = { "bullchicken/bc_die1.wav", "bullchicken/bc_die2.wav", "bullchicken/bc_die3.wav", "bullchicken/bc_idle1.wav", "bullchicken/bc_pain3.wav" }
static const pet_idle = 13
static const pet_run = 13
static const pet_die = 5
static const PET_COST = 3000
static const Float:pet_idle_speed = 0.5
static const Float:pet_run_speed = 13.0
static const Float:player_gravity = 0.8

new item_pet[33]
new item_have[33]
new item_at_spawn[33]
new Float:item_leaptime[33]

new maxplayers

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_event("DeathMsg","DeathMsg","a")
	register_event("HLTV","HLTV", "a","1=0", "2=0")
	
	register_forward(FM_Think,"FM_Think_hook")
	register_forward(FM_PlayerPreThink, "FM_PlayerPreThink_hook")
	
	RegisterHam(Ham_Spawn, "player", "player_spawn", 1)	
	RegisterHam(Ham_Touch, "info_target", "player_touch")
	
	maxplayers = get_maxplayers()

	register_clcmd("say /pet","BP")
	register_clcmd("say_team /pet","BP")
}

public BP(player)
{
	if(!is_user_alive(player)||cs_get_user_team(player)!=CS_TEAM_CT)	return
	if(cs_get_user_money(player)<PET_COST)
	{
		print_cc(player,"!g[FR]!n Nu ai suficienți bani pentru a cumpăra un liliac.")
		return
	}
	create_pet(player)
	cs_set_user_money(player,cs_get_user_money(player)-PET_COST,1)
	new name[32];
	print_cc(player,"!g[FR]!n Jucătorul!t %s!n și-a cumpărat liliac!",get_user_name(player,name,charsmax(name)))
}

public plugin_precache()
{
	new i = 0
	for(i = 0; i < sizeof pet_sounds; i++)	fm_precache_sound(pet_sounds[i])
	
	fm_precache_model(pet_model)	
}

public HLTV()
{
	new entid = -1
	while((entid = fm_find_ent_by_class(entid, "zp_bat")))	if(pev(entid,PET_FLAG) == PET_KILLED)	fm_remove_entity(entid)		
}

public DeathMsg() 
{
	new id = read_data(2)
	if(item_have[id])	kill_pet(id)
}

public kill_pet(id)
{
	if(pev_valid(item_pet[id]))
	{
		set_pev(item_pet[id],pev_sequence,pet_die)
		set_pev(item_pet[id],pev_gaitsequence,pet_die)
		set_pev(item_pet[id],pev_framerate,1.0)
		
		set_pev(item_pet[id],PET_FLAG,PET_KILLED)
		
		fm_drop_to_floor(item_pet[id])
		
		item_have[id] = 0
	}	
	item_pet[id] = 0
}

public player_spawn(player)
{
	if(is_user_alive(player))
	{
		if(item_have[player])	set_task(get_cvar_float("zp_delay") + 1.0,"new_round_gravity",player)
		else if(item_at_spawn[player])
		{
			create_pet(player)
			item_at_spawn[player] = 0
		}
	}	
}
public new_round_gravity(id)	fm_set_user_gravity(id,player_gravity)

public player_touch(this,idother)
{	
	if(!this || !idother)	return HAM_IGNORED
	
	new classname[32]
	pev(this,pev_classname,classname,31)
	if(equal(classname,"zp_bat") && is_a_player(idother) && !item_have[idother] && cs_get_user_team(idother)==CS_TEAM_CT)
	{
		if(pev(this,PET_FLAG) == PET_KILLED)
		{
			remove_pet(this)
			create_pet(idother)				
		}
	}	
	return HAM_IGNORED
}

public create_pet(id)
{
	if(item_have[id])
	{
		client_print(id,print_chat,"[ZP] Tu deja ai un liliac.")
		return PLUGIN_HANDLED
	}
	else if(!is_user_alive(id))
	{
		client_print(id,print_chat,"[ZP] Iti vei primi propriul liliac la urmatoarea runda.")
		item_at_spawn[id] = 1
		return PLUGIN_HANDLED
	}	
	else
	{
		item_pet[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"))
		set_pev(item_pet[id],pev_classname,"zp_bat")
		
		engfunc(EngFunc_SetModel,item_pet[id],pet_model)
		
		new Float:origin[3]
		pev(id,pev_origin,origin)			
		
		set_pev(item_pet[id],pev_origin,origin)
		set_pev(item_pet[id],pev_solid,SOLID_TRIGGER)
		set_pev(item_pet[id],pev_movetype,MOVETYPE_FLY)
		set_pev(item_pet[id],pev_owner,33)
		set_pev(item_pet[id],pev_nextthink,1.0)
		set_pev(item_pet[id],pev_sequence,0)
		set_pev(item_pet[id],pev_gaitsequence,0)
		set_pev(item_pet[id],pev_framerate,1.0)
		
		fm_set_user_gravity(id,player_gravity)		
		
		engfunc(EngFunc_EmitSound,item_pet[id],CHAN_AUTO,pet_sounds[random_num(0,sizeof pet_sounds - 1)],1.0, 1.2, 0, PITCH_NORM)	
		
		client_print(id,print_chat,"[ZP] Acum ai un liliac ! [ saritura lunga / gravitatie scazuta / animal prietenos ]")		
		
		item_have[id] = 1
	}
	return PLUGIN_HANDLED
}

public FM_Think_hook(ent)
{
	for(new i = 0; i <= maxplayers; i++)
	{
		if(ent == item_pet[i])
		{
			static Float:origin[3]
			static Float:origin2[3]
			static Float:velocity[3]
			pev(ent,pev_origin,origin2)
			get_offset_origin_body(i,Float:{50.0,0.0,0.0},origin)
			
			if(get_distance_f(origin,origin2) > 300.0)
			{
				set_pev(ent,pev_origin,origin)
			}
			
			else if(get_distance_f(origin,origin2) > 80.0)
			{
				get_speed_vector(origin2,origin,250.0,velocity)
				set_pev(ent,pev_velocity,velocity)
				if(pev(ent,pev_sequence) != pet_run || pev(ent,pev_framerate) != pet_run_speed)
				{
					set_pev(ent,pev_sequence,pet_run)
					set_pev(ent,pev_gaitsequence,pet_run)
					set_pev(ent,pev_framerate,pet_run_speed)
				}
			}
			
			else if(get_distance_f(origin,origin2) < 75.0)
			{
				if(pev(ent,pev_sequence) != pet_idle || pev(ent,pev_framerate) != pet_idle_speed)
				{
					set_pev(ent,pev_sequence,pet_idle)
					set_pev(ent,pev_gaitsequence,pet_idle)
					set_pev(ent,pev_framerate,pet_idle_speed)
				}
				set_pev(ent,pev_velocity,Float:{0.0,0.0,0.0})
			}
			pev(i,pev_origin,origin)
			origin[2] = origin2[2]
			entity_set_aim(ent,origin)			
			set_pev(ent,pev_nextthink,1.0)
			break
		}
	}
}

public FM_PlayerPreThink_hook(id)
{
	if (!is_user_alive(id))
		return
	
	if(allowed_leap(id))
	{
		static Float:velocity[3]
		velocity_by_aim(id, get_cvar_num("zp_leap_force"), velocity)
		
		velocity[2] = get_cvar_float("zp_leap_height")
		
		set_pev(id, pev_velocity, velocity)
		
		item_leaptime[id] = get_gametime()
	}
}

public allowed_leap(id)
{	
	if(cs_get_user_team(id)==CS_TEAM_T)	return false
	
	if(!item_have[id])	return false
	
	if (!(pev(id, pev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)	return false
	
	static buttons
	buttons = pev(id, pev_button)
	if (!is_user_bot(id) && (!(buttons & IN_JUMP) || !(buttons & IN_DUCK)))	return false
	
	if (get_gametime() - item_leaptime[id] < get_cvar_float("zp_leap_cooldown"))	return false
	
	return true
}

public is_a_player(ent)
{
	if(ent > 0 && ent < 33)	return true
	
	return false
}

public remove_pet(ent) 	if(pev_valid(ent)) 	fm_remove_entity(ent)

// Get entity's speed (from fakemeta_util)
stock fm_get_speed(entity)
{
	static Float:velocity[3]
	pev(entity, pev_velocity, velocity)
	
	return floatround(vector_length(velocity));
}
stock get_offset_origin_body(ent,const Float:offset[3],Float:origin[3])
{
	if(!pev_valid(ent))	return 0;
	
	new Float:angle[3]
	pev(ent,pev_angles,angle)
	
	pev(ent,pev_origin,origin)
	
	origin[0] += floatcos(angle[1],degrees) * offset[0]
	origin[1] += floatsin(angle[1],degrees) * offset[0]
	
	origin[1] += floatcos(angle[1],degrees) * offset[1]
	origin[0] += floatsin(angle[1],degrees) * offset[1]
	
	return 1;
}

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
{
	new_velocity[0] = origin2[0] - origin1[0]
	new_velocity[1] = origin2[1] - origin1[1]
	new_velocity[2] = origin2[2] - origin1[2]
	new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
	new_velocity[0] *= num
	new_velocity[1] *= num
	new_velocity[2] *= num
	
	return 1;
}

stock entity_set_aim(ent,const Float:origin2[3],bone=0)
{
	if(!pev_valid(ent))	return 0;
	
	static Float:origin[3]
	origin[0] = origin2[0]
	origin[1] = origin2[1]
	origin[2] = origin2[2]
	
	static Float:ent_origin[3], Float:angles[3]
	
	if(bone)	engfunc(EngFunc_GetBonePosition,ent,bone,ent_origin,angles)
	else	pev(ent,pev_origin,ent_origin)
	
	origin[0] -= ent_origin[0]
	origin[1] -= ent_origin[1]
	origin[2] -= ent_origin[2]
	
	static Float:v_length
	v_length = vector_length(origin)
	
	static Float:aim_vector[3]
	aim_vector[0] = origin[0] / v_length
	aim_vector[1] = origin[1] / v_length
	aim_vector[2] = origin[2] / v_length
	
	static Float:new_angles[3]
	vector_to_angle(aim_vector,new_angles)
	
	new_angles[0] *= -1
	
	if(new_angles[1]>180.0) new_angles[1] -= 360
	if(new_angles[1]<-180.0) new_angles[1] += 360
	if(new_angles[1]==180.0 || new_angles[1]==-180.0) new_angles[1]=-179.999999
	
	set_pev(ent,pev_angles,new_angles)
	set_pev(ent,pev_fixangle,1)
	
	return 1;
}

print_cc(id, fmt[], any:...)
{
	static saytext = 0, fake_user;
	if (!saytext)
	{
		saytext = get_user_msgid("SayText");
		fake_user = get_maxplayers() + 1;
	}
	new msg[192];
	vformat(msg, charsmax(msg), fmt, 3)
	replace_all(msg, sizeof(msg) - 1, "!g", "^x04");
	replace_all(msg, sizeof(msg) - 1, "!n", "^x01");
	replace_all(msg, sizeof(msg) - 1, "!t", "^x03");
	message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, saytext, _, id);
	write_byte(id ? id : fake_user);
	write_string(msg);
	message_end();
}
nu merge saritura (ctrl + space) si daca nu mor cand sunt antifurien si trec la furien inca am liliacul si imi dezactiveaza gravitatia de la furien..
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2551
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 37 times
Been thanked: 387 times
Contact:

18 Nov 2019, 23:25

Code: Select all

/* Plugin generated by AMXX-Studio */

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

#define PLUGIN "ZP: Bat"
#define VERSION "1.0"
#define AUTHOR "Sn!ff3r"

#define fm_precache_model(%1) 		engfunc(EngFunc_PrecacheModel,%1)
#define fm_precache_sound(%1) 		engfunc(EngFunc_PrecacheSound,%1)
#define fm_remove_entity(%1) 		engfunc(EngFunc_RemoveEntity, %1)
#define fm_drop_to_floor(%1) 		engfunc(EngFunc_DropToFloor,%1)
#define fm_find_ent_by_class(%1,%2) 	engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
#define fm_set_user_gravity(%1,%2) 	set_pev(%1,pev_gravity,%2)

#define PET_FLAG 			pev_flTimeStepSound
#define PET_KILLED 			389

static const pet_model[] = "models/stukabat.mdl"
static const pet_sounds[][] = { "bullchicken/bc_die1.wav", "bullchicken/bc_die2.wav", "bullchicken/bc_die3.wav", "bullchicken/bc_idle1.wav", "bullchicken/bc_pain3.wav" }
static const pet_idle = 13
static const pet_run = 13
static const pet_die = 5
static const PET_COST = 3000
static const Float:pet_idle_speed = 0.5
static const Float:pet_run_speed = 13.0
static const Float:player_gravity = 0.8

new item_pet[33]
new item_have[33]
new item_at_spawn[33]
new Float:item_leaptime[33]

new maxplayers

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_event("DeathMsg","DeathMsg","a")
	register_event("HLTV","HLTV", "a","1=0", "2=0")
	
	register_forward(FM_Think,"FM_Think_hook")
	register_forward(FM_PlayerPreThink, "FM_PlayerPreThink_hook")
	
	RegisterHam(Ham_Spawn, "player", "player_spawn", 1)	
	RegisterHam(Ham_Touch, "info_target", "player_touch")
	
	maxplayers = get_maxplayers()

	register_clcmd("say /pet","BP")
	register_clcmd("say_team /pet","BP")
}

public BP(player)
{
	if(!is_user_alive(player)||cs_get_user_team(player)!=CS_TEAM_CT)	return
	if(cs_get_user_money(player)<PET_COST)
	{
		print_cc(player,"!g[FR]!n Nu ai suficienți bani pentru a cumpăra un liliac.")
		return
	}
	create_pet(player)
	cs_set_user_money(player,cs_get_user_money(player)-PET_COST,1)
	new name[32];
	print_cc(player,"!g[FR]!n Jucătorul!t %s!n și-a cumpărat liliac!",get_user_name(player,name,charsmax(name)))
}

public plugin_precache()
{
	new i = 0
	for(i = 0; i < sizeof pet_sounds; i++)	fm_precache_sound(pet_sounds[i])
	
	fm_precache_model(pet_model)	
}

public HLTV()
{
	new entid = -1
	while((entid = fm_find_ent_by_class(entid, "zp_bat")))	if(pev(entid,PET_FLAG) == PET_KILLED)	fm_remove_entity(entid)		
}

public DeathMsg() 
{
	new id = read_data(2)
	if(item_have[id])	kill_pet(id)
}

public kill_pet(id)
{
	if(pev_valid(item_pet[id]))
	{
		set_pev(item_pet[id],pev_sequence,pet_die)
		set_pev(item_pet[id],pev_gaitsequence,pet_die)
		set_pev(item_pet[id],pev_framerate,1.0)
		
		set_pev(item_pet[id],PET_FLAG,PET_KILLED)
		
		fm_drop_to_floor(item_pet[id])
		
		item_have[id] = 0
	}	
	item_pet[id] = 0
}

public player_spawn(player)
{
	if(is_user_alive(player))
	{
		switch(cs_get_user_team(player)
		{
			case CS_TEAM_CT:
			{
				if(item_have[player])	set_task(get_cvar_float("zp_delay") + 1.0,"new_round_gravity",player)
				else if(item_at_spawn[player])
				{
					create_pet(player)
					item_at_spawn[player] = 0
				}
			}
			case CS_TEAM_T..CS_TEAM_SPECTATOR:
			{
				kill_pet(player)
			}
		}
	}	
}
public new_round_gravity(id)	fm_set_user_gravity(id,player_gravity)

public player_touch(this,idother)
{	
	if(!this || !idother)	return HAM_IGNORED
	
	new classname[32]
	pev(this,pev_classname,classname,31)
	if(equal(classname,"zp_bat") && is_a_player(idother) && !item_have[idother] && cs_get_user_team(idother)==CS_TEAM_CT)
	{
		if(pev(this,PET_FLAG) == PET_KILLED)
		{
			remove_pet(this)
			create_pet(idother)				
		}
	}	
	return HAM_IGNORED
}

public create_pet(id)
{
	if(item_have[id])	client_print(id,print_chat,"[ZP] Tu deja ai un liliac.")
	else if(!is_user_alive(id))
	{
		client_print(id,print_chat,"[ZP] Iti vei primi propriul liliac la urmatoarea runda.")
		item_at_spawn[id] = 1
	}	
	else
	{
		item_pet[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"))
		set_pev(item_pet[id],pev_classname,"zp_bat")
		
		engfunc(EngFunc_SetModel,item_pet[id],pet_model)
		
		new Float:origin[3]
		pev(id,pev_origin,origin)			
		
		set_pev(item_pet[id],pev_origin,origin)
		set_pev(item_pet[id],pev_solid,SOLID_TRIGGER)
		set_pev(item_pet[id],pev_movetype,MOVETYPE_FLY)
		set_pev(item_pet[id],pev_owner,33)
		set_pev(item_pet[id],pev_nextthink,1.0)
		set_pev(item_pet[id],pev_sequence,0)
		set_pev(item_pet[id],pev_gaitsequence,0)
		set_pev(item_pet[id],pev_framerate,1.0)
		
		fm_set_user_gravity(id,player_gravity)		
		
		engfunc(EngFunc_EmitSound,item_pet[id],CHAN_AUTO,pet_sounds[random_num(0,sizeof pet_sounds - 1)],1.0, 1.2, 0, PITCH_NORM)	
		
		client_print(id,print_chat,"[ZP] Acum ai un liliac ! [ saritura lunga / gravitatie scazuta / animal prietenos ]")		
		
		item_have[id] = 1
	}
}

public FM_Think_hook(ent)
{
	for(new i = 0; i <= maxplayers; i++)
	{
		if(ent == item_pet[i])
		{
			static Float:origin[3]
			static Float:origin2[3]
			static Float:velocity[3]
			pev(ent,pev_origin,origin2)
			get_offset_origin_body(i,Float:{50.0,0.0,0.0},origin)
			
			if(get_distance_f(origin,origin2) > 300.0)	set_pev(ent,pev_origin,origin)
			else if(get_distance_f(origin,origin2) > 80.0)
			{
				get_speed_vector(origin2,origin,250.0,velocity)
				set_pev(ent,pev_velocity,velocity)
				if(pev(ent,pev_sequence) != pet_run || pev(ent,pev_framerate) != pet_run_speed)
				{
					set_pev(ent,pev_sequence,pet_run)
					set_pev(ent,pev_gaitsequence,pet_run)
					set_pev(ent,pev_framerate,pet_run_speed)
				}
			}
			else if(get_distance_f(origin,origin2) < 75.0)
			{
				if(pev(ent,pev_sequence) != pet_idle || pev(ent,pev_framerate) != pet_idle_speed)
				{
					set_pev(ent,pev_sequence,pet_idle)
					set_pev(ent,pev_gaitsequence,pet_idle)
					set_pev(ent,pev_framerate,pet_idle_speed)
				}
				set_pev(ent,pev_velocity,Float:{0.0,0.0,0.0})
			}

			pev(i,pev_origin,origin)
			origin[2] = origin2[2]
			entity_set_aim(ent,origin)			
			set_pev(ent,pev_nextthink,1.0)

			break
		}
	}
}

public FM_PlayerPreThink_hook(id)
{
	if (!is_user_alive(id))	return
	
	if(allowed_leap(id))
	{
		static Float:velocity[3]
		velocity_by_aim(id, get_cvar_num("zp_leap_force"), velocity)
		velocity[2] = get_cvar_float("zp_leap_height")
		set_pev(id, pev_velocity, velocity)
		
		item_leaptime[id] = get_gametime()
	}
}
public allowed_leap(id)
{	
	if(cs_get_user_team(id)==CS_TEAM_T||!item_have[id]||!(pev(id, pev_flags) & FL_ONGROUND))	return false
	
	static buttons
	buttons = pev(id, pev_button)
	if (!(buttons & IN_JUMP) || !(buttons & IN_DUCK))	return false
	
	if (get_gametime() - item_leaptime[id] < get_cvar_float("zp_leap_cooldown"))	return false
	
	return true
}

public is_a_player(ent)
{
	if(ent > 0 && ent < 33)	return true
	
	return false
}

public remove_pet(ent) 	if(pev_valid(ent)) 	fm_remove_entity(ent)

stock get_offset_origin_body(ent,const Float:offset[3],Float:origin[3])
{
	if(!pev_valid(ent))	return 0;
	
	new Float:angle[3]
	pev(ent,pev_angles,angle)
	
	pev(ent,pev_origin,origin)
	
	origin[0] += floatcos(angle[1],degrees) * offset[0]
	origin[1] += floatsin(angle[1],degrees) * offset[0]
	
	origin[1] += floatcos(angle[1],degrees) * offset[1]
	origin[0] += floatsin(angle[1],degrees) * offset[1]
	
	return 1;
}

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
{
	new_velocity[0] = origin2[0] - origin1[0]
	new_velocity[1] = origin2[1] - origin1[1]
	new_velocity[2] = origin2[2] - origin1[2]
	new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
	new_velocity[0] *= num
	new_velocity[1] *= num
	new_velocity[2] *= num
	
	return 1;
}

stock entity_set_aim(ent,const Float:origin2[3],bone=0)
{
	if(!pev_valid(ent))	return 0;
	
	static Float:origin[3]
	origin[0] = origin2[0]
	origin[1] = origin2[1]
	origin[2] = origin2[2]
	
	static Float:ent_origin[3], Float:angles[3]
	
	if(bone)	engfunc(EngFunc_GetBonePosition,ent,bone,ent_origin,angles)
	else	pev(ent,pev_origin,ent_origin)
	
	origin[0] -= ent_origin[0]
	origin[1] -= ent_origin[1]
	origin[2] -= ent_origin[2]
	
	static Float:v_length
	v_length = vector_length(origin)
	
	static Float:aim_vector[3]
	aim_vector[0] = origin[0] / v_length
	aim_vector[1] = origin[1] / v_length
	aim_vector[2] = origin[2] / v_length
	
	static Float:new_angles[3]
	vector_to_angle(aim_vector,new_angles)
	
	new_angles[0] *= -1
	
	if(new_angles[1]>180.0) new_angles[1] -= 360
	if(new_angles[1]<-180.0) new_angles[1] += 360
	if(new_angles[1]==180.0 || new_angles[1]==-180.0) new_angles[1]=-179.999999
	
	set_pev(ent,pev_angles,new_angles)
	set_pev(ent,pev_fixangle,1)
	
	return 1;
}

print_cc(id, fmt[], any:...)
{
	static saytext = 0, fake_user;
	if (!saytext)
	{
		saytext = get_user_msgid("SayText");
		fake_user = get_maxplayers() + 1;
	}
	new msg[192];
	vformat(msg, charsmax(msg), fmt, 3)
	replace_all(msg, sizeof(msg) - 1, "!g", "^x04");
	replace_all(msg, sizeof(msg) - 1, "!n", "^x01");
	replace_all(msg, sizeof(msg) - 1, "!t", "^x03");
	message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, saytext, _, id);
	write_byte(id ? id : fake_user);
	write_string(msg);
	message_end();
}
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
Post Reply

Return to “Cereri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests