|
 |
|
|
|
|
|
GTA Modification Forums
New keypresses No more 'shift + crouch' for mods.
 |
|
 |
| |
Seemann  |
Posted: Wednesday, Nov 22 2006, 12:21
|
Ruhe

Group: Members
Joined: Sep 3, 2004



|
Same method is available for San Andreas. MA 0x969110 is the start of an array that keeps 30 last pressed keys in SA. So, accessing to this address allows to create new keypress checks and even create new cheats/passwords in run-time. Using this I've got simple integer value for an array index that points at this address: -229908. Though, | CODE | 0@ = -229908 008B: 1@ = &0(0@,1i)
|
stores last 4 chars to 1@. I've written different variants how to check out one, two, three, four, five last chars and even 16 ones. | CODE | // custom keypresses, v. SA
// EXAMPLE 1: TEST 1 key press (space) 0@ = -229908 while true 008B: 1@ = &0(0@,1i) // get last keypresses 0085: 2@ = 1@ div(1@, 256) // 1char 256, 2chars: 65536: 3chars: 16777216 mul(1@, 256) // same 0062: 2@ -= 1@ // get needed number of chars (1) if 2@ == 32 //0x20 // test if it's SPACE then 03E5: text_box 'CHEAT1' // Cheat activated Break end wait 1000 end
// EXAMPLE 2: TEST 2 keys ('NO') 0@ = -229908 while true 008B: 1@ = &0(0@,1i) // get last keypresses 0085: 2@ = 1@ div(1@, 65536) // 1char 256, 2chars: 65536: 3chars: 16777216 mul(1@, 65536) // same 0062: 2@ -= 1@ // get needed number of chars (2) if 2@ == 20047 //0x4e4f // test if player typed NO then 03E5: text_box 'CHEAT1' // Cheat activated Break end wait 1000 end
// EXAMPLE 3: TEST 3 keys ('WOW') 0@ = -229908 while true 008B: 1@ = &0(0@,1i) // get last keypresses 0085: 2@ = 1@ div(1@, 16777216) // 1char 256, 2chars: 65536: 3chars: 16777216 mul(1@, 16777216) // same 0062: 2@ -= 1@ // get needed number of chars (3) if 2@ == 5721943 //0x574f57 // test if player typed WOW then 03E5: text_box 'CHEAT1' // Cheat activated Break end wait 1000 end
// EXAMPLE 4: TEST 4 keys ('HACK') 0@ = -229908 while true if &0(0@,1i) == 1212236619 //0x4841434B // test if player typed HACK then 03E5: text_box 'CHEAT1' // Cheat activated Break end wait 1000 end
// EXAMPLE 5: TEST 5 keys ('SANNY')
// test 5th char 's' from address +4b, then test 'anny' from the beginning;
// addr keys // -229908: X X X X | -229908: A N N Y // -229907: X X X O <- | -229907: _ _ _ S
while true 0@ = -229907 // +32bits; next 4 bytes/chars in the last keypresses block 008B: 1@ = &0(0@,1i) 0085: 2@ = 1@ div(1@, 256) mul(1@, 256) 0062: 2@ -= 1@ // 5th char is the last in the second block: if 2@ == 83 //0x53 // test if S is the 5th pressed key then 0@ = -229908 008B: 3@ = &0(0@,1i) if 3@ == 1095650905 //0x414E4E59 // test if player also typed ANNY after that then 03E5: text_box 'CHEAT1' // Cheat activated Break end end wait 1000 end
// EXAMPLE 6: TEST 16 keys: '1234567812345678' 0@ = -57477 while true if &0(0@,1v) == "8765432187654321" // test if last pressed key combo is "1234567812345678" then 03E5: text_box 'CHEAT1' // Cheat activated Break end wait 1000 end
|
Edit: Just realised that the code I posted works only for me (with newest version of SB), because SB v2.99 doesn't support hex numbers in a math expression. So, I converted these numbers to decimal format in order the code can be compiled. This post has been edited by Seemann on Thursday, Nov 23 2006, 07:53
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
Seemann  |
Posted: Wednesday, Mar 7 2007, 13:23
|
Ruhe

Group: Members
Joined: Sep 3, 2004



|
You can check if ANY key is pressed via the mission scripts. 1. Open the keyslist http://sannybuilder.com/dev/keycodes.htmFind the key you need to check. 2. First column contains the index pointing to the key related memory address. Using the array's method of reading the memory you can get the current state of the key. 3. The keys located at the column KeyLo returns 0xFF when pressed. The keys located at the column KeyHi returns 0xFF0000 when pressed. 4. Read the mem addy using index and compare the value with the conforming constant. Example1. Check ENTER| CODE | 0@ = 304490 // Enter's index
:loop wait 0 &0(0@,1i) == 0x00FF0000 // KeyHi jf @loop
player.money($player_char) += 100 // Enter pressed!
| Example2. Check TILDE (~)| CODE | 0@ = 304550 // Tilde's index
:loop wait 0 &0(0@,1i) == 0xFF // KeyLo jf @loop
player.money($player_char) += 100 // Tilde pressed!
| Example3. Combined checks: Num1+ Num2| CODE | 0@ = 304484 // Num1,Num2 index
:loop wait 0 &0(0@,1i) == 0x00FF00FF // Num1+Num2 jf @loop
player.money($player_char) += 100 // Whoa! Num1+Num2 pressed!
|
All indexes are for version 1.0
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
| |
 |
|
 |
|
|
|
|