Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Arena War
      2. After Hours
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA Next

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

Seemann

SA Memory handling

Recommended Posts

Seemann

You could not pass a string parameter to the thread.

 

 

create_thread @CLV thread_name 'vchng'

 

This is the problem. Pass the string array index, or a label where the string's stored:

 

 

:mystringhex"vchng" 00end

 

Share this post


Link to post
Share on other sites
Bigun

I've tried this:

:debug_var_testthread 'VCHNG'[email protected] = 2create_thread @CLV thread_name @mystring local_num 2 set_value 40wait 2000054C: use_GXT_table 'POOL'01E3: text_1number_styled 'NUM' [email protected] 5000 ms 1  // ~1~end_thread:mystringhex"vchng" 00end

 

 

But it didn't work. confused.gif

I also tried to be smartass and do this:

:debug_var_testthread 'VCHNG'[email protected] = 205AA: [email protected] = 'vchng' // 8-byte strings create_thread @CLV thread_name [email protected] local_num 2 set_value 40wait 2000054C: use_GXT_table 'POOL'01E3: text_1number_styled 'NUM' [email protected] 5000 ms 1  // ~1~end_thread

 

 

And it output weird results; depending on the value, it either crashes, or successfully modifies the thread's local var, but always to '103'. :\

 

Please be more detailed in the next reply since I didn't really get everything, what do you mean about array index? Use a global array with strings, and pass the index to the wanted string, maybe? Well I want to use Darkpact so I can't use globals, which is a major reason to use the CLV thread in the first place. Actually, thinking about it, I'm an idiot, I don't think Darkpact even works with Sanny... sucks.

Share this post


Link to post
Share on other sites
Seemann

Yes, I mean the global array as it's the way it may work. But if you dont want to use it, there's another way:

 

 

:CLV{ [email protected] thread_name index at @Thread_Names  [email protected] local var num to modify [email protected] value to set to var} 03A4: name_thread 'CLV'0006: [email protected] = 67251:CLV_LOOP008B: [email protected] = &0([email protected],1i)00D6: if8039:   not  [email protected] == 0004D: jump_if_false @CLV_END// 0001: wait 0 // not necessary0085: [email protected] = [email protected]: [email protected] /= 8000E: [email protected] -= 13483950016: [email protected] /= 4000E: [email protected] -= 269679200D6: if// 05AD: &0([email protected],1s) == &@Thread_Names([email protected],1s)hexAD05           // opcode      (05AD)0C             // data type0000           // array name  (&0)0400           // index name  ([email protected])0102           // size&type0C             // data [email protected]_Names  // array name&index name ([email protected])0102           // size&typeend004D: jump_if_false @CLV_LOOP//add to [email protected] (local var num + 15)000A: [email protected] += 15005A: [email protected] += [email protected]: &0([email protected],1i) = [email protected]:CLV_END004E: end_thread// thread names, all of 8 bytes:Thread_Nameshex"vchng" 00 00 00 // 8 bytes"vchng2" 00 00   // 8 bytesend

 

 

 

and example:

 

 

:TEST1thread 'VCHNG'[email protected] = 2create_thread @CLV thread_name_index 0 local_num 2 set_value 12wait 2000054C: use_GXT_table 'POOL'01E3: text_1number_styled 'NUM' [email protected] 5000 ms 1  // ~1~end_thread

 

 

 

But it works only if the CLV thread and Thread_Names are located at the first 64k of the main.scm (single globalvar limitation). Otherwise use CLEO.

 

As for DP, Y_Less posted the Sanny's version of it (with pdescobar's corrections). I guess it should work.

Share this post


Link to post
Share on other sites
Seemann

It's a code to get the handle of nearest random ped / car / object to a variable.


Originally was written by PLPynton
but that code was buggy and never worked for me. I've fixed and improved it.

The code accepts 4 parameters for the search: XYZ coord of the point from where begin to search and radius of the searching.
If there's any ped (or car, whatever you wish) in this radius, the code stores. its handle in variable [email protected]
Otherwise it returns -1. It will ignore the player or his car also.


This code is written in native line-by-line syntax so it could be used in SAMB as well (if there's someone still using it, he-he..).
Only labels and aDMA (&) should be converted (@ -> JJ, & -> $)



{   The Interceptor        by PLPynton and Seemann       Parameters:   [email protected] - input coord X   [email protected] - input coord Y   [email protected] - input coord Z   [email protected] - search radius   variables [email protected]@ in use      [email protected] = Result (returns -1 if not found)         }:AIC_GETACTOR0006: [email protected] = 3058680006: [email protected] = @AIC_TESTACTORHANDLE0006: [email protected] = 19880002: jump @AIC_STARTSEARCH:AIC_GETVEHICLE0006: [email protected] = 3058690006: [email protected] = @AIC_TESTVEHICLEHANDLE0006: [email protected] = -10006: [email protected] = 25840256:   player $PLAYER_CHAR defined004D: jump_if_false @AIC_STARTSEARCH00DF:   actor $PLAYER_ACTOR driving004D: jump_if_false @AIC_STARTSEARCH03C0: [email protected] = actor $PLAYER_ACTOR car0002: jump @AIC_STARTSEARCH:AIC_GETOBJECT0006: [email protected] = 3058710006: [email protected] = @AIC_TESTOBJECTHANDLE0006: [email protected] = 412:AIC_STARTSEARCH0085: [email protected] = [email protected] // (int)008B: [email protected] = &0([email protected],1i) // (int)0085: [email protected] = [email protected] // (int)000E: [email protected] -= 107871600016: [email protected] /= 4008B: [email protected] = &0([email protected],1i) // (int)000E: [email protected] -= 107871680016: [email protected] /= 4008B: [email protected] = &0([email protected],1i) // (int)0006: [email protected] = -10085: [email protected] = [email protected] // (int)0006: [email protected] = 0:AIC_SEARCHLOOPMAIN000A: [email protected] += 200050: gosub @AIC_READ4B0085: [email protected] = [email protected] // (int)8039:   not  [email protected] == 0004D: jump_if_false @AIC_SEARCHLOOPNEXT000A: [email protected] += 480050: gosub @AIC_READ4B0085: [email protected] = [email protected] // (int)000A: [email protected] += 40050: gosub @AIC_READ4B0085: [email protected] = [email protected] // (int)000A: [email protected] += 40050: gosub @AIC_READ4B0085: [email protected] = [email protected] // (int)050A: [email protected] = distance_between_XYZ [email protected] [email protected] [email protected] and_XYZ [email protected] [email protected] [email protected]:   [email protected] > [email protected] // (float)004D: jump_if_false @AIC_SEARCHLOOPNEXT0085: [email protected] = [email protected] // (int)0085: [email protected] = [email protected] // (int)008B: [email protected] = &0([email protected],1i) // (int)000A: [email protected] += 40050: gosub @AIC_READ4B0085: [email protected] = [email protected] // (int)005A: [email protected] += [email protected] // (int)0050: gosub @AIC_READ1B0012: [email protected] *= 256005A: [email protected] += [email protected] // (int)0002: jump [email protected]:AIC_TESTVEHICLEHANDLE056E:   is [email protected] valid_vehicle_handle004D: jump_if_false @AIC_NOHANDLE00D6: if or003B:   [email protected] == [email protected] // (int)0119:   car [email protected] wrecked004D: jump_if_false @AIC_NEWSEARCHRADIUS0002: jump @AIC_NOHANDLE:AIC_TESTACTORHANDLE056D:   is [email protected] valid_actor_handle004D: jump_if_false @AIC_NOHANDLE00D6: if or003C:   $PLAYER_ACTOR == [email protected] // (int)0118:   actor [email protected] dead004D: jump_if_false @AIC_NEWSEARCHRADIUS0002: jump @AIC_NOHANDLE:AIC_TESTOBJECTHANDLE//0001: wait 083CA:   not object [email protected] exists004D: jump_if_false @AIC_NEWSEARCHRADIUS:AIC_NOHANDLE0006: [email protected] = -10002: jump @AIC_SEARCHLOOPNEXT:AIC_NEWSEARCHRADIUS{    use 0051: return to break the loop  immediately when found at least one actor/car/object,  does not matter if he's nearest one.}// v EXTRA SEARCH CRITERIA GOES HERE v{ [email protected] contains the handle of an actor/car/object that should be excluded from the search result (for example a handle found previously).}//803B:   [email protected]  [email protected]//004D: jump_if_false @AIC_NOHANDLE   0085: [email protected] = [email protected]:AIC_SEARCHLOOPNEXT005A: [email protected] += [email protected] // (int)0085: [email protected] = [email protected] // (int)000A: [email protected] += 1002D:   [email protected] >= [email protected] // (int)004D: jump_if_false @AIC_SEARCHLOOPMAIN0051: return// ---------------------------------:AIC_READ1B0085: [email protected] = [email protected] // (int)0085: [email protected] = [email protected] // (int)0016: [email protected] /= 40012: [email protected] *= 40062: [email protected] -= [email protected] // (int)0012: [email protected] *= 8000E: [email protected] -= 107871680016: [email protected] /= 4008B: [email protected] = &0([email protected],1i) // (int)0085: [email protected] = [email protected] // (int)0006: [email protected] = 00006: [email protected] = 0:AIC_READ1B_LOOP08B9:   test [email protected] bit [email protected]: jump_if_false @AIC_READ1B_NEXTBIT08BF: set [email protected] bit [email protected]:AIC_READ1B_NEXTBIT000A: [email protected] += 1000A: [email protected] += 10039:   [email protected] == 8004D: jump_if_false @AIC_READ1B_LOOP0051: return:AIC_READ4B0085: [email protected] = [email protected] // (int)000E: [email protected] -= 107871680016: [email protected] /= 4008B: [email protected] = &0([email protected],1i) // (int)0085: [email protected] = [email protected] // (int)0051: return


Example:

 while truewait 100 00A0: store_actor $PLAYER_ACTOR position_to [email protected] [email protected] [email protected] [email protected] = 15.0 gosub @AIC_GETVEHICLE if   [email protected]  -1 then    020B: explode_car [email protected] // versionA    // 0085: [email protected] = [email protected] // exclude this handle from the next search, see extra search criteria in the code endend


Screenshot:

A marker above random object
t719381_mfff.JPG

Edited by Seemann

Share this post


Link to post
Share on other sites
X_ATP_X

 

-------------------------------------------------

 

EXAMPLE 1.

Make extremely long trains, 15+ carriages!

 

Original (in Russian)

Screenshot

-------------------------------------------------

 

 

:LONGTRAINSthread 'TRAINS'   for [email protected] = -382229 to -382216    wait 0     &0([email protected],1i) = #STREAKC          end                                                // type0 changed!  // load models  #FREIGHT.Load  #FREIFLAT.Load  #STREAKC.Load  while true    if and      Model.Available(#FREIGHT)      Model.Available(#FREIFLAT)      Model.Available(#STREAKC)       then       Break    end    wait 0  end      // create train with new carriages   06D8: [email protected] = create_train_at 2278.1771 -1144.8823 27.5108 type 0 direction 1   #FREIGHT.Destroy  #FREIFLAT.Destroy  #STREAKC.Destroy  end_thread

 

 

 

You describe how to change train type 0. But How can I change other train Types?

Maybe I stands in The Russian version But cant Russian. Can You Explain how to Change The Other train Types?

Is it Possible To add for example only 5 Carrigages and not 15?

Share this post


Link to post
Share on other sites
Seemann

Read this post to find out the addresses where the game keeps the info about train types.

 

If you wanna change another type, say 3, and make it 5 carriages in length, do the following:

 

take an address of train type (0x8D45B8). it will be the address of the locomotive. write to this address which model you want for it. next 5 dwords (4 bytes each) will be carriages models. so, write to the 0x8D45B8+4, 0x8D45B8+8, 0x8D45B8+12, 0x8D45B8+16, 0x8D45B8+20 addresses models ID for carriages. then write zero to the next address (0x8D45B8+24). so, when you create a train of type 3, the game will read these addresses until it will find zero, and you will get a train with 5 carriages.

 

to write to a memory address use CLEO opcode 0A8C.

 

 

0A8C: write_memory 0x8D45BC size 4 value #FREIFLAT virtual_protect 0

 

 

Share this post


Link to post
Share on other sites
X_ATP_X

 

Read this post to find out the addresses where the game keeps the info about train types.

 

If you wanna change another type, say 3, and make it 5 carriages in length, do the following:

 

take an address of train type (0x8D45B8). it will be the address of the locomotive. write to this address which model you want for it. next 5 dwords (4 bytes each) will be carriages models. so, write to the 0x8D45B8+4, 0x8D45B8+8, 0x8D45B8+12, 0x8D45B8+16, 0x8D45B8+20 addresses models ID for carriages. then write zero to the next address (0x8D45B8+24). so, when you create a train of type 3, the game will read these addresses until it will find zero, and you will get a train with 5 carriages.

 

to write to a memory address use CLEO opcode 0A8C.

 

 

0A8C: write_memory 0x8D45BC size 4 value #FREIFLAT virtual_protect 0

 

 

 

Ok Thanks That works.

Edited by X_ATP_X

Share this post


Link to post
Share on other sites
Seemann

 

-------------------------------------------------

Making cheats

the easiest way

-------------------------------------------------

 

Making cheats (custom keypresses) seems to be a very common problem in SA scripting. People keep asking how to make them. Even there are ways to check the keys typed (first post of this topic has one of them), they are complex and require knowledge of memory structure.

 

Time ago I wrote a code that allows to make the cheats easily. All you need is to store a cheat string to a variable, call the scm function and check the result (true or false).

 

First of all, read this post to understand how passing the strings to scm functions or threads work.

 

Now, the code to check a custom cheat:

 

 

:TestCheatif   0AA9:    is_game_version_originalthen   [email protected] = 0x969110 // keypresses buffer 1.0   [email protected] = 0xA48960 // mission locals 1.0else   [email protected] = 0x96B790 // keypresses buffer 1.01   [email protected] = 0xA4AFE0 // mission locals 1.01end// get [email protected]'s offset0A9F: [email protected] = current_thread_pointer0A8E: [email protected] = [email protected] + 0xDC // mission Flag0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0if   [email protected] == 1then   0085: [email protected] = [email protected]   [email protected] += 0x3Cend// get cheat string [email protected] = 0while true   0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0   if and       [email protected] > 0       [email protected]  0   dec([email protected])          dec([email protected])   0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0 // last cheat char   // lowercase to uppercase (a->A)   if       [email protected] > 90   then       [email protected] -= 32   end   0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0 // last pressed key   inc([email protected])      if       803B:   [email protected]  [email protected] // (int)   then       059A: return_false       0AB2: ret 0   endend0A8C: write_memory [email protected] size 1 value 0 virtual_protect 00485: return_true0AB2: ret 0

 

 

Copy this code without any changes to your script (it does not matter is it a mission or just a script; the code is designed in the way it works for both).

 

You may save the provided code to an external file and include it to your script using directive $INCLUDE (or $I). For example, download the file TestCheat.inc, copy it to the directory with your script's source, add the line

 

{$I TestCheat.inc}

 

at the very end of the script and that all. When you compile, the code will be read from the external file by the compiler automatically.

 

So, how to use this code and check your own cheats. Very easy.

 

Save the cheat string (for example, the cheat will be NOCOPS) to a variable

 

[email protected] = 'nocops'

 

Now call the scm function TestCheat with this string as argument (the post I linked above explains the way it works).

 

0AB1: call_scm_func @TestCheat 2 [email protected] [email protected]

 

And if the function returned true it means the player typed this cheat in-game. So you need to put the function' call in a loop:

 

CLEO script example:

 

{$CLEO}0000:while true   wait 250 ms   [email protected] = 'nocops'   if        0AB1: call_scm_func @TestCheat 2 [email protected] [email protected]   then        0110: clear_player $PLAYER_CHAR wanted_level   endend{$I TestCheat.inc}

 

 

^ When you typed nocops in-game the function return true, and the command clear_wanted_level will be executed.

 

If your cheat is longer than 7 symbols, use long strings:

 

 

{$CLEO}0000:while true   wait 250 ms   [email protected] = "leavemealone"   if        0AB1: call_scm_func @TestCheat 4 [email protected] [email protected] [email protected] [email protected]   then        0110: clear_player $PLAYER_CHAR wanted_level   endend    {$I TestCheat.inc}

 

 

Notes:

1. the cheat string is case-insensitive. You may write [email protected] = 'nocops', [email protected] = 'NoCoPs', [email protected] = 'nOCOPs', it will still work.

2. The cheat could be from 1 to 16 symbols in length.

 

Share this post


Link to post
Share on other sites
coin-god

Nice to see anew way, but i will stick to the old way tounge.gif

 

Good one icon14.gif

Share this post


Link to post
Share on other sites
GamerShotgun

Sorry for bumping this, but is there a way to do this in VC? smile.gif

Share this post


Link to post
Share on other sites
Deji

I know it's an awsum topic n'all.. but 'bumping' is heavily frowned upon wink.gif

 

No, because I believe VC doesn't support arrays. That's what "CLEO For VC" was created for.

Share this post


Link to post
Share on other sites
GamerShotgun

Well, that's cool, but I don't really know how I'm able to do cheats like this. I mean, by typing words, not just pressing combinations.

Share this post


Link to post
Share on other sites
Briangangsta

hello everyone i was wondering if it is possible to make a cheat that can make the current savegame 100% finished with everything unlocked, completed and all territories taken over

 

thx biggrin.gifalien.gif

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.