-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsv_propinfo.txt
205 lines (175 loc) · 6.66 KB
/
sv_propinfo.txt
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
--@name sv_propinfo
--@author legokidlogan
--@server
--[[
Stuff not visible on client:
- :isFrozen()
- :getDriver()
--]]
local connectedPlayers = {}
local players = find.allPlayers()
local playerCount = #players
local function playerUpdate()
players = find.allPlayers()
playerCount = #players
end
local function safeGetMass( ent )
local physObj = aimEnt:getPhysicsObject()
if isValid( physObj ) then
return physObj:getMass()
end
return "NAN"
end
local function safeIsFrozen( ent )
local physObj = ent:getPhysicsObject()
if isValid( physObj ) then
return ent:isFrozen()
end
return "No physics object"
end
local function roundReturn( v, n )
v:round( n )
return v
end
timer.create( "LKL_PropInfo_EntityCheck", 0.5, 0, function()
for i = 1, playerCount do
local ply = players[i]
if not isValid( ply ) or not rawget( connectedPlayers, ply ) then continue end
aimEnt = ply:getEyeTrace().Entity
local info = {}
if isValid( aimEnt ) then
info = {
Entity = {
Color = not aimEnt:isPlayer() and ply == owner() and ( ( hasPermission( "entities.setPos", aimEnt ) and Color( 0, 255, 0 ) ) or Color( 255, 0, 0 ) )
},
Size = {
Data = string.replace( tostring( roundReturn( aimEnt:obbSize(), 3 ) ), " ", ", " ),
},
Position = {
Data = string.replace( tostring( roundReturn( aimEnt:getPos(), 3 ) ), " ", ", " ),
},
Angles = {
Data = string.replace( tostring( roundReturn( aimEnt:getAngles(), 3 ) ), " ", ", " ),
},
Mass = {
Data = safeGetMass( aimEnt ),
},
Frozen = {
Data = safeIsFrozen( aimEnt ),
Color = ( safeIsFrozen( aimEnt ) and Color( 0, 255, 0 ) ) or Color( 255, 0, 0 ),
},
OtherStuff = {},
}
if aimEnt:isVehicle() then
rawset( info, "OtherStuff", {
{
Type = "Driver",
Data = ( aimEnt.getDriver and isValid( aimEnt:getDriver() ) and aimEnt:getDriver() ) or "No driver",
Color = aimEnt.getDriver and isValid( aimEnt:getDriver() ) and aimEnt:getDriver():isPlayer() and team.getColor( aimEnt:getDriver():getTeam() ):setA( 255 ),
},
} )
end
net.start( "LKL_PropInfo_ExtraInfo" )
net.writeTable( info )
net.send( ply )
end
end
end )
hook.add( "PlayerSay", "LKL_PropInfo_PlayerSay", function( ply, msg )
if not connectedPlayers[ply] then return end
LS = string.explode( " ", msg )
if LS[1] ~= "/pi" then return end
local command = LS[2]
local printInfo = {}
local toggleDir = false
if command == "model" or command == "mod" then
printInfo = {
Color( 255, 255, 255 ),"[PropInfo] ",
Color( 255, 255, 255 ),"That entity's model is ",
Color(255,255,0),ply:getEyeTrace().Entity:getModel()
}
elseif command == "material" or command == "mat" then
printInfo = {
Color( 255, 255, 255 ),"[PropInfo] ",
Color( 255, 255, 255 ),"That entity's material is ",
Color(255,255,0),ply:getEyeTrace().Entity:getMaterial()
}
elseif command == "type" or command == "class" then
printInfo = {
Color( 255, 255, 255 ),"[PropInfo] ",
Color( 255, 255, 255 ),"That entity's type is ",
Color(255,255,0),ply:getEyeTrace().Entity:getClass()
}
elseif command == "position" or command == "pos" or command == "p" then
printInfo = {
Color( 255, 255, 255 ),"[PropInfo] ",
Color( 255, 255, 255 ),"That entity's position is ",
Color(255,255,0),"" .. tostring( roundReturn( ply:getEyeTrace().Entity:getPos() ) )
}
elseif ( command == "users" or command == "u" ) and ply == owner() then
if table.count( connectedPlayers ) == 0 then
printInfo = {
Color( 255, 255, 255 ),"[PropInfo] ",
Color( 255, 150, 150 ),"There currently are no connected players.",
}
else
printInfo = {
Color( 255, 255, 255 ),"[PropInfo] ",
Color( 255, 255, 255 ),"The currently connected players are ",
}
for person, _ in pairs( connectedPlayers ) do
table.insert( printInfo, team.getColor( person:getTeam() ) )
table.insert( printInfo, person:getName() )
table.insert( printInfo, Color( 255, 255, 255 ) )
table.insert( printInfo, ", " )
end
table.remove( printInfo, #printInfo )
end
elseif command == "direction" or command == "dir" or command == "d" then
toggleDir = true
else
printInfo = {
Color( 255, 255, 255 ),"[PropInfo] ",
Color( 255, 255, 255 ),"The available commands are ",
Color(255,255,0),"help",
Color( 255, 255, 255 ),", ",
Color(255,255,0),"model",
Color( 255, 255, 255 ),", ",
Color(255,255,0),"material",
Color( 255, 255, 255 ),", ",
Color(255,255,0),"position",
Color( 255, 255, 255 ),", ",
Color(255,255,0),"direction",
Color( 255, 255, 255 ),", and ",
Color(255,255,0),"type",
Color( 255, 255, 255 ),"."
}
end
net.start( "LKL_PropInfo_Command" )
net.writeTable( printInfo )
net.writeBool( toggleDir )
net.send( ply )
return ""
end )
hook.add( "PlayerInitialSpawn", "LKL_PropInfo_PlayerSpawned", playerUpdate )
hook.add( "PlayerDisconnected", "LKL_PropInfo_PlayerLeft", function( ply )
playerUpdate( ply )
connectedPlayers[ply] = nil
end )
net.receive( "LKL_PropInfo_HUDConnectionChange", function( _, ply )
if net.readBool() then
connectedPlayers[ply] = true
print(
Color( 255, 255, 255 ), "[PropInfo] ",
team.getColor( ply:getTeam() ), ply:getName(),
Color( 150, 255, 150 ), " has connected!"
)
else
connectedPlayers[ply] = nil
print(
Color( 255, 255, 255 ), "[PropInfo] ",
team.getColor( ply:getTeam() ), ply:getName(),
Color( 255, 150, 150 ), " has disconnected!"
)
end
end )