|
7 registered members (3run, miwok, AndrewAMD, Quad, TipmyPip, fairtrader, 1 invisible),
637
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
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
Serious User
|
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
OP
Senior Member
|
OP
Senior Member
Joined: Jun 2008
Posts: 428
|
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
Serious User
|
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:
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
OP
Senior Member
|
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 
|
|
|
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
Serious User
|
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
OP
Senior Member
|
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); } }
|
|
|
|