-
Notifications
You must be signed in to change notification settings - Fork 0
/
cs.sc
63 lines (51 loc) · 1.5 KB
/
cs.sc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
__config() -> {'stay_loaded' -> true};
get_save_dir() -> (return('./cs-saves'));
__command() -> (
_switch();
);
_switch() -> (
player=player();
if(query(player,'gamemode_id')==3,
_back_to_normal()
,//else
_spectator()
);
);
_spectator() -> (
player=player();
global_x=query(player,'x');
global_y=query(player,'y');
global_z=query(player,'z');
global_pitch=query(player,'pitch');
global_yaw=query(player,'yaw');
global_dim=query(player,'dimension');
global_gm=query(player,'gamemode');
task( _() -> (
write_file(player()~'name', 'text',
global_x+';'+
global_y+';'+
global_z+';'+
global_yaw+';'+
global_pitch+';'+
global_dim+';'+
global_gm+
';');
));
run('gamemode spectator '+player);
return();
);
_back_to_normal() -> (
player=player();
if(global_dim==0,
ret_val = read_file(player~'name', 'text');
if(ret_val == null,return(););
ret_values = split(';',ret_val:0);
run('gamemode '+ret_values:6+' '+player);
run('execute in '+ret_values:5+' run tp '+player+' '+ret_values:0+' '+ret_values:1+' '+ret_values:2+' '+ret_values:3+' '+ret_values:4);
,//else
run('gamemode '+global_gm+' '+player);
run('execute in '+global_dim+' run tp '+player+' '+global_x+' '+global_y+' '+global_z+' '+global_yaw+' '+global_pitch);
);
delete_file(player~'name', 'text');
return();
);