View Single Post
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 11-03-2013 , 18:03   Re: Custom Start Guns ( Updated 17/10/2013 )
Reply With Quote #26

Code:
public CBase_PlayerPre_Spawn( id ) 
{
	if( !get_pcvar_num( g_iSpawnMode ) || !is_user_connected( id ) )
		return HAM_HANDLED;
Connected check should come first. So if it is a player joining ( Spawn() called on connect ) then your not checking the cvar for no reason.

Also here:

Code:
public CBase_PlayerPost_Spawn( id ) 
{
	if( !get_pcvar_num( g_iSpawnMode ) )
		return HAM_HANDLED;
	
	if( g_bDiedLastRound[ id ] ) 
	{ 
		if( is_user_alive( id ) )
			GiveStartWeapons( id, cs_get_user_team( id ), get_pcvar_num( g_iSpawnMode ) );
Alive check should come before all others, again so your not checking the cvar and bool if its just a player joining.

Other thing I would recommend is caching the cvar once per round at start, since it will only have an effect once per round.

Also your code hurts my eyes a bit - perhaps you should consider using a bit of spacing between lines where necessary
hornet is offline