Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (dr_panther, Quad), 903 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
server controls client, client doesn't do anything #83248
07/25/06 16:33
07/25/06 16:33
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
ok when i start a -sv -cl session, the controls are fine, you move around and fire and such, but as soon as a client starts (-cl) then we have a problem, the client's camera is wrong, it will not position itself where it should be, also the client can't fire, or move. The server on the other hand is doing most of the acting, but in a wrong way; first it controls the clients moving, and firing, but it controls it's own camera movement and all. i will post camera, multiplayer, actions, and movement/firing.

Skills used:
Code:

define health , skill1;
define ammo, skill2;
define ammo1_reserve, skill9;
define ammo2_reserve, skill10;
define ammo3_reserve, skill11;
define ammo1_used, skill12;
define ammo2_used, skill13;
define ammo3_used, skill14;
define energy_weap_used, skill15;
define walk_speed, skill3;
define back_speed, skill4;
define strafe_speed, skill5;
define evade_speed, skill6;
define boost_speed, skill7;
define fall_speed, skill8;
define fast_mech, flag1;
define balanced_mech, flag2;
define heavy_mech, flag3;
define fire_time, skill16; //firing speed of weapon
define weapon_num, skill17; //number of the weapon
define animate_cgun, skill23;



The player actions:
Code:

action player_serv
{
sleep(.5);
my.heavy_mech = on;
my.scale_x = .5;
my.scale_y = .5;
my.scale_z = .5;
energy_recharge();
double_tap_key();
init_cameras();
movement_func();
my.fat = on;
my.polygon = on;
if (my.fast_mech == on)
{
my.health = 500;//health for heavy mech
my.walk_speed = 35; //walk speed for heavy mech
my.back_speed = 30; //backpedal speed for heavy mech
my.strafe_speed = 30; //strafing speed for heavy mech
my.evade_speed = 100; //evade speed for heavy mech
my.boost_speed = 90; //boosting speed for heavy mech
my.fall_speed = 25; //fall speed for heavy mech

}
if (my.balanced_mech == on)
{
my.health = 700; //health for balanced mech
my.walk_speed = 25; //walk speed for balanced mech
my.back_speed = 20; //backpedal speed for balanced mech
my.strafe_speed = 20; //strafing speed for balanced mech
my.evade_speed = 85; //evade speed for balanced mech
my.boost_speed = 75; //boosting speed for balanced mech
my.fall_speed = 35; //fall speed for balanced mech
midsaber_func();

}
if (my.heavy_mech == on)
{
my.health = 900; //health for heavy mech
my.walk_speed = 15; //walk speed for heavy mech
my.back_speed = 15; //backpedal speed for heavy mech
my.strafe_speed = 15; //strafing speed for heavy mech
my.evade_speed = 70; //evade speed for heavy mech
my.boost_speed = 60; //boosting speed for heavy mech
my.fall_speed = 45; //fall speed for heavy mech
hov_mecha_fire(); //include the heavy mech firing function
}
ent_create ("block.mdl", vector(my.x + 100, my.y, my.z + 100), dyn_light);
}

action player_client
{
sleep(.5);
my.scale_x = .5;
my.scale_y = .5;
my.scale_z = .5;
my.enable_scan = on;
my.event = miss_track_event;
energy_recharge();
double_tap_key();
init_cameras();
movement_func();
my.fat = on;
my.polygon = on;
if (my.fast_mech == on)
{
my.health = 500;//health for heavy mech
my.walk_speed = 35; //walk speed for heavy mech
my.back_speed = 30; //backpedal speed for heavy mech
my.strafe_speed = 30; //strafing speed for heavy mech
my.evade_speed = 100; //evade speed for heavy mech
my.boost_speed = 90; //boosting speed for heavy mech
my.fall_speed = 25; //fall speed for heavy mech

}
if (my.balanced_mech == on)
{
my.health = 700; //health for balanced mech
my.walk_speed = 25; //walk speed for balanced mech
my.back_speed = 20; //backpedal speed for balanced mech
my.strafe_speed = 20; //strafing speed for balanced mech
my.evade_speed = 85; //evade speed for balanced mech
my.boost_speed = 75; //boosting speed for balanced mech
my.fall_speed = 35; //fall speed for balanced mech
midsaber_func();

}
if (my.heavy_mech == on)
{
my.health = 900; //health for heavy mech
my.walk_speed = 15; //walk speed for heavy mech
my.back_speed = 15; //backpedal speed for heavy mech
my.strafe_speed = 15; //strafing speed for heavy mech
my.evade_speed = 70; //evade speed for heavy mech
my.boost_speed = 60; //boosting speed for heavy mech
my.fall_speed = 45; //fall speed for heavy mech
hov_mecha_fire(); //include the heavy mech firing function
}
ent_create ("block.mdl", vector(my.x + 100, my.y, my.z + 100), dyn_light);
}



Firing and movement:
Code:

function hov_mecha_fire()
{
while (my != null)
{
ammo_func();
my.fire_time += 0.1 *time;
rotate_cgun();
if (my.weapon_num == 0)
{
if (fire_key && my.ammo > 0)
{
speed_up = 1;
slow_down = 0;
if (my.fire_time > .2 && my.animate_cgun > 15)
{
spawn_bullet_chaingun();
my.ammo1_used += 1;
my.fire_time = 0;
}
}
else
{
slow_down = 1;
speed_up = 0;
}
}
if (my.weapon_num != 0)
{
slow_down = 1;
speed_up = 0;
}

if (my.weapon_num == 1)
{
if (fire_key && my.ammo > 20)
{
if (my.fire_time > 1)
{
my.energy_weap_used = on;
spawn_laser();
my.ammo2_used += 20;
my.fire_time = 0;
}
}
if (fire_key == off)
{
my.energy_weap_used = off;
}
}

if (my.weapon_num == 2)
{
if (fire_key && my.ammo > 0)
{
if (my.fire_time > 0.7)
{
spawn_missle_1();
spawn_missle_2();
my.ammo3_used += 2;
my.fire_time = 0;
}
}
if (alt_fire_key && my.ammo > 0)
{
if (my.fire_time > 2)
{
//spawn_3miss_right();
//spawn_3miss_left();
my.ammo2_used -= 6;
my.fire_time = 0;
}
}
}
wait(1);
}
}

function movement_func()
{
while (player != null)
{
ent_cycle ("idle", my.idle_percent);
move_mode = ignore_passents;

if (my.evade_fwd == off || my.evade_back == off || my.evade_left == off || my.evade_right == off)
{
my.cut_off_evade = 0;
}
if (walk_key == on) //walk forward
{
ent_cycle ("walk", my.walk_percent);
my.walk_percent += 3 *time;
ent_move (vector (my.walk_speed *time,0,0),nullvector);
}

if (my.evade_fwd) //if it's double tapped, evade
{
my.use_energy = 1;
while (my.cut_off_evade < 6 && my.energy > 0)
{
my.cut_off_evade += 1 *time;
my.energy -= 8 *time;
ent_move (vector (my.evade_speed *time,0,0),nullvector);
wait(1);
}
}

if (backpedal_key == on) //walk backward
{
ent_move (vector (- my.back_speed *time,0,0),nullvector);
}

if (my.evade_back == on) //if it's double tapped, evade
{
my.use_energy = 1;
while (my.cut_off_evade < 6 && my.energy > 0)
{
my.cut_off_evade += 1 *time;
my.energy -= 8 *time;
ent_move (vector (- my.evade_speed *time,0,0),nullvector);
wait(1);
}
}


if (lstrafe_key == on) //strafe left
{
ent_move (vector (0,my.strafe_speed *time,0),nullvector);
/*my.strafe_percent += 3 *time;
ent_animate (my, "s_left" , my.strafe_percent, 0);*/
}


if (my.evade_left == on) //if it's double tapped, evade
{
my.use_energy = 1;
while (my.cut_off_evade < 6 && my.energy > 0)
{
my.cut_off_evade += 1 *time;
my.energy -= 8 *time;
ent_move (vector (0,my.evade_speed *time,0),nullvector);
wait(1);
}
}


if (rstrafe_key == on) //strafe right
{
move_mode = ignore_passents;
ent_move (vector (0,- my.strafe_speed *time,0),nullvector);
/*my.strafe_percent += 3 *time;
ent_animate (my, "s_right" , my.strafe_percent, 0);*/
}


if (my.evade_right == on) //if it's double tapped, evade
{
my.use_energy = 1;
while (my.cut_off_evade < 6 && my.energy > 0)
{
my.cut_off_evade += 1 *time;
my.energy -= 8 *time;
ent_move (vector (0,- my.evade_speed *time,0),nullvector);
wait(1);
}
}

else
{
my.tilt = 0;
my.roll = 0;
}

if (jump_key == on) //boost and drain energy
{
if (my.energy > 0)
{
my.use_energy = 1;
my.energy -= 5 *time;
c_move (my, vector (0,0, my.boost_speed *time), nullvector, glide + ignore_passable);
}
}

else
{
my.use_energy = 0;
}

ent_move (vector (0,0, -my.fall_speed *time), nullvector);
c_trace(my.x, vector(my.x, my.y, my.z -500),ignore_me|ignore_passable|ignore_sprites);
if((normal.x != 0) || (normal.y != 0))
{
temp.tilt = 0;
temp.roll = 0;
temp.pan = -my.pan;
vec_rotate(normal, temp);
temp.tilt = -asin(normal.x);
temp.roll = -asin(normal.y);
my.tilt += 0.2*ang(temp.tilt - my.tilt);
my.roll += 0.2*ang(temp.roll - my.roll);
}
wait(1);
}
}



Camera:
Code:

// needed functions ///////////////////////////
function init_cameras()
{
camera.size_x = screen_size.x;
camera.size_y = screen_size.y; //make the 1st person camera the size of the screen
camera.genius = player; //the 1st person camera follows the player
camera.visible = on; //make first person the default camera
while (1)
{
update_views();
wait (1);
} //contiually update the views
}

function camera_trace()
{
my.skill42 = camera_distance;
trace_mode = ignore_me + ignore_passable;
vec_set(temporary_distance.x, camera.x);
temporary_distance.z -= 50 * time;
distance_traced = c_trace(my.x, temporary_distance.x, use_box);
if (distance_traced == 0) // Nothing in the way?
{
if (camera_distance < my.skill42)
{
camera_distance += 1 * time;
}
}
else
{
distance_traced -= 5 * time;
camera.x = my.x - distance_traced * cos(camera.pan); // place the camera behind the player
camera.y = my.y - distance_traced * sin(camera.pan); // at the new distance given by distance_traced
}
}

function update_views()
{
my.pan -= mouse_force.x * mouse_speed_x * time; //change the players pan with the mouse
//first person cam values
if (cam_mode == 0)
{
hud.alpha = 25;
hud.overlay = on;
hud.visible = on;
chaingun.visible = on;
laz_gun.visible = on;
camera.x = my.x;
camera.y = my.y;
camera.z = my.z + eye_height;
camera.pan = my.pan;
camera.roll = my.roll;
my.visible = off;
if (invert_mouse == 0)
{
camera.tilt = clamp ((camera.tilt + mouse_force.y *mouse_speed_y), -23, 45);
}
else
{
camera.tilt = clamp ((camera.tilt - mouse_force.y *mouse_speed_y), -23, 45);
}
}

//3rd person cam values
else
{
camera_trace();
hud.visible = off;
chaingun.visible = off;
laz_gun.visible = off; //make guns invisible
cam_dist = cos (tilt_3rd) * cam_dist_total;
camera.x = my.x - cos (my.pan) * cam_dist;
camera.y = my.y - sin (my.pan) * cam_dist;
camera.z = my.z + cam_3rd_height - cos (cam_dist_total);
camera.pan = my.pan; //camera only follows the player
camera.roll = my.roll; //do not include camera rolling
my.visible = on;
if (invert_mouse == 0)
{ //do not invert the camera tilt and clamp it to a certain angle
camera.tilt = clamp ((camera.tilt + mouse_force.y *mouse_speed_y), -23, 45) - tilt_3rd;
}
else
{ //invert the camera tilt and clamp it to a certain angle
camera.tilt = clamp ((camera.tilt - mouse_force.y *mouse_speed_y), -23, 45) - tilt_3rd;
}
}
}






- aka Manslayer101
Re: server controls client, client doesn't do anything [Re: mpdeveloper_B] #83249
07/25/06 16:49
07/25/06 16:49
Joined: Sep 2005
Posts: 159
The Netherlands
D
Dutchie666 Offline
Member
Dutchie666  Offline
Member
D

Joined: Sep 2005
Posts: 159
The Netherlands
all entitys(unless you create them via ent_createlocal) are handled server side.
you if you start an entity and start the input functions from within the entity, only the server will send the input.
so what you must do is in the function main or something is to start a function wich gets the input, than sends it to his own player(player must be made by: player = ent_create(etc) via send_skill...

Re: server controls client, client doesn't do anyt [Re: Dutchie666] #83250
07/26/06 20:44
07/26/06 20:44
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
how do i send the functions? i already have a ent_create for the server and client, does this mean that for the server i should call ent_create, and for the client i need to call ent_createlocal?

btw as shown above the functions are called within the player action, is this okay?


- aka Manslayer101
Re: server controls client, client doesn't do anyt [Re: mpdeveloper_B] #83251
07/26/06 20:50
07/26/06 20:50
Joined: Sep 2005
Posts: 159
The Netherlands
D
Dutchie666 Offline
Member
Dutchie666  Offline
Member
D

Joined: Sep 2005
Posts: 159
The Netherlands
not that is not okay..

you must do something like this:

function main(){here your stuff...


player = ent_create("yourmodel.mdl",spawnpoint,player_client);
init_cameras();
input_player();
etc..
}

in input player you must set skills of YOUR player.
so something like this:
function input_player(){
while(player){
if(key_w){
player.skill1 = 1;
}
send_skill(player.skill1);
player.skill1=0; // reset is so we won't input it if we don't press w
wait(1);
}
}

and then check in the player function if skill1 is 1 and then let him walk...

Re: server controls client, client doesn't do anyt [Re: Dutchie666] #83252
07/26/06 21:09
07/26/06 21:09
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
so basically what i have to do is change my above code where everything is my.this, into player.this ? and instead of using ent_createlocal i have to change it to ent_create?


- aka Manslayer101
Re: server controls client, client doesn't do anyt [Re: mpdeveloper_B] #83253
07/26/06 21:24
07/26/06 21:24
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
Code:

function spawn_ent_multi()

{
if (connection == 0)
{
player = ent_create (mecha01,pos,player_serv); //if you are the server, set you up as server
}
if (connection == 3)
{
player = ent_create (mecha01,pos,player_serv); //if you are the server, set you up as server
}
if (connection == 2)
{
player = ent_create (mecha01,pos,player_client); //if you are a client, set you up as a client
init_cameras();
movement_func();
hov_mecha_fire(); //include the heavy mech firing function
}
}


this is my entity creation how should i change this and the code in the first post? btw: this function is called in main()


- aka Manslayer101
Re: server controls client, client doesn't do anyt [Re: mpdeveloper_B] #83254
07/26/06 21:47
07/26/06 21:47
Joined: Sep 2005
Posts: 159
The Netherlands
D
Dutchie666 Offline
Member
Dutchie666  Offline
Member
D

Joined: Sep 2005
Posts: 159
The Netherlands
what i should do is get the inputs in 1 function. from that function you send the skills wich are changed by that input to the server... than the player action checks if a skill is 1 and than handles the movement.
what you do now is handle the movement from the same script as where you get the input, etc...
and also what i should do i put the nosend_frame to on in the player action. and than with proc_local i should run a function wich checks wich animation you must run. and than run that animation

the camera you must keep how it is now.

i guess you have to rewrtie many of your code to work good for multiplayer...

Re: server controls client, client doesn't do anyt [Re: Dutchie666] #83255
07/27/06 02:47
07/27/06 02:47
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
that is not how my skills are set up, look in the first post, the movements (walk_speed) etc are set up to send a certain number to the c_move and ent_move commands. when i use ent_create on the server, it's fine, when i use it on the client, then the server and client fight each other for owner ship of the functions. i want to know how to send the functions (movement_func, hov_mecha_fire, etc) to each player individualy. i've tried using proc_local and proc_client, but it will not send them properly, how can i fix this?


- aka Manslayer101
Re: server controls client, client doesn't do anyt [Re: Dutchie666] #83256
07/31/06 16:01
07/31/06 16:01
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
Quote:


function main(){here your stuff...


player = ent_create("yourmodel.mdl",spawnpoint,player_client);
init_cameras();
input_player();
etc..
}

in input player you must set skills of YOUR player.
so something like this:
function input_player(){
while(player){
if(key_w){
player.skill1 = 1;
}
send_skill(player.skill1);
player.skill1=0; // reset is so we won't input it if we don't press w
wait(1);
}
}

and then check in the player function if skill1 is 1 and then let him walk...




okay i understand this post now, so should i do the same with the functions? should i:

func_name();
proc_client (func_name);

and what about vars?

Last edited by Manslayer101; 07/31/06 16:04.

- aka Manslayer101
Re: server controls client, client doesn't do anyt [Re: mpdeveloper_B] #83257
07/31/06 16:26
07/31/06 16:26
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
that doesn't work for me....why?


- aka Manslayer101
Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

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