[Req] Capsule edit

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Отговори
Потребителски аватар

Автор на темата
Eduardsozols22
Foreigner
Foreigner
Мнения: 17
Регистриран: 07 фев 2019, 23:16

[Req] Capsule edit

Мнение от Eduardsozols22 » 08 фев 2019, 02:17

Изображение


Kapsule prablema.
Vidajot aruzije eta nenada!

Nada stobi vidavala he granatu i +10 hp posle upadenije
Nenada glow efekta!

Код: Избери всички

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This plugin is based on original Half-Life game. When someone dies, release a capsule that contains the
weapons and items of dead player. When another player grabs capsule, receive items in the capsule.

There're three modes of playing with capsules:
* cp_teammode 0: Every player can pick capsules
* cp_teammode 1: Only players of the same team can pick capsules droped by someone
* cp_teammode 2: Only players of the other team can pick capsules droped by someone

You can enable/disable glowing:
* cp_glowmode 0: Glow disabled
* cp_glowmode 1: Glow enabled

Cvars: 
cp_teammode 1:
	0: Anyone can catch the capsule.
	1: Only the same team can catch the capsule.
	2: Only the opposing team can catch the capsule.

cp_glowmode 1:
	0: Glow disabled.
	1: Glow enabled.

cp_remove 0:
	0: Do not remove the capsules.
	1: Remove the capsules.

cp_bounce 1:
	0: Off the bounce in the capsule.
	1: On the bounce on the capsule. 

Credits:
Joropito
IneedHelp
meTaLiCroSS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

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

#define Plugin	"Capsule"
#define Version	"2.9"
#define Author	"Asd'"

#define	Clip 51
#define WeaponLinux 4

/*················[Models][Sprites][Sounds]···············*/
new CapsuleMdl[] = "models/w_weaponbox.mdl"

new ReceivedSd[] = "items/gunpickup3.wav"
new BounceSd[] = "weapons/g_bounce1.wav"

new SmokeSpr[] = "sprites/steam1.spr"
/*························································*/

/*·························[Weapons Consts][BPAmmo Consts]·························*/
new const Weapons = (
	(1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) |
	(1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) |
	(1<<CSW_GALIL)	| (1<<CSW_FAMAS) | (1<<CSW_AWP) |
	(1<<CSW_MP5NAVY) | (1<<CSW_M249) | (1<<CSW_M3) | 
	(1<<CSW_M4A1) | (1<<CSW_TMP) | (1<<CSW_G3SG1) |
	(1<<CSW_SG552) | (1<<CSW_AK47) | (1<<CSW_P90) |
	(1<<CSW_P228) | (1<<CSW_ELITE) | (1<<CSW_FIVESEVEN) | 
	(1<<CSW_USP) | (1<<CSW_GLOCK18)	| (1<<CSW_DEAGLE) | 
	(1<<CSW_FLASHBANG) | (1<<CSW_HEGRENADE) | (1<<CSW_SMOKEGRENADE)
)

new const MaxBPAmmo[] = {
	-1, 52, -1, 90, 1, 32, 1, 100, 90, 1, 120, 100,
	100, 90, 90, 90, 100, 120,
	30, 120, 200, 32, 90, 120, 90,
	2, 35, 90, 90, -1, 100
}
/*·················································································*/

/*······[Glow Colors]·····*/
new Float:Colors[3][3] = {
	{0.0, 200.0, 0.0}, 
	{200.0, 0.0, 0.0}, 
	{0.0, 0.0, 200.0} 
}
/*······················*/

/*·····[Variables]·····*/
new Bounce
new Remove
new GlowMode
new TeamMode
new Smoke
/*·····················*/

/*·····[Arrays]·····*/
new UserWeapons[33]
new Capsule[33]
new UserAmmo[33]
new UserClip[33]
/*···················*/

public plugin_init( )
{
	/* Plugin */
	register_plugin( Plugin, Version, Author )
	
	/* Cvars & Commands */
	Bounce = register_cvar( "cp_bounce", "1" )	
	Remove = register_cvar( "cp_remove", "0" )	
	GlowMode = register_cvar( "cp_glowmode", "1" )
	TeamMode = register_cvar( "cp_teammode", "1" )
	
	/* Engine Fowards */
	register_touch( "Capsule", "player", "CapsuleTouch" )
	register_touch( "Capsule", "worldspawn", "CapsuleBounce" )
	register_think( "Capsule", "CapsuleThink" )
	
	/* Hamsandwich Forwards */
	RegisterHam( Ham_Killed, "player", "CapsuleCreate", 1 )
	RegisterHam( Ham_Spawn, "player", "CapsuleRemoved", 1 )
	
	/* Others */
	register_cvar( "cp_author", Author, FCVAR_SERVER|FCVAR_SPONLY ) /* Game monitor */
	register_cvar( "cp_version", Version, FCVAR_SERVER|FCVAR_SPONLY ) /* Game monitor */
}

public plugin_precache( )
{
	/* Precache model */
	precache_model( CapsuleMdl )
	
	/* Precache sprite */
	Smoke = precache_model( SmokeSpr )
	
	/* Precache sounds */
	precache_sound( ReceivedSd )
	precache_sound( BounceSd )
}

public CapsuleCreate( Victim, Attacker, ShouldGib )
{
	new Float:Origin[3]
	new Float:Velocidad[3]
	
	CapsuleRemove( Victim )
	
	new Entidad = create_entity( "info_target" )
	new Team = get_user_team( Victim )
	
	entity_get_vector( Victim, EV_VEC_origin, Origin )
	entity_set_string( Entidad, EV_SZ_classname, "Capsule" )
	entity_set_model( Entidad, CapsuleMdl )
	
	if( get_pcvar_num( GlowMode ) )
	{
		entity_set_int( Entidad, EV_INT_rendermode, kRenderNormal)
		entity_set_int( Entidad, EV_INT_renderfx, kRenderFxGlowShell )
		
		entity_set_vector( Entidad, EV_VEC_rendercolor, get_pcvar_num( TeamMode ) ? Colors[Team] : Colors[0] )
		entity_set_float( Entidad, EV_FL_renderamt, 10.0 )
	}
	
	entity_set_edict( Entidad, EV_ENT_owner, Victim )
	entity_set_int( Entidad, EV_INT_iuser1, Team )
	entity_set_int( Entidad, EV_INT_iuser2, Victim )
	
	entity_set_size( Entidad, Float:{ -10.0, -10.0, -0.0 },  Float:{ 10.0, 10.0, 0.0 } )
	entity_set_origin( Entidad, Origin )
	
	entity_set_int( Entidad, EV_INT_solid, SOLID_TRIGGER )
	
	if( get_pcvar_num( Bounce ) )
		entity_set_int( Entidad, EV_INT_movetype, MOVETYPE_BOUNCE )
	else
		entity_set_int( Entidad, EV_INT_movetype, MOVETYPE_TOSS )
	
	entity_get_vector( Victim, EV_VEC_velocity, Velocidad )
	entity_set_vector( Entidad, EV_VEC_velocity, Velocidad )
	
	Capsule[Victim] = Entidad
	
	CapsuleItems( Victim, Entidad )
	entity_set_float( Entidad, EV_FL_nextthink, get_gametime( ) + 1.0 )
	
	return HAM_HANDLED
}

public CapsuleRemoved( id )
{
	if( get_pcvar_num( Remove ) )
		CapsuleRemove( id )
	
	return HAM_IGNORED
}

public CapsuleThink( Entidad )
{
	new Float:Origin[3]
	pev( Entidad, pev_origin, Origin )
	
	new OriginEnd[3]
	OriginEnd[0] = floatround( Origin[0] )
	OriginEnd[1] = floatround( Origin[1] )
	OriginEnd[2] = floatround( Origin[2] )
	
	message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
	write_byte( TE_SMOKE )
	write_coord( OriginEnd[0] )
	write_coord( OriginEnd[1] )
	write_coord( OriginEnd[2] )
	write_short( Smoke )
	write_byte( random_num( 5, 10 ) )
	write_byte( 10 )
	message_end( )
	
	entity_set_float( Entidad, EV_FL_nextthink, get_gametime( ) + 1.0 )
}

public CapsuleBounce( Entidad, World )
{
	if( !is_valid_ent( Entidad ) )
		return PLUGIN_HANDLED
	
	if( entity_get_edict( Entidad, EV_ENT_owner ) )
		entity_set_edict( Entidad, EV_ENT_owner, 0 )
	
	if( get_pcvar_num( Bounce ) )
	{	
		new Float:Velocidad[3]
		entity_get_vector( Entidad, EV_VEC_velocity, Velocidad )
		
		Velocidad[0] -= Velocidad[0] / 10.0
		Velocidad[1] -= Velocidad[1] / 5.0
		Velocidad[2] -= Velocidad[2] / 0.0
		
		entity_set_vector( Entidad, EV_VEC_velocity, Velocidad )
		emit_sound( Entidad, CHAN_ITEM, BounceSd, 1.0, ATTN_NORM, 0, PITCH_NORM )
	}
	return PLUGIN_HANDLED
}


public CapsuleTouch( Entidad, Index )
{
	if( !is_user_alive( Index ) )
		return PLUGIN_HANDLED
	
	if( !is_valid_ent( Entidad ) )
		return PLUGIN_HANDLED
	
	if( entity_get_edict( Entidad, EV_ENT_owner ) )
		return PLUGIN_HANDLED
	
	new WeaponsDT[32]
	new OldEntidad = entity_get_int( Entidad, EV_INT_iuser2 )
	new NewAmmo
	new OldAmmo
	new NewClip
	new WPEntidad
	
	entity_get_string( Entidad, EV_SZ_noise1, UserWeapons, charsmax( UserWeapons ) )
	entity_get_string( Entidad, EV_SZ_noise2, UserAmmo, charsmax( UserAmmo) )
	entity_get_string( Entidad, EV_SZ_noise3, UserClip, charsmax( UserClip) )
	
	for(new i = 0; i < charsmax( UserWeapons ); i++)
	{
		if( UserWeapons[i] == 0 )
			break
		
		if( MaxBPAmmo[UserWeapons[i]] > 0 )
		{
			if( !user_has_weapon( Index, UserWeapons[i] ) )
			{
				get_weaponname( UserWeapons[i], WeaponsDT, charsmax( WeaponsDT ) )
				give_item( Index, WeaponsDT )
				
				WPEntidad = WeaponEntidad( Index, UserWeapons[i]) 
				NewAmmo = UserAmmo[i]
				NewClip = UserClip[i]
			}
			else
			{
				OldAmmo = cs_get_user_bpammo( Index, UserWeapons[i] )
				NewAmmo = ( MaxBPAmmo[UserWeapons[i]] + OldAmmo ) < UserAmmo[i] ? MaxBPAmmo[UserWeapons[i]] : UserAmmo[i]
				WPEntidad = WeaponEntidad( Index, UserWeapons[i] )
				NewClip = get_pdata_int( WPEntidad, Clip, WeaponLinux )
			}
			cs_set_user_bpammo( Index, UserWeapons[i], NewAmmo )
			set_pdata_int( WPEntidad, Clip, NewClip, WeaponLinux )
		}
	}
	emit_sound( Entidad, CHAN_ITEM, ReceivedSd, 1.0, ATTN_NORM, 0, PITCH_NORM )
	CapsuleRemove( OldEntidad )
	
	return PLUGIN_HANDLED
}

public CapsuleItems( Index, Entidad )
{
	new CarriedWeapons[32]
	new NumWeapons
	new WeaponID
	new i
	
	get_user_weapons( Index, CarriedWeapons, NumWeapons )
	
	for(i = 0; i < NumWeapons; i++)
	{
		UserWeapons[i] = CarriedWeapons[i]
		WeaponID = WeaponEntidad( Index, UserWeapons[i] )
		
		if( Weapons & ( 1 << CarriedWeapons[i] ) )
			get_user_ammo( Index, CarriedWeapons[i], UserClip[i], UserAmmo[i] )
		else
			UserAmmo[i] = UserClip[i] = -1
		
		ExecuteHamB( Ham_Weapon_RetireWeapon, WeaponID )
		ExecuteHamB( Ham_RemovePlayerItem, Index, WeaponID )
		ExecuteHamB( Ham_Item_Kill, WeaponID )
	}
	UserWeapons[i] = UserAmmo[i] = UserClip[i] = 0
	
	entity_set_string( Entidad, EV_SZ_noise1, UserWeapons )
	entity_set_string( Entidad, EV_SZ_noise2, UserAmmo )
	entity_set_string( Entidad, EV_SZ_noise3, UserClip )
}

/*·························[Stocks]·························*/
stock CapsuleRemove( Index )
{
	if( ( Capsule[Index] != 0 ) && is_valid_ent( Capsule[Index] ) )
	{
		remove_entity( Capsule[Index] )
		Capsule[Index] = 0
	}
}

stock WeaponEntidad( Index, WeaponID )
{
	static szWeaponName[32]
	get_weaponname( WeaponID, szWeaponName, charsmax( szWeaponName ) )
	
	return find_ent_by_owner(-1, szWeaponName, Index )
}
/*·························································*/
Последна промяна от stambeto2006 TM® на 08 фев 2019, 07:19, променено общо 1 път.
Причина: Use [code] for your source code.

Потребителски аватар

Автор на темата
Eduardsozols22
Foreigner
Foreigner
Мнения: 17
Регистриран: 07 фев 2019, 23:16

[Req] Capsule edit

Мнение от Eduardsozols22 » 08 фев 2019, 14:06

МНЕНИЕТО Е СКРИТО ОТ СТРАНА НА МОДЕРАТОР! ЦЪКНИ ВЪРХУ ЛЕНТАТА ЗА ДА ГО ПРЕГЛЕДАШ.
Последна промяна от stambeto2006 TM® на 08 фев 2019, 14:19, променено общо 1 път.
Причина: It is forbidden to publish two posts one after the other.

Потребителски аватар

Автор на темата
Eduardsozols22
Foreigner
Foreigner
Мнения: 17
Регистриран: 07 фев 2019, 23:16

[Req] Capsule edit

Мнение от Eduardsozols22 » 16 фев 2019, 02:21

МНЕНИЕТО Е СКРИТО ОТ СТРАНА НА МОДЕРАТОР! ЦЪКНИ ВЪРХУ ЛЕНТАТА ЗА ДА ГО ПРЕГЛЕДАШ.
Последна промяна от OciXCrom TM на 16 фев 2019, 14:54, променено общо 1 път.
Причина: You're not allowed to do that! Use the "bump" button from the thread options down below if you really need to.

Отговори

Върни се в “Заявки за плъгини”

Кой е на линия

Потребители, разглеждащи този форум: M36 и 1 гост