FriendsManager
Jump to navigation
Jump to search
IFriendsManager.h
///////////// Copyright © 2006, Scott Loyd. All rights reserved. /////////////
//
// File: IFriendsManager.h
// Description:
// For use with CLIENT SIDE ONLY.
// Provides an interface for working with friends data.
//
// Created On: 7/1/06 9:28 PM
// Created By: Scott Loyd <mailto:scottloyd@gmail.com>
/////////////////////////////////////////////////////////////////////////////
#ifndef IFRIENDSMANAGER_H
#define IFRIENDSMANAGER_H
class IFriendsManager
{
public:
//Optional: Sets the Tracker ID of the local player.
virtual void SetTrackerID(unsigned int iTrackerID) = 0;
//Returns true if iFriendTrackerID is in iMyTrackerIDs buddy list.
//iFriendTrackerID - Tracker ID of a friend to search for
//iMyTrackerID - Tracker ID of the local player (if 0, it uses value from SetTrackerID)
virtual bool IsFriend(unsigned int iFriendTrackerID, unsigned int iMyTrackerID = 0) = 0;
//Returns string of most recently used buddy name that friends has. It returns NULL if
// no one was found using that TrackerID.
//iTrackerID - ID of a buddy to lookup
//iMyTrackerID - Tracker ID of the local player (if 0, it uses value from SetTrackerID)
virtual const char *BuddyName(unsigned int iTrackerID, unsigned int iMyTrackerID = 0) = 0;
};
//Accessor
IFriendsManager *FriendsManager();
/*
//TODO: You need to set this next chunk up in your code!
//Used to get the TrackerID that can be compared in friends.
unsigned int C_PlayerResource::GetFriendsID( int iIndex )
{
if ( !IsConnected( iIndex ) )
return 0;
player_info_t sPlayerInfo;
if ( engine->GetPlayerInfo( iIndex, &sPlayerInfo ) )
return sPlayerInfo.friendsID;
return 0;
}
//Example Usage (ge_scoreboard.cpp)
void CGEScoreBoard::InitScoreboardSections()
{
[snip]
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
if ( pPlayer )
FriendsManager()->SetTrackerID(g_PR->GetFriendsID(pPlayer->entindex()));
[snip]
}
bool CGEScoreBoard::GetPlayerScoreInfo(int playerIndex, KeyValues *kv)
{
[snip]
unsigned int trackerID = g_PR->GetFriendsID(playerIndex);
//Now that we have a trackerID, is this guy on the local players buddy list?
// Also if trackerID is the local players trackerID, it will return false.
if(FriendsManager()->IsFriend(trackerID))
kv->SetInt("tracker",TrackerImage); //You should find some more code for this in
// CClientScoreBoardDialog
[snip]
}
*/
#endif //IFRIENDSMANAGER_H