Hello.
I have my server written in BGT.
Errors do not occur, but it does not work!
Writes that ping-1, as well as when chatting around the chat history, writes runtime error!
What could be the problem?
Help me please!
Client code:
#include "form.bgt"
#include "includes/logo.bgt"
#include "includes/m.bgt"
#include "includes/menu.bgt"
#include "includes/dlg.bgt"
#include "sound_pool.bgt"
string[] chat_history;
int chat_position;
string name="No name";
bool connecting = false;
network net;
network_event event;
void main()
{
show_game_window("Endless war");
set_sound_decryption_key("kidsdetki", true);
set_sound_storage("sounds.dat");
wait(1000);
net.setup_client(10, 100);
mainmenu();
}
void test()
{
dlgplay("test.wav");
}
void set_name()
{
name=input_box("Enter name","Please enter youre name: ","");
mainmenu();
}
void game()
{
net.connect("127.0.0.1", 4321);
while(true)
{
event=net.request();
if(event.type==event_connect)
{
speak("Welcome to the Endless war.");
break;
}
}
while(true)
{
event=net.request();
if(connecting==false)
{
net.send_reliable(0,"connect|"+name,0);
connecting=true;
}
if(key_pressed(KEY_F3))
{
double time=net.get_peer_average_round_trip_time(0);
speak("The ping took "+time+" milliseconds.");
}
if(key_down(KEY_LSHIFT) or key_down(KEY_RSHIFT) and key_pressed(KEY_SLASH))
net.send_reliable(0,"/who",0);
if(key_pressed(KEY_LBRACKET))
{
chat_position--;
if(chat_position<0)
chat_position=0;
speak(chat_history[chat_position]);
}
if(key_pressed(KEY_RBRACKET))
{
chat_position++;
if(chat_position>=chat_history.length)
chat_position=(chat_history.length-1);
speak(chat_history[chat_position]);
}
if(key_pressed(KEY_ESCAPE))
{
speak("Disconnecting");
net.send_reliable(0,"dc|"+name,0);
net.destroy();
mainmenu();
}
if(event.type==event_disconnect)
{
net.destroy();
mainmenu();
}
if(event.type==event_receive)
{
string[] msg=string_split(event.message,"|",true);
if(msg[0]=="chat")
{
string chmessage=msg[1]+" say: "+msg[2];
speak(chmessage);
chat_history.insert_last(chmessage);
}
if(msg[0]=="dc")
speak(msg[1]+" offline");
if(msg[0]=="connect")
speak(msg[1]+" online");
}
}
}
void chatbox()
{
audio_form form;
form.set_output_mode(active_sr());
form.create_window("Chat",false);
int chat=form.create_input_box("&chat");
int ok=form.create_button("&ok",true);
int cancel=form.create_button("&cancel",false,true);
form.focus(chat);
while(true)
{
wait(1);
form.monitor();
if(form.is_pressed(cancel))
{
speak("Canceled");
return;
}
if(form.is_pressed(ok))
{
if(form.get_text(chat)!="")
{
net.send_reliable(0,form.get_text(chat),0);
return;
}
else
{
speak("Canceled");
return;
}
}
}
}
Server code:
network host;
network_event event;
void main()
{
show_game_window("Server");
string port=input_box("Port", "What port should the server be on?","4321");
host.setup_server(string_to_number(port),10,100);
while(true)
{
event=host.request();
if(event.type==event_receive)
{
string[] msg=string_split(event.message,"|",true);
if(msg[0]=="connect")
host.send_reliable(0,event.message,0);
if(msg[0]=="who")
{
string whoms;
uint[] peers=host.get_peer_list();
if(peers.length>1) whoms=peers.length+" players online";
if(peers.length==1) whoms="No players online";
host.send_reliable(event.peer_id,"who|"+whoms,0);
}
if(msg[0]=="dc")
{
host.send_reliable(0,"dc|"+msg[1],0);
host.disconnect_peer(event.peer_id);
}
}
if(key_pressed(KEY_ESCAPE)) {
host.destroy();
exit();
wait(5);
}
wait(5);
}
}
Thanks in advance!

Thumbs up +1

My chat program

Download link

http://www.tdstudios.esy.es/chat2.rar

Thumbs up +1

Reely cool. going to download

Thumbs up +1

Please can you make it english, i want to understand what is going on when tts voice speaks.
Thankyou

Thumbs up +1

http://www.tdstudios.esy.es/chat2.rar

Thumbs up +1

If i try to log in to the acount that i created, it just keeps quiet.
What am i doing wrong?
And the options is not translated. please if you can translate it, do that
thanks

Thumbs up +1

Can anyone explain why my code does not work?

Thumbs up