Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

How do i call a tpclink script in game?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do i call a tpclink script in game?

    Like the title says i wanna make the tcplink client example to get executed in game for me to see if it works. But i dont really know how to implement it, im a total noob with uscript. I would really apreciate if someone could give me some guidanse on implementing a tcplink script step by step without assuming any knowldege in this matter. Thanks in advance.

  • #2
    Have you followed this tutorial?
    http://www.theballthegame.com/tutorialudk.htm

    Then you add these tcplink scripts in your project.

    In my project I've another c++ program that can send messages to udk via tcp/ip.

    Here's the code that send message to udk via tcp/ip.

    Code:
    #include <winsock2.h>
    #include <ws2tcpip.h>
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <assert.h>
    #include <math.h>
    #include <float.h>
    #include <limits.h>
    #include <time.h>
    #include <ctype.h>
     
    #ifdef _EiC
    #define WIN32
    #endif
    
    
    //using namespace std;
    #define HISTORY_LENGTH 5
    
    #define DEFAULT_BUFLEN 512
    #define DEFAULT_PORT "3742"
    #define DEFAULT_SERVER_IP "127.0.0.1"
    
    WSADATA wsaData;
    
    SOCKET ConnectSocket = INVALID_SOCKET;
    
    int SocketInit();
    
    int main(int argc, char** argv )
    {
    	SocketInit();
    	
    	int iResult = 0;
    
    	char sendbuf[512] = "CuteValue;1.0";
    	iResult = send(ConnectSocket, sendbuf, (int) strlen(sendbuf), 0);
    	if (iResult == SOCKET_ERROR) {
    		printf("send failed: %d\n", WSAGetLastError());
    		closesocket(ConnectSocket);
    		WSACleanup();
    	}
       return 0;
    }
    
    int SocketInit()
    {
    	int iResult;
    
    	// Initialize Winsock
    	iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
    	if (iResult != 0) {
    		printf("WSAStartup failed: %d\n", iResult);
    		return 0;
    	}
    	else		
    	{
    		printf("WSAStartup succeeded: %d\n", iResult);
    	}
    
    	struct addrinfo *result = NULL,
                    *ptr = NULL,
                    hints;
    
    	ZeroMemory( &hints, sizeof(hints) );
    	hints.ai_family = AF_UNSPEC;
    	hints.ai_socktype = SOCK_STREAM;
    	hints.ai_protocol = IPPROTO_TCP;
    
    	// Resolve the server address and port
    	iResult = getaddrinfo(DEFAULT_SERVER_IP, DEFAULT_PORT, &hints, &result);
    	if (iResult != 0) {
    		printf("getaddrinfo failed: %d\n", iResult);
    		WSACleanup();
    		return 0;
    	}
    	else
    		printf("getaddrinfo succeeded: %d\n", iResult);
    
    	// Attempt to connect to the first address returned by
    	// the call to getaddrinfo
    	ptr=result;
    
    	// Create a SOCKET for connecting to server
    	ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype, 
    		ptr->ai_protocol);
    
    	if (ConnectSocket == INVALID_SOCKET) {
    		printf("Error at socket(): %ld\n", WSAGetLastError());
    		freeaddrinfo(result);
    		WSACleanup();
    		return 1;
    	}
    
    	// Connect to server.
    	iResult = connect( ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen);
    	if (iResult == SOCKET_ERROR) {
    		closesocket(ConnectSocket);
    		ConnectSocket = INVALID_SOCKET;
    	}
    
    	// Should really try the next address returned by getaddrinfo
    	// if the connect call failed
    	// But for this simple example we just free the resources
    	// returned by getaddrinfo and print an error message
    
    	freeaddrinfo(result);
    
    	if (ConnectSocket == INVALID_SOCKET) {
    		printf("Unable to connect to server!\n");
    		WSACleanup();
    		getchar();
    		return 1;
    	}
    
    	//int recvbuflen = DEFAULT_BUFLEN;	
    
    	return 1;
    }
    change default port to the one specified in tcpserver script under default properties section and server ip to the ip of the pc running udk server.
    u will also need to put WS2_32.lib odbc32.lib odbccp32.lib those static libs to linker input section.

    and somewhere in your udk playercontroller script or some initialization script, spawn that tcp server class to start listening incoming message.

    Code:
    //declare TcpLinkServer
    var TcpLinkServer tcpLinkServer;
    
    
    simulated function PostBeginPlay()
    {
    	//spawn and init the class
    	tcpLinkServer = spawn(class'TcpLinkServer');
    	tcpLinkServer.TcpLinkInit();
    }

    Comment


    • #3
      Ok, i'll try that way, thanks you so much for the explanation. I'll post here if something comes up. Thnx again.

      Comment


      • #4
        k24101990

        is this online server?
        can u explain step and detail one by one
        can i take my game to public server without steam , Hamachi ,gamespy
        i want to create online game for 10-15 people

        Comment


        • #5
          Originally posted by k24101990 View Post
          is this online server?
          can u explain step and detail one by one
          can i take my game to public server without steam , Hamachi ,gamespy
          i want to create online game for 10-15 people
          I really want to do this for my game. For my game we want a 3 max co-op per game. we're only at the concept fase now and i have no idea how to set up multiplayer stuff...

          could anyone give me some tips?

          Comment


          • #6
            i belived it has many people want to do this
            i research about this
            found something but i don't understand
            DLLBind ---->what is this it connect with game online server isn't it?
            Server Bowser --->what is these
            MasterServer ---->whoeooo
            TCPLink ----> oh my god

            i don't know which on these use to create server public online without programs(steam)
            i confuse and try it's very hard to do something like these

            Comment


            • #7
              Originally posted by k24101990 View Post
              i belived it has many people want to do this
              i research about this
              found something but i don't understand
              DLLBind ---->what is this it connect with game online server isn't it?
              Server Bowser --->what is these
              MasterServer ---->whoeooo
              TCPLink ----> oh my god

              i don't know which on these use to create server public online without programs(steam)
              i confuse and try it's very hard to do something like these
              DLLBind is used to allow you to write C++ code that your UnrealScript code can execute.
              TCPLink is not that bad, its actually pretty straight forward. It just wraps up the sending of text over the TCP protocol.

              http://bettertech.gneu.org/blog/2011...ystem-for-udk/ << tutorial of TCPLink connecting to a web server.

              The Server browser and master server id need to understand context to respond to. Typically server browsers allow you to browse servers. Master Server is a label applied to the server that oversees all others, you would likely find these in online games that store high scores and the like.

              Comment


              • #8
                Step

                thank you bob it's clear in my mind

                i want to create Server pubplic what have i do with mygameinfo.uc
                mycontroller.uc mypawn.uc ..... ...... ....

                i'm a newbie about coder PHP C+ ASP
                it's hard for me to talk my game UDK on pubplic Server

                i want to make client to connect easy way without steam hamachi .....

                please give me step one by one please ...

                Comment


                • #9
                  I don't think you are on the same page. It sounds like you want to network the game with TCPLink, and that is not going to happen. I think the only way i can help you is if you actually explain what you want to do better.

                  I am also fairly sure that you wont be getting a "step one by one" walk through of it, because with my tutorial and the other ones out there you already have as much detail as will be provided.

                  Comment


                  • #10
                    actually i want to take my game to pubplic (online) without steam hamachi
                    how can i do that ?is it possible?
                    i don't know where i begin these?

                    one more what is Replication?
                    is it about online server?

                    Comment

                    Working...
                    X