According to scancodes 2 page and its main page, the scancode hardware set is 2, and the code for the up arrow is E0, 75, and for numpad8 it is just 75, which means that the arrow key is an extended key, so you need to enable extended key flag. This code successfully allows you to manage data from a script:
PWNFUNC(EmulateKeyPressINPUT) { // This structure will be used to create the keyboard // input event. INPUT ip; // Set up a generic keyboard event. ip.type = INPUT_KEYBOARD; ip.ki.dwFlags = 0; if(params[4] == 1) { ip.ki.wScan = params[2]; // hardware scan code for key ip.ki.wVk = 0; // virtual-key code for the key ip.ki.dwFlags |= KEYEVENTF_SCANCODE; } else { ip.ki.wScan = 0; // hardware scan code for key ip.ki.wVk = params[2]; // virtual-key code for the key } ip.ki.time = 0; ip.ki.dwExtraInfo = 0; if(params[3] == 1) { ip.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY; } if(params[1] == 1) { ip.ki.dwFlags |= KEYEVENTF_KEYUP; } return SendInput(1, &ip, sizeof(INPUT)); }
usage example for script:
GetMovementSpeed(pos[0][0],pos[0][1],pos[0][2],true); new Float:speed = floatsqroot(pos[0][0]*pos[0][0]+pos[0][1]*pos[0][1]+pos[0][2]*pos[0][2])*174.0; if ( speed > 260.0 ) speed = 260.0; if(GetVehicleModel() == 520)//f-22 airplane { static sent = 0; static status = 0; static vKEY_UP = VK_UP; static vKEY_DOWN = VK_DOWN; static bool:extended = false; static bool:hardware = false; if(IsKeyDown(VK_KEY_0)) { vKEY_UP = VK_NUMPAD8; vKEY_DOWN = VK_NUMPAD2; } else if(IsKeyDown(VK_KEY_9)) { vKEY_UP = VK_UP; vKEY_DOWN = VK_DOWN; } else if(IsKeyDown(VK_KEY_8)) { extended = true; } else if(IsKeyDown(VK_KEY_7)) { extended = false; } else if(IsKeyDown(VK_KEY_6)) { hardware = true; } else if(IsKeyDown(VK_KEY_5)) { hardware = false; } DrawText( id,50.0,170.0,0xFFFFFFFF, sprintf("UP: %x DOWN: %x Extended: %d Hardware: %d",vKEY_UP,vKEY_DOWN,extended,hardware) ); if(IsKeyDown(VK_TAB)) { if(speed < 200.0) { if(status == 0) { new PressedKeys[2]; PressedKeys[0] = EmulateKeyPress(KEYPRESS_UP,vKEY_DOWN,extended,hardware); PressedKeys[1] = EmulateKeyPress(KEYPRESS_DOWN,vKEY_UP,extended,hardware); DrawTextTimed(id,50.0,210.0,0xFFFFFFFF,sprintf("Presses:{%d,%d} if(speed < 200.0)",PressedKeys[0],PressedKeys[1]),2000,250,0); sent = 1; status = 1; } DrawText( id,50.0,160.0,0xFFFFFFFF, "GO birdy!! gooo!!!!" ); } else if(speed > 210.0) { if(status == 0) { new PressedKeys[2]; PressedKeys[0] = EmulateKeyPress(KEYPRESS_UP,vKEY_UP,extended,hardware); PressedKeys[1] = EmulateKeyPress(KEYPRESS_DOWN,vKEY_DOWN,extended,hardware); DrawTextTimed(id,50.0,210.0,0xFFFFFFFF,sprintf("Presses:{%d,%d} if(speed > 210.0)",PressedKeys[0],PressedKeys[1]),2000,250,1); sent = 2; status = 1; } DrawText( id,50.0,160.0,0xFFFFFFFF, "TOO fastststs!!!! SOTTP STOP!!!" ); } else { status = 0; EmulateKeyPress(KEYPRESS_UP,vKEY_UP,extended,hardware); EmulateKeyPress(KEYPRESS_UP,vKEY_DOWN,extended,hardware); } } else if(sent == 1) { DrawTextTimed(id,50.0,220.0,0xFFFFFFFF,sprintf("Presses:{%d} if(sent == 1)",EmulateKeyPress(KEYPRESS_UP,vKEY_UP,extended,hardware)),2000,250,2); sent = 0; status = 0; DrawText( id,50.0,160.0,0xFFFFFFFF, "You won't see this message" ); } else if(sent == 2) { DrawTextTimed(id,50.0,230.0,0xFFFFFFFF,sprintf("Presses:{%d} if(sent == 1)",EmulateKeyPress(KEYPRESS_UP,vKEY_DOWN,extended,hardware)),2000,250,3); sent = 0; status = 0; DrawText( id,50.0,160.0,0xFFFFFFFF, "Nor this one, c'mon if you do, you can notice a change in one frame between 2 other frames?!" ); } else { DrawText( id,50.0,160.0,0xFFFFFFFF, "Something other is going on.. our relation ship is too complicated :(" ); } } else { DrawText( id,50.0,160.0,0xFFFFFFFF, "Well, no autopilot if you're not in an F-22.." ); }
allows you to change flags using 5,6,7,8 keys and enter keys with 9 and 0