mp_template_v2 Help

Posted By: DLively

mp_template_v2 Help - 07/14/15 18:28

Hi There.

Im using the new multiplayer template from the latest AUM 114.

I am trying to convert the number pressing to buttons, as to make a more appealing menu..

I've got everything working fine, besides one small thing...

If you've used the template you'd know that when you start a dedicated server that is_client = !key_1; // or 1 if you've pressed 2 and 0 if you've pressed 1

This is my Mod:
Code:
///////////////////////////////
// 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;
			}
		}
	}
}

////////////////////////////////////////



Basically, it when i connect through online connect or lan connect, it just gives a topview like the server view,Adds the clients, but there is no fps view

any help or thoughts?
Posted By: DLively

Re: mp_template_v2 Help - 07/14/15 19:12

Also, what is the reason for invalid time stamps?
Posted By: EpsiloN

Re: mp_template_v2 Help - 07/14/15 21:36

I havent used the template and I'm not familiar with it, but my guess is that it joins, but doesnt act as a client. You probably are missing some definition somewhere, that this app should be a client app...

Here's my implementation (not a real template, but more like a base for MP projects):
Multiplayer - Basic Extensive Tutorial
Posted By: Superku

Re: mp_template_v2 Help - 07/17/15 15:25

"there is no fps view"
You mean on the dedicated server? That's the point of it, yes. Or do you mean the clients themselves?

Btw. you need to disable mouse_mode again after your selection, otherwise you should not be able to rotate the player.

"Also, what is the reason for invalid time stamps?"
When do you get those error messages precisely?
Posted By: DLively

Re: mp_template_v2 Help - 07/28/15 23:22

Sorry for the delay, I've been very busy.

adding "is_client = 1;" to function lanclient_button() fixed it

The time stamps (what I suspect) are caused when about 4 or so people connect to the server.
Posted By: DLively

Re: mp_template_v2 Help - 07/29/15 03:41

rewind_do: invalid time stamp

that is the error. it crashes the server.
I have not yet seen the error when there is only a server running...
the error is produced when there is one or more clients, and we all get them at the same time..

any thoughts?
Posted By: Superku

Re: mp_template_v2 Help - 07/29/15 06:50

That's strange but I think I should be able to fix that later today or tomorrow!
Does it happen when a new client connects or while playing?
Posted By: DLively

Re: mp_template_v2 Help - 07/29/15 21:54

Sa-weet laugh I noticed that it generally only happens if there are clients connected or joining... laugh

Edit: the error mostly happens while playing though... and then the server gets the error message too.

Edit2: I also wanted to mention that I left a dedicated server running all night with no errors wink
Posted By: Superku

Re: mp_template_v2 Help - 07/30/15 18:33

Hm not completely sure what causes the issue but I think it's a one time issue when a new client connects and the game time isn't synchronized yet.
Please try the following patch:
http://superku.de/mp_template_v2patch1.zip
(EDIT: Updated with another micro patch.)
Posted By: DLively

Re: mp_template_v2 Help - 07/31/15 23:06

It seems to be working much better on my end anyway.. I haven't received the error message again but we only had it open for 10 minutes. maybe 15. But we received the errors long before that amount of time with the previous version.

So as far as I can tell its working the way it should.

I haven't tried the micro patch yet tho... Will let you know as soon as I do



BTW: Thanks for your help, and also -> Thanks for this awesome multiplayer template... Its very well coded laugh
© 2024 lite-C Forums