google-site-verification: googlebaca44933768a824.html Get Friend - Old Royal Hack Forum

Announcement

Collapse
No announcement yet.

Get Friend

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Get Friend

    So Im trying to tell whether a player is my friend or not, here is how im trying.

    Code:
    bool cPlayers::IsFriend(int index)
    {
              CSteamID steam;
    	  steam = g_pSteamFriends->GetFriendByIndex(g_pEngine->GetPlayerForUserID(index));
    			
              if ( g_pSteamFriends->HasFriend(steam))
    	        return true;
              return false;
    }
    However it says everyone is my friend, lol. Anyways, index is the player number in the esp drawing loop, maybe that is not what is to be passed through? Maybe GetFriendByIndex is the wrong way to get the infos?
    /* fibre */


    #2
    Mabye you are just very popular. Look at lawgivers friend system.

    Comment


      #3
      Originally posted by Scotsman View Post
      Mabye you are just very popular. Look at lawgivers friend system.
      link?

      Comment


        #4
        Originally posted by Scotsman View Post
        Mabye you are just very popular. Look at lawgivers friend system.
        Lol, the bots will never be my friends! Ok, Ill have a look for it somewhere.
        /* fibre */

        Comment


          #5
          Code:
          	// friend iteration
          	virtual int GetFriendCount() = 0;
          	virtual CSteamID GetFriendByIndex(int iFriend) = 0;
          These functions are used to iterate through friends. And int iFriend is not the player ID on the server but the ID the friend has on your Friendlist. =)


          PS: I would get the players steam ID and then use

          Code:
          // returns true if the specified user is considered a friend (can see our online status)
          	virtual bool HasFriend( CSteamID steamIDFriend ) = 0;
          Code:
          class CSteamID
          {
          public:
          
          	//-----------------------------------------------------------------------------
          	// Purpose: Constructor
          	//-----------------------------------------------------------------------------
          	CSteamID()
          	{
          		m_unAccountID = 0;
          		m_EAccountType = k_EAccountTypeInvalid;
          		m_EUniverse = k_EUniverseInvalid;
          		m_unAccountInstance = 0;
          	}
          
          
          	//-----------------------------------------------------------------------------
          	// Purpose: Constructor
          	// Input  : unAccountID -	32-bit account ID
          	//			eUniverse -		Universe this account belongs to
          	//			eAccountType -	Type of account
          	//-----------------------------------------------------------------------------
          	CSteamID( uint32 unAccountID, EUniverse eUniverse, EAccountType eAccountType )
          	{
          		Set( unAccountID, eUniverse, eAccountType );
          	}
          
          
          	//-----------------------------------------------------------------------------
          	// Purpose: Constructor
          	// Input  : unAccountID -	32-bit account ID
          	//			unAccountInstance - instance 
          	//			eUniverse -		Universe this account belongs to
          	//			eAccountType -	Type of account
          	//-----------------------------------------------------------------------------
          	CSteamID( uint32 unAccountID, unsigned int unAccountInstance, EUniverse eUniverse, EAccountType eAccountType )
          	{
          #if defined(_SERVER) && defined(Assert)
          		Assert( ! ( ( k_EAccountTypeIndividual == eAccountType ) && ( 1 != unAccountInstance ) ) );	// enforce that for individual accounts, instance is always 1
          #endif // _SERVER
          		InstancedSet( unAccountID, unAccountInstance, eUniverse, eAccountType );
          	}
          
          
          	//-----------------------------------------------------------------------------
          	// Purpose: Constructor
          	// Input  : ulSteamID -		64-bit representation of a Steam ID
          	// Note:	Will not accept a uint32 or int32 as input, as that is a probable mistake.
          	//			See the stubbed out overloads in the private: section for more info.
          	//-----------------------------------------------------------------------------
          	CSteamID( uint64 ulSteamID )
          	{
          		SetFromUint64( ulSteamID );
          	}
          
          
          	//-----------------------------------------------------------------------------
          	// Purpose: Sets parameters for steam ID
          	// Input  : unAccountID -	32-bit account ID
          	//			eUniverse -		Universe this account belongs to
          	//			eAccountType -	Type of account
          	//-----------------------------------------------------------------------------
          	void Set( uint32 unAccountID, EUniverse eUniverse, EAccountType eAccountType )
          	{
          		m_unAccountID = unAccountID;
          		m_EUniverse = eUniverse;
          		m_EAccountType = eAccountType;
          		m_unAccountInstance = 1;
          	}
          
          
          	//-----------------------------------------------------------------------------
          	// Purpose: Sets parameters for steam ID
          	// Input  : unAccountID -	32-bit account ID
          	//			eUniverse -		Universe this account belongs to
          	//			eAccountType -	Type of account
          	//-----------------------------------------------------------------------------
          	void InstancedSet( uint32 unAccountID, uint32 unInstance, EUniverse eUniverse, EAccountType eAccountType )
          	{
          		m_unAccountID = unAccountID;
          		m_EUniverse = eUniverse;
          		m_EAccountType = eAccountType;
          		m_unAccountInstance = unInstance;
          	}
          
          
          	//-----------------------------------------------------------------------------
          	// Purpose: Initializes a steam ID from its 52 bit parts and universe/type
          	// Input  : ulIdentifier - 52 bits of goodness
          	//-----------------------------------------------------------------------------
          	void FullSet( uint64 ulIdentifier, EUniverse eUniverse, EAccountType eAccountType )
          	{
          		m_unAccountID = ( ulIdentifier & 0xFFFFFFFF );						// account ID is low 32 bits
          		m_unAccountInstance = ( ( ulIdentifier >> 32 ) & 0xFFFFF );			// account instance is next 20 bits
          		m_EUniverse = eUniverse;
          		m_EAccountType = eAccountType;
          	}
          
          
          	//-----------------------------------------------------------------------------
          	// Purpose: Initializes a steam ID from its 64-bit representation
          	// Input  : ulSteamID -		64-bit representation of a Steam ID
          	//-----------------------------------------------------------------------------
          	void SetFromUint64( uint64 ulSteamID )
          	{
          		m_unAccountID = ( ulSteamID & 0xFFFFFFFF );							// account ID is low 32 bits
          		m_unAccountInstance = ( ( ulSteamID >> 32 ) & 0xFFFFF );			// account instance is next 20 bits
          
          		m_EAccountType = ( EAccountType ) ( ( ulSteamID >> 52 ) & 0xF );	// type is next 4 bits
          		m_EUniverse = ( EUniverse ) ( ( ulSteamID >> 56 ) & 0xFF );			// universe is next 8 bits
          	}
          
          
          #if defined( INCLUDED_STEAM_COMMON_STEAMCOMMON_H ) 
          	//-----------------------------------------------------------------------------
          	// Purpose: Initializes a steam ID from a Steam2 ID structure
          	// Input:	pTSteamGlobalUserID -	Steam2 ID to convert
          	//			eUniverse -				universe this ID belongs to
          	//-----------------------------------------------------------------------------
          	void SetFromSteam2( TSteamGlobalUserID *pTSteamGlobalUserID, EUniverse eUniverse )
          	{
          		m_unAccountID = pTSteamGlobalUserID->m_SteamLocalUserID.Split.Low32bits * 2 + 
          			pTSteamGlobalUserID->m_SteamLocalUserID.Split.High32bits;
          		m_EUniverse = eUniverse;		// set the universe
          		m_EAccountType = k_EAccountTypeIndividual; // Steam 2 accounts always map to account type of individual
          		m_unAccountInstance = 1;	// individual accounts always have an account instance ID of 1
          	}
          
          	//-----------------------------------------------------------------------------
          	// Purpose: Fills out a Steam2 ID structure
          	// Input:	pTSteamGlobalUserID -	Steam2 ID to write to
          	//-----------------------------------------------------------------------------
          	void ConvertToSteam2( TSteamGlobalUserID *pTSteamGlobalUserID ) const
          	{
          		// only individual accounts have any meaning in Steam 2, only they can be mapped
          		// Assert( m_EAccountType == k_EAccountTypeIndividual );
          
          		pTSteamGlobalUserID->m_SteamInstanceID = 0;
          		pTSteamGlobalUserID->m_SteamLocalUserID.Split.High32bits = m_unAccountID % 2;
          		pTSteamGlobalUserID->m_SteamLocalUserID.Split.Low32bits = m_unAccountID / 2;
          	}
          #endif // defined( INCLUDED_STEAM_COMMON_STEAMCOMMON_H )
          
          	//-----------------------------------------------------------------------------
          	// Purpose: Converts steam ID to its 64-bit representation
          	// Output : 64-bit representation of a Steam ID
          	//-----------------------------------------------------------------------------
          	uint64 ConvertToUint64() const
          	{
          		return (uint64) ( ( ( (uint64) m_EUniverse ) << 56 ) + ( ( (uint64) m_EAccountType ) << 52 ) + 
          			( ( (uint64) m_unAccountInstance ) << 32 ) + m_unAccountID );
          	}
          
          
          	//-----------------------------------------------------------------------------
          	// Purpose: Converts the static parts of a steam ID to a 64-bit representation.
          	//			For multiseat accounts, all instances of that account will have the
          	//			same static account key, so they can be grouped together by the static
          	//			account key.
          	// Output : 64-bit static account key
          	//-----------------------------------------------------------------------------
          	uint64 GetStaticAccountKey() const
          	{
          		// note we do NOT include the account instance (which is a dynamic property) in the static account key
          		return (uint64) ( ( ( (uint64) m_EUniverse ) << 56 ) + ((uint64) m_EAccountType << 52 ) + m_unAccountID );
          	}
          
          
          	//-----------------------------------------------------------------------------
          	// Purpose: create an anonomous game server login to be filled in by the AM
          	//-----------------------------------------------------------------------------
          	void CreateBlankAnonLogon( EUniverse eUniverse )
          	{
          		m_unAccountID = 0;
          		m_EAccountType = k_EAccountTypeAnonGameServer;
          		m_EUniverse = eUniverse;
          		m_unAccountInstance = 0;
          	}
          
          	//-----------------------------------------------------------------------------
          	// Purpose: Is this an anonomous game server login that will be filled in?
          	//-----------------------------------------------------------------------------
          	bool BBlankAnonAccount() const
          	{
          		return m_unAccountID == 0 && 
          			m_EAccountType == k_EAccountTypeAnonGameServer &&
          			m_unAccountInstance == 0;
          	}
          
          	//-----------------------------------------------------------------------------
          	// Purpose: Is this a game server account id?
          	//-----------------------------------------------------------------------------
          	bool BGameServerAccount() const
          	{
          		return m_EAccountType == k_EAccountTypeGameServer || m_EAccountType == k_EAccountTypeAnonGameServer;
          	}
          
          	// simple accessors
          	void SetAccountID( uint32 unAccountID )		{ m_unAccountID = unAccountID; }
          	uint32 GetAccountID() const					{ return m_unAccountID; }
          	uint32 GetUnAccountInstance() const			{ return m_unAccountInstance; }
          	EAccountType GetEAccountType() const		{ return m_EAccountType; }
          	EUniverse GetEUniverse() const				{ return m_EUniverse; }
          	void SetEUniverse( EUniverse eUniverse )	{ m_EUniverse = eUniverse; }
          	bool IsValid() const						{ return !( m_EAccountType == k_EAccountTypeInvalid ); }
          
          	// this set of functions is hidden, will be moved out of class
          	CSteamID( const char *pchSteamID, EUniverse eDefaultUniverse = k_EUniverseInvalid );
          	char * Render() const;				// renders this steam ID to string
          	static char * Render( uint64 ulSteamID );	// static method to render a uint64 representation of a steam ID to a string
          
          	void SetFromString( const char *pchSteamID, EUniverse eDefaultUniverse );
          	bool SetFromSteam2String( const char *pchSteam2ID, EUniverse eUniverse );
          
          	bool operator==( const CSteamID &val ) const { return ( ( val.m_unAccountID == m_unAccountID ) && ( val.m_unAccountInstance == m_unAccountInstance )
          													&& ( val.m_EAccountType == m_EAccountType ) &&  ( val.m_EUniverse == m_EUniverse ) ); } 
          	bool operator!=( const CSteamID &val ) const { return !operator==( val ); }
          
          	// DEBUG function
          	bool BValidExternalSteamID() const;
          
          	// These are defined here to prevent accidental implicit conversion of a u32AccountID to a CSteamID.
          	// If you get a compiler error about an ambiguous constructor/function then it may be because you're
          	// passing a 32-bit int to a function that takes a CSteamID. You should explicitly create the SteamID
          	// using the correct Universe and account Type/Instance values.
          	CSteamID( uint32 );
          	CSteamID( int32 );
          
          	// 64 bits total
          	uint32				m_unAccountID : 32;			// unique account identifier
          	unsigned int		m_unAccountInstance : 20;	// dynamic instance ID (used for multiseat type accounts only)
          	EAccountType		m_EAccountType : 4;			// type of account
          	EUniverse			m_EUniverse : 8;			// universe this account belongs to
          };


          Or go the other way, iterate to your friends, get steam ID's in a std::vector or something and then compare with the players steam ids on the server =)
          Last edited by Lawgiver; 07-22-2009, 11:34 AM.

          Comment

          Working...
          X