///////////////////////////////
// mp_main.c
// by Superku, 2015
// [EDIT by Superku: removed e-mail]
///////////////////////////////
#define PRAGMA_PATH "gui"
#include <acknex.h>
#include <default.c>
#include "mp_helper.c"
#include "mp_chat.c"
#include "mp_weapons.c"
#include "mp_player.c"
var menu_panel_selected = 0;
BMAP* dserver_map = "dserver.tga";
BMAP* lanclient_map = "lancli.tga";
BMAP* onclient_map = "onlicli.tga";
BMAP* servclient_map = "servcli.tga";
function center_panel(PANEL* panel, BMAP* Bmap){
panel.pos_x = (screen_size.x - bmap_width(Bmap))/2;
panel.pos_y = (screen_size.y - bmap_height(Bmap))/2;
}
///////////////////////////////
...
function dserver_button(){
is_client = 0;
session_open("mpsession");
menu_panel_selected = 1;
}
function server_client_button(){
is_client = 1;
session_open("mpsession");
menu_panel_selected = 2;
}
function lanclient_button(){
session_connect("mpsession","");
menu_panel_selected = 3;
}
function online_client_button();
PANEL* dedicated_server_pan={
button(0,0,dserver_map,dserver_map,dserver_map,dserver_button,NULL,NULL);
button(0,78,servclient_map,servclient_map,servclient_map,server_client_button, NULL,NULL);
button(0,156,lanclient_map,lanclient_map,lanclient_map,lanclient_button, NULL,NULL);
button(0,234,onclient_map,onclient_map,onclient_map,online_client_button, NULL,NULL);
flags = SHOW;
}
function online_client_button(){
set(txt_ip_input,SHOW);
txt_ip_input.pos_x = screen_size.x/2;
txt_ip_input.pos_y = screen_size.y*0.334;
reset(dedicated_server_pan, SHOW);
ip_input();
while(!key_enter)
{
DEBUG_VAR(total_frames,300);
if(key_ctrl) inkey_active = 0;
if(!key_ctrl || !key_v) key_ctrl_v_off = 1;
else
{
if(key_ctrl_v_off)
{
key_ctrl_v_off = 0;
clipboard_get_string(str_ip_address);
wait(1);
ip_input();
}
}
wait(1);
}
str_cpy((txt_ip_input.pstring)[2],"Trying to connect to address...");
wait(2);
session_connect("mpsession",str_ip_address);
menu_panel_selected = 4;
}
////////////////////////////////////////192.168.0.101
void main()
{
fps_max = 60;
vec_set(screen_color,COLOR_BLACK);
vec_set(sky_color,COLOR_BLACK);
sun_light = 50;
video_mode = 8;
video_aspect = 1.777;
camera.clip_near = 2;
camera.clip_far = 10000;
random_seed(0);
init_dplay_settings(); // call this function before the first wait() instruction
wait(1);
draw_textmode("Arial",1,20,100);
// basic game menu stuff
mouse_mode = 2;
while(menu_panel_selected == 0) // server or client?
{
vec_set(mouse_pos,mouse_cursor);
center_panel(dedicated_server_pan, dserver_map);
wait(1);
}
reset(dedicated_server_pan, SHOW);
dplay_level_load("map1.wmb"); // use this function to load the first multiplayer level
weapon_models_init();
set(txt_chat_main,SHOW);
if(connection != 2) init_server();
else init_client();
wait(1);
if(is_client)
{
spawn_get_position(temp);
player = ent_create("guard.mdl",temp,fnc_player);
while(player.client_id != dplay_id)
{
draw_text(str_printf(NULL,"Waiting for Player Creation... %.3f",(double)player.client_id),20,20,COLOR_WHITE);
wait(1);
}
if(connection != 2)
{
int i;
/*if(connection == 3)
{
i = player_id_get(0);
if(i > 0) str_cpy(str_pl_names[i-1],"Server Player");
}*/
for(i = 0; i < 2; i++)
{
spawn_get_position(temp);
you = ent_create("guard.mdl",temp,fnc_player);
your.ai_controlled = 1+i;
}
}
}
}
////////////////////////////////////////