Closed Aldrin-John-Olaer-Manalansan closed 1 month ago
As mentioned in release log opcode 0A99 is no longer modifying game's working directory. Why do you mix build in opcodes with native function call of CreateDirectoryA? There is create_directory opcode in CLEO and it will work as expected with 0A99 used within same script. resolve_path opcode can be used to obtain absolute path if there is need for it.
Modified application working directory crashes game whenever it tries to load in some resources, as it expects it to be set to game root.
As mentioned in release log opcode 0A99 is no longer modifying game's working directory. Why do you mix build in opcodes with native function call of CreateDirectoryA? There is create_directory opcode in CLEO and it will work as expected with 0A99 used within same script. resolve_path opcode can be used to obtain absolute path if there is need for it.
Modified application working directory crashes game whenever it tries to load in some resources, as it expects it to be set to game root.
How can I resolve filepath to gta sa user directory? Can you help me fix this code?
{$CLEO}
{$USE file}
0000:
// 0A99: set_current_directory 1 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~USER Directory
0@ = Fs.ResolvePath("GTA San Andreas User Files")
0ACD: show_text_highpriority "path~n~%s" time 10000 0@
wait 10000
// Create Backup Directory if not exist
0AC6: 2@ = label @ChatLogBackupPath pointer
if 8AE4: not does_directory_exist 2@
then
if 0AE5: create_directory 2@ // succeeded
then 0ACD: show_text_highpriority "~y~Created Backup Directory" time 10000
else 0ACD: show_text_highpriority "~r~Failed to Create Backup Directory!" time 10000
end
end
//
0A93: terminate_this_custom_script
:ChatLogBackupPath
hex
"SAMP\\ChatLogs\0"
end
Modified application working directory crashes game whenever it tries to load in some resources, as it expects it to be set to game root.
It only crashes when the script does not put the working directory back to the root folder. But this workaround fixes the crashing problem at opcode 0A99:
Cleo 4.4.4:
{$CLEO}
{$USE file}
0000:
0A99: set_current_directory 1 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~USER Directory
// Create Backup Directory if not exist
0AC6: 2@ = label @ChatLogBackupPath pointer
if 8AE4: not does_directory_exist 2@
then
if 0AE5: create_directory 2@ // succeeded
then 0ACD: show_text_highpriority "~y~Created Backup Directory" time 10000
else 0ACD: show_text_highpriority "~r~Failed to Create Backup Directory!" time 10000
end
end
0A99: set_current_directory 0 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Root Directory
//
0A93: terminate_this_custom_script
:ChatLogBackupPath
hex
"SAMP\\ChatLogs\0"
end
In CLEO5 you should be able to refer to the folder using virtual path prefix user:\
that resolves to your user settings folder:
{$CLEO}
{$USE file}
// Create Backup Directory if not exist
if not does_directory_exist "user:\\SAMP\\ChatLogs"
then
if create_directory "user:\\SAMP\\ChatLogs" // succeeded
then print_string_now "~y~Created Backup Directory" time 10000
else print_string_now "~r~Failed to Create Backup Directory!" time 10000
end
end
terminate_this_custom_script
In CLEO5 you should be able to refer to the folder using virtual path prefix
user:\
that resolves to your user settings folder:{$CLEO} {$USE file} // Create Backup Directory if not exist if not does_directory_exist "user:\\SAMP\\ChatLogs" then if create_directory "user:\\SAMP\\ChatLogs" // succeeded then print_string_now "~y~Created Backup Directory" time 10000 else print_string_now "~r~Failed to Create Backup Directory!" time 10000 end end terminate_this_custom_script
Exactly what I need, Thank you!
I have a script that is supposed to create a folder tree inside %Documents%\GTA San Andreas User Files folder:
I'm expecting this script to create folder structure like this: %Documents%\GTA San Andreas User Files\SAMP\ChatLogs
But the script creates the folders inside the GTA Game Root Folder: %GTASA Game Folder%\SAMP\ChatLogs
According to Opcode Database Documentation: I tried passing a value of 0 or 1 at opcode 0A99 but it still does not set working directory at gtasa user files folder.
This is strange because at cleo 4.4.1, opcode 0A99 is working properly. But in Cleo 5, it doesn't work the way I want it to be. Any Ideas how to fix it without specifying the entire absolute path? 0A99: set_current_directory "C:\Users\mypc\Documents\GTA San Andreas User Files"