Raised This Month: $ Target: $400
 0% 

How do I add a model to a grenade in this plugin?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Apocalyman
Member
Join Date: Nov 2022
Old 08-24-2023 , 14:34   How do I add a model to a grenade in this plugin?
Reply With Quote #1

Hello. This is a last request plugin where in one last request in one point the player can choose a pumpkin last request duel where it works fine but the grenade itself doesnt have a pumpkin model and I wanted to ask how could I give that specific grenade in the "pumpkin" part a model? I want to give it a pumpkin model of course but I dont know how.
Code:
/* Includes */

#include < amxmodx >
#include < fakemeta_util >
#include < fun >
#include < cstrike >
#include < hamsandwich >
#include < dhudmessage >

/* Defines */

#define TASKID_COUNTDOWN	1561
#define	TASKID_MSG		1562
#define TASKID_BEACON		1563
#define MAX_SOUNDS		9

new Rambo[ ] = "Apoc/JbLR/rambo.mp3";
new s4s[ ] = "Apoc/JbLR/s4s.mp3";


native StartContest( const index, const player, contest );
native start_dodgeball( const index, const player );
native GetUserBalls( const index );
/* Enums */

enum _:enWeaponsData
{
	wName[ 32 ],
	wClass[ 32 ],
	wIndex
};

enum _:enComboData
{
	cmbName[ 32 ],
	cmdIndex
};

/* Arrays */

new Info[ 5 ][ ] =
{
	"JailBreak Last Request",
	"1.0",
	"Built by Rejack || Edit by @.TheBomB`",
	" Apoc ",			// Prefix
	"Apoc"			// Chat Prefix
};

new szTypes[ ][ ] =
{
	"Shot 4 Shot",
	"Custom War",
	"Special Duels",
	"Chat Duels",
	"Rambo"
};

new LR_SPEARGUN = 2;

new szWarOptions[ ][ ] =
{
	"Normal",
	"HP",
	"HS",
	"Gravity"
};

new szMusic[ MAX_SOUNDS ][ ] =
{
	"Apoc/JbLR/Short/jb_lr_1.mp3",
	"Apoc/JbLR/Short/jb_lr_2.mp3",
	"Apoc/JbLR/Short/jb_lr_3.mp3",
	"Apoc/JbLR/Short/jb_lr_4.mp3",
	"Apoc/JbLR/Short/jb_lr_5.mp3",
	"Apoc/JbLR/Short/jb_lr_6.mp3",
	"Apoc/JbLR/Short/jb_lr_7.mp3",
	"Apoc/JbLR/Short/jb_lr_8.mp3",
	"Apoc/JbLR/Short/jb_lr_9.mp3"


}

new szS4S[ ][ enWeaponsData ] =
{
	{ "Deagle",	"weapon_deagle",	CSW_DEAGLE },
	{ "Awp",	"weapon_awp",		CSW_AWP },
	{ "Scout",	"weapon_scout",		CSW_SCOUT },
	{ "USP",	"weapon_usp",		CSW_USP },
	{ "Glock 18",	"weapon_glock18",	CSW_GLOCK18 }
};

new szWar[ ][ enWeaponsData ] =
{
	{ "M4A1",	"weapon_m4a1",		CSW_M4A1 },
	{ "AK47",	"weapon_ak47",		CSW_AK47 },
	{ "M249",	"weapon_m249",		CSW_M249 },
	{ "MP5",	"weapon_mp5navy",	CSW_MP5NAVY },
	{ "M3",		"weapon_m3",		CSW_M3 },
	{ "Glock",	"weapon_glock18",	CSW_GLOCK18 },
	{ "USP",	"weapon_usp",		CSW_USP },
	{ "Deagle",	"weapon_deagle",	CSW_DEAGLE },
	{ "Famas",	"weapon_famas",		CSW_FAMAS },
	{ "Galil",	"weapon_galil",		CSW_GALIL },
	{ "Knife",	"weapon_knife",		CSW_KNIFE },
	{ "Awp",	"weapon_awp",		CSW_AWP },
	{ "Grenade",	"weapon_hegrenade",	CSW_HEGRENADE },
	{ "Smoke",	"weapon_smokegrenade",	CSW_SMOKEGRENADE },
	{ "Xm 1014",	"weapon_xm1014",	CSW_XM1014 },
	{ "Scout",	"weapon_scout",	         CSW_SCOUT },
	{ "UMP 45",	"weapon_ump45",	         CSW_UMP45}
};


new szFun[ ][ ] =
{
	"Shark",
	"Drop Bomb",
	"Drop Deagle",
	"Shot The Bomb",
	"Survival",
	"Invisible",
	"Spray",
	"Hide'N'Seek",
	"Strip Weapon",
	"Combo",
	"Drop Bomb [\rNo Pool\w]",
	"Dodgeball",
	"Deagle Power",
	"Power Grenade",
	"Spear Gun",
	"Tactical Knifes",
         "Pumpkin",
	"Cannon"
};

new const szContests[ ][ ] =
{
         "First Write",
	"Translate",
	"Missing Letter",
	"Mathematics",
	"Type Race"
};

new g_szCombo[ ] = { IN_ATTACK, IN_ATTACK2, IN_BACK, IN_FORWARD, IN_MOVELEFT, IN_MOVERIGHT, IN_JUMP, IN_DUCK, IN_RELOAD, IN_USE, IN_SCORE };

new szCombo[ ][ ] = { "Attack", "Attack2", "Back", "Forward", "Left", "Right", "Jump", "Duck", "Reload", "Use", "Score" };

new const szGuns[][] =
{
        "events/awp.sc",
        "events/g3sg1.sc",
        "events/ak47.sc",
        "events/scout.sc",
        "events/m249.sc",
        "events/m4a1.sc",
        "events/sg552.sc",
        "events/aug.sc",
        "events/sg550.sc",
        "events/m3.sc",
        "events/xm1014.sc",
        "events/usp.sc",
        "events/mac10.sc",
        "events/ump45.sc",
        "events/fiveseven.sc",
        "events/p90.sc",
        "events/deagle.sc",
        "events/p228.sc",
        "events/glock18.sc",
        "events/mp5n.sc",
        "events/tmp.sc",
        "events/elite_left.sc",
        "events/elite_right.sc",
        "events/galil.sc",
        "events/famas.sc"
};

new TheStriped, TheStriper;

native is_after_lr()

native is_player_premium( index );

native give_speargun( index );
native remove_speargun( index );

native give_tactical( index );
native remove_tactical( index );

native give_pumpkin__( index );
native remove_pumpkin__( index );

native get_cannon( index );
native remove_cannon( index );

new szItem[ 128 ];
new bool: bActive, bool: bShot, bool: bPlayer[ 33 ], bool: bTurn[ 33 ], bool: bMsg[ 33 ], bool: bCombo, bool: bPressed, bool: bPowerDeagle;
new g_iMaxPlayers, g_iTimer, g_iCount, iType, iWar, iDuel, g_iCombo[ 11 ], iCombo[ 33 ], beaconSprite, g_iBit, g_iForward, g_max_clients;
new Float: fCombo[ 33 ];
new bool:TakeBox;

new LR_PREMIUM = 5;

public plugin_init()
{
	
	register_plugin( Info[ 0 ], Info[ 1 ], Info[ 2 ] );

	register_saycmd( "lr", "CmdMenu" );
	register_saycmd( "infomsg", "CmdInfoMsg" );
	
	register_event( "DeathMsg", "evDeathMsg", "a" );
	register_logevent( "evRoundStart", 2, "1=Round_Start" );
	
	register_forward( FM_PlaybackEvent, "FwdPlaybackEvent" );
	register_forward( FM_PlayerPreThink, "FwdPreThink" );
	register_forward( FM_SetModel, "FwdSetModel" );
	register_forward( FM_Voice_SetClientListening, "FwdVoiceSetClientListening" );
	
	unregister_forward( FM_PrecacheEvent, g_iForward, 1 );
	
	RegisterHam( Ham_TakeDamage, "player", "FwdTakeDamage", 0 );
	
	g_iMaxPlayers = get_maxplayers();
	g_max_clients = global_get( glb_maxClients );
	
	
}

public FwdUseButton()
{
	if ( !bActive )
		return 1;
	
	return 4;
}

public plugin_precache()
{
	beaconSprite = precache_model( "sprites/white.spr" );
	
	precache_sound( Rambo );
	precache_sound( s4s );
	
	g_iForward = register_forward( FM_PrecacheEvent, "FwdPrecacheEvent", 1 );
	
	for ( new i; i < MAX_SOUNDS; i++ )
		precache_sound( szMusic[ i ] );
}

public plugin_natives()
{
	register_library( "LastRequest" );
	
	register_native( "is_user_lr", "native_is_user_lr" );
	register_native( "is_lr_start", "native_is_lr_satrt" );
	register_native( "is_lr_active", "native_is_lr_satrt" );
	register_native( "stop_lr", "native_stop_lr" );
	register_native( "is_lr_dodgeball", "native_is_lr_dodgeball" );
	register_native( "get_user_bmsg", "_get_user_bmsg" );
	register_native( "is_after_lr", "_is_after_lr" );
}

public bool: native_is_lr_satrt()
	return bActive;

public _is_after_lr(plugin,params)
	return TakeBox;	
	
public native_stop_lr()
	StopRequest( ( get_param( 1 ) == 0 ) ? false : true );
	
public bool: native_is_user_lr( plugin, params )
	return bPlayer[ get_param( 1 ) ];

public _get_user_bmsg( plugin, params )
{
	return bMsg[ get_param( 1 ) ];
}

public bool: native_is_lr_dodgeball( plugin, params )
	return (iType==2&&iDuel==11) ? true : false;
	
/* Others */

public CmdInfoMsg( client )
{
	bMsg[ client ] = !bMsg[ client ];
	
	ColorPrint( client, "You^4 %s^3 Info Message^1!", bMsg[ client ] ? "Disabled" : "Enabled" );
	
	return 1;
}

public client_putinserver( client )
{
	bPlayer[ client ] = false;
	
	bTurn[ client ] = false;
}

public client_disconnect( client )
{
	if ( bPlayer[ client ] && bActive && iType != 3 )
	{
		StopRequest();
		
		ColorPrint( 0, "The^3 Last Request^1 was stopped because^4 %s^1 left the game.", szName( client ) );
	}
}

/* Menu */

public CmdMenu( client )
{
	if ( !is_user_valid( client ) )
		return ColorPrint( client, GetReason( client ) );
	
	formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Last Request", Info[ 3 ] );
	
	new Menu = menu_create( szItem, "SubMenu" );
	
	for ( new i; i < sizeof szTypes - 1; i++ )
		AddItem( Menu, "%s %s", szTypes[ i ], (i==3) ? "^n":"" );
	
	menu_additem( Menu, "\yRambo" );
	
	menu_addblank( Menu, 0 );
	
	menu_display( client, Menu );
	
	return 1;
}

public SubMenu( client, Menu, Item )
{
	if ( !is_user_valid( client ) )
		return ColorPrint( client, GetReason( client ) );
	
	if ( Item == MENU_EXIT )
	{
		menu_destroy( Menu );
		
		return 1;
	}
	
	new iMenu;
	
	if ( Item != 1 )
	{
		
		formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w %s Duels", Info[ 3 ], szTypes[ Item ] );
		
		iMenu = menu_create( szItem, "SubDuels" );
	}
	
	iType = Item;
	
	switch ( Item )
	{
		case 0:
		{
			for ( new i; i < sizeof szS4S; i++ )
				menu_additem( iMenu, szS4S[ i ] );
		}
		
		case 1:
		{
			CmdWar( client );
			
			return 1;
		}
		
		case 2:
		{
			for ( new i; i < sizeof szFun; i++ )
				menu_additem( iMenu, szFun[ i ] );
		}
		
		case 3:
		{
			for ( new i; i < sizeof szContests; i++ )
				menu_additem( iMenu, szContests[ i ] );
		}
		
		case 4:	// Rambo
		{
			StopRequest();
			
			iType = 4;
			
			bPlayer[ client ] = true;
			
			bActive = true;
			
			fm_strip_user_weapons( client );
			
			fm_give_item( client, "weapon_m249" );
			
			cs_set_user_bpammo( client, CSW_M249, 9999 );
			
			fm_set_user_health( client, TeamCount( "CT" ) * 500 );
			
			for ( new i = 1; i < g_iMaxPlayers; i++ )
			{
				if ( !is_user_alive( i ) || !is_user_connected( i ) || cs_get_user_team( i ) != CS_TEAM_CT )
					continue;
				
				fm_strip_user_weapons( i );
				
				fm_give_item( i, "weapon_m4a1" );
				
				fm_give_item( i, "weapon_deagle" );
				
				fm_give_item( i, "weapon_knife" );
				
				cs_set_user_bpammo( i, CSW_M4A1, 120 );
				
				cs_set_user_bpammo( i, CSW_DEAGLE, 70 );
				
				fm_set_user_health( i, 100 );
			}
			
			CmdMsg();
			
			ColorPrint( 0, "^3%s^1 started^4 Rambo^1!", szName( client ) );
			client_cmd( 0, "; mp3 play ^"sound/%s", Rambo );
			
			fn_Cells()
			
			return 1;
		}
	}
	
	menu_display( client, iMenu );
	
	menu_destroy( Menu );
	
	return 1;
}
			
public CmdWar( client )
{
	if ( !is_user_valid( client ) )
		return ColorPrint( client, GetReason( client ) );
	
	formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w War Duels", Info[ 3 ] );
	
	new Menu = menu_create( szItem, "SubWar" );
	
	AddItem( Menu, "Game Mode:\r %s", szWarOptions[ iWar ] );
	
	for ( new i; i < sizeof szWar; i++ )
	{
		if ( iWar == 2 && i == charsmax( szWar ) )
			break;
		
		menu_additem( Menu, szWar[ i ] )
	}
	
	menu_display( client, Menu );
	
	return 1;
}

public SubWar( client, Menu, Item )
{
	if ( !is_user_valid( client ) )
		return ColorPrint( client, GetReason( client ) );
	
	if ( Item == MENU_EXIT )
	{
		menu_destroy( Menu );
		
		return 1;
	}
	
	if ( Item == 0 )
	{
		if ( iWar == 3 )
			iWar = -1;
		
		iWar++;
		
		CmdWar( client );
		
		return 1;
	}
	
	iDuel = Item - 1;
	
	menu_destroy( Menu );
	
	CmdPlayers( client );
	
	return 1;
}

public SubDuels( client, Menu, Item )
{
	if ( !is_user_valid( client ) )
		return ColorPrint( client, GetReason( client ) );
	
	if ( Item == MENU_EXIT )
	{
		menu_destroy( Menu );
		
		return 1;
	}
	
	iDuel = Item;
	
	menu_destroy( Menu );
	
	CmdPlayers( client );
	
	return 1;
}

public CmdPlayers( client )
{
	if ( !is_user_valid( client ) )
		return ColorPrint( client, GetReason( client ) );
	
	formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Select a Player\d:^n^nDuel:\y %s", Info[ 3 ], GetDuel() );
	
	new Menu = menu_create( szItem, "SubPlayers" );
	
	new Players[ 32 ], iNum, szTempid[ 10 ], iPlayer;
	
	get_players( Players, iNum, "aceh", "CT" );
	
	for ( new i; i < iNum; i++ )
	{
		iPlayer = Players[ i ];
		
		num_to_str( iPlayer, szTempid, charsmax( szTempid ) );
		
		menu_additem( Menu, szName( iPlayer ), szTempid );
	}
	
	menu_display( client, Menu );
	
	return 1;
}

public SubPlayers( client, Menu, Item )
{
	if ( !is_user_valid( client ) )
		return ColorPrint( client, GetReason( client ) );
	
	if ( Item == MENU_EXIT )
	{
		menu_destroy( Menu );
		
		return 1;
	}
	
	new Trash, mData[ 6 ];
	
	menu_item_getinfo( Menu, Item, Trash, mData, charsmax( mData ), _,_, Trash );
	
	new iPlayer = str_to_num( mData );
	
	if ( cs_get_user_team( iPlayer ) != CS_TEAM_CT || !is_user_alive( iPlayer ) || !is_user_connected( iPlayer ) )
		return ColorPrint( client, "This player is no longer valid." );
	
	StopRequest( true );
	
	bPlayer[ client ] = true;
	
	bPlayer[ iPlayer ] = true;
	
	StartGames( client, iPlayer );
	
	return 1;
}

/* Forwards */

public FwdTakeDamage( victim, inf, attacker, Float:damage, damagebits )
{
	if ( !is_user_connected( victim ) || !is_user_alive( victim ) || !is_user_connected( attacker ) || !is_user_alive( attacker ) )
		return 1;
	
	if ( attacker == victim || !bPowerDeagle || !bPlayer[ attacker ] || !bPlayer[ victim ] )
		return 1;
	
	static g_mWeapon;
	
	g_mWeapon = get_user_weapon( attacker );
	
	if ( g_mWeapon == CSW_DEAGLE || g_mWeapon == CSW_HEGRENADE )
	{
		new Float:iOrigin[ 3 ], Float:Vec[ 3 ];
		
		get_velocity( victim, iOrigin, 1500.0, Vec );
		
		Vec[ 2 ] = 300.0;
		
		set_pev( victim, pev_velocity, Vec );
	}
	
	return 1;
}

public FwdPreThink( client )
{
	if ( !bPressed && TeamCount( "TERRORIST" ) == 1 && TeamCount( "CT" ) > 0 )
	{
		bPressed = true;
		
		for ( new i = 1; i < g_iMaxPlayers; i++ )
		{
			if ( !is_user_connected( i ) || !is_user_alive( i ) || cs_get_user_team( i ) != CS_TEAM_T  )
				continue;
			
			client_cmd( i, "say /lr" );
			
			break;
		}
		
		return 1;
	}
	
	if ( !bActive || !bPlayer[ client ] || !bCombo || !is_user_alive( client ) || !is_user_connected( client ) )
		return 1;
	
	new button	= fm_get_user_button( client );
	
	new oldbutton	= fm_get_user_oldbutton( client );
	
	new pressed	= button & ~oldbutton;
	
	if ( pressed & g_szCombo[ g_iCombo[ iCombo[ client ] ] ] )
	{
		iCombo[ client ]++;
		
		ColorPrint( client, "You pressed the^4 right^1 key! ^3[^4 Combo Status:^1 %i/10 ^3]", iCombo[ client ] );
		
		fCombo[ client ] = get_gametime();
		
		if ( iCombo[ client ] == 10 )
		{
			bCombo = false;
			
			for ( new i = 1; i < g_iMaxPlayers; i++ )
			{
				if ( !is_user_alive( i ) || !is_user_connected( i ) || !bPlayer[ i ] )
					continue;
				
				if ( cs_get_user_team( client ) == CS_TEAM_CT && cs_get_user_team( i ) == CS_TEAM_T
				|| cs_get_user_team( client ) == CS_TEAM_T && cs_get_user_team( i ) == CS_TEAM_CT )
					set_pev( i, pev_flags, pev( i, pev_flags) | FL_FROZEN );
			}
			
			fm_give_item( client, "weapon_m4a1" );
			
			cs_set_user_bpammo( client, CSW_M4A1, 120 );
			
			return 1;
		}
		
		return 1;
	}
	
	if ( fCombo[ client ] + 1 < get_gametime() )
	{
		fCombo[ client ] = get_gametime();
		
		iCombo[ client ] = 0;
			
		return 1;
	}
	
	if ( pressed )
	{
		iCombo[ client ] = 0;
		
		ColorPrint( client, "Wrong key! you^4 failed^1!^3 try again^1!" );
	}
	
	return 1;
}

public FwdPrecacheEvent( type, const name[] )
{
	for ( new i = 0; i < sizeof szGuns; ++i )
	{
		if ( equal( szGuns[ i ], name ) )
		{
			g_iBit |= (1<<get_orig_retval());
			
			return 2;
		}
	}
	
	return 1;
}

public FwdPlaybackEvent( iFlags, client, iEvent )
{
	if ( !( g_iBit & (1<<iEvent) ) || !(1<=client<=g_max_clients) )
		return 2;
	
	if ( bActive && bPlayer[ client ] && bShot )
	{
		if ( !bTurn[ client ] )
			return 4;
		
		for ( new i = 1; i < g_iMaxPlayers; i++ )
		{
			if ( !is_user_alive( i ) || !is_user_connected( i ) || !bPlayer[ i ] || bTurn[ i ] )
				continue;
			
			if ( i == client )
				continue;
			
			bTurn[ i ] = true;
			
			cs_set_weapon_ammo( fm_find_ent_by_owner( 1, szS4S[ iDuel ][ wClass ], i ), 1 );
		}
		
		bTurn[ client ] = false;
		
		cs_set_weapon_ammo( fm_find_ent_by_owner( 1, szS4S[ iDuel ][ wClass ], client ), 0 );
	}
	
	return 2;
}

public FwdSetModel( ent )
{
	if ( !bActive )
		return 1;
	
	if ( !pev_valid( ent ) )
		return 1;
	
	if ( iDuel == 1 || iDuel == 2 || iDuel == 3 || iDuel == 10 )
	{
		static client; client = pev( ent,pev_owner );
		
		if ( !( 1 <= client <= g_max_clients ) )
			return 1;
			
		switch( get_user_team( client ) )
		{
			case 1: fm_set_rendering( ent, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 1 );
			
			case 2: fm_set_rendering( ent, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 1 );
		}
	}
	
	return 1;
}

public FwdVoiceSetClientListening( Rec, Sender, bool:bListen ) 
{
	if ( !is_user_connected( Sender ) || !is_user_connected( Rec ) || get_user_flags( Sender ) & ADMIN_BAN
	|| cs_get_user_team( Sender ) == CS_TEAM_CT && is_user_alive( Sender )
	|| cs_get_user_team( Sender ) == CS_TEAM_T && is_user_alive( Sender ) && TeamCount( "TERRORIST" ) == 1 )
		return 1;
	
	engfunc( EngFunc_SetClientListening, Rec, Sender, 0 );
	
	return 4;
}

/* Beacon */


public CmdBeacon( const client )
{
	if ( !bActive || !bPlayer[ client ] )
		return 1;
	
	static CsTeams: iTeam;
	
	iTeam = cs_get_user_team( client );
	
	static iOrigin[ 3 ];
	get_user_origin( client, iOrigin );
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY );
	write_byte(TE_BEAMCYLINDER );				// TE id
	write_coord(iOrigin[0])					// x
	write_coord(iOrigin[1])					// y
	write_coord(iOrigin[2]-20)				// z
	write_coord(iOrigin[0])    				// x axis
	write_coord(iOrigin[1]);				// y axis
	write_coord(iOrigin[2]+200);				// z axis
	write_short( beaconSprite );				// sprite
	write_byte(0);						// startframe   
	write_byte(1);						// framerate   
	write_byte(5);						// life
	write_byte(5);  					// width
	write_byte(1);   					// noise    
	write_byte( (iTeam==CS_TEAM_CT) ? 0 : 255 );  		// red  
	write_byte( 0 );  					// green  
	write_byte( (iTeam==CS_TEAM_CT) ? 255 : 0 );  		// blue  
	write_byte(255);					// brightness
	write_byte(0);						// speed
	message_end();
	
	set_task( 1.5, "CmdBeacon", client );
	
	return 1;
}


/* Events */

public evCountdown()
{
	if ( g_iTimer <= 0 )
	{
		if ( iDuel == 9 )
		{
			bCombo = true;
			
			ComboMsg();
		
			return 1;
		}
			
		for ( new i = 1; i < g_iMaxPlayers; i++ )
		{
			if ( !is_user_connected( i ) || !is_user_alive( i ) || !bPlayer[ i ] || cs_get_user_team( i ) != CS_TEAM_T )
				continue;
			
			set_pev( i, pev_flags, pev( i, pev_flags ) & ~FL_FROZEN );
		}
		
		g_iCount = 10;
		
		evCount();
		
		return 1;
	}
	
	new Vox[ 32 ];num_to_word( g_iTimer, Vox, charsmax( Vox ) );
	
	client_cmd( 0, "spk ^"vox/%s^"", Vox, (g_iTimer > 1) ? "s" : "" );
	
	set_hudmessage( 255, 0, 0, -1.0, 0.35, 1, 6.0, 1.0, 0.1, 0.1, -1 );
	
	show_hudmessage( 0, "%s will start in %i Seconds!", GetDuel(), g_iTimer );
	
	g_iTimer--;
	
	set_task( 1.0, "evCountdown", TASKID_COUNTDOWN );
	
	return 1;
}

public evCount()
{
	if ( g_iCount <= 0 )
	{
		if ( iType == 2 )
		{
			{
				for ( new i = 1; i < g_iMaxPlayers; i++ )
				{
					if ( !is_user_connected( i ) || !is_user_alive( i ) || !bPlayer[ i ] )
						continue;
					
					if ( iDuel == 7 )
					{
						if ( cs_get_user_team( i ) == CS_TEAM_CT )
							fm_set_user_godmode( i, 0 );
						
						if ( cs_get_user_team( i ) == CS_TEAM_T )
						{
							fm_give_item( i, "weapon_m4a1" );
							
							cs_set_user_bpammo( i, CSW_M4A1, 999 );
						}
					}
					
					if ( iDuel == 8 )
					{
						if ( cs_get_user_team( i ) == CS_TEAM_CT )
						{
							fm_give_item( i, "weapon_m4a1" );
							
							cs_set_user_bpammo( i, CSW_M4A1, 999 );
						}
					}
				}
			}
		}
		
		return 1;
	}
	
	//set_hudmessage( 0, 130, 255, -1.0, -1.0, 1, 6.0, 1.0, 0.1, 0.1, -1 );
	
	//show_hudmessage( 0, "%i", g_iCount );
	
	set_hudmessage
	
	g_iCount--;
	
	set_task( 1.0, "evCount", TASKID_COUNTDOWN );
	
	return 1;
}

public evRoundStart()
{
	StopRequest();
}

public evDeathMsg()
{
	if ( !bActive )
		return 0;
	
	new attacker = read_data( 1 );
	new victim = read_data( 2 );
	
	if ( !is_user_connected( attacker ) || !is_user_connected( victim ) || !bPlayer[ attacker ] || !bPlayer[ victim ] )
		return 0;
	
	if ( attacker != victim )
	{
		client_cmd( 0, "; mp3 play ^"sound/%s", szMusic[ random( MAX_SOUNDS ) ] );
		client_cmd(attacker,"dsdance")
		ColorPrint( 0, "^3%s^1 won the^4 %s^1 against^3 %s^1!", szName( attacker  ), GetDuel(), szName( victim ) );
		TakeBox = true
		set_task(10.0, "DontTake")
	}
	
	if( iType == LR_PREMIUM && iDuel == LR_SPEARGUN )
		remove_speargun( attacker );
		
	bPlayer[ attacker ] = bPlayer[ victim ] = false;
	
	StopRequest();
	
	return 0;
}

public DontTake()
{
	TakeBox = false
}	

stock StopRequest( bool: bReset = false )
{
	bActive		= false;
	
	bShot		= false;
	
	bCombo		= false;
	
	bPressed	= false;
	
	bPowerDeagle	= false;
	
	if ( !bReset )
		iDuel = iType = iWar = 0;
	
	remove_task( TASKID_COUNTDOWN );
	
	remove_task( 19234 )
	
	remove_task( TASKID_MSG );
	
	remove_task( TASKID_BEACON );
	
	set_user_hitzones( 0, 0, 255 );
	
	for ( new i = 1; i < g_iMaxPlayers; i++ )
	{
		if ( !is_user_connected( i ) || !is_user_alive( i ) )
			continue;
		
		bPlayer[ i ] = false;
		
		bTurn[ i ] = false;
		
		fm_set_user_gravity( i, 1.0 );
		
		fm_set_user_noclip( i, 0 );
		
		fm_set_user_rendering( i );
		
		fm_set_user_godmode( i, 0 );
	}	
}

/* Messages */

public CmdMsg()
{	
	if ( !bActive )
		return 1;
	
	new Players[ 32 ], iNum, szMsg[ 512 ], szText[ 128 ];
	
	get_players( Players, iNum );
		
	formatex( szMsg, charsmax( szMsg ), "^nApoc Jailbreak | Last Request^n^nDuel: %s", GetDuel() );

	AddLines( szMsg, charsmax( szMsg ) );
	
	for ( new i; i < iNum; i++ )
	{
		new iPlayer = Players[ i ];
		
		if ( bPlayer[ iPlayer ] )
		{	
			
			formatex( szText, charsmax( szText ), "%s: %s | %i Health^n", (cs_get_user_team( iPlayer )==CS_TEAM_CT) ? "Guard" : "Prisoner", szName( iPlayer ), get_user_health( iPlayer ), GetUserBalls( iPlayer ) );
			
			if ( iType == 2 && iDuel == 11 )	/* Dodgeball */
			formatex( szText, charsmax( szText ), "^%s: %s | %i Health | Balls Threw: %i^n", (cs_get_user_team( iPlayer )==CS_TEAM_CT) ? "Guard" : "Prisoner", szName( iPlayer ), get_user_health( iPlayer ), GetUserBalls( iPlayer ) );
			
			add( szMsg, charsmax( szMsg ), szText );
		}
	}
	
	add( szMsg, charsmax( szMsg ), "^n^nTo disable this message type /infomsg ." );
	
	ShowMsg( szMsg );
	
	set_task( 0.3, "CmdMsg", TASKID_MSG );
	
	return 1;
}

public ComboMsg()
{
	if ( !bCombo || !bActive )
		return 1;
	
	new Players[ 32 ], iNum, iPlayer, szMsg[ 512 ], szText[ 192 ];
		
	get_players( Players, iNum );
	
	set_hudmessage( 0, 130, 255, 0.08, 0.12, 1, 0.1, 0.3, 0.1, 0.1 );
	
	formatex( szMsg, charsmax( szMsg ), "%s  Last Request^n%s^n", Info[ 3 ], GetDuel() );
		
	AddLines( szMsg, charsmax( szMsg ) );
		
	AddPlayers( szMsg, charsmax( szMsg ), szText, charsmax( szText ) );
	
	add( szMsg, charsmax( szMsg ), "^n^nTo disable this message type /infomsg ." );
	
	for ( new i; i < iNum; i++ )
	{
		iPlayer = Players[ i ];
		
		if ( bMsg[ iPlayer ] )
			continue;
	
	
	
		set_hudmessage( 0, 130, 255, -1.0, 0.23, 1, 0.1, 0.3, 0.1, 0.1 );
		
		show_hudmessage( iPlayer, "^n%s%s%s^n%s%s%s^n%s%s%s^n%s%s%s^n%s%s%s^n%s%s%s^n%s%s%s^n%s%s%s^n%s%s%s^n%s%s%s^n",
		(iCombo[ iPlayer ]==0) ? ">>" : "", szCombo[ g_iCombo[ 0 ] ], (iCombo[ iPlayer ]==0) ? "<<" : "",
		(iCombo[ iPlayer ]==1) ? ">>" : "", szCombo[ g_iCombo[ 1 ] ], (iCombo[ iPlayer ]==1) ? "<<" : "",
		(iCombo[ iPlayer ]==2) ? ">>" : "", szCombo[ g_iCombo[ 2 ] ], (iCombo[ iPlayer ]==2) ? "<<" : "",
		(iCombo[ iPlayer ]==3) ? ">>" : "", szCombo[ g_iCombo[ 3 ] ], (iCombo[ iPlayer ]==3) ? "<<" : "",
		(iCombo[ iPlayer ]==4) ? ">>" : "", szCombo[ g_iCombo[ 4 ] ], (iCombo[ iPlayer ]==4) ? "<<" : "",
		(iCombo[ iPlayer ]==5) ? ">>" : "", szCombo[ g_iCombo[ 5 ] ], (iCombo[ iPlayer ]==5) ? "<<" : "",
		(iCombo[ iPlayer ]==6) ? ">>" : "", szCombo[ g_iCombo[ 6 ] ], (iCombo[ iPlayer ]==6) ? "<<" : "",
		(iCombo[ iPlayer ]==7) ? ">>" : "", szCombo[ g_iCombo[ 7 ] ], (iCombo[ iPlayer ]==7) ? "<<" : "",
		(iCombo[ iPlayer ]==8) ? ">>" : "", szCombo[ g_iCombo[ 8 ] ], (iCombo[ iPlayer ]==8) ? "<<" : "",
		(iCombo[ iPlayer ]==9) ? ">>" : "", szCombo[ g_iCombo[ 9 ] ], (iCombo[ iPlayer ]==9) ? "<<" : "" );
			
		add( szMsg, charsmax( szMsg ), szText );
		
	}
	
	set_task( 0.2, "ComboMsg", TASKID_MSG );
	
	return 1;
}

stock ShowMsg( szMsg[] )
{
	new Players[ 32 ], iNum, iPlayer;
	
	get_players( Players, iNum, "ch" );
	
	set_hudmessage( 0, 130, 255, 0.04, 0.19, 0, 6.0, 0.2, 0.1, 0.1, -1 );
	
	for ( new i; i < iNum; i++ )
	{
		iPlayer = Players[ i ];
		
		if ( bMsg[ iPlayer ] )
			continue;
		
		show_hudmessage( iPlayer, szMsg );
	}
}
		
/* Stocks */
 
stock StartGames( const client, const iPlayer )
{
	new Item = iDuel;
	
	bActive = true;
	
	fm_strip_user_weapons( client );
	
	fm_strip_user_weapons( iPlayer );
	
	SetHealth( client, iPlayer, 100 );
	
	g_iTimer = 5;
	
	CmdBeacon( client );
	
	CmdBeacon( iPlayer );
	
	switch ( iType )
	{
		case 0:	// Shot 4 Shot
		{
			client_cmd( 0, "; mp3 play ^"sound/%s", s4s );
			
			bShot = true;
			
			bTurn[ client ] = true;
			
			bTurn[ iPlayer ] = false;
			
			fm_give_item( client, szS4S[ Item ][ wClass ] );
			
			fm_give_item( iPlayer, szS4S[ Item ][ wClass ] );
			
			cs_set_weapon_ammo( fm_find_ent_by_owner( 1, szS4S[ Item ][ wClass ], client ), 1 );
			
			cs_set_weapon_ammo( fm_find_ent_by_owner( 1, szS4S[ Item ][ wClass ], iPlayer ), 0 );
		}
		
		case 1:	// War
		{	
			switch ( iWar )
			{
				case 1:	SetHealth( client, iPlayer, 1500 );
				
				case 2:
				{
					set_user_hitzones( 0, 0, 2 );
					
					SetHealth( client, iPlayer, 1000 );
				}
				
				case 3:	fm_set_user_gravity( client, 0.5 ), fm_set_user_gravity( iPlayer, 0.5 ), SetHealth( client, iPlayer, 750 );
			}
			
			if ( szWar[ Item ][ wIndex ] == CSW_KNIFE )
			{
				fm_give_item( client, "weapon_knife" );
				
				fm_give_item( iPlayer, "weapon_knife" );
			}
			
			else	GiveWeapons( client, iPlayer, szWar[ Item ][ wClass ], szWar[ Item ][ wIndex ] );
		}
		
		case 2:	// Fun
		{
			switch ( Item )
			{
				case 0:	// Kill the Noclip Man
				{
					fm_give_item( client, "weapon_deagle" );
					
					cs_set_user_bpammo( client, CSW_DEAGLE, 999 );
					
					fm_give_item( iPlayer, "weapon_knife" );
					
					fm_set_user_noclip( iPlayer, 1 );
				}

				case 1, 10:	// Bomb Toss && Spray the Bomb Contest
				{
					GiveWeapons( client, iPlayer, "weapon_c4", CSW_C4 );
					
					fm_give_item( client, "weapon_knife" );
					
					fm_give_item( iPlayer, "weapon_knife" );

				}
					
				case 2:	// Gun Toss
				{
					fm_give_item( client, "weapon_deagle" );
					
					fm_give_item( iPlayer, "weapon_deagle" );
					
					cs_set_weapon_ammo( fm_find_ent_by_owner( 1, "weapon_deagle", client ), 0 );
					
					cs_set_weapon_ammo( fm_find_ent_by_owner( 1, "weapon_deagle", iPlayer ), 0 );
					
					fm_give_item( client, "weapon_knife" );
					
					fm_give_item( iPlayer, "weapon_knife" );

				}
					
				case 3:	//  Away the Bomb
				{
					GiveWeapons( client, iPlayer, "weapon_deagle", CSW_DEAGLE );
					
					GiveWeapons( client, iPlayer, "weapon_c4", CSW_C4 );

				}
					
				case 4:	// Survival Duel
				{
					SetHealth( client, iPlayer, 100, 5000 );
					
					fm_give_item( client, "weapon_m4a1" );
					
					cs_set_user_bpammo( client, CSW_M4A1, 999 );
					
					fm_give_item( iPlayer, "weapon_knife" );
				}
					
				case 5:	// Invisible Duel
				{
					fm_set_user_rendering( client, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 16 );
					
					fm_set_user_rendering( iPlayer, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 16 );
					
					GiveWeapons( client, iPlayer, "weapon_m4a1",  CSW_M4A1 );
					
					SetHealth( client, iPlayer, 500 );
					
					remove_task( TASKID_BEACON );
				}
				
				case 6:	// Spray Contest
				{
					fm_give_item( client, "weapon_knife" );
					fm_give_item( iPlayer, "weapon_knife" );
				}
				
				case 7:	// Hide'N'Seek Duel
				{
					fm_set_user_rendering( client, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 16 );
					
					fm_give_item( iPlayer, "weapon_knife" );
					
					fm_set_user_godmode( iPlayer, 1 );
					
					g_iCount = 60;
					
					evCount();
				}
					
				case 8:	// Strip Duel
				{
					fm_strip_user_weapons( client );
					fm_strip_user_weapons( iPlayer );
					
					evCountdown();
					
					TheStriper = cs_get_user_team( client ) == CS_TEAM_T ? client : iPlayer;
					TheStriped = cs_get_user_team( client ) != CS_TEAM_T ? client : iPlayer;

					if( cs_get_user_team( client ) == CS_TEAM_T )
					{
						fm_give_item( client, "weapon_m4a1" );
						cs_set_user_bpammo( client, CSW_M4A1, 9999 );
						fm_set_user_health( iPlayer, 1000 );
					}
					
					else
					{
						fm_give_item( iPlayer, "weapon_m4a1" );
						cs_set_user_bpammo( iPlayer, CSW_M4A1, 9999 );
						fm_set_user_health( iPlayer, 1000 );
					}
					
					g_iCount = 10;
					
					set_task( 1.0, "StripCountdown", 19234, _,_, "b" );
					
					fm_set_user_health( client, 1000 );
					fm_set_user_health( iPlayer, 1000 );
				}
					
				case 9:	// Combo Contest
				{
					for ( new i; i < 10; i++ )
						g_iCombo[ i ] = random( sizeof g_szCombo );
					
					iCombo[ client ] = 0;
					
					iCombo[ iPlayer ] = 0;
					
					g_iTimer = 5;
					
					evCountdown();
					
					return 1;
				}
				
				case 11: // Dodgeball
					start_dodgeball( client, iPlayer );
				
				case 12: // Deagle Power
				{
					bPowerDeagle	= true;
					
					fm_give_item( client, "weapon_deagle" );
					
					fm_give_item( iPlayer, "weapon_deagle" );
					
					cs_set_user_bpammo( client, CSW_DEAGLE, 9999 );
					
					cs_set_user_bpammo( iPlayer, CSW_DEAGLE, 9999 );
					
					fm_set_user_health( client, 750 );
					fm_set_user_health( iPlayer, 750 );
				}
				
				case 13: // Grenade Power
				{
					bPowerDeagle	= true;
					
					fm_give_item( client, "weapon_hegrenade" );
					
					fm_give_item( iPlayer, "weapon_hegrenade" );
					
					cs_set_user_bpammo( client, CSW_HEGRENADE, 9999 );
					
					cs_set_user_bpammo( iPlayer, CSW_HEGRENADE, 9999 );
					
					fm_set_user_health( client, 750 );
					
					fm_set_user_health( iPlayer, 750 );
				}
				case 14: // SpearGun
				{
					
					fm_set_user_health( client, 1500 );
					fm_set_user_health( iPlayer, 1500 );
					
					g_iTimer = 5;
					evCountdown();
					
					give_speargun( client );
					give_speargun( iPlayer );
				}
				case 15:
				{
					
					fm_set_user_health( client, 1500 );
					fm_set_user_health( iPlayer, 1500 );
					
					g_iTimer = 5;
					evCountdown();
					
					give_tactical( client );
					give_tactical( iPlayer );
				}
				case 16:
				{
					
					fm_set_user_health( client, 1500 );
					fm_set_user_health( iPlayer, 1500 );
					
					g_iTimer = 5;
					evCountdown();
					
					give_pumpkin__( client );
					give_pumpkin__( iPlayer );

				}

				case 17:
				{
					
					fm_set_user_health( client, 1500 );
					fm_set_user_health( iPlayer, 1500 );
					
					g_iTimer = 5;
					evCountdown();
					
					get_cannon( client );
					get_cannon( iPlayer );

				}
			}
		}
		
		case 3:
		{
			StartContest( client, iPlayer, iDuel );
			
			return 1;
		}		
	}
	
	fn_Cells()
	
	CmdMsg();
	
	return 1;
}

public fn_Cells()
{
	static iEnt;
	
	iEnt = -1;
	
	while( ( iEnt = engfunc( EngFunc_FindEntityByString, iEnt, "classname", "func_door" ) ) != 0 )
		dllfunc( DLLFunc_Use, iEnt, 0 );
}

public StripCountdown()
{
	if( g_iCount <= 0 )
	{
		new OldStriper, OldStriped;
		
		OldStriper = TheStriper;
		OldStriped = TheStriped;
		
		TheStriped = OldStriper;
		TheStriper = OldStriped;
		
		for ( new i; i < get_maxplayers(); i++ )
		{
			new iPlayer = i;
			
			if ( bPlayer[ iPlayer ] )
			{
				fm_strip_user_weapons( iPlayer );
				
				if( i == TheStriper )
				{
					fm_give_item( iPlayer, "weapon_m4a1" );
					cs_set_user_bpammo( iPlayer, CSW_M4A1, 9999 );
					fm_set_user_health( iPlayer, 1000 );
				}
			}
		}
		
		
		g_iCount = 10;
	
	}
	
	else
	{
		set_dhudmessage( 255, 0, 0, -1.0, 0.35, 1, 6.0, -1.0 )
		
		for ( new i = 0;  i < get_maxplayers(); i++ )
		{
			if( !is_user_alive( i ) )
				continue;
				
			if( TheStriped == i && user_has_weapon( i, CSW_M4A1 ) )
				fm_strip_user_weapons( i );
				
			//new iPlayer = i;
				
			if( TheStriper == i )
				show_dhudmessage( i, "You have %i Second%s^nleft to try kill %s.", g_iCount, g_iCount == 1 ? "" : "s", szName( TheStriped ) );
					
			else if( TheStriped == i )
				show_dhudmessage( i, "You have %i Second%s^nleft to try staying alive from %s.", g_iCount, g_iCount == 1 ? "" : "s", szName( TheStriper ) );
		}
	}
	
}

stock SetHealth( const client, const iPlayer, iHealth = 100, pHealth = 0 )
{
	fm_set_user_health( client, iHealth );
	
	fm_set_user_health( iPlayer, (pHealth!=0) ? pHealth : iHealth );
}

stock GiveWeapons( const client, const iPlayer, szClass[], g_iIndex, bool: bSpecial = false )
{
	fm_give_item( client, szClass );
	
	fm_give_item( iPlayer, szClass );
	
	if ( bSpecial )
		return 1;
	
	if ( g_iIndex != CSW_KNIFE || g_iIndex != CSW_C4 )
		cs_set_user_bpammo( client, g_iIndex, 999 ), cs_set_user_bpammo( iPlayer, g_iIndex, 999 );
	
	return 1;
}

stock GetDuel()
{	
	new szBuffer[ 128 ];
	
	switch ( iType )
	{
		case 0:	formatex( szBuffer, charsmax( szBuffer ), "%s | Shot4Shot", szS4S[ iDuel ] );
		
		case 1:	formatex( szBuffer, charsmax( szBuffer ), "%s | %s Duel", szWar[ iDuel ], szWarOptions[ iWar ] );
		
		case 2:	formatex( szBuffer, charsmax( szBuffer ), szFun[ iDuel ] );
		
		case 3:	formatex( szBuffer, charsmax( szBuffer ), "%s Contest", szContests[ iDuel ] );
		
		case 4:	formatex( szBuffer, charsmax( szBuffer ), "Rambo" );
	}
	
	return szBuffer;
}

stock ColorPrint( const client, const string[], any:... )
{
	new szMsg[ 191 ], Players[ 32 ], PNum = 1;
	
	static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "^4[ ^1%s ^4]^1 ", Info[ 4 ] );
	
	vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
	
	if ( client )
		Players[ 0 ] = client;
	
	else
		get_players( Players, PNum, "ch" );
	
	for ( new i; i < PNum; i++ )
	{
		if( is_user_connected( Players[ i ] ) )
		{
			message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );
			
			write_byte( Players[ i ] );
			
			write_string( szMsg );
			
			message_end( );
		}
	}
	
	return 1;
}

stock szName( const index )
{
	new ClientName[ 32 ];
	
	get_user_name( index, ClientName, charsmax( ClientName ) );
	
	return ClientName;
}

stock register_saycmd( szCommand[], szFunction[] )
{
	new szSayType[ ][ ] = { "say", "say_team" }, szSigns[ ][ ] = { "!", "/" }, szSign[ 64 ];
	
	for ( new i; i < sizeof szSayType; i++ )
	{
		for ( new j; j < sizeof szSigns; j++ )
		{
			formatex( szSign, charsmax( szSign ), "%s %s%s", szSayType[ i ], szSigns[ j ], szCommand );
			
			register_clcmd( szSign, szFunction );
		}
	}
}

stock TeamCount( szTeam[] )
{
	new Players[ 32 ], iNum; 
	
	get_players( Players, iNum, "aceh", szTeam );
	
	return iNum;
}

stock GetReason( const index )
{
	new szReason[ 128 ];
	
	if ( !is_user_alive( index ) )
		szReason = "^1You need to be^4 Alive^1.";
		
	if ( cs_get_user_team( index ) != CS_TEAM_T )
		szReason = "^1You need to be a^4 Terrorist^1.";
	
	if ( TeamCount( "TERRORIST" ) > 1 )
		szReason = "^1There are too many^3 Alive Terrorists^1.";
	
	if ( TeamCount( "CT" ) <= 0 )
		szReason = "^1There are too many^3 Alive Counter-Terrorists^1.";
	
	if ( bActive )
		szReason = "^1A Last-Request has already been started.";
	
	return szReason;
}

stock bool: is_user_valid( const index )
{
	if ( !is_user_alive( index ) )
		return false;
		
	if ( cs_get_user_team( index ) != CS_TEAM_T )
		return false;
	
	if ( TeamCount( "TERRORIST" ) > 1 )
		return false;
	
	if ( TeamCount( "CT" ) <= 0 )
		return false;
	
	if ( bActive )
		return false;
	
	return true;
}
	
stock AddItem( Menu, string[], any:... )
{
	new szMsg[ 128 ];static iLen;
	
	vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
	
	formatex( szItem, charsmax( szItem ), szMsg );
	
	menu_additem( Menu, szItem );
}

stock AddLines( Output[], Len )
{
	add( Output, Len, "^n----------------------------------^n" );
}

stock AddPlayers( Output[], Len, Src[], srcLen )
{
	for ( new i = 1; i < g_iMaxPlayers; i++ )
	{
		if ( !is_user_connected( i ) || !is_user_alive( i ) || !bPlayer[ i ] )
			continue;
		
		formatex( Src, srcLen, "^n %s:^n    %s : %i HP", (cs_get_user_team( i )==CS_TEAM_CT)? "CT's" :"T's", szName( i ), get_user_health( i ) );
		
		add( Output, Len, Src );
	}
}

stock get_velocity( ent, Float:fOrigin[ 3 ], Float:fSpeed, Float:fVelocity[ 3 ] )
{
	new Float:fEntOrigin[3];
	
	pev( ent, pev_origin, fEntOrigin );
	
	new Float:fDistance[3];
	fDistance[0] = fEntOrigin[0] - fOrigin[0];
	fDistance[1] = fEntOrigin[1] - fOrigin[1];
	fDistance[2] = fEntOrigin[2] - fOrigin[2];
	
	new Float:fTime = ( vector_distance( fEntOrigin,fOrigin ) / fSpeed );
	
	fVelocity[0] = fDistance[0] / fTime;
	fVelocity[1] = fDistance[1] / fTime;
	fVelocity[2] = fDistance[2] / fTime;
	
	return (fVelocity[0] && fVelocity[1] && fVelocity[2]);
}

Last edited by Apocalyman; 08-26-2023 at 08:00.
Apocalyman is offline
Tote
Senior Member
Join Date: Jul 2023
Old 08-25-2023 , 08:30   Re: How do I add a model to a grenade in this plugin?
Reply With Quote #2

give_pumpkin__( client );

there is a native from another plugin being used, send the main plugin used to give pumpkin so we can help you
Tote is offline
Apocalyman
Member
Join Date: Nov 2022
Old 08-26-2023 , 08:05   Re: How do I add a model to a grenade in this plugin?
Reply With Quote #3

Quote:
Originally Posted by Tote View Post
give_pumpkin__( client );

there is a native from another plugin being used, send the main plugin used to give pumpkin so we can help you
Oh okay gotcha. This is the main plugin where it gives pumpkin:
Code:
#include <amxmodx>
#include <fun>
#include <hamsandwich>
#include <fakemeta_util>
#include <cstrike>

#define PLUGIN "Pumpkin Grenade"
#define VERSION "3.0"
#define AUTHOR "Chrescoe1"

//Resource
new const v_model_pumpkin[] = 	"models/Apoc/v_pumpkin.mdl"
new const p_model_pumpkin[] = 	"models/Apoc/p_pumpkin.mdl"
new const w_model_pumpkin[] = 	"models/Apoc//w_pumpkin.mdl"
new const cluster_models[] =	"models/Apoc/w_pumpkinSmall3.mdl"
new const g_soundexpl[] = 		"weapons/Apoc/pump_exp.wav"
new const blast_sprite[] =	 "sprites/shockwave.spr"
new const cluster_trail[] =	"sprites/laserbeam.spr"	
new const exp_sprite[] = 		"sprites/pumpkin_exp.spr"

//Settings
const Float:expl_damage =  70.0 // ???? ????????? ????????
const Float:expl_damage_ent = 60.0 // ???? ????????? ?????? \ ???
const Float:expl_radius =  240.0 // ?????? ????? ???????
const Float:cluster_damage = 13.0 // ???? ????????? ?????????
const Float:cluster_damage_ent = 20.0 // ???? ????????? ?????? \ ???
const Float:cluster_radius = 140.0 // ?????? ????? ???????

const cluster_num_min = 15 // ??? ???-?? ????????
const cluster_num_max = 30 // ???? ???-?? ????????
const Float:cluster_rad_min =  250.0 // ??? ?????? ??????? ???????
const Float:cluster_rad_max =  350.0 // ???? ?????? ??????? ???????
const Float:cluster_up_min =  350.0 // ??? ???¸? ???????? ?????
const Float:cluster_up_max =  450.0 // ???? ???¸? ???????? ?????

#define weapon_name "weapon_hegrenade"
#define Bomb_Classname "Pumpkin_Grenade"
#define Cluster_Classname "Pumpkin_ClusterBomb"
#define weaponlist_name "weapon_pumpkin"
#define weaponlist_original "weapon_hegrenade"

native is_day();
native get_running_day_pumpkin();

native is_lr_active();
native is_user_lr( index );

new bool:g_has_pumpkin[32]
new g_sprRing,spriteexpl,g_Trail
new Msg_Weaponlist,Msg_ScreenShake,Msg_ScreenFade
public plugin_precache()
{
	precache_generic( "sprites/weapon_pumpkin.txt" )
	precache_generic( "sprites/640hud41.spr" )
	precache_generic( "sprites/640hud7.spr" )

	precache_sound( "weapons/Apoc/Days/pump_deploy.wav" )
	precache_sound( "weapons/Apoc/Days/pump_in.wav" )
	precache_sound( "weapons/Apoc/Days/pump_throw.wav" )
	
	precache_model(w_model_pumpkin)
	precache_model(v_model_pumpkin)
	precache_model(p_model_pumpkin)
	precache_model(cluster_models)
	precache_sound(g_soundexpl)
	
	spriteexpl	= precache_model(exp_sprite)
	g_Trail		= precache_model(cluster_trail)
	g_sprRing	= precache_model(blast_sprite)
}
public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	Msg_Weaponlist = get_user_msgid("WeaponList")
	Msg_ScreenShake = get_user_msgid("ScreenShake")
	Msg_ScreenFade = get_user_msgid("ScreenFade")
	
	//Ham
	RegisterHam(Ham_Item_AddToPlayer, weapon_name, "Ham_AddToPlayer_Post", 1)
	RegisterHam(Ham_Item_Deploy, weapon_name, "Ham_Item_Deploy_Post", 1)
	
	//Fakemeta
	register_forward(FM_SetModel, "Fakemeta_SetModel")
	register_forward(FM_Touch, "Fakemeta_Touch")
	
	//Hook Weapon
	register_clcmd(weaponlist_name, "hook_weapon")
	
	register_logevent( "evRoundStart", 2, "1=Round_Start" );
}

public evRoundStart()
{
	for( new i = 0; i < get_maxplayers(); i++ )
	{
		if( is_user_connected( i ) )
			remove_pumpkin( i );
	}
}

public plugin_natives()
{
	register_native( "give_pumpkin__", "_give_pumpkin" );
	register_native( "remove_pumpkin__", "_remove_pumpkin" );
}

public _give_pumpkin( plugin, params )
{
	new client = get_param( 1 );
	
	if( is_day() && get_running_day_pumpkin() || is_lr_active() && is_user_lr( client ) )
		give_user_pumpkin( client )
}

public _remove_pumpkin( plugin, params )
{
	new client = get_param( 1 );
	
	remove_pumpkin( client );
}

public remove_pumpkin( id )
	g_has_pumpkin[ id ] = false;
	
public give_user_pumpkin( id )
{
	if( g_has_pumpkin[ id ] )
		return PLUGIN_HANDLED;
		
	g_has_pumpkin[ id ]= true
	
	give_item( id, "weapon_hegrenade" )
	cs_set_user_bpammo( id, CSW_HEGRENADE, 9999 );
	
	return PLUGIN_HANDLED
}


public hook_weapon(id){client_cmd(id,weaponlist_original);return PLUGIN_HANDLED;}

//Ham
public Ham_AddToPlayer_Post(ent, id)
{
	if(!pev_valid(ent))return HAM_IGNORED	
	//Update WeaponList
	message_begin(MSG_ONE_UNRELIABLE, Msg_Weaponlist, _, id)
	write_string(g_has_pumpkin[id]? weaponlist_name : weaponlist_original)
	write_byte(12)
	write_byte(1)
	write_byte(-1)
	write_byte(-1)
	write_byte(3)
	write_byte(1)
	write_byte(CSW_HEGRENADE)
	write_byte(24)
	message_end()			
	return HAM_HANDLED		
}
public Ham_Item_Deploy_Post(ent)
{
	if(!pev_valid(ent))return
	
	new id = get_pdata_cbase(ent, 41, 4)
	
	if (is_user_alive(id))
	{
		if(g_has_pumpkin[id] )
		{
			if( is_day() && get_running_day_pumpkin())
			{
				set_pev(id, pev_viewmodel2, v_model_pumpkin)
				set_pev(id, pev_weaponmodel2, p_model_pumpkin)
			}
		}
	}
}
//Fakemeta
public Fakemeta_SetModel(ent, const Model[])
{
	if( !pev_valid( ent ) )
		return FMRES_IGNORED;
		
	new id = pev( ent, pev_owner )
	
		
	if( is_day() && !get_running_day_pumpkin() )
		return FMRES_IGNORED;
		
	if(equal(Model, "models/w_hegrenade.mdl") )	//If model HE Grenade
	{
		if( g_has_pumpkin[id] )	//if owner has bomb
		{
			Trail(ent,g_Trail,12,8,255,155,55,255)
			set_pev(ent, pev_classname, Bomb_Classname)	//Set classname	
			set_pev(ent, pev_dmgtime, 9999999.0)		//Block Explode
			engfunc(EngFunc_SetModel, ent, w_model_pumpkin)	//Change Model
			return FMRES_SUPERCEDE
		}
	}
	return FMRES_IGNORED	
}
public Fakemeta_Touch(ent, touch)
{
	if(!pev_valid(ent) )
		return HAM_IGNORED;
		
	if( is_day() && !get_running_day_pumpkin() )
		return HAM_IGNORED;
		
	new EntClassname[32],TouchClassname[32]
	pev(ent, pev_classname, EntClassname, sizeof(EntClassname))
	
	if(pev_valid(touch))
		pev(touch, pev_classname, TouchClassname, sizeof(TouchClassname))
	
	if(equal(EntClassname, Bomb_Classname))
	{
		if(pev_valid(touch))
		{
			if(equal(TouchClassname, Cluster_Classname))return HAM_SUPERCEDE
			if(equal(TouchClassname, Bomb_Classname))return HAM_SUPERCEDE
		}
		Pumpkin_Explode(ent)
		return HAM_SUPERCEDE
	}
	
	if(equal(EntClassname, Cluster_Classname))
	{
		if(pev_valid(touch))
		{
			if(equal(TouchClassname, Cluster_Classname))return HAM_SUPERCEDE
			if(equal(TouchClassname, Bomb_Classname))return HAM_SUPERCEDE
		}
		Cluster_Explode(ent)
		return HAM_SUPERCEDE
	}
	return HAM_IGNORED
}
//Public Func
public Pumpkin_Explode(ent)
{
	new Float:ExpOrigin[3],owner= pev(ent, pev_owner)
	pev(ent,pev_origin,ExpOrigin)
		
	engfunc(EngFunc_EmitSound, ent, CHAN_WEAPON,g_soundexpl, 1.0, ATTN_NORM, 0, PITCH_NORM)
	
	//Explode	
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ExpOrigin, 0)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, ExpOrigin[0])
	engfunc(EngFunc_WriteCoord, ExpOrigin[1])
	engfunc(EngFunc_WriteCoord, ExpOrigin[2]+50.0)
	write_short(spriteexpl)
	write_byte(30)
	write_byte(10)
	write_byte(0)
	message_end()
	
	ExplodeDecals(ExpOrigin)
	Light(ExpOrigin,45,250,150,50,15)	
	Ring(ExpOrigin,20,80)
	Ring(ExpOrigin,40,60)
	Ring(ExpOrigin,60,40)
	Ring(ExpOrigin,80,20)
	
	static victim = -1
	while((victim = engfunc(EngFunc_FindEntityInSphere, victim, ExpOrigin, expl_radius)) != 0)
	{
		if(victim>0&&pev(victim, pev_takedamage)!=DAMAGE_NO&&pev(victim, pev_solid)!=SOLID_NOT)
		{	
			if(is_user_connected(victim))
			{
					ExecuteHamB(Ham_TakeDamage, victim, ent, owner,expl_damage , DMG_NERVEGAS),
					ScreenFadeAndShake(victim)
			}
			else ExecuteHamB(Ham_TakeDamage, victim, ent, owner,expl_damage_ent , DMG_NERVEGAS)
		}
	}
	
	//Make Cluster Grenade
	//Code by Alexander.3 - http://forum.zombielite.ru/index.php?/topic/81-clustergrenade/
	for (new i=0;i<random_num(cluster_num_min,cluster_num_max); i++)
	{	
		new bomb			
		bomb = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))	
		engfunc(EngFunc_SetOrigin, bomb, ExpOrigin)	
		engfunc(EngFunc_SetModel, bomb, cluster_models)	
		set_pev(bomb, pev_solid, SOLID_TRIGGER)		
		set_pev(bomb, pev_classname, Cluster_Classname)	
		set_pev(bomb, pev_movetype, MOVETYPE_TOSS)	
		set_pev(bomb, pev_owner, pev(ent, pev_owner))	
		Util_PlayAnimation(bomb,1,0.6)	//Play Anim
		
		new Float:velocity[3]
		velocity[0] = random_float(-random_float(cluster_rad_min,cluster_rad_max), random_float(cluster_rad_min,cluster_rad_max))	
		velocity[1] = random_float(-random_float(cluster_rad_min,cluster_rad_max), random_float(cluster_rad_min,cluster_rad_max))	
		velocity[2] = random_float(-random_float(cluster_rad_min,cluster_rad_max), random_float(cluster_rad_min,cluster_rad_max))+ random_float(cluster_up_min,cluster_up_max)
		
		
		set_pev(bomb, pev_velocity, velocity)
		
		new Float: Angles[3]
		Angles[1]=random_float(0.0,360.0)
		set_pev(bomb,pev_angles,Angles)
		
		Trail(bomb,g_Trail,4,4,255,155,55,255)
	}
	
	if( pev_valid( ent ) )
		engfunc(EngFunc_RemoveEntity, ent)
}

public Cluster_Explode(ent)
{
	if (!pev_valid( ent ) )
		return;
	
	new Float:ExpOrigin[3],victim = -1
	//new owner = pev( ent, pev_owner );
		
	if( is_day() && !get_running_day_pumpkin() )
		return;
	
	pev(ent, pev_origin, ExpOrigin)
	
	Ring(ExpOrigin,20,40)
	Ring(ExpOrigin,40,20)
	Light(ExpOrigin,15,250,150,50,15)
	
	//Explode
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, ExpOrigin, 0)
	write_byte(TE_EXPLOSION)
	engfunc(EngFunc_WriteCoord, ExpOrigin[0])
	engfunc(EngFunc_WriteCoord, ExpOrigin[1])
	engfunc(EngFunc_WriteCoord, ExpOrigin[2] + 15.0)
	write_short(spriteexpl)
	write_byte(5)
	write_byte(10)
	write_byte(0)
	message_end()
	
	while((victim = engfunc(EngFunc_FindEntityInSphere, victim, ExpOrigin, cluster_radius)) != 0)
	{
		if(victim>0&&pev(victim, pev_takedamage)!=DAMAGE_NO&&pev(victim, pev_solid)!=SOLID_NOT)
		{	
			if(is_user_connected(victim))
			{
					ExecuteHamB(Ham_TakeDamage, victim, ent, pev(ent,pev_owner),cluster_damage , DMG_NERVEGAS),
					ScreenFadeAndShake(victim)
			}
			else ExecuteHamB(Ham_TakeDamage, victim, ent, pev(ent,pev_owner),cluster_damage_ent , DMG_NERVEGAS)
		}
	}
	
	if( pev_valid( ent) )
		engfunc( EngFunc_RemoveEntity, ent )
	
}

//Stocks
stock Trail(ent,sprite,life,size,R,G,B,F)
{
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_BEAMFOLLOW)
		write_short(ent)
		write_short(sprite)
		write_byte(life)
		write_byte(size)
		write_byte(R)
		write_byte(G)
		write_byte(B)
		write_byte(F)
		message_end()
}
stock ExplodeDecals(Float:Origin[3])
{
	engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, Origin, 0)
	write_byte(TE_WORLDDECAL)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_byte(engfunc(EngFunc_DecalIndex,"{scorch3"))
	message_end()
}

stock Light(Float:Origin[3],RAD,R,G,B,Life)
{
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_DLIGHT)
	engfunc(EngFunc_WriteCoord, Origin[0])
	engfunc(EngFunc_WriteCoord, Origin[1])
	engfunc(EngFunc_WriteCoord, Origin[2])
	write_byte(RAD)	//Radius
	write_byte(R)	// r
	write_byte(G)	// g
	write_byte(B)	// b
	write_byte(Life)	//Life
	write_byte(10)
	message_end() 
}
stock Ring(Float:flOrigin[3],Size,width)
{
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flOrigin, 0)
	write_byte(TE_BEAMCYLINDER)			// TE id
	engfunc(EngFunc_WriteCoord, flOrigin[0])		// x
	engfunc(EngFunc_WriteCoord, flOrigin[1])		// y
	engfunc(EngFunc_WriteCoord, flOrigin[2]-20.0)		// z
	engfunc(EngFunc_WriteCoord, flOrigin[0])		// x axis
	engfunc(EngFunc_WriteCoord, flOrigin[1])		// y axis
	engfunc(EngFunc_WriteCoord, flOrigin[2] + Size)	// z axis
	write_short(g_sprRing) 	// sprite
	write_byte(0) 		// startframe
	write_byte(0) 		// framerate
	write_byte(10) 		// life
	write_byte(width) 	// width
	write_byte(0) 		// noise
	write_byte(255) 		// red
	write_byte(155) 		// green
	write_byte(55) 		// blue
	write_byte(255) 		// brightness
	write_byte(0) 		// speed
	message_end()
}
stock ScreenFadeAndShake(victim)
{
	// ScreenShake		
	message_begin(MSG_ONE_UNRELIABLE, Msg_ScreenShake, {0,0,0}, victim)
	write_short(1<<14)
	write_short((1<<12) * 8)
	write_short((2<<12) * 7)
	message_end()
			
	//ScreenFade
	message_begin(MSG_ONE_UNRELIABLE, Msg_ScreenFade, _, victim)
	write_short(6<<8)
	write_short(6<<10)
	write_short(1<<1)
	write_byte(255)
	write_byte(155)
	write_byte(55)
	write_byte(255)
	message_end()	
}
stock Util_PlayAnimation(index, sequence, Float: framerate = 1.0)
{
	  set_pev(index, pev_animtime, get_gametime())
	  set_pev(index, pev_framerate,  framerate)
	  set_pev(index, pev_frame, 0.0)
	  set_pev(index, pev_sequence, sequence)
}
As for the weird question marks I dont know why there are but everything is working fine with this plugin

Last edited by Apocalyman; 08-26-2023 at 08:07.
Apocalyman is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-26-2023 , 15:57   Re: How do I add a model to a grenade in this plugin?
Reply With Quote #4

Quote:
Originally Posted by Apocalyman View Post
Oh okay gotcha. This is the main plugin where it gives pumpkin:
That plugin sets the model to the pumpkin model, presumably when it's thrown. Is that happening? Or are you expecting something else?

Quote:
Originally Posted by Apocalyman View Post
As for the weird question marks I dont know why there are but everything is working fine with this plugin
That typically happens when there are non-ASCII characters and something converts them to question marks because it doesn't know what those characters are. When posting pull plugins like this (long), attach the .sma file. If the original characters are in the file, they'll stay there if you attach the file.
__________________
fysiks is offline
Apocalyman
Member
Join Date: Nov 2022
Old 08-26-2023 , 16:30   Re: How do I add a model to a grenade in this plugin?
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
That plugin sets the model to the pumpkin model, presumably when it's thrown. Is that happening? Or are you expecting something else?



That typically happens when there are non-ASCII characters and something converts them to question marks because it doesn't know what those characters are. When posting pull plugins like this (long), attach the .sma file. If the original characters are in the file, they'll stay there if you attach the file.
Oh okay I understand and i meant i want it to have the model when its being held
Apocalyman is offline
Apocalyman
Member
Join Date: Nov 2022
Old 08-27-2023 , 15:14   Re: How do I add a model to a grenade in this plugin?
Reply With Quote #6

Quote:
Originally Posted by Apocalyman View Post
Oh okay I understand and i meant i want it to have the model when its being held
UP
Apocalyman is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-27-2023 , 19:37   Re: How do I add a model to a grenade in this plugin?
Reply With Quote #7

FYI, it is against the rules to bump your posts. Unofficially, it's generally "OK" to bump your post after 2 weeks from the last post. Also, you can't practically expect everyone to have had a chance to read your post/thread within 24 hours, you need to wait.

Regarding the topic at hand, from what I can tell, the plugin is already replacing the models for others to see the pumpkin in your hand. Are you sure you have the correct models?
__________________
fysiks is offline
Apocalyman
Member
Join Date: Nov 2022
Old 08-27-2023 , 23:42   Re: How do I add a model to a grenade in this plugin?
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
FYI, it is against the rules to bump your posts. Unofficially, it's generally "OK" to bump your post after 2 weeks from the last post. Also, you can't practically expect everyone to have had a chance to read your post/thread within 24 hours, you need to wait.

Regarding the topic at hand, from what I can tell, the plugin is already replacing the models for others to see the pumpkin in your hand. Are you sure you have the correct models?
Thanks for the heads up about the bumping posts part, about the plugin, the short one does not use the model in your hand which I want it to (also the plugin just shows a different model for the grenade in your hand others see it as a grenade still which is fine) and the long does show you the model while holding it which is I what I want on the short code as well (long code is where the native is from too)
Apocalyman is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-28-2023 , 00:46   Re: How do I add a model to a grenade in this plugin?
Reply With Quote #9

The plugin that you posted in pose #1 uses (requires) the plugin you posted in post #3 so I'm not sure what you mean by wanting the function of the second one in the first one because it should already be there.

If your plugin runs at all then a version of the plugin in post #3 is running but you'll want to make sure you're running the version that you want.

It's still a bit confusing about what you're saying because the plugin in post #3 doesn't appear to do anything on its own so if it's not being called by some other plugin, it doesn't do anything.
__________________
fysiks is offline
Apocalyman
Member
Join Date: Nov 2022
Old 08-28-2023 , 16:42   Re: How do I add a model to a grenade in this plugin?
Reply With Quote #10

Quote:
Originally Posted by fysiks View Post
The plugin that you posted in pose #1 uses (requires) the plugin you posted in post #3 so I'm not sure what you mean by wanting the function of the second one in the first one because it should already be there.

If your plugin runs at all then a version of the plugin in post #3 is running but you'll want to make sure you're running the version that you want.

It's still a bit confusing about what you're saying because the plugin in post #3 doesn't appear to do anything on its own so if it's not being called by some other plugin, it doesn't do anything.
Let me sum it up again simply. The first plugin I sent is supposed to have a pumpkin model when being held (only for the player like the second plugin/code) but it doesnt for some reason. The second plugin I sent DOES the pumpkin model held for the player and I want the first plugin to have that like the second plugin. hope that clears it! (im only talking about all of the plugins that I sent here which I only sent 2)

Last edited by Apocalyman; 08-28-2023 at 16:42.
Apocalyman 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 07:28.


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