Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Simple Chat - Should be easy to implement... #100878
12/03/06 18:00
12/03/06 18:00
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline OP
Expert
Germanunkol  Offline OP
Expert

Joined: Jun 2006
Posts: 2,640
Earth
I've tested this, and since I'm getting tired of chatting to myself (and my small brother was busy doing other stuff) I figured I'd share it now. It is a simple chat code in WDL, which hopefully should be easy to implement in your multiplayer projects. I did it just for fun, and to get more familiar with multiplayer concepts.
I'll update it if you give me good ideas as to how I could improve it. What I was thinking of was a list of conected players...?
Tell me what you think. you can enter chat mode on "c" and exit it on "esc". Enter sends the entered text... Right now, player names can only be given by the -pl command line option.
Test level is included.
Free to use.
Enjoy
rar:
http://files.filefront.com//;6291716;;/
zip:
http://files.filefront.com//;6291717;;/

Micha
ps: sorry, you need to create shortcuts and add -cl -sv and -cl still...


~"I never let school interfere with my education"~
-Mark Twain
Re: Simple Chat - Should be easy to implement... [Re: Germanunkol] #100879
12/03/06 19:10
12/03/06 19:10
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
Well this is a nice contribution Germanunkol ^^
I'm not an experted in coding a multiplayer game but it is a simple and yes easy to implant code

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: Simple Chat - Should be easy to implement... [Re: frazzle] #100880
12/03/06 21:42
12/03/06 21:42
Joined: Jun 2005
Posts: 4,875
broozar Offline
Expert
broozar  Offline
Expert

Joined: Jun 2005
Posts: 4,875
is it just me and win98 or why's the app always crashing after pressing the "c"-button?

Re: Simple Chat - Should be easy to implement... [Re: broozar] #100881
12/04/06 13:31
12/04/06 13:31
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline OP
Expert
Germanunkol  Offline OP
Expert

Joined: Jun 2006
Posts: 2,640
Earth
Even when you try it over LAN? maybe I should add that...: I wasn'T able to test it over internet yet, due to some router stuff... has anyone else tried it? over Lan? over the internet??


~"I never let school interfere with my education"~
-Mark Twain
Re: Simple Chat - Should be easy to implement... [Re: Germanunkol] #100882
12/06/06 20:12
12/06/06 20:12
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline OP
Expert
Germanunkol  Offline OP
Expert

Joined: Jun 2006
Posts: 2,640
Earth
Apperantly the chat works fine on XP, but has problems on windows 98... just so you don't use it on win 98 if you use it ... thx, DaBro0zar!

Micha


~"I never let school interfere with my education"~
-Mark Twain
Re: Simple Chat - Should be easy to implement... [Re: Germanunkol] #100883
03/13/07 18:42
03/13/07 18:42
Joined: Feb 2007
Posts: 40
S
SuperTux Offline
Newbie
SuperTux  Offline
Newbie
S

Joined: Feb 2007
Posts: 40
what must I change, thtat this code can work without the Levelload function (that means my Level load script can work and load the chat )

Re: Simple Chat - Should be easy to implement... [Re: SuperTux] #100884
03/13/07 18:57
03/13/07 18:57
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline OP
Expert
Germanunkol  Offline OP
Expert

Joined: Jun 2006
Posts: 2,640
Earth
Hi!
what you mean is that you want to load your own level, right?
actually, my level doesn't need to be loaded, if I remember right. And it doesn't matter which level you load, you can load your own level as well.
What you have to do is this:

copy and paste all of my code into your main code file (before your function main)
put the content of my function main into your main, and delete mine. (it won't like it if you have 2 main functions...)

then delete my level_load instruction, cause you'll only need yours...

is this what you meant?
Micha


~"I never let school interfere with my education"~
-Mark Twain
Re: Simple Chat - Should be easy to implement... [Re: Germanunkol] #100885
03/14/07 14:54
03/14/07 14:54
Joined: Feb 2007
Posts: 40
S
SuperTux Offline
Newbie
SuperTux  Offline
Newbie
S

Joined: Feb 2007
Posts: 40
YES that is it.
Excuse my Bad Englisch, but I'm a badner from Germany and

Mir könne alles außer Hochdeutsch und das bezieht sich auch aufs Englisch das net könne ;-)

Re: Simple Chat - Should be easy to implement... [Re: SuperTux] #100886
03/14/07 15:45
03/14/07 15:45
Joined: Feb 2007
Posts: 40
S
SuperTux Offline
Newbie
SuperTux  Offline
Newbie
S

Joined: Feb 2007
Posts: 40
there is an Error :
<text^messeage_text {>

Double Defenition message_text TEXT TEXT


and so on

ok than i post the code
Code:

////////////////////////////////////////////////////////////////////////
// A6 main wdl:
// Created by WED.
////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
// The PATH keyword gives directories where template files can be found.
path "C:\\Programme\\GStudio6\\template_6"; // Path to A6 templates directory
path "C:\\Programme\\GStudio6\\template_6\\code"; // Path to A6 template code subdirectory
path "C:\\Programme\\GStudio6\\template_6\\images"; // Path to A6 template image subdirectory
path "C:\\Programme\\GStudio6\\template_6\\sounds"; // Path to A6 template sound subdirectory
path "C:\\Programme\\GStudio6\\template_6\\models"; // Path to A6 template model subdirectory

/////////////////////////////////////////////////////////////////
// Filename of the starting level.
string level_str = <pinka_1.WMB>; // give file names in angular brackets

////////////////////////////////////////////////////////////////////////////
// Included files
include <gid01.wdl>; // global ids
include <display00.wdl>; // basic display settings
include <cameraSelect.wdl>;
include <cameraTarget.wdl>;
include <camera3rd01.wdl>;
include <plSelect.wdl>;
include <miscInput01.wdl>;
include <plBipedInput01.wdl>;
include <bipedPhy01.wdl>;
include <bipedAnim01.wdl>;
include <bipedSnd01.wdl>;
include <plBiped01.wdl>;
include <plBipedHUD01.wdl>;
include <trigger00.wdl>;
include <particle00.wdl>;
include <zoom.wdl>;
include <money.wdl>;
include <levels00.wdl>;
//include <tut1.wdl>;// ich habe tut aus kommentier, da es nicht funzt !
include <chat.wdl>;


font standard_font = "Courier New",3,14;

string new_message;
string message1;
string message2;
string message3;
string message4;
string message5;
string entry[100];
string finished_entry[150];

text message_text
{
font = standard_font;
strings =4;
pos_x = 10;
string = message1,message2,message3,message4,message5;
layer = 7;
}

text entry_text
{
font = standard_font;
string = entry;
layer = 7;
pos_x = 10;
pos_y = 10;
}

function scroll_message(new_message)
{
str_cpy(message5,message4);
str_cpy(message4,message3);
str_cpy(message3,message2);
str_cpy(message2,message1);
str_cpy(message1,new_message);
}

function chat()
{
camera.ambient = -75;
message_text.visible = on;
entry_text.visible = on;
}

function server_function(str)
{
if(event_type == event_string && str == finished_entry) //was the string for exchanging messages sent?
{
scroll_message(str);
send_string(str);
}
if(event_type == event_join)
{
str_cpy(finished_entry," -> ");
str_cat(finished_entry,str);
str_cat(finished_entry," joined. <-");
scroll_message(finished_entry);
send_string(finished_entry);
}
if(event_type == event_leave)
{
str_cpy(finished_entry," -> ");
str_cat(finished_entry,str);
str_cat(finished_entry," left. <-");
scroll_message(finished_entry);
send_string(finished_entry);
}
}

function client_function(str)
{
if(event_type == event_string && str == finished_entry) //was the string for exchanging messages sent?
{
scroll_message(str);
}
}


function main()
{


//you can place more of your code here...
wait(1);

}
}
/////////////////////////////////////////////////////////////////
// Desc: The main() function is started at game start
function main()
{
message_text.pos_y = screen_size.y - 80;
on_server = server_function;
on_client = client_function;
on_c = chat; //enter chat mode on "c"

//place your commands somewhere around here...

while(1)
{
if(camera.ambient == -75) //if you're in chat mode...
{
result = inkey(entry);
if(result == 27) //pressed exit? Then leave chat mode.
{
camera.ambient = 0;
message_text.visible = off;
entry_text.visible = off;
}
else //pressed enter etc... continue: send string and go back to inkey();
{
str_cpy(finished_entry,player_name);
str_cat(finished_entry,": ");
str_cat(finished_entry,entry);
send_string(finished_entry);
ifdef server; //if you're a client you'll get the string sent back to you by the server, so don't show it yet.
scroll_message(finished_entry);
endif;
str_cpy(entry,"");
}

}
// set some common flags and variables
// freeze all entity functions
freeze_mode = 1;
// no level has been loaded yet...
gid01_level_state = gid01_level_not_loaded;

// entry: Warning Level (0,1, or 2)
// entry_help: Sets sensitivity to warnings (0 = none, 1 = some, 2 = all).
warn_level = 2; // announce bad texture sizes and bad wdl code


// entry: Starting Mouse Mode (0, 1, or 2)
mouse_mode = 0;

// wait 3 frames (for triple buffering) until it is flipped to the foreground
wait(3);

// now load the level
level_load(level_str);

wait(2); // let level load
// level should be loaded at this point...
gid01_level_state = gid01_level_loaded;

//+++ load starting values


// un-freeze the game
freeze_mode = 0;

// save start of game here
wait(6); // allow time for functions that wait for "gid01_level_loaded" to load
file_delete("start0.SAV"); // remove any old savefile
wait(1);
if( game_save("start",0,SV_ALL) <= 0)
{
diag("\nWARNING! main - Cannot save 'start' of level (ignore on restarts).");
}
else
{
diag("\nWDL: main - Game 'start' saved.");
}


// main game loop
while(1)
{
if(gid01_level_state != gid01_level_loaded)
{
freeze_mode = 1; // pause the game
while(gid01_level_state != gid01_level_loaded) { wait(1); }
freeze_mode = 0; // resume the game
}
wait(1);
}

}


// Desc: this is the function used to restart the game.
function main_restart_game()
{
// wait 3 frames (for triple buffering) until it is flipped to the foreground
wait(3);

// freeze the game
freeze_mode = 1;

if( game_load("start",0) <= 0)
{
diag("\nWARNING! main_restart_game - Cannot load 'start' of level.");
}
else
{
diag("\nWDL: main_restart_game - Game 'start' loaded");
}

// un-freeze the game
freeze_mode = 0;
}


// Desc: this is the function used to quit the game.
function main_quit()
{
//+++ // save global skills & strings
exit;
}

/////////////////////////////////////////////////////////////////
// The following definitions are for the pro edition window composer
// to define the start and exit window of the application.
WINDOW WINSTART
{
TITLE "3D GameStudio";
SIZE 480,320;
MODE IMAGE; //STANDARD;
BG_COLOR RGB(240,240,240);
FRAME FTYP1,0,0,480,320;
// BUTTON BUTTON_START,SYS_DEFAULT,"Start",400,288,72,24;
BUTTON BUTTON_QUIT,SYS_DEFAULT,"Abort",400,288,72,24;
TEXT_STDOUT "Arial",RGB(0,0,0),10,10,460,280;
}

/* no exit window at all..
WINDOW WINEND
{
TITLE "Finished";
SIZE 540,320;
MODE STANDARD;
BG_COLOR RGB(0,0,0);
TEXT_STDOUT "",RGB(255,40,40),10,20,520,270;

SET FONT "",RGB(0,255,255);
TEXT "Any key to exit",10,270;
}*/


/////////////////////////////////////////////////////////////////
//INCLUDE <debug.wdl>;



Re: Simple Chat - Should be easy to implement... [Re: SuperTux] #100887
03/14/07 15:57
03/14/07 15:57
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline OP
Expert
Germanunkol  Offline OP
Expert

Joined: Jun 2006
Posts: 2,640
Earth
Okay.
also, 2 sachen. ich hätte den text nicht message_text nennen sollen, tut mir leid, ich wusste nicht dass in den templates noch eine "message_text" besteht, weil ich die templates kaum benutze.
Außerdem hat das in der function main nicht ganz gestimmt. die while schleife aus meinem code musste nach hinten, und ihr inhalt in die while schleife die schon besteht. Sonst geht der code zu meiner while(1) schleife, die für immer asgeführt wird, und geht nie weiter. Das bedeutet, zum beispiel die level_load funktion wäre nie ausgeführt worden. Außerdem war der rest meiner function main noch da, die musste ganz raus... so dass es nur eine function main gibt.
Sonst müsste alles mehr oder weniger gehen.

Mach bitte zuerst eine backup copie von deinem script bevor du meins ausprobierst, ich will nicht dass mein code deinen überschreibt und dann ich schuld war dass es nicht mehr geht^^...

dann probier das hier mal:

Code:
 ////////////////////////////////////////////////////////////////////////
// A6 main wdl:
// Created by WED.
////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////
// The PATH keyword gives directories where template files can be found.
path "C:\\Programme\\GStudio6\\template_6"; // Path to A6 templates directory
path "C:\\Programme\\GStudio6\\template_6\\code"; // Path to A6 template code subdirectory
path "C:\\Programme\\GStudio6\\template_6\\images"; // Path to A6 template image subdirectory
path "C:\\Programme\\GStudio6\\template_6\\sounds"; // Path to A6 template sound subdirectory
path "C:\\Programme\\GStudio6\\template_6\\models"; // Path to A6 template model subdirectory

/////////////////////////////////////////////////////////////////
// Filename of the starting level.
string level_str = <pinka_1.WMB>; // give file names in angular brackets

////////////////////////////////////////////////////////////////////////////
// Included files
include <gid01.wdl>; // global ids
include <display00.wdl>; // basic display settings
include <cameraSelect.wdl>;
include <cameraTarget.wdl>;
include <camera3rd01.wdl>;
include <plSelect.wdl>;
include <miscInput01.wdl>;
include <plBipedInput01.wdl>;
include <bipedPhy01.wdl>;
include <bipedAnim01.wdl>;
include <bipedSnd01.wdl>;
include <plBiped01.wdl>;
include <plBipedHUD01.wdl>;
include <trigger00.wdl>;
include <particle00.wdl>;
include <zoom.wdl>;
include <money.wdl>;
include <levels00.wdl>;
//include <tut1.wdl>;// ich habe tut aus kommentier, da es nicht funzt !
include <chat.wdl>;


font standard_font = "Courier New",3,14;

string new_message;
string message1;
string message2;
string message3;
string message4;
string message5;
string entry[100];
string finished_entry[150];

text chat_message_text
{
font = standard_font;
strings =4;
pos_x = 10;
string = message1,message2,message3,message4,message5;
layer = 7;
}

text entry_text
{
font = standard_font;
string = entry;
layer = 7;
pos_x = 10;
pos_y = 10;
}

function scroll_message(new_message)
{
str_cpy(message5,message4);
str_cpy(message4,message3);
str_cpy(message3,message2);
str_cpy(message2,message1);
str_cpy(message1,new_message);
}

function chat()
{
camera.ambient = -75;
chat_message_text.visible = on;
entry_text.visible = on;
}

function server_function(str)
{
if(event_type == event_string && str == finished_entry) //was the string for exchanging messages sent?
{
scroll_message(str);
send_string(str);
}
if(event_type == event_join)
{
str_cpy(finished_entry," -> ");
str_cat(finished_entry,str);
str_cat(finished_entry," joined. <-");
scroll_message(finished_entry);
send_string(finished_entry);
}
if(event_type == event_leave)
{
str_cpy(finished_entry," -> ");
str_cat(finished_entry,str);
str_cat(finished_entry," left. <-");
scroll_message(finished_entry);
send_string(finished_entry);
}
}

function client_function(str)
{
if(event_type == event_string && str == finished_entry) //was the string for exchanging messages sent?
{
scroll_message(str);
}
}

/////////////////////////////////////////////////////////////////
// Desc: The main() function is started at game start
function main()
{
chat_message_text.pos_y = screen_size.y - 80;
on_server = server_function;
on_client = client_function;
on_c = chat; //enter chat mode on "c"

//place your commands somewhere around here...


// set some common flags and variables
// freeze all entity functions
freeze_mode = 1;
// no level has been loaded yet...
gid01_level_state = gid01_level_not_loaded;

// entry: Warning Level (0,1, or 2)
// entry_help: Sets sensitivity to warnings (0 = none, 1 = some, 2 = all).
warn_level = 2; // announce bad texture sizes and bad wdl code


// entry: Starting Mouse Mode (0, 1, or 2)
mouse_mode = 0;

// wait 3 frames (for triple buffering) until it is flipped to the foreground
wait(3);

// now load the level
level_load(level_str);

wait(2); // let level load
// level should be loaded at this point...
gid01_level_state = gid01_level_loaded;

//+++ load starting values


// un-freeze the game
freeze_mode = 0;

// save start of game here
wait(6); // allow time for functions that wait for "gid01_level_loaded" to load
file_delete("start0.SAV"); // remove any old savefile
wait(1);
if( game_save("start",0,SV_ALL) <= 0)
{
diag("\nWARNING! main - Cannot save 'start' of level (ignore on restarts).");
}
else
{
diag("\nWDL: main - Game 'start' saved.");
}


// main game loop
while(1)
{
if(gid01_level_state != gid01_level_loaded)
{
freeze_mode = 1; // pause the game
while(gid01_level_state != gid01_level_loaded) { wait(1); }
freeze_mode = 0; // resume the game
}
if(camera.ambient == -75) //if you're in chat mode...
{
result = inkey(entry);
if(result == 27) //pressed exit? Then leave chat mode.
{
camera.ambient = 0;
chat_message_text.visible = off;
entry_text.visible = off;
}
else //pressed enter etc... continue: send string and go back to inkey();
{
str_cpy(finished_entry,player_name);
str_cat(finished_entry,": ");
str_cat(finished_entry,entry);
send_string(finished_entry);
ifdef server; //if you're a client you'll get the string sent back to you by the server, so don't show it yet.
scroll_message(finished_entry);
endif;
str_cpy(entry,"");
}
}

wait(1);
}

}


// Desc: this is the function used to restart the game.
function main_restart_game()
{
// wait 3 frames (for triple buffering) until it is flipped to the foreground
wait(3);

// freeze the game
freeze_mode = 1;

if( game_load("start",0) <= 0)
{
diag("\nWARNING! main_restart_game - Cannot load 'start' of level.");
}
else
{
diag("\nWDL: main_restart_game - Game 'start' loaded");
}

// un-freeze the game
freeze_mode = 0;
}


// Desc: this is the function used to quit the game.
function main_quit()
{
//+++ // save global skills & strings
exit;
}

/////////////////////////////////////////////////////////////////
// The following definitions are for the pro edition window composer
// to define the start and exit window of the application.
WINDOW WINSTART
{
TITLE "3D GameStudio";
SIZE 480,320;
MODE IMAGE; //STANDARD;
BG_COLOR RGB(240,240,240);
FRAME FTYP1,0,0,480,320;
// BUTTON BUTTON_START,SYS_DEFAULT,"Start",400,288,72,24;
BUTTON BUTTON_QUIT,SYS_DEFAULT,"Abort",400,288,72,24;
TEXT_STDOUT "Arial",RGB(0,0,0),10,10,460,280;
}

/* no exit window at all..
WINDOW WINEND
{
TITLE "Finished";
SIZE 540,320;
MODE STANDARD;
BG_COLOR RGB(0,0,0);
TEXT_STDOUT "",RGB(255,40,40),10,20,520,270;

SET FONT "",RGB(0,255,255);
TEXT "Any key to exit",10,270;
}*/


/////////////////////////////////////////////////////////////////
//INCLUDE <debug.wdl>;



Hoffe es geht!

Micha

Last edited by Germanunkol; 03/14/07 19:17.

~"I never let school interfere with my education"~
-Mark Twain
Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

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