Jump to content
  • 0

Costumes and Discord RPC


peakzinho

Question

Hello, I would like to know if there are any solutions for what I need.

1st question: if I am using a one-handed weapon disguise and want to use a two-handed weapon, when changing the weapon the disguise is automatically dismantled.


2nd question: I can't even put the level of the players in my rpc discord system, someone can help?. Please give me a tutorial.

Link to post

7 answers to this question

Recommended Posts

  • 0
  • VIP

Regarding the discord RPC,  you could try something like this:

 

#include "InstanceBase.h"
#include "PythonCharacterManager.h"
  
CInstanceBase* pkMainInstance = CPythonCharacterManager::Instance().GetMainInstancePtr();
char info[32 + 1];
snprintf(info, sizeof(info), "Level: %u", pkMainInstance->GetLevel());
activity.SetDetails(info);

/*
You can get other player's informations such as player name, empire id, duel state, alignment, race, etc using the same object 'pkMainInstance', you can get a list of these functions from InstanceBase.h.
*/
 

 

 

252709OrangeWarning.png'activity' is an object of type 'discord::Activity', you should adapt it to your source.

 

 

Edited by Finnis
Info

r

Link to post
  • 0
12 hours ago, Finnis said:

Regarding the discord RPC,  you could try something like this:

 

#include "InstanceBase.h"
#include "PythonCharacterManager.h"
  
CInstanceBase* pkMainInstance = CPythonCharacterManager::Instance().GetMainInstancePtr();
char info[32 + 1];
snprintf(info, sizeof(info), "Level: %u", pkMainInstance->GetLevel());
activity.SetDetails(info);

/*
You can get other player's informations such as player name, empire id, duel state, alignment, race, etc using the same object 'pkMainInstance', you can get a list of these functions from InstanceBase.h.
*/
 

 

 

252709OrangeWarning.png'activity' is an object of type 'discord::Activity', you should adapt it to your source.

 

 

#ifdef ENABLE_DISCORD_RPC
#include "discord_rpc.h"
#ifdef _DEBUG
#pragma comment(lib, "discord_rpc_d.lib")
#else
#pragma comment(lib, "discord_rpc_r.lib")
#endif
static int64_t StartTime;
static constexpr auto DiscordClientID = "758991963747516459";
auto szSiteName = "Website: <Em Construção>";
auto szIconName = "image1";
void CPythonNetworkStream::Discord_Start()
{
    StartTime = time(0);
    DiscordEventHandlers handlers;
    memset(&handlers, 0, sizeof(handlers));
    Discord_Initialize(DiscordClientID, &handlers, 1, nullptr);
    Discord_Update(true, false, false);
}
void CPythonNetworkStream::Discord_Update(const bool login, const bool select, const bool loading)
{
    DiscordRichPresence discordPresence;
    memset(&discordPresence, 0, sizeof(discordPresence));
    char szBufName[256+1];
    char szBufWarp[256+1];
    char szEmpireId[256+1];
    char szEmpireName[256+1];
    char szRaceName[256+1];
    CInstanceBase* pInstance = CPythonCharacterManager::Instance().GetMainInstancePtr();
    
    if (login)
    {
        discordPresence.details = "On Login";
        discordPresence.state = szSiteName;
        discordPresence.largeImageKey = szIconName;
        discordPresence.largeImageText = szSiteName;
    }
    else if (select)
    {
        discordPresence.details = "On Select";
        discordPresence.state = szSiteName;
        discordPresence.largeImageKey = szIconName;
        discordPresence.largeImageText = szSiteName;
    }
    else if (loading)
    {
        discordPresence.details = "On Loading";
        discordPresence.state = szSiteName;
        discordPresence.largeImageKey = szIconName;
        discordPresence.largeImageText = szSiteName;
    }
    else
    {
        std::string GuildName;
        DWORD GuildID = CPythonPlayer::Instance().GetGuildID();
        CPythonGuild::Instance().GetGuildName(GuildID, &GuildName);
        
        if (GuildID != 0)
            _snprintf(szBufName, sizeof(szBufName), "Name: %s - Guild: %s", CPythonPlayer::Instance().GetName(), &GuildName);
        else
            _snprintf(szBufName, sizeof(szBufName), "Name: %s", CPythonPlayer::Instance().GetName());
        
        _snprintf(szBufWarp, sizeof(szBufWarp), "Location: %s", CPythonBackground::Instance().GetMapName());
        _snprintf(szEmpireId, sizeof(szEmpireId), "%s", GetEmpireIcon());
        _snprintf(szEmpireName, sizeof(szEmpireName), "Empire: %s", GetEmpireName());
        _snprintf(szRaceName, sizeof(szRaceName), "Race: %s", GetRaceName());
        std::string szName = pInstance->GetNameString();
        
        if (pInstance->IsGameMaster())
        {
            discordPresence.details = GetStaffRank();
            discordPresence.state = szBufName;
        }
        else if (szName.find("[VET]") != std::string::npos)
        {
            discordPresence.details = "Rank: Veteran";
            discordPresence.state = szBufName;
        }
        else if (szName.find("[GFX]") != std::string::npos)
        {
            discordPresence.details = "Rank: Graphic Designer";
            discordPresence.state = szBufName;
        }
        else if (szName.find("[PM]") != std::string::npos)
        {
            discordPresence.details = "Rank: Promoter";
            discordPresence.state = szBufName;
        }
        else
        {
            discordPresence.details = szBufName;
            discordPresence.state = szBufWarp;
        }
        
        discordPresence.largeImageKey = GetRaceIcon();
        discordPresence.largeImageText = szRaceName;
        discordPresence.smallImageKey = GetEmpireIcon();
        discordPresence.smallImageText = szEmpireName;
    }
    
    discordPresence.startTimestamp = StartTime;
    Discord_UpdatePresence(&discordPresence);
}
void CPythonNetworkStream::Discord_Close()
{
    Discord_Shutdown();
}

const char * CPythonNetworkStream::GetStaffRank()
{
    CInstanceBase* pInstance = CPythonCharacterManager::Instance().GetMainInstancePtr();
    std::string szName = pInstance->GetNameString();
    
    if (szName.find("[SA]") != std::string::npos)
        return "Rank: Server Admin";
    else if (szName.find("[TM]") != std::string::npos)
        return "Rank: Team Manager";
    else if (szName.find("[GA]") != std::string::npos)
        return "Rank: Game Admin";
    else if (szName.find("[GM]") != std::string::npos)
        return "Rank: Game Master";
    else if (szName.find("[H]") != std::string::npos)
        return "Rank: Helper";
    else if (szName.find("[MID]") != std::string::npos)
        return "Rank: Middleman";
    else
        return szSiteName;
}

const char * CPythonNetworkStream::GetRaceIcon()
{
    CInstanceBase* pInstance = CPythonCharacterManager::Instance().GetMainInstancePtr();
    int raceId = pInstance->GetRace();
    
    if (raceId == 0)
        return "warrior_m";
    else if (raceId == 1)
        return "ninja_w";
    else if (raceId == 2)
        return "sura_m";
    else if (raceId == 3)
        return "shaman_w";
    else if (raceId == 4)
        return "warrior_w";
    else if (raceId == 5)
        return "ninja_m";
    else if (raceId == 6)
        return "sura_w";
    else if (raceId == 7)
        return "shaman_m";
    else
        return szIconName;
}

const char * CPythonNetworkStream::GetRaceName()
{
    CInstanceBase* pInstance = CPythonCharacterManager::Instance().GetMainInstancePtr();
    int raceId = pInstance->GetRace();
    
    if (raceId == 0 || raceId == 4)
        return "Warrior";
    else if (raceId == 1 || raceId == 5)
        return "Ninja";
    else if (raceId == 2 || raceId == 6)
        return "Sura";
    else if (raceId == 3 || raceId == 7)
        return "Shaman";
    else
        return szSiteName;
}

const char * CPythonNetworkStream::GetEmpireIcon()
{
    CInstanceBase* pInstance = CPythonCharacterManager::Instance().GetMainInstancePtr();
    int empireId = pInstance->GetEmpireID();
    
    if (empireId == 1)
        return "empire_a";
    else if (empireId == 2)
        return "empire_b";
    else if (empireId == 3)
        return "empire_c";
    else
        return szIconName;
}

const char * CPythonNetworkStream::GetEmpireName()
{
    CInstanceBase* pInstance = CPythonCharacterManager::Instance().GetMainInstancePtr();
    int empireId = pInstance->GetEmpireID();
    
    if (empireId == 1)
        return "Shinsoo (Red)";
    else if (empireId == 2)
        return "Chunjo (Yellow)";
    else if (empireId == 3)
        return "Jinno (Blue)";
    else
        return szSiteName;
}
#endif

Can help bro?

Link to post
  • 0
  • VIP
7 hours ago, peakzinho said:

up

thanks all :)

Replace:
	if (GuildID != 0)
            _snprintf(szBufName, sizeof(szBufName), "Name: %s - Guild: %s", CPythonPlayer::Instance().GetName(), &GuildName);
        else
            _snprintf(szBufName, sizeof(szBufName), "Name: %s", CPythonPlayer::Instance().GetName());
With this:
	if (GuildID != 0)
            _snprintf(szBufName, sizeof(szBufName), "Name: %s - Guild: %s", CPythonPlayer::Instance().GetName(), GuildName.c_str());
        else
            _snprintf(szBufName, sizeof(szBufName), "Name: %s", CPythonPlayer::Instance().GetName());
        
	char szLevel[256];
	_snprintf(szLevel, sizeof(szLevel), "Level: %u", CPythonPlayer::Instance().GetStatus(POINT_LEVEL));
		
	strcat(szBufName, szLevel);

 

Edited by Finnis

r

Link to post
  • 0
6 hours ago, Finnis said:
Replace:
	if (GuildID != 0)
            _snprintf(szBufName, sizeof(szBufName), "Name: %s - Guild: %s", CPythonPlayer::Instance().GetName(), &GuildName);
        else
            _snprintf(szBufName, sizeof(szBufName), "Name: %s", CPythonPlayer::Instance().GetName());
With this:
	if (GuildID != 0)
            _snprintf(szBufName, sizeof(szBufName), "Name: %s - Guild: %s", CPythonPlayer::Instance().GetName(), GuildName.c_str());
        else
            _snprintf(szBufName, sizeof(szBufName), "Name: %s", CPythonPlayer::Instance().GetName());
        
	char szLevel[256];
	_snprintf(szLevel, sizeof(szLevel), "Level: %u", CPythonPlayer::Instance().GetStatus(POINT_LEVEL));
		
	strcat(szBufName, szLevel);

 

Thank you :)

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



Shoutbox

Shoutbox

Chatroom Rules

 

Join our Discord

A request for help = Shoutbox Ban

Be respectful & Respect the rules

 

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.