A simple multi-player code please

Posted By: bomber

A simple multi-player code please - 02/02/08 06:18

I've read locoweed's tutorial, but that was making an entire multiplayer game I just need a small code that I can add to my script so it becomes multiplayer.
Posted By: MMike

Re: A simple multi-player code please - 02/02/08 14:31

check aums!
Posted By: fastlane69

Re: A simple multi-player code please - 02/02/08 22:27

Quote:

that I can add to my script so it becomes multiplayer.




Doesn't work that way. There is no code that when you plug into your existing single player (SP) code makes it multiplayer (MP).

You either code it MP from day one or don't do MP at all.
Posted By: Leonardo

Re: A simple multi-player code please - 02/07/08 10:51

Check Locoweed's site, I believe he has a simple bare-bone MP script there.
And fastlane is right, you don't plug MP scripts in an SP game to make it multiplayer. You do it the other way around - you plug SP scripts into a MP game.
Posted By: PrenceOfDarkness

Re: A simple multi-player code please - 02/08/08 06:51

LMAO, i'm sorry but this is so funny! I wish I would have thought of that:
Quote:

I just need a small code that I can add to my script so it becomes multiplayer




I've spent the last year and a half trying to get the higher concepts of multiplayer on A6/A7, I've probably spent 2.5 years all together on multiplayer and still don't get some stuff. So, if someone gives you a small peace of code that instantly makes your game multiplayer I will kill myself

I don't know your understanding of multiplayer, but like everyone else has suggested locoweed's tutorial is the best way to get started. Just don't stop there, you must mess with the stuff yourself or else you will never fully grasp it. Good Luck, and maybe you can write all of us that small peace of code that will transform our game into multiplayer.
Posted By: Henning

Re: A simple multi-player code please - 02/21/08 22:34

Hi bomber,

it's right, you have to write the game for multiplayer, here is just a small example that runs under A7.07 using Lite-C.
Maybe it helps to see concepts.

// Simple Multiplayer
// 3D Gamestudio A7 Version 7.07 commercial

#include <acknex.h>
#include <default.c>

ENTITY* clPlayer;
ENTITY* svPlayer;

var isMove = 0;
var isInput = 0;
var showX = 0;
var showY = 0;

function moveMe () { // movement for both on server
while (1) {
my.x += my.skill1 * time_step;
my.y += my.skill2 * time_step;
ent_sendnow (me);

isMove++; // moveMe() running?
if (isMove > 999) isMove = 0;
wait (1);
}
}

function getInput () { // wsad control on client and server separately
if (connection == 2) me = clPlayer;
if (connection == 3) me = svPlayer;

while (1) {
if (key_w == 1) my.skill1 = 5;
if (key_s == 1) my.skill1 = -5;
if (key_a == 1) my.skill2 = 5;
if (key_d == 1) my.skill2 = -5;
if (!key_any) {
my.skill1 = 0;
my.skill2 = 0;
}

if (connection == 2) send_skill (my.skill1, SEND_VEC|SEND_UNRELIABLE);

showX = my.skill1; // show input
showY = my.skill2; // show input
isInput++; // getInput() running?
if (isInput > 999) isInput = 0;
wait (1);
}
}

////////////////////////////// main ///////////////////////////////////////
function main () {
level_load ("M.wmb"); // just a platform and a cylinder at +X for orientation
wait (-0.5);
vec_set(camera.x,vector(-200, 0 , 20));

while (connection == 0) wait (1);

if (connection == 2) { // client
clPlayer = ent_create ("BlueBox.mdl", vector (70, 30, 0), moveMe);
}

if (connection == 3) { // client / server
svPlayer = ent_create ("RedSphere.mdl", vector (70, -30, 0), moveMe);
}
wait (-0.5);

getInput();
}

PANEL* diag_pan = {
flags = VISIBLE;
digits (4,10,"Diagnostics",*,1,NULL);
digits (4,20,"connection =",*,1,NULL);
digits (80,20,3.0,*,1,connection);
digits (4,50,session_name,*,1,NULL);
digits (4,60,player_name,*,1,NULL);
digits (4,70,"Input :",*,1,NULL);
digits (80,70,3.0,*,1,isInput);
digits (4,80,"Move :",*,1,NULL);
digits (80,80,3.0,*,1,isMove);
digits (4,90,"Inp X :",*,1,NULL);
digits (80,90,3.0,*,1,showX);
digits (4,100,"Inp Y :",*,1,NULL);
digits (80,100,3.0,*,1,showY);
}
Posted By: bomber

Re: A simple multi-player code please - 02/24/08 12:58

Quote:

Check Locoweed's site, I believe he has a simple bare-bone MP script there.
And fastlane is right, you don't plug MP scripts in an SP game to make it multiplayer. You do it the other way around - you plug SP scripts into a MP game.



where's locoweed's site?
Posted By: Henning

Re: A simple multi-player code please - 02/28/08 20:55

It is at:
http://www.thekidgame.com/Locoweed3DGS/multiplayer.htm
Posted By: xbox

Re: A simple multi-player code please - 03/25/08 14:18

Hey i found a simple code to add that makes it become multiplayer. I tried it and it does work. I used the techdemo level and there are some minor glitches but other that that it works. Although it is a tutorial, all you have to do is copy the red text to your main script and do what it says. IT IS SO EASY, A CAVEMAN COULD DO IT. lol. This is what i use for my multiplayer games.
click here
© 2024 lite-C Forums