Console Handler

Scripting particularly to improve NoX is discussed in here

Console Handler

Postby panic » Tue Jan 14, 2020 12:33 am

make a handler of Console command
You can use console commands in native scripts

void CmdLine(string command);

Requirements::
- Nox Original (1.2b)
- script compiler with support memory read/write

Native Script Code::

Code: Select all
void CharToWideChar(string x)
{
    int ptr = GetMemory(0x97bb40 + (4 * SToInt(x))), dump = 0x751030, arr[2], read, sh = 0xff, end = 0;

    while (1)
    {
        read = GetMemory(ptr);
        if (!(read & 0xff) || !((read >> 8) &0xff) || !((read >> 16) &0xff) || !((read >> 24) &0xff))
            end = 1;
        arr[0] = (read & sh) | (((read >> 8) & sh) << 16);
        arr[1] = ((read >> 16) & sh) | (((read >> 24) & sh) << 16);
        SetMemory(dump, arr[0]);
        SetMemory(dump + 4, arr[1]);
        dump += 8;
        ptr += 4;
        if (end)
            break;
    }
    SetMemory(dump, 0);
}

void UploadConsoleParse()
{
    int arr[7], link;

    if (!link)
    {
        arr[0] = 0;
        arr[1] = 0x443c8068; arr[2] = 0x68016a00; arr[3] = 0x751030; arr[4] = 0x82454ff;
        arr[5] = 0x310cc483; arr[6] = 0x90c3c0;
        CancelTimer(FrameTimerWithArg(10, UploadConsoleParse, UploadConsoleParse));
        link = GetMemory(GetMemory(0x75ae28) + (0x30 * GetMemory(GetMemory(0x83395c) + 8) + 0x1c));
    }
    SetMemory(0x5c31cc, link + 4);
}

void CmdLine(string x)
{
    CharToWideChar(x);
    UploadConsoleParse();
    Unused50();
    SetMemory(0x5c31cc, 0x513c60);
}


Note: 'UploadConsoleParse' function must be called on 'MapInitialize' before using

Testing Code::

Code: Select all
void DisplayBroadMessage()
{
    CmdLine("broadcast Hello World! +_+!!");
}


OUTPUT::

Image
panic
Veteran
Posts: 322
Joined: Thu Nov 12, 2015 3:47 pm

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron