-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a method for retrieving global game/mission var #10
Comments
Using global variables in CLEO scripts is a bad practice and source of many issues. How can you guarantee correct results on a modified main.scm where global variables have different ids? |
While I understand that dealing with global variables is a bad practice in any context, it is what Rockstar decided to do, and it is the only way to check whether a specific mission has been passed or not. Some use cases include rewarding the player for passing a specific mission, activating a feature only after a certain amount of progress or displaying achievements. Based on your concern, I made a test with CLEO 2.0.0.6 on GTA 3:
This was the result: So it seems that either 0 is returned when accessing a global var that doesn't exist, or IniFile.WriteInt() is doing some magic. I tried to work around this limit by writing the values to an ini file with CLEO, which I was then going to access in my javascript with CLEO-Redux; but the File and ini plugins break when CLEO-Redux is loaded, and they cannot be used. |
those plugins will only work if original CLEO 2.0.0.6 is present in the same directory
most likely $THIS_DOES_NOT_EXIST was compiled to the first free id (one that is not declared in CustomVariables.ini) and all free variables get initialized to 0 by the default.
Right, also someone mentioned on Discord that usage of timer/counter opcodes require a global variable. I will look into what we can do here. |
Thank you! |
Script that reads from and writes to the global SCM variable from JS code: Download Example script that displays $ONMISSION variable on screen. To change the var value use import { readScmVariable, writeScmVariable } from "./cleo_plugins/scm";
// get variable offset for the current game
const ONMISSION_ID = getOnMissionId();
// display the variable value on screen
while (true) {
wait(250);
FxtStore.insert("scm_var", readScmVariable(ONMISSION_ID).toString());
Text.PrintNow("scm_var", 500, 1);
}
// $ONMISSION var has different id in each game
function getOnMissionId() {
switch (GAME) {
case "re3":
case "gta3":
case "gta3_unreal":
return 207;
case "reVC":
case "vc":
case "vc_unreal":
return 313;
case "sa":
case "sa_unreal":
return 409;
}
throw new Error("Unsupported game");
} |
In CLEO+ I created the opcodes for the local variable, it was pretty easy btw (internally, the game uses a pointer). I think this is important to add it natively in CLEO Redux. Global variables have always been bad practice, and now it's worse as a game patch can change their id (rare, but still), plus this problem that every game is an id, you have to search for ids etc. There are also more common cases, like using an available global variable, and in a patch it is no longer available, or another script uses too etc...
Remember that there are some stats that help with this, and it's a much better practice, some of them count how many missions of certain character has passed, or a certain mission has been completed, or how many cities have been unlocked etc. It doesn't solve all cases, but most of it (some more important). That is, before using global variable, make sure you need to use. |
Available with scm.ts |
No description provided.
The text was updated successfully, but these errors were encountered: