[0.3DL] Force a key press

benberk

Member
Joined
Jan 19, 2020
Messages
19
Reaction score
3
Location
Constantine
As I wrote in the title section... Local player will force the SHIFT key and ped will jump as soon as I type a command(example). Is this possible in 0.3DL?

I found a few methods like SetGamekeyState but they didn't work for me.
 

dphome

Well-known member
Joined
Mar 21, 2020
Messages
475
Solutions
9
Reaction score
168
Location
Poland
Activation: GO1
PHP:
{$CLEO .cs}

0000: NOP

WAIT 8500

WHILE TRUE
WAIT 0

IF 0256:   player $PLAYER_CHAR defined
THEN
    IF 0ADC:   test_cheat "GO1"
    THEN
        0AB1: @Set_Virtual_Key 2 KeyOffSet 0x392 state 255 {0x392 - shift, 0x20 - spacebar}
        WAIT 30
        0AB1: @Set_Virtual_Key 2 KeyOffSet 0x392 state 0 {0x392 - shift, 0x20 - spacebar}
    END
END

END

:Set_Virtual_Key
{
    255 = true
    0 = false
    0AB1: @Set_Virtual_Key 2 KeyOffSet 0x57 state 255
}
2@ = 0xB72CC8
0@ *= 2
005A: 2@ += 0@  // (int)
0A8C: write_memory 2@ size 1 value 1@ virtual_protect 0
0AB2: ret 0
Activation: GO2
PHP:
{$CLEO .cs}

0000: NOP

WAIT 8500

WHILE TRUE
WAIT 0

IF 0256:   player $PLAYER_CHAR defined
THEN
    IF 0ADC:   test_cheat "GO2"
    THEN
        0AB1: @ForcePressGameKeyOffset 1 _KeyOffset 29 {29 - jump true}
        WAIT 30
        0AB1: @ForcePressGameKeyOffset 1 _KeyOffset 28 {28 - jump false}
    END
END

END

:ForcePressGameKeyOffset
{
    0AB1: @ForcePressGameKeyOffset 1 _KeyOffset 0@
}
0@ += 0xB734D0 // High Priority Controls
0A8C: write_memory 0@ size 1 value 255 virtual_protect 0
0AB2: ret 0
 

Attachments

  • GO1.cs
    17.9 KB · Views: 0
  • GO2.cs
    17.8 KB · Views: 1

dphome

Well-known member
Joined
Mar 21, 2020
Messages
475
Solutions
9
Reaction score
168
Location
Poland
PHP:
#define KEY_SPACE        0x20
#define KEY_LSHIFT        0xA0
#define KEY_LSHIFT_TEST    0x392

SetVirtualKeyState(KEY_LSHIFT_TEST, 255);
Sleep(30);
SetVirtualKeyState(KEY_LSHIFT_TEST, 0);

void SetVirtualKeyState(BYTE key, BYTE state)
{
    *(uint8_t *)(0xB72CC8 + (key * 2)) = state;
}
 

benberk

Member
Joined
Jan 19, 2020
Messages
19
Reaction score
3
Location
Constantine
PHP:
#define KEY_SPACE        0x20
#define KEY_LSHIFT        0xA0
#define KEY_LSHIFT_TEST    0x392

SetVirtualKeyState(KEY_LSHIFT_TEST, 255);
Sleep(30);
SetVirtualKeyState(KEY_LSHIFT_TEST, 0);

void SetVirtualKeyState(BYTE key, BYTE state)
{
    *(uint8_t *)(0xB72CC8 + (key * 2)) = state;
}
no work for 0.3dl
 

dphome

Well-known member
Joined
Mar 21, 2020
Messages
475
Solutions
9
Reaction score
168
Location
Poland
no work for 0.3dl
Fixed.
PHP:
#define KEY_SPACE    0x20
#define KEY_SHIFT    0x392

void SetVirtualKeyState(int key, int state)
{
    *(uint32_t *)(0xB72CC8 + (key * 2)) = state;
}

SetVirtualKeyState(KEY_SHIFT, 255);
Sleep(30);
SetVirtualKeyState(KEY_SHIFT, 0);
 

Attachments

  • bin.rar
    375.7 KB · Views: 8
  • src.rar
    13.1 MB · Views: 24
Top