Results 1 to 16 of 16
  1. #1
    MSgt. Shooter Person
    Join Date
    Nov 2009
    Posts
    57

    Default Reading an external file

    Hi ppl,

    Is it possible to read data from an external file? It doesn't really matter what type it is, but txt would be preferable (or at least something with plain text inside it).

    The idea is that a web page modifies a certain local file, and that on speceific moments in the game, the game read it out and does stuff with the data it got from the file.

    Anyone know how I would be able to do this?

    Thanks!

  2. #2
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    Not without writing a DLLBind to do it.
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  3. #3
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Posts
    128

    Default

    (1) UDK can read configs. (the ini files) but only on startup

    (2) If you want to communicate with a web page, better use TCPLink
    Theres even an example with communicating to web page (http://udn.epicgames.com/Three/TcpLink.html )
    Also a web server ( http://udn.epicgames.com/Three/WebServer.html ) - but i dont know what it does.

  4. #4
    MSgt. Shooter Person
    Join Date
    Nov 2009
    Posts
    57

    Default

    Quote Originally Posted by Demestotenes View Post
    (1) UDK can read configs. (the ini files) but only on startup

    (2) If you want to communicate with a web page, better use TCPLink
    Theres even an example with communicating to web page (http://udn.epicgames.com/Three/TcpLink.html )
    Also a web server ( http://udn.epicgames.com/Three/WebServer.html ) - but i dont know what it does.
    I've been trying to figure out how to use TCPlink. But I can't figure it out. I plan to use it to read data from a website or java based web application and use the read data ingame to change the players inventory (for example). Anyone know how I could use TCPlink for that? The most optimal situation would be that I could integrate some kind of command into kismet that I can trigger the reading of data through kismet or something likke that.

    Could anyone lend me a hand?
    Last edited by Kratilim; 06-22-2010 at 08:47 AM.

  5. #5
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Posts
    128

    Default

    Can you run your own program on the server you use?

  6. #6
    MSgt. Shooter Person
    Join Date
    Nov 2009
    Posts
    57

    Default

    Quote Originally Posted by Demestotenes View Post
    Can you run your own program on the server you use?
    What exactly do you meen?

  7. #7
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Posts
    128

    Default

    Can you run your own .exe on the remote web server?

  8. #8
    MSgt. Shooter Person
    Join Date
    Nov 2009
    Posts
    57

    Default

    Quote Originally Posted by Demestotenes View Post
    Can you run your own .exe on the remote web server?
    Not really no. I must confess that I'm still exploring the possibility if it can work at all. If I know it can work, then I can start creating the web based app. The way the player would use it is that the player uses the web based app to communicate with other players, trade in inventory items and what not, and communicate that back to unreal to modify the player appropriately.

    That is what I'd like to accomplish. If it can work, I'm going to ask a friend of mine to create the web based stuff for me. But I want to know if its possible at all first. (this stufff is for a school project btw)

  9. #9
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Posts
    128

    Default

    Theres a quick solution for making webserver-to-UDK data transfer.
    ( http://udn.epicgames.com/Three/TcpLink.html )
    At the end of this page, theres example code to download. Use the class TcpLinkClient.
    It automatically requests a webpage in HTTP protocol and then gets the HTML text.

    You could make a PHP script on your page, which would create the appropirate HTML file (and it would be dled by UDK)

    Using that example code on google.com i got the following result. The HTML page is downloaded.
    ScriptLog: [TcpLinkClient] Resolving: www.google.com
    ScriptLog: Create link
    ScriptLog: [TcpLinkClient] www.google.com resolved to 74.125.39.99:0
    ScriptLog: [TcpLinkClient] Bound to port: 49940
    Log: CheckConnectionAttempt: Connection attempt has not yet completed.
    Log: CheckConnectionAttempt: Connection attempt has not yet completed.
    Log: CheckConnectionAttempt: Connection attempt has not yet completed.
    Log: CheckConnectionAttempt: Connection attempt has not yet completed.
    ScriptLog: [TcpLinkClient] event opened
    ScriptLog: [TcpLinkClient] Sending simple HTTP query
    ScriptLog: [TcpLinkClient] end HTTP query
    ScriptLog: [TcpLinkClient] ReceivedText:: HTTP/1.0 302 Found
    Location: http://www.google.pl/
    Cache-Control: private
    Content-Type: text/html; charset=UTF-8
    Set-Cookie: PREF=ID=d8a76e6020ebfee0:TM=1277212262:LM=12772122 62:S=qONC9I6eKKRKk3lW; expires=Thu, 21-Jun-2012 13:11:02 GMT; path=/; domain=.google.com
    Set-Cookie: NID=36=eZgu1WTeZJgbi23qYJ0CXOP8iUDckhbrOdTKcrBP9QS vxUPtZDPZh_-_Upxnbzoa2V4s1rh0z0BXDxRaWlwr3Gn65wYOr_Ot5_fww-QUXcECZuhzltCPhDZwPj1VOyy8; expires=Wed
    , 22-Dec-2010 13:11:02 GMT; path=/; domain=.google.com; HttpOnly
    Date: Tue, 22 Jun 2010 13:11:02 GMT
    Server: gws
    Content-Length: 218
    X-XSS-Protection: 1; mode=block

    <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
    <TITLE>302 Moved</TITLE></HEAD><BODY>
    <H1>302 Moved</H1>
    The document has moved
    <A HREF="http://www.google.pl/">here</A>.
    </BODY></HTML>


    ScriptLog: [TcpLinkClient] event closed

  10. #10
    MSgt. Shooter Person
    Join Date
    Nov 2009
    Posts
    57

    Default

    Quote Originally Posted by Demestotenes View Post
    Theres a quick solution for making webserver-to-UDK data transfer.
    ( http://udn.epicgames.com/Three/TcpLink.html )
    At the end of this page, theres example code to download. Use the class TcpLinkClient.
    It automatically requests a webpage in HTTP protocol and then gets the HTML text.

    You could make a PHP script on your page, which would create the appropirate HTML file (and it would be dled by UDK)

    Using that example code on google.com i got the following result. The HTML page is downloaded.
    This is probably a very noobish question... But how do I make sure it actually uses/calls the TCPLinkClient script? Where do I call uppon it to make sure it reads google.com? When I put the script in my script folder, it does nothing by itself.

  11. #11
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Posts
    128

    Default

    I placed an exec function in GameInfo and then called it with console.
    Code:
    class DemeUIGame extends GameInfo;
    
    exec function CreateLink()
    {
    	 Spawn(class'TcpLinkClient');
    	`Log("Create link");
    }
    
    DefaultProperties
    { 
    	PlayerControllerClass=class'DemeUIPlayerController'
    	HUDType=class'DemeUIHud'
    }

  12. #12
    MSgt. Shooter Person
    Join Date
    Nov 2009
    Posts
    57

    Default

    Quote Originally Posted by Demestotenes View Post
    I placed an exec function in GameInfo and then called it with console.
    Code:
    class DemeUIGame extends GameInfo;
    
    exec function CreateLink()
    {
    	 Spawn(class'TcpLinkClient');
    	`Log("Create link");
    }
    
    DefaultProperties
    { 
    	PlayerControllerClass=class'DemeUIPlayerController'
    	HUDType=class'DemeUIHud'
    }
    Thanks!

    Now for the next thing. Since XML would be the most usefull way to read/write data. Is there a way to read out XML data and assign the read values to specific strings and such? In other words, Sectioning off parts of what it reads as seperate data.

  13. #13
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Posts
    128

    Default

    There are alot of helpful functions for string processing
    http://udn.epicgames.com/Three/Strin...ealScript.html

  14. #14
    Skaarj
    Join Date
    Feb 2010
    Location
    Norway
    Posts
    21

    Default

    Quote Originally Posted by Kratilim View Post
    Since XML would be the most usefull way to read/write data. Is there a way to read out XML data and assign the read values to specific strings and such? In other words, Sectioning off parts of what it reads as seperate data.
    It is doable, but it involves C++ programming.
    Just done it myself, made a DLL that reads and writes to a XML file.
    Used a premade library in C++ called TinyXML.
    http://www.grinninglizard.com/tinyxmldocs/index.html
    and integrated that with the example code for DLLbind from the UDN pages.

  15. #15
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    Quote Originally Posted by Kratilim View Post
    Thanks!

    Now for the next thing. Since XML would be the most usefull way to read/write data. Is there a way to read out XML data and assign the read values to specific strings and such? In other words, Sectioning off parts of what it reads as seperate data.
    XML is very, very rarely useful or desireable.
    http://www.ericbla.de http://www.dungeondefenders.com http://en.wikipedia.org/wiki/Warm_Gun http://www.rekoil.com http://www.groundbranch.com

    - Please don't send me private messages asking programming questions, those would be better asked on the Programming forum here. Thanks

  16. #16
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Posts
    128

    Default

    Quote Originally Posted by Blade[UG] View Post
    XML is very, very rarely useful or desireable.
    Yes
    I would rather make it like UDK's configs
    variable_name=value
    other_var=other_value
    ...
    and then add a switch-case analyser for those files.
    Code:
    switch(VarName)
    {
    case "MyInt":
    MyInt = int(VarValue);
    break;
    case "SomeOtherInt":
    SomeOtherInt = int(VarValue);
    break;
    }
    Or maybe utilise name somehow ( i dont know, but maybe its possible to assign a variable just knowing its name (during runtime).


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.