-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathapply.lua
72 lines (58 loc) · 1.64 KB
/
apply.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
PLUGIN.name = 'Adds /Apply command'
PLUGIN.author = 'Bilwin'
ix.command.Add('Apply', {
description = 'Introduce yourself',
OnRun = function(_, client)
if not client:GetCharacter() then return end
local cid = client:GetCharacter():GetInventory():HasItem('cid')
if cid then
ix.chat.Send(client, 'ic', cid:GetData('name', 'N/A') .. ', #' .. cid:GetData('id', 'N/A'))
else
ix.chat.Send(client, 'ic', client:GetCharacter():GetName())
end
hook.Run('RecognizeCharacter', client)
end
})
if SERVER then
function PLUGIN:Recognize(client, level)
if type(level) ~= 'number' then return end
local targets = {}
if level < 1 then
local entity = client:GetEyeTraceNoCursor().Entity
if (IsValid(entity) && entity:IsPlayer() && entity:GetCharacter()
&& ix.chat.classes.ic:CanHear(client, entity)) then
targets[1] = entity
end
else
local class = 'w'
if level == 2 then
class = 'ic'
elseif level == 3 then
class = 'y'
end
class = ix.chat.classes[class]
for _, v in ipairs(player.GetAll()) do
if client ~= v && v:GetCharacter() && class:CanHear(client, v) then
targets[#targets + 1] = v
end
end
end
if #targets > 0 then
local id = client:GetCharacter():GetID()
local i = 0
for _, v in ipairs(targets) do
if v:GetCharacter():Recognize(id) then
i = i + 1
end
end
if i > 0 then
net.Start('ixRecognizeDone')
net.Send(client)
hook.Run('CharacterRecognized', client, id)
end
end
end
function PLUGIN:RecognizeCharacter(client)
return self:Recognize(client, 2)
end
end