-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.lua
More file actions
105 lines (77 loc) · 2.69 KB
/
functions.lua
File metadata and controls
105 lines (77 loc) · 2.69 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
94
95
96
97
98
99
100
101
102
103
104
105
local ProjectileTable =
{
["arrow"] = 60,
["snowball"] = 61,
["egg"] = 62,
["fireball"] = 63,
["firecharge"] = 64,
["enderpearl"] = 65,
["skull"] = 66,
["splashpotion"] = 73,
["expbottle"] = 76,
["firework"] = 77,
["fishingfloat"] = 90,
}
function GetBlockXYZFromTrace(Player)
local World = Player:GetWorld()
local Tracer = cTracer(World)
local EyePos = Vector3f(Player:GetEyePosition().x, Player:GetEyePosition().y, Player:GetEyePosition().z)
local EyeVector = Vector3f(Player:GetLookVector().x, Player:GetLookVector().y, Player:GetLookVector().z)
Tracer:Trace(EyePos, EyeVector, 50)
return Tracer.BlockHitPosition.x, Tracer.BlockHitPosition.y, Tracer.BlockHitPosition.z
end
function Strike(Name)
local exist = false
cRoot:Get():FindAndDoWithPlayer(Name,
function(Player)
exist = true
Player:GetWorld():CastThunderbolt(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ())
end
)
return exist
end
function Throw(Player, ProjectileName, Speed)
local Direction = Player:GetThrowSpeed(Speed)
local Pos = Player:GetThrowStartPos()
local Item = cItem()
local ProjectileName = string.lower(ProjectileName)
local Projectile = ProjectileTable[ProjectileName]
return Player:GetWorld():CreateProjectile(Pos.x, Pos.y, Pos.z, Projectile, Player, Item, Direction)
end
function ExecuteForEachPlayer(Player, CommandPrefix, CommandSuffix)
local ExecuteCommand = function(OtherPlayer)
local FinalCommand = ""
if (CommandSuffix ~= "") then
FinalCommand = CommandPrefix .. " " .. OtherPlayer:GetName() .. " " .. CommandSuffix
else
FinalCommand = CommandPrefix .. " " .. OtherPlayer:GetName()
end
if (OtherPlayer:GetName() ~= Player:GetName()) then
cRoot:Get():GetPluginManager():ExecuteCommand(Player, FinalCommand)
end
end
cRoot:Get():ForEachPlayer(ExecuteCommand)
return true
end
function SetGlobalMaxSpeed(Player, Celerity)
Player:SetFlyingMaxSpeed(Celerity)
Player:SetNormalMaxSpeed(Celerity)
Player:SetSprintingMaxSpeed(Celerity*1.3)
return true
end
function SetMaxSpeed(Player, Celerity, Mode)
if (Mode == string.lower("flying")) then
Player:SetFlyingMaxSpeed(Celerity)
return true
elseif (Mode == string.lower("normal") or Mode == string.lower("walking")) then
Player:SetNormalMaxSpeed(Celerity)
return true
elseif (Mode == string.lower("sprinting") or Mode == string.lower("running")) then
Player:SetSprintingMaxSpeed(Celerity * 1.3)
return true
elseif (Mode == string.lower("global") or Mode == string.lower("all")) then
SetGlobalMaxSpeed(Player, Celerity)
return true
end
return false
end