-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHelpReqAPI
More file actions
74 lines (56 loc) · 1.98 KB
/
HelpReqAPI
File metadata and controls
74 lines (56 loc) · 1.98 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
local helpreq = {}
local currHelpReqs = {}
local HReqCount = 1
local plrRanks = script.Parent.Parent.PlayerRanks
function helpreq.AddReq(targ: Player)
if table.find(currHelpReqs,targ.UserId) == nil then
table.insert(currHelpReqs,targ.UserId)
local plrs = game.Players:GetChildren()
for i=1,#plrs do
if plrRanks:FindFirstChild(plrs[i].Name) then
local r = plrRanks:FindFirstChild(plrs[i].Name)
if r.Value > 0 then
local HelpReqUI = plrs[i].PlayerGui:FindFirstChild("HelpRequests")
if HelpReqUI then
local main = HelpReqUI.Main
local newReq = main.Template:Clone()
newReq.Name = tostring(targ.UserId)
newReq.LayoutOrder = HReqCount
newReq.Main.Desc.Text = targ.Name.." ("..targ.UserId..") is requesting staff assistance"
newReq.TP:WaitForChild("LocalScript").Enabled = true
newReq.Parent = main
newReq.Visible = true
end
end
end
end
HReqCount += 1
end
end
function helpreq.ProcessReq(plr,targ:Player)
if plr and targ then
if table.find(currHelpReqs,targ.UserId) then
table.remove(currHelpReqs,table.find(currHelpReqs,targ.UserId))
local targchar = targ.Character or targ.CharacterAdded:Wait()
local targplrpos = CFrame.new(targchar.PrimaryPart.Position)
local staffchar = plr.Character or plr.CharacterAdded:Wait()
staffchar.PrimaryPart.CFrame = CFrame.new(Vector3.new(targchar.PrimaryPart.Position.X,targchar.PrimaryPart.Position.Y + 20,targchar.PrimaryPart.Position.Z))
local plrs = game.Players:GetChildren()
for i=1,#plrs do
if plrRanks:FindFirstChild(plrs[i].Name) then
local r = plrRanks:FindFirstChild(plrs[i].Name)
if r.Value > 0 then
local HelpReqUI = plrs[i].PlayerGui:FindFirstChild("HelpRequests")
if HelpReqUI then
local main = HelpReqUI.Main
if main:FindFirstChild(tostring(targ.UserId)) then
main:FindFirstChild(tostring(targ.UserId)):Destroy()
end
end
end
end
end
end
end
end
return helpreq