Log in to reply

Help with savegame scripting pleeeeeease

  • Hello guys, here's a noob on gta scripting. I'm trying to make some functions to add special abilities to my characters (fireproof, increase maximum health etc) as rewards of completing my missions (just like what is in GTASA and GTAVC). Problem here is I would like these abilities only accessible in the savegames in which I completed the missions and "acquired" those abilities like a "native" skills like stamina, strength etc.
    I did some searching on Google, and all I found is how to make a function run after any game start. One possible solution someone mentioned is using WritePrivateProfileString function to modify config files but this seems impossible to hold and read different data to different save slots.
    Please can anyone tell me is it possible to attach some addon properties to a game file through scripts or where did Rockstar put the code that stands for the skill points of characters? Many thanks for help.

    PS English is not my native language. Apologies for any poor English.
    PPS I'm currently coding with C# because I have learnt a few lessons. I would try to change to C++ or LUA if it is really necessary.

  • @Maffine21 By Reading your topic, what I've understood is(Please correct me if I am wrong)

    You are making a script where you wish to reward the player upon completing certain tasks and those achievements/progress can be saved and loaded the next time player continues from.

    If this is what you are looking for, I am no expert at scripting as well, but If I were you, I will make a custom config file to save and load this data something like an XML file. This will hold all the custom states. You will also need bunch of Boolean to check if the player has reached a certain point to have that reward or no.

    This file then can be used, when loading up the game next time and holding the data at the current session.

    Lastly, if you wish, you can encrypt/decrypt that data, so it can't be messed easily.

    P.s. Please be aware, if your script will need(Read/Write/Executable) rights at the same time(which most of the scripts do), No matter what you try, user can still break into the code to replace the values as per their liking. I think, that's what they call a DRM issue. :D

  • @ashishcw Hi, thanks a lot for the advise, unfortunately what I am looking for is a little bit further. Please let me explain. What I'm trying to do is the same creating a config file thing. However, I am trying to, say, create a series of booleans, each of them represent whether I have acquired the special ability. Then, depending on which save I'm loading, the game can read the respective data in the config file and decide whether to unlock the reward. For example, if I load an old save, in which Franklin hasn't finished the addon missions, then Franklin doesn't have the abilities. Then I switch to another save in which Franklin has already finished the missions, so he has the abilities. Do you know if there is anyway I can achieve this? Much appreciated : - )
    PS Sorry for my bad explanation:disappointed_relieved: Don't know if I make myself clear

  • @Maffine21 Hello Maffine, Sorry for the late reply. And thank you for the explanation, but here I have few more questions. Although, I am unsure, if would I be able to help to solve your problem, but I will certainly try my best to do so. (:

    So, as you have mentioned, about the custom config file to check if the player has reached a certain point or unlocked the special ability,
    by this did you mean, the Game's Default Ability thing e.g. Franklin has special ability of slow car driving at high speed in traffic, Michele has bullet-time as special ability or something, and I don't remember about trevor.?

    About the game save file and your custom script to allocate the your add-on abilities, I think, this will do the job, and at the best, you can just add a note to user, if an old load game option is been used, then simply reload all the scripts(for scripthookv it's insert key on the keyboard I guess.) This allows the scripts to reload/restart on the run-time. Meaning users don't have to quit the game on the new session. (:

    And the last part Don't worry about the explanation, it's okay, neither my English is good, It's not my primary language, but I am trying to improvise this as well, so I can understand what others are trying to say. (:

  • Thanks for the advise @ashishcw , and sorry for the late reflection. Been working through the function and finally I can say I sort of figure it out. I have checked various native functions, and turns out, there isn't (at least as far as what I can more or less understand) a function that can return the value of the save slot player is using. My best guess is the STAT LOAD function (Oh yeah btw I turn to C++ as it somehow managed to load stats lol) however most of the time it only returns false without any regularities. My conclusion is that most likely there is not really an explicit "save" concept for this game. There are only combinations of stats values ready to be read as a whole. (Of course there should be a sth like "stats set index" written somewhere in the memory to tell the game which set of stats should be called but as far as I know there's no way to dig it out)
    So, for someone who is working on making addon stats to the save data, here I recommend the solution I use. As a reverse to the save mechanism, I use the STATS::STAT_GET_(whatever datatype u want to get) to call several stats(e.g. people u killed, time spent driving a car etc. Full list accessible at updates.rpf/common/data/spstatssetup.xml with openiv) and, say, put together to generate a (very likely if it is long enough) unique serial. Then u can output it in an ini file and put all ur custom stats data under their respective sector. At last, u can setup a script to generate the same format of serial after game start and compare if there is any match in the ini file. If all goes well, the match should lead u to the correct slot. The final step I have not tested practically, but I figure there will be less uncertain, for there should always be a way in any system to monitor the change of the files. So, we can set an eventhandler for the change of files under save folder(which can only mean saving games), and trigger the game to manipulate our ini file.
    That's how I make this function work. Hope it can help somebody out. And thanks again @ashishcw u have inspired me a lot!

  • @Maffine21 Nice finding mate.! and yes as it was mentioned earlier, so do I believe, game uses more than one set of functions to save the game progress. (:

    About custom config, I think, creating this and handling all your script generated triggers with this custom class, should offer you more flexibility and control over it's behavior. The same way you will be able to write the system generated pointers. :)

    I know this is a bit out of topic, but so was/am I working on the new mod, where the player's progress needs to be saved, majority on the custom flags(If player has reached a certain point etc) based on which, the script be able to generate the random events. The script I am aiming to make as smart as possible. Which will decide on the run-time of what level of difficulty, player be able to face.(In Game AI Driven Competition.) Let's see how it goes. (:

    About the last part, Thank you so much for mentioning my name like this, it's an honor, and be always there if you need any help around this. I will certainly help you as much as I could. BTW, keep me posted with your progress of the mod. (:

    P.s. Apologies for the wrong English, if there is/are any.

Log in to reply

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.