IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
Forum Rules GTA Modification Forums

Please post mod releases in the Mod Showroom

GTAGarage.com
free mod hosting from GTANet, simply login with your GTAForums account details

GTAModding.com
GTANet's modding wiki

GTA Modding Chatroom
provided by irc.gtanet.com (Don't have an IRC client? Click here)


  Reply to this topicStart new topicStart Poll

 does this make sense?

 snippets from GTAG
 
HeresOtis  
Posted: Friday, May 4 2012, 15:58
Quote Post


Mark Chump
Group Icon
Group: Members
Joined: Apr 29, 2011

XXXXX



Would this code work? It reads a string from my ini file which the string would be - John Carter. Then if I type that using the keyboard, it reads Congratulations. I tried it and it doesn't crash, but it doesn't read congratulations.

CODE
{$CLEO}

0000: NOP

gosub @readStringfromINI

while true
   wait 50
   0AC6: 10@ = label @Text offset
   0085: 5@ = 10@ // Pass offset to other variable, because we will mess with it
   0A8D: 6@ = read_memory 0x969110 size 1 virtual_protect 0 // Read last key pressed
   if
       8AB0:   not key_pressed 0x8 // Backspace
   then
       if
           not 6@ == 0 // Are we pressed any key?
       then
           if and
               8AB0: key_pressed 0x10 // Shift
               6@ > 0x40 // Testing are these keypresses...
               6@ < 0x5B // ...are letters, not digits
           then
               6@ += 0x20 // Converts code to uppercase
           end
           005A: 5@ += 7@ // (int) // Calculates ofsset of actual character
           0A8C: write_memory 5@ size 1 value 6@ virtual_protect 0 // Writes new text to allocated memory space
           0A8C: write_memory 0x969110 size 1 value 0 virtual_protect 0 // Clears keypresses buffer
           7@ += 0x1
       end
   else // If backspace is pressed...
       if
           7@ > 0x0 // Is there is any characters?
       then
           7@ -= 0x1 // Jump to previous character
           005A: 5@ += 7@ // (int) // Calculates ofsset of PREVIOUS character
           0A8C: write_memory 5@ size 1 value 0x0 virtual_protect 0 // Clears that character
       end
   end
   0ACD: show_text_highpriority 10@ time 100 // Typed text
   if
       003B:   10@ == 11@ // (int)
   then
       0AD0: show_formatted_text_lowpriority "Congratulations" time 2000
       0A93:
   end
end      

:Text
hex
   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
end

:readStringfromINI
repeat
   wait 0
until Player.Defined(0)
0AF4: 0@v = read_string_from_ini_file "cleo\PoliceDB.ini" section "Names" key "1"
0AB1: call_scm_func @convDecStrtoInt 4 long_string 0@ 1@ 2@ 3@ store_result 11@
return

:convDecStrtoInt
{
Description:    
   Converts string to integer and returns it into variable.
Type: SET

Parameters:
  Passed:
   if only short string:
        0@ - first part of string
        1@ - second part of string
   if long string:
        3@ - thirth part of string
        4@ - fourth part of string
         
  Result:
    10@ - converted string to integer
   
Example:
 short string: 0AB1: call_scm_func @convDecStrtoInt 2 short_string 0@ 1@ store_result 6@
 long string:  0AB1: call_scm_func @convDecStrtoInt 4 long_string 0@ 1@ 2@ 3@ store_result 6@
}
0662: "By fastman92.tk"
0AA7: call_function 0x69DB50 num_params 1 pop 1 get_string 0@v length_to 4@

//Check for negative number of string
0AC7: 5@ = var 0@ offset
0A8D: 7@ = read_memory 5@ size 1 virtual_protect 0
   if
   7@ == 45
   then
   000A: 5@ += 1
   0AD3: 0@v = format "%s" 5@
   12@ = 1
   end

0085: 6@ = 4@ // (int)
while 6@ > 0
wait 0
0AC7: 5@ = var 0@ offset
005A: 5@ += 4@ // (int)
0062: 5@ -= 6@ // (int)


0A8D: 7@ = read_memory 5@ size 1 virtual_protect 0
7@ -= 48
0085: 8@ = 6@ // (int)
8@ -= 1
0AB1: call_scm_func @Pow_integer 2 base 10 exponent 8@ store_to 8@
006A: 8@ *= 7@ // (int)
005A: 10@ += 8@ // (int)

6@ -= 1
end
   if
   12@ == 1
   then
   10@ *= -1
   end
0AB2: ret 1 10@

:Pow_integer
{
Description:    
   Returns base raised to the power of exp. Passed base and expotent should be integer.
Type: SET

Parameters:
  Passed:
    0@ - base
    1@ - exponent
  Result:
    0@ - base raised to the power of exp.

Example:
 0AB1: call_scm_func @Pow_integer 2 base 2 exponent 4 store_to 0@
}
// 0@ - 5
// 1@ - 0
0085: 3@ = 0@ // (int)
2@ = 1

if
0029: 1@ >= 1
then
jump @POW_INT_POSITIVE
else
jump @POW_INT_NEGATIVE
end

:POW_INT_POSITIVE
if
8039: 2@ !== 1@
else_jump @POW_INT_RETURN
006A: 3@ *= 0@ // (int)
inc(2@)
jump @POW_INT_POSITIVE

:POW_INT_NEGATIVE
if
8039: 2@ !== 1@
else_jump @POW_INT_RETURN
0072: 3@ /= 0@ // (int)
dec(2@)
jump @POW_INT_NEGATIVE

:POW_INT_RETURN
0AB2: ret 1 3@
PM
  Top
 

 
Deji  
Posted: Sunday, May 6 2012, 02:02
Quote Post


Coding like a Rockstar!
Group Icon
Group: Members
Joined: Dec 24, 2007

ja.gif

XXXXX



CODE
003B:   10@ == 11@ // (int)


You're comparing string pointers, not the strings themselves. 05AE is for that.
Users WebsitePM
  Top
 

 
HeresOtis  
Posted: Sunday, May 6 2012, 02:58
Quote Post


Mark Chump
Group Icon
Group: Members
Joined: Apr 29, 2011

XXXXX



The keyboard code uses
CODE

0AC6: 10@ = label @Text offset
0085: 5@ = 10@ // Pass offset to other variable, because we will mess with it
// rest of code
0ACD: show_text_highpriority 10@ time 100 // Typed text

Wouldn't I need to convert 10@ to a string and then compare them using 05AE?
PM
  Top
 

 
Deji  
Posted: Sunday, May 6 2012, 11:13
Quote Post


Coding like a Rockstar!
Group Icon
Group: Members
Joined: Dec 24, 2007

ja.gif

XXXXX



0ACD works with string pointers, 003D doesn't. By the way, why use this and not just test_cheat? Since you don't seem to actually be creating a proper form of keyboard input.

Here's an example of calling strcmp that you could use to test the entered string...
CODE
0AF4: 11@v = read_string_from_ini_file "cleo\PoliceDB.ini" section "Names" key "1"
0AA7: call_function 0x8229B6 num_params 2 pop 2 10@ 11@v 2@  // call strcmp
IF 2@ == 0
THEN // strings matched!
ELSE // strings didn't match
END
Users WebsitePM
  Top
 

 
HeresOtis  
Posted: Sunday, May 6 2012, 15:44
Quote Post


Mark Chump
Group Icon
Group: Members
Joined: Apr 29, 2011

XXXXX



I'll try the sample you provided. I was trying to make a police computer like LCPDFR where you can type in the names of people, which the names will be in the ini. I already have the method to read random names from the ini.

EDIT: It works, thanks. Here's where I put it.
CODE
0ACD: show_text_highpriority 10@ time 100 // Typed text
   0AA7: call_function 0x8229B6 num_params 2 pop 2 10@ 11@v 2@  // call strcmp
   if
       2@ == 0
   then // strings matched!
       0AD0: show_formatted_text_lowpriority "Congratulations" time 2000
       0A93:
//    else // strings didn't match
   end


This post has been edited by HeresOtis on Sunday, May 6 2012, 15:58
PM
  Top
 

 

0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)

0 Members:

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG