GM:S 1.4 %USERPROFILE% is not working?[SOLVED]

Discussion in 'Programming' started by alper41, Mar 17, 2019.

  1. alper41

    alper41 Member

    Joined:
    Jul 5, 2018
    Posts:
    75
    Hello again, I'm facing a brand new problem, I want to add a steam cloud feature to my game, but %USERPROFILE% doesn't work, it also works when I type the user name of my computer instead of %USERPROFILE%

    Code:
    if steam_is_cloud_enabled_for_app()
    steam_file_write_file("ayarlar.ini","C:\Users\alper\AppData\Local\Alpha___Beta\ayarlar.ini")
    this code works but only works on my own computer

    Code:
    if steam_is_cloud_enabled_for_app()
    steam_file_write_file("ayarlar.ini","C:\Users\%USERPROFILE%\AppData\Local\Alpha___Beta\ayarlar.ini")
    not working
     
    Last edited: Mar 18, 2019 at 1:23 PM
  2. alper41

    alper41 Member

    Joined:
    Jul 5, 2018
    Posts:
    75
    Help me please
     
  3. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    788
    Help us help you by providing code that exhibit the problem.
     
  4. alper41

    alper41 Member

    Joined:
    Jul 5, 2018
    Posts:
    75
    I understand

    Code:
    if steam_is_cloud_enabled_for_app()
    steam_file_write_file("ayarlar.ini","C:\Users\alper\AppData\Local\Alpha___Beta\ayarlar.ini")
    this code works but only works on my own computer

    Code:
    if steam_is_cloud_enabled_for_app()
    steam_file_write_file("ayarlar.ini","C:\Users\%USERPROFILE%\AppData\Local\Alpha___Beta\ayarlar.ini")
    not working
     
  5. Vishnya

    Vishnya Member

    Joined:
    Jul 6, 2016
    Posts:
    55
    I think you should write
    Code:
    "%userprofile%\..."
    instead
    Code:
    "C:\Users\%userprofile%\..."
     
  6. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    788
    Not being at my computer with GMS right now but I'm not sure why %userprofile% would be expanded. Maybe it's supposed to by that function, but I would rather expect you need to use environtment_get_variable and concatenate strings to get the full path using its value.
     
  7. alper41

    alper41 Member

    Joined:
    Jul 5, 2018
    Posts:
    75
    Code:
    a = environment_get_variable("USERPROFILE\");
    
    if steam_is_cloud_enabled_for_app()
    steam_file_write_file("ayarlar.ini",a+"AppData\Local\Alpha___Beta\ayarlar.ini")
    I tried this way but it didn't work

    Code:
    Complie Message:
    
    Failed to find local file: AppData\Local\Alpha___Beta\ayarlar.ini
     
    Last edited: Mar 18, 2019 at 11:09 PM
  8. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    788
    You shouldn't have \ in the environment_get_variable() call, the name of it does not include a backslash. Maybe you can try
    Code:
    var userprofile = environment_get_variable("USERPROFILE");
    show_debug_message("USERPROFILE = " + userprofile);
    if (steam_is_cloud_enabled_for_app()) {
        steam_file_write_file("ayarlar.ini", userprofile + "\AppData\Local\Alpha___Beta\ayarlar.ini");
    }
    
     
    alper41 likes this.
  9. alper41

    alper41 Member

    Joined:
    Jul 5, 2018
    Posts:
    75
    Thanks thanks, worked
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice