本文整理汇总了C++中CAccount::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ CAccount::GetName方法的具体用法?C++ CAccount::GetName怎么用?C++ CAccount::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAccount
的用法示例。
在下文中一共展示了CAccount::GetName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetActiveCaseVariation
// Return the name of an account which already exists, and is using the same name with one or more letters in a different case
SString CAccountManager::GetActiveCaseVariation ( const SString& strName )
{
// Check for exact match already existing
if ( Get( strName ) )
return "";
std::vector < CAccount* > results;
// Case insensitive search to find all variations
m_List.FindAccountMatches ( &results, strName, false );
for ( uint i = 0 ; i < results.size () ; i++ )
{
CAccount* pAccount = results[i];
if ( pAccount->IsRegistered () && pAccount->GetName () != strName )
{
return pAccount->GetName ();
}
}
return "";
}
示例2: LogOut
bool CAccountManager::LogOut ( CClient* pClient, CClient* pEchoClient )
{
// Is he logged in?
if ( !pClient->IsRegistered () )
{
if ( pEchoClient )
pEchoClient->SendEcho ( "logout: You were not logged in" );
return false;
}
if ( pClient->GetClientType () != CClient::CLIENT_PLAYER )
{
if ( pEchoClient )
pEchoClient->SendEcho ( "logout: Only players can log out" );
return false;
}
CPlayer* pPlayer = static_cast < CPlayer* > ( pClient );
CAccount* pCurrentAccount = pClient->GetAccount ();
pCurrentAccount->SetClient ( NULL );
CAccount* pAccount = g_pGame->GetAccountManager ()->AddGuestAccount( GUEST_ACCOUNT_NAME );
pClient->SetAccount ( pAccount );
// Call our script event
CLuaArguments Arguments;
Arguments.PushAccount ( pCurrentAccount );
Arguments.PushAccount ( pAccount );
if ( !pPlayer->CallEvent ( "onPlayerLogout", Arguments ) )
{
// DENIED!
pClient->SetAccount ( pCurrentAccount );
pCurrentAccount->SetClient ( pClient );
delete pAccount;
return false;
}
// Tell the console
CLogger::AuthPrintf ( "LOGOUT: %s logged out as '%s'\n", pClient->GetNick (), pCurrentAccount->GetName ().c_str () );
// Tell the player
if ( pEchoClient )
pEchoClient->SendEcho ( "logout: You logged out" );
return true;
}
示例3: GetAccountName
int CLuaFunctionDefs::GetAccountName ( lua_State* luaVM )
{
// string getAccountName ( account theAccount )
CAccount* pAccount;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pAccount );
if ( !argStream.HasErrors () )
{
std::string strName = pAccount->GetName ();
if ( !strName.empty () )
{
lua_pushstring ( luaVM, strName.c_str () );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例4: Player_OnVerb
bool CChar::Player_OnVerb( CScript &s, CTextConsole * pSrc ) // Execute command from script
{
ADDTOCALLSTACK("CChar::Player_OnVerb");
if ( !m_pPlayer )
return false;
LPCTSTR pszKey = s.GetKey();
int cpVerb = FindTableSorted( pszKey, CCharPlayer::sm_szVerbKeys, COUNTOF(CCharPlayer::sm_szVerbKeys)-1 );
if ( cpVerb <= -1 )
{
if ( ( !strnicmp(pszKey, "GUILD", 5) ) || ( !strnicmp(pszKey, "TOWN", 4) ) )
{
bool bIsGuild = !strnicmp(pszKey, "GUILD", 5);
pszKey += bIsGuild ? 5 : 4;
if ( *pszKey == '.' )
{
pszKey += 1;
CItemStone *pMyGuild = Guild_Find(bIsGuild ? MEMORY_GUILD : MEMORY_TOWN);
if ( pMyGuild )
{
CScript sToParse(pszKey, s.GetArgRaw());
return pMyGuild->r_Verb(sToParse, pSrc);
}
}
return false;
}
}
switch ( cpVerb )
{
case CPV_KICK: // "KICK" = kick and block the account
return (IsClient() && GetClient()->addKick(pSrc));
case CPV_PASSWORD: // "PASSWORD"
{
// Set/Clear the password
if ( pSrc != this )
{
if ( pSrc->GetPrivLevel() <= GetPrivLevel() || pSrc->GetPrivLevel() < PLEVEL_Admin )
{
pSrc->SysMessage(g_Cfg.GetDefaultMsg(DEFMSG_MSG_ACC_PRIV));
return false;
}
}
CAccount * pAccount = m_pPlayer->GetAccount();
ASSERT(pAccount != NULL);
if ( !s.HasArgs() )
{
pAccount->ClearPassword();
SysMessage(g_Cfg.GetDefaultMsg(DEFMSG_MSG_ACC_PASSCLEAR));
SysMessage(g_Cfg.GetDefaultMsg(DEFMSG_MSG_ACC_PASSCLEAR_RELOG));
g_Log.Event(LOGM_ACCOUNTS|LOGL_EVENT, "Account '%s', password cleared\n", pAccount->GetName());
}
else
{
if ( pAccount->SetPassword(s.GetArgStr()) )
{
SysMessage(g_Cfg.GetDefaultMsg(DEFMSG_MSG_ACC_ACCEPTPASS));
g_Log.Event(LOGM_ACCOUNTS|LOGL_EVENT, "Account '%s', password set to '%s'\n", pAccount->GetName(), s.GetArgStr());
return true;
}
SysMessage(g_Cfg.GetDefaultMsg(DEFMSG_MSG_ACC_INVALIDPASS));
}
break;
}
default:
return false;
}
return true;
}
示例5: LogIn
bool CAccountManager::LogIn ( CClient* pClient, CClient* pEchoClient, const char* szAccountName, const char* szPassword )
{
// Is he already logged in?
if ( pClient->IsRegistered () )
{
if ( pEchoClient ) pEchoClient->SendEcho ( "login: You are already logged in" );
return false;
}
if ( pClient->GetClientType () != CClient::CLIENT_PLAYER )
{
if ( pEchoClient ) pEchoClient->SendEcho ( "login: Only players can log in" );
return false;
}
// Get the players details
CPlayer* pPlayer = static_cast < CPlayer* > ( pClient );
SString strPlayerName = pPlayer->GetNick ();
SString strPlayerIP = pPlayer->GetSourceIP ();
SString strPlayerSerial = pPlayer->GetSerial ();
if ( m_AccountProtect.IsFlooding ( strPlayerIP.c_str () ) )
{
if ( pEchoClient ) pEchoClient->SendEcho ( SString( "login: Account locked", szAccountName ).c_str() );
CLogger::AuthPrintf ( "LOGIN: Ignoring %s trying to log in as '%s' (IP: %s Serial: %s)\n", strPlayerName.c_str (), szAccountName, strPlayerIP.c_str (), strPlayerSerial.c_str () );
return false;
}
// Grab the account on his nick if any
CAccount* pAccount = g_pGame->GetAccountManager ()->Get ( szAccountName );
if ( !pAccount )
{
if ( pEchoClient ) pEchoClient->SendEcho( SString( "login: No known account for '%s'", szAccountName ).c_str() );
CLogger::AuthPrintf ( "LOGIN: %s tried to log in as '%s' (Unknown account) (IP: %s Serial: %s)\n", strPlayerName.c_str (), szAccountName, strPlayerIP.c_str (), strPlayerSerial.c_str () );
return false;
}
if ( pAccount->GetClient () )
{
if ( pEchoClient ) pEchoClient->SendEcho ( SString( "login: Account for '%s' is already in use", szAccountName ).c_str() );
return false;
}
if ( !IsValidPassword( szPassword ) || !pAccount->IsPassword ( szPassword ) )
{
if ( pEchoClient ) pEchoClient->SendEcho ( SString( "login: Invalid password for account '%s'", szAccountName ).c_str() );
CLogger::AuthPrintf ( "LOGIN: %s tried to log in as '%s' with an invalid password (IP: %s Serial: %s)\n", strPlayerName.c_str (), szAccountName, strPlayerIP.c_str (), strPlayerSerial.c_str () );
m_AccountProtect.AddConnect ( strPlayerIP.c_str () );
return false;
}
// Check serial authorization
if ( IsAuthorizedSerialRequired( pAccount ) )
{
pAccount->AddSerialForAuthorization( strPlayerSerial, strPlayerIP );
if ( !pAccount->IsSerialAuthorized( strPlayerSerial ) )
{
if ( pEchoClient )
pEchoClient->SendEcho( SString( "login: Serial pending authorization for account '%s' - See https:""//mtasa.com/authserial", szAccountName ) );
CLogger::AuthPrintf( "LOGIN: %s tried to log in as '%s' with an unauthorized serial (IP: %s Serial: %s)\n", *strPlayerName, szAccountName, *strPlayerIP, *strPlayerSerial );
CLogger::AuthPrintf( "LOGIN: See https:""//mtasa.com/authserial\n" );
return false;
}
}
// Log him in
CAccount* pCurrentAccount = pClient->GetAccount ();
pClient->SetAccount ( pAccount );
pAccount->SetClient ( pClient );
// Call the onPlayerLogin script event
CLuaArguments Arguments;
Arguments.PushAccount ( pCurrentAccount );
Arguments.PushAccount ( pAccount );
Arguments.PushBoolean ( false ); // was bAutoLogin
if ( !pPlayer->CallEvent ( "onPlayerLogin", Arguments ) )
{
// DENIED!
pClient->SetAccount ( pCurrentAccount );
pAccount->SetClient ( NULL );
return false;
}
// Success is here
pAccount->OnLoginSuccess ( strPlayerSerial, strPlayerIP );
SString strGroupList = SString::Join ( ", ", g_pGame->GetACLManager ()->GetObjectGroupNames ( pAccount->GetName (), CAccessControlListGroupObject::OBJECT_TYPE_USER ) );
CLogger::AuthPrintf ( "LOGIN: (%s) %s successfully logged in as '%s' (IP: %s Serial: %s)\n", strGroupList.c_str (), pClient->GetNick (), pAccount->GetName ().c_str (), strPlayerIP.c_str (), strPlayerSerial.c_str () );
// Tell the player
if ( pEchoClient )
{
pEchoClient->SendEcho ( "login: You successfully logged in" );
}
// Update who was info
if ( pClient->GetClientType () == CClient::CLIENT_PLAYER )
g_pGame->GetConsole ()->GetWhoWas ()->OnPlayerLogin ( static_cast < CPlayer* > ( pClient ) );
// Delete the old account if it was a guest account
if ( !pCurrentAccount->IsRegistered () )
//.........这里部分代码省略.........
示例6: hasObjectPermissionTo
int CLuaACLDefs::hasObjectPermissionTo ( lua_State* luaVM )
{
// bool hasObjectPermissionTo ( string / element theObject, string theAction [, bool defaultPermission = true ] )
CResource* pResource = NULL; CElement* pElement = NULL; SString strObject; SString strRightName; bool bDefault; CAccessControlListGroupObject::EObjectType eObjectType;
CScriptArgReader argStream ( luaVM );
if ( argStream.NextIsUserDataOfType < CResource > () )
argStream.ReadUserData ( pResource );
else
if ( argStream.NextIsUserDataOfType < CElement > () )
argStream.ReadUserData ( pElement );
else
argStream.ReadString ( strObject );
argStream.ReadString ( strRightName );
argStream.ReadBool ( bDefault, true );
if ( !argStream.HasErrors () )
{
if ( pResource )
{
// Grab the resource's name
strObject = pResource->GetName ();
eObjectType = CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE;
}
else if ( pElement )
{
// Grab the client this player/console/whatever is
CClient* pClient = pElement->GetClient ();
if ( pClient )
{
// Get his account
CAccount* pAccount = pClient->GetAccount ();
if ( pAccount )
{
// Grab the username
strObject = pAccount->GetName ();
eObjectType = CAccessControlListGroupObject::OBJECT_TYPE_USER;
}
}
}
else
{
// Extract the object name itself including the type
const char * szName = CAccessControlListManager::ExtractObjectName ( strObject.c_str (), eObjectType );
strObject = szName ? szName : "";
}
// Got a string?
if ( !strObject.empty () )
{
// Extract the right name itself including the type
CAccessControlListRight::ERightType eRightType;
strRightName = CAccessControlListManager::ExtractRightName ( strRightName, eRightType );
// Did we get a right name without the prefix?
if ( strRightName )
{
bool bHasPermission = m_pACLManager->CanObjectUseRight ( strObject, eObjectType, strRightName, eRightType, bDefault );
// Return whether we had access or not
lua_pushboolean ( luaVM, bHasPermission );
return 1;
}
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
// Failed
lua_pushnil ( luaVM );
return 1;
}
示例7: LogOut
bool CAccountManager::LogOut ( CClient* pClient, CClient* pEchoClient )
{
// Is he logged in?
if ( !pClient->IsRegistered () )
{
if ( pEchoClient )
pEchoClient->SendEcho ( "logout: You were not logged in" );
return false;
}
if ( pClient->GetClientType () == CClient::CLIENT_CONSOLE )
{
if ( pEchoClient )
pEchoClient->SendEcho ( "logout: Console may not log out" );
return false;
}
CAccount* pCurrentAccount = pClient->GetAccount ();
pCurrentAccount->SetClient ( NULL );
CAccount* pAccount = new CAccount ( g_pGame->GetAccountManager (), false, GUEST_ACCOUNT_NAME );
pClient->SetAccount ( pAccount );
// Call the onClientLogout event
CElement* pClientElement = NULL;
switch ( pClient->GetClientType () )
{
case CClient::CLIENT_PLAYER:
{
CPlayer* pPlayer = static_cast < CPlayer* > ( pClient );
pClientElement = static_cast < CElement* > ( pPlayer );
break;
}
case CClient::CLIENT_CONSOLE:
{
CConsoleClient* pConsoleClient = static_cast < CConsoleClient* > ( pClient );
pClientElement = static_cast < CElement* > ( pConsoleClient );
break;
}
}
if ( pClientElement )
{
// Call our script event
CLuaArguments Arguments;
Arguments.PushAccount ( pCurrentAccount );
Arguments.PushAccount ( pAccount );
if ( !pClientElement->CallEvent ( "onPlayerLogout", Arguments ) )
{
// DENIED!
pClient->SetAccount ( pCurrentAccount );
pCurrentAccount->SetClient ( pClient );
delete pAccount;
return false;
}
}
// Tell the console
CLogger::AuthPrintf ( "LOGOUT: %s logged out as '%s'\n", pClient->GetNick (), pCurrentAccount->GetName ().c_str () );
// Tell the player
if ( pEchoClient )
pEchoClient->SendEcho ( "logout: You logged out" );
return true;
}