Help with Request_ConsoleCommand and Apostrophes

Discussion in 'Empyrion API' started by Hackasaurus Rex, Aug 2, 2017.

  1. Hackasaurus Rex

    Hackasaurus Rex Ensign

    Joined:
    Jul 15, 2017
    Messages:
    7
    Likes Received:
    0
    I'm trying to use the Request_ConsoleCommand game request as part of a simple notifications mod, and one of my notifications should look like,

    "Remember, safety in numbers. Always make sure you're allied with your main faction."

    My mod pulls a line from a .txt file, that being one of 'em, and sticks it in a chat message function. The resulting function looks like,

    gameAPI.Game_Request(CmdId.Request_ConsoleCommand, (ushort)CmdId.Request_InGameMessage_AllPlayers, new Eleon.Modding.PString(SAY 'Remember, safety in numbers. Always make sure you're allied with your main faction.'));

    Note the single quotes. This result ends up not doing the chat at all, and I'm thinking the string is escaping after "you're". I've tried using double quotes on the outside, and all messages fail using that, even strings without single quotes. I think it needs single quotes. But for aesthetic reasons, I'd like to try to keep the apostrophes in the notifications. EAH seems to have figured it out with their UI chat messages and the timetable messages. I've also attempted to escape them on the .txt file with the backslashes, but those had the same result.

    TL;DR: My string is escaping itself attempting to use an apostrophe. Double quotes surrounding the string doesn't work, neither does escaping them with back slashes in the .txt file.

    Apologies with the formatting, I can't seem to find any sort of code tags. Any help is appreciated, thank you.
     
    #1
    Last edited: Aug 2, 2017
  2. Xango2000

    Xango2000 Captain

    Joined:
    Jun 15, 2016
    Messages:
    385
    Likes Received:
    202
    are you trying to do
    Code:
                    GameAPI.Game_Request(CmdId.Request_ConsoleCommand, (ushort)CmdId.Request_ConsoleCommand, new Eleon.Modding.PString("SAY '" + msg + "'"));
    
    Note: it writes a Telnet command you need to start the line with Say
    or
    Code:
    GameAPI.Game_Request(CmdId.Request_InGameMessage_AllPlayers, (ushort)CmdId.Request_InGameMessage_AllPlayers, new IdMsgPrio(Player, msg, Convert.ToByte(Priority), Duration));
    
    with
    Player = PlayerID or 0 for All players
    msg = 'Remember, safety in numbers. Always make sure you're allied with your main faction.'
    Priority = a number 0-2
    Duration = Duration in Seconds
     
    #2
  3. Hackasaurus Rex

    Hackasaurus Rex Ensign

    Joined:
    Jul 15, 2017
    Messages:
    7
    Likes Received:
    0
    I'm doing the telnet say command. I do have the "say" part in there, I forgot to add it in this thread. It's edited now.
     
    #3
  4. Xango2000

    Xango2000 Captain

    Joined:
    Jun 15, 2016
    Messages:
    385
    Likes Received:
    202
    say 'Remember, safety in numbers. Always make sure you''re allied with your main faction.'

    that isn't a double quote btw. it's 2 Apostrophes.
    tested in a telnet session, it works.
     
    #4
  5. Hackasaurus Rex

    Hackasaurus Rex Ensign

    Joined:
    Jul 15, 2017
    Messages:
    7
    Likes Received:
    0
    Huh- it works. Thank you. How'd you figure it out? I've noticed that in EAH when doing a scheduled chat, in the alert in the top right, it'd have two single quotes, but I've always thought it was a double quote, until now.
     
    #5
  6. Xango2000

    Xango2000 Captain

    Joined:
    Jun 15, 2016
    Messages:
    385
    Likes Received:
    202
    Googled it... Took me a few tries to get the right search parameters
     
    #6
  7. cmwhee

    cmwhee Commander

    Joined:
    Oct 31, 2016
    Messages:
    118
    Likes Received:
    72
    Did you eventually get this working, I can't get Request_ConsoleCommand to do anything but fire an error event
     
    #7
  8. Hackasaurus Rex

    Hackasaurus Rex Ensign

    Joined:
    Jul 15, 2017
    Messages:
    7
    Likes Received:
    0
    I did, can you paste your code in here?
     
    #8
  9. cmwhee

    cmwhee Commander

    Joined:
    Oct 31, 2016
    Messages:
    118
    Likes Received:
    72
    This was a problem with my code. It works fine

    Thanks!
     
    #9

Share This Page