1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GM:S 1.4 How to use the get_string_async correctly

Discussion in 'Programming' started by xShadowsx, Jul 25, 2016.

  1. xShadowsx

    xShadowsx Guest

    I have been trying to implement this function im my project however whenever I try to enter the correct string it never performs the right command. It always returns "Unable to breach firewall", can someone fix this code please

    uskun = get_string_async("Breach Firewall with special password", "")
    if uskun = "shadowlord"
    {
    global.uskunfire = 0;
    suskun = 0;
    show_message_async("Firewall Successfully Breached...");
    }
    else
    {
    show_message_async("Unable to breach firewall");
    }
     
  2. Stubbjax

    Stubbjax Member

    Joined:
    Jun 22, 2016
    Posts:
    95
    Are you using an asyncronous event to read the input? You'd also need to retrieve the string from the data map in the relevant async event.

    The manual contains the information you need.
     
  3. xShadowsx

    xShadowsx Guest

    All I want it to do is to perform a function when the word shadowlord is entered, I found a function known as get_string, however it said it was used for debugging purposes and instead use the followiing function get_string_async. Im quite a noob and dont know how i would go about applying to my situation since all that example does is store a username if thats what it is.

    How would I add the map and assign it a string I want and how would I apply it to the if statement above.

    Please I need help...
     
  4. Stubbjax

    Stubbjax Member

    Joined:
    Jun 22, 2016
    Posts:
    95
    Have you even read this?
     
  5. xShadowsx

    xShadowsx Guest

    It always returns data structure doesnt exist...
     
  6. Stubbjax

    Stubbjax Member

    Joined:
    Jun 22, 2016
    Posts:
    95
    I don't see how, seeing as async_load is an inbuilt data structure that always exists (in the relevant async event).
     
  7. xShadowsx

    xShadowsx Guest

    ############################################################################################
    ERROR in
    action number 1
    of Mouse Event for Left Button
    for object Text:

    Data structure with index does not exist.
    at gml_Object_Text_LeftButtonDown_1 (line 2) - var i_d = ds_map_find_value(async_load, "id");
    ############################################################################################
     
  8. Stubbjax

    Stubbjax Member

    Joined:
    Jun 22, 2016
    Posts:
    95
     
  9. xShadowsx

    xShadowsx Guest

  10. Stubbjax

    Stubbjax Member

    Joined:
    Jun 22, 2016
    Posts:
    95
    Then why does that error message indicate that you are using a LeftButtonDown event?
     
  11. xShadowsx

    xShadowsx Guest

    Dont you put the whole code together in one event. Like this
    msg = get_string_async("What's your name?","Anon");
    var i_d = ds_map_find_value(async_load, "id");
    if i_d == msg
    {
    if ds_map_find_value(async_load, "status")
    {
    if ds_map_find_value(async_load, "result") != ""
    {
    global.Name = ds_map_find_value(async_load, "result");
    }
    }
    }
    Feels bad all I want is for my code to work. I understand bettter from examples..
     
  12. Stubbjax

    Stubbjax Member

    Joined:
    Jun 22, 2016
    Posts:
    95
    No, you do not. You put the get_string_async in the event you want to call the message from, and the handling of the input in the relevant async event. Had you actually read this like I suggested earlier, which explains exactly where to put which code, you wouldn't have to keep asking the same questions.
     
  13. xShadowsx

    xShadowsx Guest

    I am sorry I wasted your time stubbjax, up till now I did not know that the asynchronous Dialogs "EVENT" <======= had even existed and so I didnt know where to put the rest of the code.. So I am gonna go hit my head on a wall, thank you for your time and patience 0_0
     
  14. Stubbjax

    Stubbjax Member

    Joined:
    Jun 22, 2016
    Posts:
    95
    Not a problem; glad I could help! My style of assistance is more geared towards pointing people in the right direction rather than spoonfeeding the answer (you'll learn better that way). :)
     
  15. FeNniX

    FeNniX Member

    Joined:
    Jan 24, 2019
    Posts:
    16
    Will you spoonfeed me? How should I retrieve variable as soon as user inputed something in get_string_async?
     

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