gms_instance_sync_var_add
Usage: gms_instance_sync_var_add ( "variable", value [, precision] )
Description
Adds a variable to the list of variabeles that are sent on the next call to an
server_instance_sync function. Only needed in GM:Studio.
Replies (5)
Last message on 27 May 2017
/// DUMMY OBJECT CREATE EVENT
//----Session variables for player (Immitation)
gms_instance_sync_var_add("healthMax", 100);
gms_instance_sync_var_add("health", 100);
gms_instance_sync_var_add("kills", 0);
gms_instance_sync(id, is_onetime | isc_local);
/// BULLET END STEP EVENT
// Hit player
var p = collision_line(x, y,
x + lengthdir_x(speed, direction),
y + lengthdir_y(speed, direction),
//obj_player, 1, 1);
obj_dummy, 1, 1);
if p != noone{
show_debug_message(p); // DEBUG
//var pid = gms_instance_get(p, "player_id");
var hp = gms_instance_get(p, "health");
show_debug_message(hp); // DEBUG
if hp > 0{
if hp - damage > 0{
gms_instance_set(p, "health", hp - damage);
}else{
gms_instance_set(p, "health", 0);
var kls = gms_other_get(from, "kills");
gms_instance_set(from, "kills", kls + 1);
}
instance_destroy();
}
}
/// BULLET CREATE SCRIPT
var xx, yy, dir, b;
xx = argument0;
yy = argument1;
dir = argument2
b = instance_create(xx, yy, obj_bullet);
b.sprite_index = argument3;
b.image_angle = dir;
b.direction = dir;
b.speed = argument4;
b.damage = argument5;
b.from = argument6;
gms_instance_sync_var_add("damage", b.damage);
gms_instance_sync_var_add("from", b.damage);
gms_instance_sync(b, is_onetime | isc_local);
hp keeps returning 0 in the show_debug_message and I'm not sure why? :S
Never mind I missed the part about user event 12 for Game Maker Studio!
You really have thought of everything haven't you :P
Thanks you so much this is the best thing ever!!!!
Size43
(Administrator)
on
27 May 2017, 16:00:05
Awesome, thanks!