1

Topic: Changing Ninja

Hello,
i want to make a Rcon-Command where you get a "superninja", so you don't have to wait between attacking. So I created a Rcon command called "superninja".
Then, in player.h, I added a bool calld m_hasSuperNinja. I need to change that bool in m_pPlayer from gamecontext.cpp (there's the function thats called when the rcon gets executed). But how do I access m_pPlayer from gamecontext.cpp, so I can use that boolean in character.cpp?

Greets!

2 (edited by Neox 2013-03-18 21:29:10)

Re: Changing Ninja

Try pPlayer->m_hasSuperNinja (or m_apPlayers[ClientID]->m_hasSuperNinja, ClientID who is the client id sure replace it with the correct types)

This is only if you already know using rcon functions, because you'll need to use pSelf-> (like this pSelf->m_apPlayers[ClientID]->m_hasSuperNinja)

while(!Success())
    TryAgain();
Try until you succeed.

3

Re: Changing Ninja

hi, choose sth, what might help you (I haven't tested it yet, sry):

player.h:

bool m_SuperNinja;

character.cpp:

void CCharacter::FireWeapon()
{
    if(m_ReloadTimer != 0 && (m_ActiveWeapon != WEAPON_NINJA || !m_pPlayer->m_SuperNinja))
        return;
 ...

gamecontext.h:

static void ConSuperNinja(IConsole::IResult *pResult, void *pUserData);

gamecontext.cpp:

void CGameContext::OnConsoleInit()
{
 ...
 Console()->Register("superninja", "i", CFGFLAG_SERVER, ConSuperNinja, this, "Switch SuperNinja of given player");
...
void CGameContext::ConSuperNinjal(IConsole::IResult *pResult, void *pUserData)
{
    CGameContext *pSelf = (CGameContext *)pUserData;
    int ClientID = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
    
    if(!pSelf->m_apPlayers[ClientID])
        return;

    pSelf->m_apPlayers[ClientID]->m_SuperNinja ^= true;
}
#yemDX is a known troll