Re: Sending other peers variable values in bgt

2019-07-01 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: Sending other peers variable values in bgt

I'm trying to start my game, but the peer gets a bgt run time error. The players were created, correctly on both sides, but now I'm getting an error on the peer's side. Code is below.void create(){show_game_window("Game Server");tts_voice voice;if(host.setup_server(6500, 1, 100)==false){speak("Error. The server could not be set up.");exit();}speak("You are now hosting an online game.");network_event event;while(true){event=host.request();if(key_pressed(KEY_ESCAPE)){_online_=false;cmenu();}if(event.type==event_connect){p.play_stationary("sounds/message.wav",false);dlg("connections", host.connected_peers);}if(key_pressed(KEY_RETURN)){maxplay=host.connected_peers;maxplay+=1;//we increase the max count by 1 because of the host.for(i=0; i{players.insert_last(player());}host.send_reliable(0, "start "+maxplay, 0);dlg("players", "there are "+maxplay+" players");play=0;players[play].turn=true;if(maxplay<3)tim_music.restart();elsetim_music.pause();tim_crystal.restart();tim_gold.restart();tim_orb.restart();o_index=0;gamemenu();}}}void join(){show_game_window("Game Client");tts_voice voice;uint server_id=0;if(host.setup_client(1, 1)==false){speak("Error. The client could not be set up.");exit();}speak("Please enter the IP address or host name that you wish to connect to.");string address=input_box("Address", "Please enter the host name or address to connect to.");clipboard_read_text;if(address==""){speak("Exiting.");exit();}speak("Connecting, please wait.");host.connect(address, 6500);network_event event;while(true){event=host.request();if(key_pressed(KEY_ESCAPE)){_online_=false;cmenu();}if(event.type==event_connect){p.play_stationary("sounds/message.wav",false);dlg("Hell yeah!", "You are connected.");server_id=event.peer_id;}if(event.type==event_receive){string[] parsed=string_split(event.message," ",true);if(parsed[0]=="start" and parsed.length()==2){maxplay=string_to_number(parsed[1]);for(i=0; i{players.insert_last(player());}dlg("players", "there are "+players.length+" players");*I know that there is one less player than the length but this was a test to see if the players were actually created*play=0;*if I slash this next line, I get a dlg error. If I leave it in, I get an out of bounds error*players[play].turn=true;if(maxplay<3)tim_music.restart();elsetim_music.pause();tim_crystal.restart();tim_gold.restart();tim_orb.restart();o_index=0;gamemenu();}}if(event.type==event_disconnect){voice.speak_interrupt_wait("The connection to " + host.get_peer_address(event.peer_id) + " failed. Exiting.");exit();}if(key_down(KEY_LMENU) and key_pressed(KEY_F4)){host.destroy();voice.speak_interrupt_wait("Exiting.");exit();}wait(5);}}

URL: https://forum.audiogames.net/post/445427/#p445427




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Sending other peers variable values in bgt

2019-07-01 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: Sending other peers variable values in bgt

I'm trying to start my game, but the peer gets a bgt run time error. The players were created, correctly on both sides, but now I'm getting an error on the peer's side. Code is below.void create(){show_game_window("Game Server");tts_voice voice;if(host.setup_server(6500, 1, 100)==false){speak("Error. The server could not be set up.");exit();}speak("You are now hosting an online game.");network_event event;while(true){event=host.request();if(key_pressed(KEY_ESCAPE)){_online_=false;cmenu();}if(event.type==event_connect){p.play_stationary("sounds/message.wav",false);dlg("connections", host.connected_peers);}if(key_pressed(KEY_RETURN)){maxplay=host.connected_peers;maxplay+=1;//we increase the max count by 1 because of the host.for(i=0; i{players.insert_last(player());}host.send_reliable(0, "start "+maxplay, 0);dlg("players", "there are "+maxplay+" players");play=0;players[play].turn=true;if(maxplay<3)tim_music.restart();elsetim_music.pause();tim_crystal.restart();tim_gold.restart();tim_orb.restart();o_index=0;gamemenu();}}}void join(){show_game_window("Game Client");tts_voice voice;uint server_id=0;if(host.setup_client(1, 1)==false){speak("Error. The client could not be set up.");exit();}speak("Please enter the IP address or host name that you wish to connect to.");string address=input_box("Address", "Please enter the host name or address to connect to.");clipboard_read_text;if(address==""){speak("Exiting.");exit();}speak("Connecting, please wait.");host.connect(address, 6500);network_event event;while(true){event=host.request();if(key_pressed(KEY_ESCAPE)){_online_=false;cmenu();}if(event.type==event_connect){p.play_stationary("sounds/message.wav",false);dlg("Hell yeah!", "You are connected.");server_id=event.peer_id;}if(event.type==event_receive){string[] parsed=string_split(event.message," ",true);if(parsed[0]=="start" and parsed.length()==2){maxplay=string_to_number(parsed[1]);for(i=0; i{players.insert_last(player());}dlg("players", "there are "+players.length+" players");play=0;*if I slash this next line, I get a dlg error. If I leave it in, I get an out of bounds error*players[play].turn=true;if(maxplay<3)tim_music.restart();elsetim_music.pause();tim_crystal.restart();tim_gold.restart();tim_orb.restart();o_index=0;gamemenu();}}if(event.type==event_disconnect){voice.speak_interrupt_wait("The connection to " + host.get_peer_address(event.peer_id) + " failed. Exiting.");exit();}if(key_down(KEY_LMENU) and key_pressed(KEY_F4)){host.destroy();voice.speak_interrupt_wait("Exiting.");exit();}wait(5);}}

URL: https://forum.audiogames.net/post/445427/#p445427




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Sending other peers variable values in bgt

2019-07-01 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Sending other peers variable values in bgt

Re: server, the server can be a peer. Have it so that the game only connects to the server, and have the server manage what gets sent to all the players / guests / peers / whatevers. This is kinda obnoxious because you have to divide up what the server does vs what the client does, and that can be a mess.

URL: https://forum.audiogames.net/post/445365/#p445365




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Sending other peers variable values in bgt

2019-07-01 Thread AudioGames . net Forum — Developers room : cmerry via Audiogames-reflector


  


Re: Sending other peers variable values in bgt

Hi. Here's how I'd personally do this. In your main loop.if(e.type==event_receive){string parsed=string_split(e.message," ",true);if(parsed[0]=="setx" and parsed.length()==2){x=string_to_number(parsed[1]);}}Hth.

URL: https://forum.audiogames.net/post/445355/#p445355




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Sending other peers variable values in bgt

2019-07-01 Thread AudioGames . net Forum — Developers room : cmerry via Audiogames-reflector


  


Re: Sending other peers variable values in bgt

Hi. Here's how I'd personally do this. In your main loop.if(e.type==event_receive){string parsed=string_split(e.message()," ",true);if(parsed[0]=="setx" and parsed.length()==2){x=string_to_number(parsed[1]);}}Hth.

URL: https://forum.audiogames.net/post/445355/#p445355




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Sending other peers variable values in bgt

2019-06-30 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Sending other peers variable values in bgt

I have 2 questions, one of which is not related to this topic but I don't want to create a separate topic. That question is: how hard would it be to use a server rather than peer to peer? My friend has a server, and peer to peer is very limited with more than 2 connected people, from what I know anyway.My question that is related to the topic: let's say I have a variable. Int x=15. Let's say the other person has int x=0. Can I somehow send a message to them to make their x equal my x without havign to specifically state, x=15 when I send my message? This way any time I want to send my x value, no matter what it is, theirs will be the same x value as well.

URL: https://forum.audiogames.net/post/445294/#p445294




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector