-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathchat_command_fly_mode.gsc
More file actions
93 lines (74 loc) · 1.79 KB
/
Copy pathchat_command_fly_mode.gsc
File metadata and controls
93 lines (74 loc) · 1.79 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include scripts\chat_commands;
Init()
{
CreateCommand(level.chat_commands["ports"], "flymode", "function", ::FlyModeCommand, 3, ["default_help_one_player"], ["fly"]);
}
/* Command section */
FlyModeCommand(args)
{
if (args.size < 1)
{
return NotEnoughArgsError(1);
}
error = ToggleFlyMode(args[0]);
if (IsDefined(error))
{
return error;
}
}
/* Logic section */
ToggleFlyMode(playerName)
{
player = FindPlayerByName(playerName);
if (!IsDefined(player))
{
return PlayerDoesNotExistError(playerName);
}
commandName = "fly";
ToggleStatus(commandName, "Fly Mode", player);
if (GetStatus(commandName, player))
{
player DoFlyMode(true);
player thread ThreadFlyMode();
}
else
{
player DoFlyMode(false);
player notify("chat_commands_fly_mode_off");
}
}
ThreadFlyMode()
{
self endon("disconnect");
self endon("chat_commands_fly_mode_off");
for(;;)
{
self waittill("spawned_player");
self DoFlyMode(true);
}
}
DoFlyMode(enabled)
{
if (enabled)
{
if ( self.sessionstate == "playing" )
{
self allowSpectateTeam( "freelook", true );
self.sessionstate = "spectator";
} else {
self.sessionstate = "playing";
self allowSpectateTeam( "freelook", false );
}
}
else
{
if ( self.sessionstate == "playing" )
{
self allowSpectateTeam( "freelook", true );
self.sessionstate = "spectator";
} else {
self.sessionstate = "playing";
self allowSpectateTeam( "freelook", false );
}
}
}