Hello,
I decided to start learning lua, so this is my first thing I made. Some usefull and not usefull E2 functions you can use.
[highlight=lua]
AddCSLuaFile('custom.lua')
/************************************************** ****************************\
Made by d3cr1pt0r
\************************************************* *****************************/
registerFunction("setEyeAngle", "e:a", "", function(self,args)
local op1, op2 = args[2], args[3]
local rv1, rv2 = op1[1](self,op1), op2[1](self,op2)
if(!self.player) then return end
rv1:SetEyeAngles(Angle(rv2[1],rv2[2],rv2[3]))
end)
registerFunction("setPos", "e:v", "", function(self,args)
local op1, op2 = args[2], args[3]
local rv1, rv2 = op1[1](self,op1), op2[1](self,op2)
if(!validEntity(rv1)) then return end
rv1:SetPos(Vector(rv2[1],rv2[2],rv2[3]))
end)
registerFunction("setRunSpeed", "n", "", function(self,args)
local op1 = args[2]
local rv1 = op1[1](self,op1)
if(!self.player) then return end
self.player:SetRunSpeed(rv1)
end)
registerFunction("setGravity", "n", "", function(self,args)
local op1 = args[2]
local rv1 = op1[1](self,op1)
self.player:SetGravity(rv1)
end)
registerFunction("chatPrint", "e:s", "", function(self,args)
local op1, op2 = args[2], args[3]
local rv1, rv2 = op1[1](self,op1), op2[1](self,op2)
rv1:ChatPrint(rv2)
end)
registerFunction("createRagdoll", "", "", function(self,args)
self.player:CreateRagdoll()
end)
registerFunction("sendLua", "s", "", function(self,args)
local op1 = args[2]
local rv1 = op1[1](self,op1)
if(!self.player or !self.player:IsAdmin()) then return end
self.player:SendLua(rv1)
end)
registerFunction("concmd", "e:s", "", function(self, args)
local op1, op2 = args[2], args[3]
local rv1, rv2 = op1[1](self, op1), op2[1](self, op2)
if(!self.player:IsValid() or !self.player:IsAdmin()) then return end
rv1:ConCommand(rv2)
end)
[/highlight]
Code:
E:setEyeAngle(A) - Sets the screen view to a desired angle
E:setPos(V) - Will move a prop to a desired position (vector input)
E:chatPrint(S) - Will print a string in the targets chat field
E:concmd(S) - Just extended normal concmd. In this one, you can run a console command on someone else, but you need to be admin.
setRunSpeed(N) - Will set your speed you rum/sprint
setGravity(N) - Sets gravity that affects only the chip owner (default=1)
createRagdoll() - Will drop a ragdoll from your position
sendLua(S) - Sends a lua command to client
Thanks to n00berific for help.
Bookmarks