/
shared.lua
272 lines (211 loc) · 8.92 KB
/
shared.lua
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
--[[---------------------------------------------------------
This file should contain variables and functions that are
the same on both client and server.
This file will get sent to the client - so don't add
anything to this file that you don't want them to be
able to see.
-----------------------------------------------------------]]
include( "obj_player_extend.lua" )
include( "gravitygun.lua" )
include( "player_shd.lua" )
include( "animations.lua" )
include( "player_class/player_default.lua" )
GM.Name = "Base Gamemode"
GM.Author = "Garry Newman"
GM.Email = "garrynewman@gmail.com"
GM.Website = "www.garry.tv"
GM.TeamBased = false
--[[---------------------------------------------------------
Name: gamemode:KeyPress( )
Desc: Player pressed a key (see IN enums)
-----------------------------------------------------------]]
function GM:KeyPress( player, key )
end
--[[---------------------------------------------------------
Name: gamemode:KeyRelease( )
Desc: Player released a key (see IN enums)
-----------------------------------------------------------]]
function GM:KeyRelease( player, key )
end
--[[---------------------------------------------------------
Name: gamemode:PlayerConnect( )
Desc: Player has connects to the server (hasn't spawned)
-----------------------------------------------------------]]
function GM:PlayerConnect( name, address )
end
--[[---------------------------------------------------------
Name: gamemode:PropBreak( )
Desc: Prop has been broken
-----------------------------------------------------------]]
function GM:PropBreak( attacker, prop )
end
--[[---------------------------------------------------------
Name: gamemode:PhysgunPickup( )
Desc: Return true if player can pickup entity
-----------------------------------------------------------]]
function GM:PhysgunPickup( ply, ent )
-- Don't pick up players
if ( ent:GetClass() == "player" ) then return false end
return true
end
--[[---------------------------------------------------------
Name: gamemode:PhysgunDrop( )
Desc: Dropped an entity
-----------------------------------------------------------]]
function GM:PhysgunDrop( ply, ent )
end
--[[---------------------------------------------------------
Name: Text to show in the server browser
-----------------------------------------------------------]]
function GM:GetGameDescription()
return self.Name
end
--[[---------------------------------------------------------
Name: Saved
-----------------------------------------------------------]]
function GM:Saved()
end
--[[---------------------------------------------------------
Name: Restored
-----------------------------------------------------------]]
function GM:Restored()
end
--[[---------------------------------------------------------
Name: EntityRemoved
Desc: Called right before an entity is removed. Note that this
isn't going to be totally reliable on the client since the client
only knows about entities that it has had in its PVS.
-----------------------------------------------------------]]
function GM:EntityRemoved( ent )
end
--[[---------------------------------------------------------
Name: Tick
Desc: Like Think except called every tick on both client and server
-----------------------------------------------------------]]
function GM:Tick()
end
--[[---------------------------------------------------------
Name: OnEntityCreated
Desc: Called right after the Entity has been made visible to Lua
-----------------------------------------------------------]]
function GM:OnEntityCreated( Ent )
end
--[[---------------------------------------------------------
Name: gamemode:EntityKeyValue( ent, key, value )
Desc: Called when an entity has a keyvalue set
Returning a string it will override the value
-----------------------------------------------------------]]
function GM:EntityKeyValue( ent, key, value )
end
--[[---------------------------------------------------------
Name: gamemode:CreateTeams()
Desc: Note - HAS to be shared.
-----------------------------------------------------------]]
function GM:CreateTeams()
-- Don't do this if not teambased. But if it is teambased we
-- create a few teams here as an example. If you're making a teambased
-- gamemode you should override this function in your gamemode
if ( !GAMEMODE.TeamBased ) then return end
TEAM_BLUE = 1
team.SetUp( TEAM_BLUE, "Blue Team", Color( 0, 0, 255 ) )
team.SetSpawnPoint( TEAM_BLUE, "ai_hint" ) -- <-- This would be info_terrorist or some entity that is in your map
TEAM_ORANGE = 2
team.SetUp( TEAM_ORANGE, "Orange Team", Color( 255, 150, 0 ) )
team.SetSpawnPoint( TEAM_ORANGE, "sky_camera" ) -- <-- This would be info_terrorist or some entity that is in your map
TEAM_SEXY = 3
team.SetUp( TEAM_SEXY, "Sexy Team", Color( 255, 150, 150 ) )
team.SetSpawnPoint( TEAM_SEXY, "info_player_start" ) -- <-- This would be info_terrorist or some entity that is in your map
team.SetSpawnPoint( TEAM_SPECTATOR, "worldspawn" )
end
--[[---------------------------------------------------------
Name: gamemode:ShouldCollide( Ent1, Ent2 )
Desc: This should always return true unless you have
a good reason for it not to.
-----------------------------------------------------------]]
function GM:ShouldCollide( Ent1, Ent2 )
return true
end
--[[---------------------------------------------------------
Name: gamemode:Move
This basically overrides the NOCLIP, PLAYERMOVE movement stuff.
It's what actually performs the move.
Return true to not perform any default movement actions. (completely override)
-----------------------------------------------------------]]
function GM:Move( ply, mv )
if ( drive.Move( ply, mv ) ) then return true end
if ( player_manager.RunClass( ply, "Move", mv ) ) then return true end
end
--[[---------------------------------------------------------
-- Purpose: This is called pre player movement and copies all the data necessary
-- from the player for movement. Copy from the usercmd to move.
-----------------------------------------------------------]]
function GM:SetupMove( ply, mv, cmd )
if ( drive.StartMove( ply, mv, cmd ) ) then return true end
if ( player_manager.RunClass( ply, "StartMove", mv, cmd ) ) then return true end
end
--[[---------------------------------------------------------
Name: gamemode:FinishMove( player, movedata )
-----------------------------------------------------------]]
function GM:FinishMove( ply, mv )
if ( drive.FinishMove( ply, mv ) ) then return true end
if ( player_manager.RunClass( ply, "FinishMove", mv ) ) then return true end
end
--[[---------------------------------------------------------
Called after the player's think.
-----------------------------------------------------------]]
function GM:PlayerPostThink( ply )
end
--[[---------------------------------------------------------
A player has started driving an entity
-----------------------------------------------------------]]
function GM:StartEntityDriving( ent, ply )
drive.Start( ply, ent )
end
--[[---------------------------------------------------------
A player has stopped driving an entity
-----------------------------------------------------------]]
function GM:EndEntityDriving( ent, ply )
drive.End( ply, ent )
end
--[[---------------------------------------------------------
To update the player's animation during a drive
-----------------------------------------------------------]]
function GM:PlayerDriveAnimate( ply )
end
--[[---------------------------------------------------------
The gamemode has been reloaded
-----------------------------------------------------------]]
function GM:OnReloaded()
end
function GM:PreGamemodeLoaded()
end
function GM:OnGamemodeLoaded()
end
function GM:PostGamemodeLoaded()
end
--
-- Name: GM:OnViewModelChanged
-- Desc: Called when the player changes their weapon to another one - and their viewmodel model changes
-- Arg1: Entity|viewmodel|The viewmodel that is changing
-- Arg2: string|old|The old model
-- Arg3: string|new|The new model
-- Ret1:
--
function GM:OnViewModelChanged( vm, old, new )
local ply = vm:GetOwner()
if ( IsValid( ply ) ) then
player_manager.RunClass( ply, "ViewModelChanged", vm, old, new )
end
end
--[[---------------------------------------------------------
Disable properties serverside for all non-sandbox derived gamemodes.
-----------------------------------------------------------]]
function GM:CanProperty( pl, property, ent )
return false
end
--[[---------------------------------------------------------
Allow hooks to override bullet without ignoring all other hooks
-----------------------------------------------------------]]
function GM:EntityFireBullets( ent, bullets )
return true
end