ko4life-net / ko

Open source development of the game Knight Online. This is a reversed engineered old version of the game aiming to replicate the nostalgic experience we all once had <3
MIT License
52 stars 21 forks source link

News Ebenezer GM Command +summonuser and +giveitem #152

Closed KnightGuard-KO closed 1 year ago

KnightGuard-KO commented 1 year ago

I opened this topic because I couldn't add coding

user.h

BOOL SpecialOperatorCommand(char* chatstr, int chatlen);

user.cpp

BOOL CUser::SpecialOperatorCommand(char* chatstr, int chatlen)
{
    CUser* pUser = NULL;
    _START_POSITION* pPositionInfo = NULL;

    int send_index = 0;
    char send_buff[1024]; memset(send_buff, NULL, 1024);

    char temp[11]; char struser[21]; char strindex[10];
    int parse_index = 0, zoneindex = -1, izone = 0, inum = 0, icount = 1, iexp = 0, igold = 0; short x = 0, z = 0;

    if (_strnicmp("+summonuser", chatstr, 11) == 0) {
        if (m_pUserData->m_bAuthority != 0) return FALSE;

        parse_index += ParseSpace(temp, chatstr + parse_index); // Command
        parse_index += ParseSpace(struser, chatstr + parse_index); // UserID

        pUser = (CUser*)m_pMain->GetUserPtr(struser, 0x02);
        if (!pUser) return FALSE;

        pUser->ZoneChange(m_pUserData->m_bZone, m_pUserData->m_curx, m_pUserData->m_curz);

        return TRUE;
    }

else if (_strnicmp("+giveitem", chatstr, 9) == 0) {
        if (m_pUserData->m_bAuthority != 0) return FALSE;

        parse_index += ParseSpace(temp, chatstr + parse_index); // Command
        parse_index += ParseSpace(struser, chatstr + parse_index); // UserID
        parse_index += ParseSpace(strindex, chatstr + parse_index); inum = atoi(strindex); // ItemID
        parse_index += ParseSpace(strindex, chatstr + parse_index); icount = atoi(strindex); // ItemCount

        pUser = (CUser*)m_pMain->GetUserPtr(struser, 0x02);
        if (!pUser) return FALSE;

        pUser->GiveItem(inum, icount);

        return TRUE;
    }
    return FALSE;
}
xGuTeK commented 1 year ago

Hi, thanks for help but if u wanna help us learn git first how to create pull request ( add code ) to repository https://www.youtube.com/watch?v=z8CYDyFqzp0

KnightGuard-KO commented 1 year ago

Hi, thanks for help but if u wanna help us learn git first how to create pull request ( add code ) to repository

https://www.youtube.com/watch?v=z8CYDyFqzp0

i get it, man, I'm coding with version 1298

I'm glad I could help

stevewgr commented 1 year ago

Closing this as not enough info. @KnightGuard-KO, please create a new issue following the template format. We can't help you without any context. Thank you!