2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: [Anet] I´ve a VServer.. but how to connect?
[Re: Espér]
#352259
01/02/11 15:21
01/02/11 15:21
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
Serious User
|
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
A command line is a string that is passed to the application at it's start. This way you can tell the application how to start before the application is loaded. You could make an option that could be "-ANetServer" and if that option is set, you start the application in video_screen = 0; mode and initialize the server. Example code:
function main()
{
if (str_stri(command_str,"-ANetServer"))
{
video_screen = 0;
StartServer();
}
else
{
StartClient();
}
}
Now how can you pass the command line option to your application? There are 2 ways: 1) During development through SED: Go in SED under Options->Preferences. There is an text box where you can add "-ANetServer" 2) After publishing: Create a batch file (.bat) with the text editor and insert the following line: YourAppName.exe -ANetServer (please correct me if I'm wrong, I'm not totally sure about the syntax!) Save the .bat file in the same folder as the .exe. And double click on the .bat to start the application.
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: [Anet] I´ve a VServer.. but how to connect?
[Re: Espér]
#352264
01/02/11 15:31
01/02/11 15:31
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
Serious User
|
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
Maybe there is an option for gamestudio to start even if no mouse is found. I don't know (you could try to search this in the forum and in the manual).
If you find no informations you could ask that in the Lite-C part of the forum or ask the developer (should be the last step, if nobody else knows the answer).
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: [Anet] I´ve a VServer.. but how to connect?
[Re: Espér]
#352275
01/02/11 16:43
01/02/11 16:43
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
Serious User
|
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
Does it work on your system at home with -nm -ANetServer?
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: [Anet] My first try at a Chat System.. some problems..
[Re: Dark_samurai]
#352282
01/02/11 18:12
01/02/11 18:12
|
Joined: Mar 2008
Posts: 2,247 Baden Württemberg, Germany
Espér
OP
Expert
|
OP
Expert
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
|
i think i´ll do the server stuff if i understand Anet a bit better.. I´ve two new problems.. 1.) i wrote a little Chat system. it works really well.. BUT.. after a bit of time, Acknex crashs without an error, it just says "Acknex isn´t working anymore"... Edit: I found out.. If i, as starter, write something when a client is online too.. the client crashes... Same thing if the client writes.. my game crashes.. Is there a way to stop that? 2.) Is there a way to call a string from the server? I just found enet_send_string... Or a way to ask from the game-starter, if a client has entered.. and then send the string again? Here´s my Chatcode:
function str_makeempty(var signcounter) //Empty the chat_in and fill it with a given number of spaces
{
str_cpy(chat_in, "");
while(signcounter > 0)
{
str_cat(chat_in, " ");
signcounter -= 1;
}
}
function wo_makeempty(var signcounter) //Empty the write_over and fill it with a given number of spaces
{
str_cpy(write_over, "");
while(signcounter > 0)
{
str_cat(write_over, " ");
signcounter -= 1;
}
}
void check_chathigh() // Check the high of the chat, and delete the upper rows if it is to high.
{
while(chat_check != 0)
{
if(chatpattern.pos_y < max_high)
{
delete_pos = str_stri(chatlog,"\n");
if(delete_pos)
{
str_clip(chatlog,delete_pos);
chatpattern.pos_y = max_high;
}
}
chat_check -= 1;
}
chat_check = 0;
}
void write_in() // Write received strings into the shown chatlog
{
if(str_cmpi(write_login, "") == 0) // write if a client has entered
{
str_cat(chatlog, write_login);
str_cat(chatlog, "\n");
str_cpy(write_login, "");
}
if(str_cmpi(chat_sav, "") == 0) // write messages
{
str_cat(chatlog, chat_sav);
str_cat(chatlog, "\n");
str_cpy(chat_sav, "");
}
}
function start_chatsystem()
{
// create login text
str_cat(write_login, spielername);
str_cat(write_login, " hat das Spiel betreten..! \n");
enet_send_string("write_login", BROADCAST);
// create variables and strings
chatpattern.pos_y = screen_size.y - 84;
chatwrite.pos_y = screen_size.y - 18;
set(chatpattern, SHOW);
set(chatwrite, SHOW);
str_cpy(write_over, "< ");
str_cat(write_over, spielername);
str_cat(write_over, " >");
str_cat(write_over, ": ");
str_cpy(write_name, write_over);
chatstart = 0;
line_len = 0;
delete_pos = 0;
max_high = screen_size.y - 192;
paragraph_len = str_len(write_over);
max_len = 100 - paragraph_len;
wait(1);
str_makeempty(max_len);
wo_makeempty(paragraph_len);
while(1)
{
write_in();
if(chatstart == 0 && inkey_active == 0 && key_m == 1)
{
inkey(chat_in);
chatstart = 1;
}
else if(chatstart == 1 && inkey_active == 0)
{
str_cpy(chat_out, chat_in);
line_len = str_len(chat_in);
if(str_cmpi(chat_in, "\w ")) //====================================== WHISPER Chat
{
// Not implemented yet
error("geflüstert!");
}
else //====================================== PUBLIC Chat
{
if(line_len > 50) // if the text has more than 50 signs
{
line_len -= 50; // cutout the first 50 signs and send them.
str_trunc(chat_in, line_len);
str_cat(chat_sav, write_name);
str_cat(chat_sav, chat_in);
enet_send_string("chat_sav", BROADCAST);
enet_send_var("chat_check", BROADCAST);
write_in();
wait(4);
str_cpy(chat_sav, ""); // cutout the last signs and send them.
str_cpy(chat_in, chat_out);
str_clip(chat_in,50);
str_cat(chat_sav, write_over);
str_cat(chat_sav, chat_in);
chat_check = 2;
enet_send_string("chat_sav", BROADCAST);
enet_send_var("chat_check", BROADCAST);
write_in();
wait(4);
}
else // 1 Line of text (less than 50 signs)
{
str_cat(chat_sav, write_name);
str_cat(chat_sav, chat_in);
wait(4);
chat_check = 1;
enet_send_string("chat_sav", BROADCAST);
enet_send_var("chat_check", BROADCAST);
write_in();
wait(4);
}
str_makeempty(100 - paragraph_len); // empty the chat_in string
str_cpy(chat_out, "");
}
chatstart = 0;
}
if(chat_check == 1)
{
chatpattern.pos_y -= 16;
check_chathigh();
}
else if(chat_check == 2)
{
chatpattern.pos_y -= 32;
check_chathigh();
}
wait(1);
}
}
function start_spieler(var conect_type) // Let the player type in his Name
{
namewrite.pos_x = (screen_size.x / 2) - 160;
namewrite.pos_y = (screen_size.y / 2) - 32;
textbitmaps.pos_x = namewrite.pos_x-20;
textbitmaps.pos_y = namewrite.pos_y-24;
set(namewrite, SHOW);
set(textbitmaps, SHOW);
inkey(spielername);
while(inkey_active == 1){wait(1);}
reset(namewrite, SHOW);
reset(textbitmaps, SHOW);
namewrite.pos_x = -5000;
textbitmaps.pos_x = -5000;
wait(2);
if(conect_type == 2)
{
enet_set_playername(spielername);
}
wait(2);
start_chatsystem();
}
Last edited by Espér; 01/02/11 19:13.
|
|
|
Re: [Anet] My first try at a Chat System.. some problems..
[Re: Espér]
#352291
01/02/11 19:13
01/02/11 19:13
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
Serious User
|
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
2) Look into enet_sv/clsend_event() I think it's exaclty what you need. 1) Please don't let the community search for coding mistakes if the code has already that size. Try to find out what is executed before it crashes (use the debugger or use the error() function to see what was called before the crash). But I would advice you to use enet_sv/clsend_event() instead of enet_send_string(). It would make your code much easier and cleaner => also bug searching will be easier then
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: [Anet] My first try at a Chat System.. some problems..
[Re: Dark_samurai]
#352305
01/02/11 19:58
01/02/11 19:58
|
Joined: Mar 2008
Posts: 2,247 Baden Württemberg, Germany
Espér
OP
Expert
|
OP
Expert
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
|
uhm.. i got it to work.. but only for the server.. the clients can´t read anything... *cry*
I really dn´t know what to need for wich connection type..
if(conecting_type == 2) //Send as Client
{
enet_clsend_event(18,chat_in,0,BROADCAST);
}
if(conecting_type == 1) //Send as Server/client
{
enet_svsend_event(16,chat_in,0,BROADCAST);
}
And the manual is really really bad documented in that...forget it.. got it to work .. however..
Last edited by Espér; 01/02/11 20:08.
|
|
|
|