#include <litec.h>
#include <acknex.h>
#include <acknet.h>
#include <windows.h>
STRING* devonlively_com= "1##.###.###.#5";//ip address of my website
STRING* temp_str="";
TEXT* ip_info={
layer = 1;pos_x = 10;pos_y = 10;string = temp_str;flags = SHOW;}
...
function main()
{
dplay_port = 7777;
if (!connection) { // not started with -cl / -sv -cl?
if (!session_connect(app_name,devonlively_com)){ // no client found on the localhost?
if(result == 0)session_open(app_name); // start as server
}
}
do { wait(1); }
while (dplay_status < 2); // wait until the session is opened or joined
dplay_entrate = 4; // 16 ticks/4 = 4 updates per second
dplay_smooth = 0; // dead reckoning not needed
dplay_localfunction = 2;
level_load (NULL);
vec_set(camera.x, vector (-600, 0, 100)); // set a proper camera position
if (connection & CONNECT_SERVER) { // this instance of the game runs on the server
video_window(0,0,0,"Server");
ent_create ("link_0.mdl",vector(100,50,40),player_move); // then create the red guard!
str_cpy(temp_str,server_name);
str_cat(temp_str," has the IP: ");
str_cat(temp_str,server_ip);
str_cat(temp_str," ");
str_cat(temp_str,session_name);
} else { // otherwise, it runs on a connected client
video_window(0,0,0,player_name);
random_seed(0); // allow random player positions
ent_create ("link_0.mdl",vector(-100+random(200),-50+random(100),40),player_move); // create the blue guard
str_cpy(temp_str,dplay_id);
}
}