Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
7 registered members (3run, miwok, AndrewAMD, Quad, TipmyPip, fairtrader, 1 invisible), 637 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
[ANET] Panel creation #293356
10/10/09 21:33
10/10/09 21:33
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
Hi,

how does it work if a client creates a runtime panel (paint something) and all other clients should see what he has created or painted?

Greets

Re: [ANET] Panel creation [Re: Rasch] #293366
10/11/09 00:52
10/11/09 00:52
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
send the location of the cursor and run the painting function on all clients ii guess.. am wayy to tired to acutually think of other methods or if this would work, i'll reply tomorrow if you dont get a better reply though wink

Re: [ANET] Panel creation [Re: darkinferno] #293384
10/11/09 08:24
10/11/09 08:24
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
If you change the color of a pixel, send the new color to the other participants.

You could create a string that contains: [x position] [y position] [color blue] [color red] [color green]

And send it as event (the string as msg paramter).


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [ANET] Panel creation [Re: Dark_samurai] #293391
10/11/09 09:06
10/11/09 09:06
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
Code:
BMAP* malpunkt = "#5x5x16"; 

function paint(var mouse_pos)
{
	bmap_fill(malpunkt,vector(0,0,0),100);
	
	PANEL* paint_panel = pan_create("bmap = malpunkt;",1);
	vec_set(paint_panel.pos_x, mouse_pos.x);
	set(paint_panel,SHOW);
}

function main()
{
	enet_init(); // enet initialisieren
	enet_svset_event(21,_str("paint")); // Malfunktion
	
	while(enet_get_connection() > 0) // solange ich ne Verbindung habe!
	{
		//...
		if(mouse_left)
		{
			enet_clsend_event(21,_str("mouse_pos"),-1);
		}
		wait(1);
	}
}



The problem is if i set: enet_svset_event(21,_str("paint"));
It runs one the client/server but not on normal clients. And clients cant use the function.

If iset it to: enet_clset_event(21,_str("paint"));
It works for nothing.

What do i do wrong?

Re: [ANET] Panel creation [Re: Rasch] #293398
10/11/09 10:03
10/11/09 10:03
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
You have to register the event also on the clients. And your event function is wrong. An event function always needs to have the same two parameters: var sender, STRING* msg. You can't send a variable directly with an event, you have to save it into the msg STRING instead:

Code:
BMAP* malpunkt = "#5x5x16"; 

function paint(var sender, STRING* msg)
{
	if(sender == enet_get_clientid()) return;
	bmap_fill(malpunkt,vector(0,0,0),100);
	
	PANEL* paint_panel = pan_create("bmap = malpunkt;",1);
	vec_set(paint_panel.pos_x, mouse_pos.x);
	set(paint_panel,SHOW);
}

function main()
{
	enet_init(); // enet initialisieren
	enet_svset_event(21,_str("paint")); // Malfunktion
	enet_clset_event(21,_str("paint"));
	
	while(enet_get_connection() > 0) // solange ich ne Verbindung habe!
	{
		//...
		if(mouse_left)
		{
			STRING* data_str;
			//copy the mouse_pos into data_str here (use str_for_var)
			enet_clsend_event(21,data_str,-1);
		}
		wait(1);
	}
}



Code not tested!


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [ANET] Panel creation [Re: Dark_samurai] #293533
10/12/09 08:44
10/12/09 08:44
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
Alrigh. Didnt know that i can set the same events with same number. But the function str_for_var doesnt exist i at the moment dont know how to convert my mouse_pos into the STRING.

I get a error msg.

Just one more hole in my head grin

Re: [ANET] Panel creation [Re: Rasch] #293577
10/12/09 15:06
10/12/09 15:06
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Yes they changed the name to str_for_num. I forgot that.

Here is the manual page: http://www.conitec.net/beta/astr_for_num.htm


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [ANET] Panel creation [Re: Dark_samurai] #293888
10/14/09 15:47
10/14/09 15:47
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
Ok i tried everything now but everytime i click mouse_left it says error in main() Something still must be wrong but cant find the problem. laugh

Thanks

Re: [ANET] Panel creation [Re: Rasch] #293898
10/14/09 16:40
10/14/09 16:40
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Please post your current code.


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [ANET] Panel creation [Re: Dark_samurai] #293924
10/14/09 19:55
10/14/09 19:55
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
function paint(var sender, STRING* msg)
{
if(sender == enet_get_clientid()) return;
bmap_fill(malpunkt,vector(0,0,0),100);

PANEL* paint_panel = pan_create("bmap = malpunkt;",1);
vec_set(paint_panel.pos_x, mouse_pos.x);
set(paint_panel,SHOW);
}

function main()
{
fps_max = 60;
video_mode = 7;
video_depth = 32;
vec_set(screen_color,vector(255,255,255));

mouse_func();

on_enter = chat_input_start;
//on_mouse_left = paint;

enet_init(); // enet initialisieren

enet_svset_event(16,_str("client_connected")); // Infoverteiler Event - User Event
enet_svset_event(17,_str("client_leave")); // Client hat Spiel verlassen
enet_svset_event(18,_str("server_shutdown")); // Server Shutdown kick von allen Clients
enet_svset_event(19,_str("connect_msg")); // Info wer sich mit dem Server vebunden hat
enet_svset_event(20,_str("chat_msg")); // Chateingabe Funktion
enet_svset_event(21,_str("paint")); // Malfunktion
enet_clset_event(21,_str("paint"));
enet_svset_event(EVENT_DISCONNECTED,_str("client_disconnected")); // Server Event wenn jemand disconnected.
enet_clset_event(EVENT_CONNECTED,_str("connected_with_server")); // Client-Event beim Verbinden von Client

while(1)
{
if(key_1)
{
enet_init_server(port,max_players,_str("")); // server start
wait(4);
enet_init_client(_str("localhost"),port,_str("")); // client start
break;
}
if(key_2)
{
enet_init_client(_str("localhost"),port,_str("")); // client start
break;
}
wait(1);
}

while(enet_get_connection() > 0) // solange ich ne Verbindung habe!
{
enet_connection = enet_get_connection();
clientid = enet_get_clientid();
ping = enet_get_ping();

if(mouse_left)
{
var temp;
STRING* data_str;
vec_set(temp, mouse_pos);
str_for_num(data_str, temp);
enet_clsend_event(21,_str("data_str"),-1);
}

if(key_esc)
{
enet_clsend_event(17,_str(clientid),-2);
//client_leave(clientid);
break;
}

wait(1);
}

on_esc = NULL;

if(clientid > 0)
{
str_cpy(zeile4, "#80");
str_cpy(zeile3, "#80");
str_cpy(zeile2, "#80");
str_cpy(zeile1, "Disconnected. Press ESC to close application");

while(key_esc != 1)
{
wait(1);
}

wait(-0.1);
sys_exit(0);
}
}

Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1