Reputation: 11
Hi All So I was Studying Steam API, And Now I want to Get The Steam id And User name Using Steam API (64bit) First I've read this on Steam Website: https://partner.steamgames.com/doc/api/ISteamFriends#GetPersonaName And Then it Didn't Work So I Searched More And Then Found This: Steam API getting persona name this didn't work again and has a compile error: E0140 too many arguments in function call. Then I found this: How to retrieve Steam username using SteamWorks API? even this didn't work again and when I run my project Visual Studio Says:The Visual Studio Error in Runtime So now I don't know What to do Please Help Me
CSteamID id = SteamUser()->GetSteamID();
const char* pchName = SteamFriends()->GetPersonaName(id);
std::cout << SteamFriends()->GetPersonaName();
std::cout << pchName;
Upvotes: 1
Views: 3264
Reputation: 86
Unfortunately I am not using Visual Studio ... But this C++ code works great in both Linux and Windows:
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <chrono>
#include <thread>
#include <fstream>
#include <steam_api.h>
void close_steam() {
SteamAPI_Shutdown();
}
void program() {
if (!SteamAPI_Init() ) {
std::cerr << "Steam's API could not be initialized!\n";
std::cerr << "Ensure that Steam is running on the same user account...\n";
std::exit(1);
}
atexit(close_steam);
}
int main() {
program();
const char* pchName = SteamFriends()->GetPersonaName();
std::cout << pchName;
}
Upvotes: 0
Reputation: 86
Use GetPersonaName() call without parameter 'id'.
const char* pchName = SteamFriends()->GetPersonaName();
Upvotes: 0