Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (92,975 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

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

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

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

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

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

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

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. 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

    2. Red Dead Redemption

    3. 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. Forum Support

    2. Site Suggestions

Sign in to follow this  
Marty McFlaY

[CLEO] How to save data of in-game and load it?

Recommended Posts

Marty McFlaY

Yeah, just like DYOM. Like it saves all the place objects, items, checkpoints etc, in a file and load it.

 

How i can do that in SB? For example: I placed some objects in Standard GTA with sanny builder. Now i want to store all objects position in a file like saving a progress. How i can do that and also how to load that?

Share this post


Link to post
Share on other sites
Marty McFlaY

Anyone can reply?

Share this post


Link to post
Share on other sites
ZAZ

Yeah, there're several methods , needs explain a bit more, what's your knowledge in coding?

Share this post


Link to post
Share on other sites
Marty McFlaY

1) Beginning

2) Easy

3) Normal

4) Intermediate

5) Hard

6) Very Hard

 

I'm in Intermediate level.

Share this post


Link to post
Share on other sites
ZAZ

Ok,

you can store objects placements in an external file, if cleo is installed, means, write model id, x,y,z coords and x,y,z, angle in a file

Then you can save and load it without making a normal savegame

 

But when you make a normal savegame, there's a disdvantage: objects, radarblips, pickups will be saved for sure in any way

 

Step by step:

 

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

 

In main.scm are used Global Variables and Local Variables

Globals have a global scope, locals only a local scope.

All existing Globals will be stored in the savefile, if you make a savegame

 

Example:

$OBJECT_M_A51_VENTCOVERB is the global var for the vent cover that you can remove in mission Black Project to get down to the secret area69

It's placed in a mission script that runs at gamestart

 

 

0107: $OBJECT_M_A51_VENTCOVERB = create_object #A51_VENTCOVERB at 245.968 1862.843 19.49 0453: set_object $OBJECT_M_A51_VENTCOVERB XY_rotation 0.0 0.0 angle -140.998 01C7: remove_object_from_mission_cleanup_list $OBJECT_M_A51_VENTCOVERB
and will be stored with your first savegame

 

This object can be used or removed later in the mission Black Project by calling this global var $OBJECT_M_A51_VENTCOVERB

You can do that from any script inside main.scm

 

 

 

If you use a local var instead,

 

 

0107: [email protected] = create_object #A51_VENTCOVERB at 245.968 1862.843 19.49
The object placement will also be stored, when you make a savegame,

but then you can't use or remove it anymore, because local vars won't be saved

 

Objects, radarblips, pickups will be saved by internal id's and codes but if they're placed by local vars, the reference is missing, because local vars won't be saved

 

The reference is only available for that thread instance that is running where the placement was done

 

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

 

In cleo you should not use global vars, because it can cause bugs and crashes

It must not, but it can, like that script below to replace the door objects and the ventcover at area69

 

 

 

{$CLEO .cs}thread 'AREAOBJ' wait 1000 [email protected] = 0 [email protected] = 0 [email protected] = 0 [email protected] = 0 [email protected] = 0 :Area69objectget_01wait 0 if 0256:   player $PLAYER_CHAR defined jf @Area69objectget_01 if [email protected] == 0 jf @Area69objectget_03 if 00FE:   actor $PLAYER_ACTOR sphere 0 in_sphere 246.1333 1863.007 20.135 radius 5.0 5.0 5.0 jf @Area69objectget_03 wait 50 if 03CA:   object $OBJECT_M_A51_VENTCOVERB exists jf @Area69objectget_01 wait 1000 if 09CC:   object $OBJECT_M_A51_VENTCOVERB model_is 3117 jf @Area69objectget_01 01BC: put_object $OBJECT_M_A51_VENTCOVERB at 245.968 1862.843 17.01 [email protected] = 1 jump @Area69objectget_01 :Area69objectget_03if [email protected] == 0 jf @Area69objectget_07 if 00FE:   actor $PLAYER_ACTOR sphere 0 in_sphere 212.8843 1885.02 13.147 radius 20.0 20.0 5.0 jf @Area69objectget_07 wait 50 if 03CA:   object $OBJECT_M_A51_BLASTDOORR exists jf @Area69objectget_01 wait 1000 if 09CC:   object $OBJECT_M_A51_BLASTDOORR model_is 2927 jf @Area69objectget_01 01BC: put_object $OBJECT_M_A51_BLASTDOORR at 205.941 1874.571 13.903 [email protected] = 1 jump @Area69objectget_01 :Area69objectget_07if [email protected] == 0 jf @Area69objectget_09 if 00FE:   actor $PLAYER_ACTOR sphere 0 in_sphere 212.8843 1885.02 13.147 radius 20.0 20.0 5.0 jf @Area69objectget_09 wait 50 if 03CA:   object $OBJECT_M_A51_BLASTDOORL exists jf @Area69objectget_01 wait 1000 if 09CC:   object $OBJECT_M_A51_BLASTDOORL model_is 2929 jf @Area69objectget_01 01BC: put_object $OBJECT_M_A51_BLASTDOORL at 205.941 1874.571 13.903 [email protected] = 1 jump @Area69objectget_01 :Area69objectget_09if [email protected] == 0 jf @Area69objectget_01 if 00FE:   actor $PLAYER_ACTOR sphere 0 in_sphere 269.3675 1883.921 17.4804 radius 20.0 20.0 5.0 jf @Area69objectget_01 wait 50 if 03CA:   object $2670 exists jf @Area69objectget_01 wait 1000 if 09CC:   object $2670 model_is 3095 jf @Area69objectget_01 01BC: put_object $2670 at 258.664 1884.06 15.925 [email protected] = 1 jump @Area69objectget_01 if [email protected] == 0 jf @Area69objectget_13 if 00FE:   actor $PLAYER_ACTOR sphere 0 in_sphere 251.271 1920.436 20.6332 radius 270.0 270.0 75.0 jf @Area69objectget_13 [email protected] = 1 jump @Area69objectget_01 :Area69objectget_13if [email protected] == 1 jf @Area69objectget_01 if 80FE:   not actor $PLAYER_ACTOR sphere 0 in_sphere 251.271 1920.436 20.6332 radius 280.0 280.0 85.0 jf @Area69objectget_01 [email protected] = 0 jump @Area69objectget_01 if [email protected] == 1 jf @Area69objectget_01 [email protected] = 0 jump @Area69objectget_01 

 

My experience is: if a mission is running and a cleoscript with global vars, it cause bugs or if many globals are used, it crashes

So many users got buggy games and savegames because they ran cleo scripts that use global vars or place radarblips and pickups and made a savegame then.

 

In any way, it's not recommanded to use globals in cleo

For cleo exist another method to give local vars a global scope

It's also not recommanded to place objects, radarblips and pickups by cleo script

 

If you wanna do it though, then make sure that the user can't get a buggy or corrupted save game

 

So let's clarify first:

Are you planning to publish a mod that spawns objects or is it for privat use?

If you planning to publish a mod, can it be a main.scm mod, a modpack?

If it should be a cleo script, should it be possible to edit the file, manually, that stores the object info?

Edited by ZAZ

Share this post


Link to post
Share on other sites
Marty McFlaY
:Main_Menu_Choice_5_Menuwait 0if  0AAB:   file_exists "CLEO\SAVE\savedata.dat"jf @ERROR0A9A: $FILE = openfile "CLEO\SAVE\savedata.dat" mode "a+"  // IF and SET0A9E: writefile $FILE size 128 from [email protected][[email protected]]wait 10000A9B: closefile $FILE0ACD: "Successfully saved" 2000Player.CanMove($PLAYER_CHAR, 1)jump @Main_Menu_Choice:ERRORwait 0if   8AAB: not file_exists "CLEO\SAVE\savedata.dat"jf @Main_Menu_Choice_5_Menu0ACD: show_text_highpriority "File 'savedata.dat' or Folder not found. Please check again" time 2000Player.CanMove($PLAYER_CHAR, 1)jump @Main_Menu

Well, i'm kinda of noob so, will you fix this. [email protected][[email protected]] is a object and $FILE is the variable of file. This ones write the object in "savedata.dat" file.

 

Data successfully stores and it looks like this:

                                                                                                                               H                                                                                                                             

But i can't load the object. Here:

:Main_Menu_Choice_6_Menuwait 0if  0AAB:   file_exists "CLEO\SAVE\savedata.dat"jf @ERROR20A9A: $FILE = openfile "CLEO\SAVE\savedata.dat" mode "r"  // IF and SET0A9D: readfile $FILE size 128 to $RFILE0A9B: closefile $FILE0ACD: show_text_highpriority "File Successfully Loaded" time 2000Player.CanMove($PLAYER_CHAR, 1)jump @Main_Menu:ERROR2wait 0if  8AAB: not  file_exists "CLEO\SAVE\savedata.dat"jf @Main_Menu_Choice_6_Menu0ACD: show_text_highpriority "File 'savedata.dat' or Folder not found. Please check again" time 2000Player.CanMove($PLAYER_CHAR, 1)jump @Main_Men

Can you fix this?

 

The answer is 2nd one. It's a modpack you can say.

Edited by Marty McFlaY

Share this post


Link to post
Share on other sites
ZAZ

I give you a template to do it by read/write ini file

 

Create first an ini file with this content:

 

[object1]objectID=1225; barrel4X=2494.7246Y=-1671.244Z=13.3A=1.1
and save it as Objectspawn.ini inside cleo folder

 

And here's the cleo script:

 

{$CLEO .cs}thread 'coords'while truewait 0    if         0AB0:   key_pressed 8// press Backspace    then        if             0A9A: [email protected] = openfile "CLEO\Objectspawn.ini" mode 114  // binary read        then            0AF0: [email protected] = get_int_from_ini_file "CLEO\Objectspawn.INI" section "object1" key "objectID" //IF and SET            0AF2: [email protected] = get_float_from_ini_file "CLEO\Objectspawn.INI" section "object1" key "x"            0AF2: [email protected] = get_float_from_ini_file "CLEO\Objectspawn.INI" section "object1" key "y"            0AF2: [email protected] = get_float_from_ini_file "CLEO\Objectspawn.INI" section "object1" key "z"            0AF2: [email protected] = get_float_from_ini_file "CLEO\Objectspawn.INI" section "object1" key "a"            0A9B: closefile [email protected]                        0247: load_model [email protected]            038B: load_requested_models            029B: [email protected] = init_object [email protected] at [email protected] [email protected] [email protected]            0177: set_object [email protected] z_angle_to  [email protected]            0249: unload_model [email protected]        end        wait 1000            end    if         0AB0:   key_pressed 9// press TAB    then            [email protected] = 1607// dolphin            [email protected] = 2478.151            [email protected] = -1662.19            [email protected] = 13.34            [email protected] = 151.612            0247: load_model [email protected]            038B: load_requested_models            029B: [email protected] = init_object [email protected] at [email protected] [email protected] [email protected]            0177: set_object [email protected] z_angle_to  [email protected]            0249: unload_model [email protected]        if             0A9A: [email protected] = openfile "CLEO\Objectspawn.ini" mode 114  // binary read        then            0AF1: write_int [email protected] to_ini_file "CLEO\Objectspawn.INI" section "object2" key "objectID"            0AF3: write_float [email protected] to_ini_file "CLEO\Objectspawn.INI" section "object2" key "x"            0AF3: write_float [email protected] to_ini_file "CLEO\Objectspawn.INI" section "object2" key "y"            0AF3: write_float [email protected] to_ini_file "CLEO\Objectspawn.INI" section "object2" key "z"            0AF3: write_float [email protected] to_ini_file "CLEO\Objectspawn.INI" section "object2" key "a"            0A9B: closefile [email protected]        end        wait 1000    endend 
Then go ingame into Grovestreet and press Backspace to spawn the object by reading data of the ini file, it's a Barrel4

Then press TAB to spawn another object, it's a dolphin

Then minimize the game and view to the Objectspawn.ini to see the new entries

Share this post


Link to post
Share on other sites
Marty McFlaY

I'm using Global Variables in SCM and still its crashing. Don't know why. The file successfully write but it crashes + my object ID is in array form. It's giving wrong ID everytime of object + also wrong X,Y,Z and Angle coords.

 

Could you have another way like: DYOM? They store every and each things by writing just variables with small calculation. I don't know how to do that. If you have any example like that then please give that to me.

Share this post


Link to post
Share on other sites
ZAZ

I'm using Global Variables in SCM and still its crashing. Don't know why. The file successfully write but it crashes + my object ID is in array form. It's giving wrong ID everytime of object + also wrong X,Y,Z and Angle coords.

Post your main.scm script. if it's too big, then describe the content of your main.scm script and post the script that spawn the objects.

 

 

 

Could you have another way like: DYOM? They store every and each things by writing just variables with small calculation. I don't know how to do that. If you have any example like that then please give that to me.

what do you want? save the the objects in a save file when you make a savegame? or do you wanna write the spawn data into a textfile?

Share this post


Link to post
Share on other sites
deltaCJ

@MartyMcFlay,

Use ZAZ's script, and see if it works, but don't use SCM then you need to start from NEW game.

 

After using ZAZ's script try to replace the models with your models, and see if they are imported back in.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

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