Hi! I'm trying to remove the text with the name and health when you look at a player, I think I have the code down:
[LUA]function GM:HUDDrawTargetID()
return false
end[/LUA]
I just don't know if I paste this into an already existing file, or if I make a new one just for it, I don't know what to name that file or where to put it. Should it go it autorun>client or autorun>server?
Thanks, first time lua"ing"
[QUOTE=captainburns;45549470]Hi! I'm trying to remove the text with the name and health when you look at a player, I think I have the code down:
[LUA]function GM:HUDDrawTargetID()
return false
end[/LUA]
I just don't know if I paste this into an already existing file, or if I make a new one just for it, I don't know what to name that file or where to put it. Should it go it autorun>client or autorun>server?
Thanks, first time lua"ing"[/QUOTE]
It would go into client and also GM: functions will not work if their hooks, it would be something like a hook.Add or a hook.Remove.
[QUOTE=LUModder;45549488]It would go into client and also GM: functions will not work if their hooks, it would be something like a hook.Add or a hook.Remove.[/QUOTE]
No you just shouldn't override them unless you're creating a game mode. Use hook.Add instead.
[QUOTE=Handsome Matt;45548165]The latter used to be faster, but as of a recent update they're equal thanks to LuaJIT.[/QUOTE]
So does LuaJIT make localizing functions redundant too, or does this only apply to tables?
[QUOTE=Revenge282;45549522]So does LuaJIT make localizing functions redundant too, or does this only apply to tables?[/QUOTE]
You should localise functions if they are only required in the scope you are defining them.
Shit like: [code]local IsValid = IsValid[/code] sucks though.
[QUOTE=crazyscouter;45549498]No you just shouldn't override them unless you're creating a game mode. Use hook.Add instead.[/QUOTE]
Should it look like this?
[LUA]function GM:HUDDrawTargetID()
return false
end
hook.Add[/LUA]
I just looked at the Garrys Mod Wiki, am I suppose to put something after .add?
Thanks for the help
No. Btw that response you quoted was in reference to LUModder, not you. Anyways, your code should look like [code]hook.Add("HUDDrawTargetID", "TurnOff", function() return false; end)[/code]
Sorry my bad, but thanks for the help!
[QUOTE=LUModder;45549426]Trying to accurately get FPS, I've tried mutliple numbers, the closest I've gotten was 1.25, can anyone help?
Code:
[CODE]
timer.Create("fpstxt",0.1,0,function()
fps:SetText(math.Round(1.2/FrameTime()))
if math.Round(1.2/FrameTime()) < 30 then fps:SetColor(Color(255,0,0)) else fps:SetColor(Color(0,255,0)) end
end)
[/CODE][/QUOTE]
Since Frametime is the time in Milliseconds it took to render the last frame, you just divide 1 by FrameTime.
[QUOTE=LUModder;45549426]Trying to accurately get FPS, I've tried mutliple numbers, the closest I've gotten was 1.25, can anyone help?
Code:
[CODE]
timer.Create("fpstxt",0.1,0,function()
fps:SetText(math.Round(1.2/FrameTime()))
if math.Round(1.2/FrameTime()) < 30 then fps:SetColor(Color(255,0,0)) else fps:SetColor(Color(0,255,0)) end
end)
[/CODE][/QUOTE]
I have no idea about accuracy, but 1 is what you want.
How to check if model exists? Like ent:IsValid(), but model
[QUOTE=TheMostUpset;45551135]How to check if model exists? Like ent:IsValid(), but model[/QUOTE]
[URL="http://wiki.garrysmod.com/page/file/Exists"]Try this?[/URL]
Edit:
Don't use that, use the method below \/
[QUOTE=TheMostUpset;45551135]How to check if model exists? Like ent:IsValid(), but model[/QUOTE]
One of these might work:
[url]http://samuelmaddock.github.io/glua-docs/#?q=util.isvalid[/url]
How can I put models from a table in diconlayouts?
[QUOTE=Icejjfish;45551774]How can I put models from a table in diconlayouts?[/QUOTE]What do you mean exactly, can you please elaborate?
[URL="http://wiki.garrysmod.com/page/VGUI/Elements/DIconLayout"]http://wiki.garrysmod.com/page/VGUI/Elements/DIconLayout[/URL] So that is an example code now I've made a table
[CODE]models = {}
models["models/player/alyx.mdl"]
models["models/player/gman.mdl"][/CODE]
Now how do I make it show in the small dpanels.
[QUOTE=Icejjfish;45551867][URL="http://wiki.garrysmod.com/page/VGUI/Elements/DIconLayout"]http://wiki.garrysmod.com/page/VGUI/Elements/DIconLayout[/URL] So that is an example code now I've made a table
[CODE]models = {}
models["models/player/alyx.mdl"]
models["models/player/gman.mdl"][/CODE]
Now how do I make it show in the small dpanels.[/QUOTE]
err maybe I'm tired, but I don't think that table will work.. aren't you meant to set the key to a value, not just set a key? you might be looking for table.insert?
[QUOTE=Icejjfish;45551867][URL="http://wiki.garrysmod.com/page/VGUI/Elements/DIconLayout"]http://wiki.garrysmod.com/page/VGUI/Elements/DIconLayout[/URL] So that is an example code now I've made a table
[CODE]models = {}
models["models/player/alyx.mdl"]
models["models/player/gman.mdl"][/CODE]
Now how do I make it show in the small dpanels.[/QUOTE]Here's something I put together for you, should work however I haven't tested it. You'd have to edit the sizes of the vgui elements and stuff to your liking:
[CODE]
-- Create a table to hold the list of models
local models = {
"models/player/alyx.mdl",
"models/player/gman.mdl",
}
-- Create the DIconLayout vgui element
local DIconLayout = vgui.Create( "DIconLayout" )
DIconLayout:SetSize( 500, 500 )
DIconLayout:SetPos( 0, 0 )
DIconLayout:SetSpaceX( 5 )
DIconLayout:SetSpaceY( 5 )
-- Loops through the models table and create a DModelPanel for each model
for k, v in pairs( models ) do
local IconLayoutItem = DIconLayout:Add( "DModelPanel" )
IconLayoutItem:SetModel( v )
IconLayoutItem:SetSize( 100, 100 )
IconLayoutItem:SetCamPos( Vector( 0, 0, 0 ) )
IconLayoutItem:SetLookAt( Vector( 0, 0, 0 ) )
end
[/CODE]
[QUOTE=ShadowRanger;45552158]Here's something I put together for you, should work however I haven't tested it. You'd have to edit the sizes of the vgui elements and stuff to your liking:
[CODE]
-- Create a table to hold the list of models
local models = {
"models/player/alyx.mdl",
"models/player/gman.mdl",
}
-- Create the DIconLayout vgui element
local DIconLayout = vgui.Create( "DIconLayout" )
DIconLayout:SetSize( 500, 500 )
DIconLayout:SetPos( 0, 0 )
DIconLayout:SetSpaceX( 5 )
DIconLayout:SetSpaceY( 5 )
-- Loops through the models table and create a DModelPanel for each model
for k, v in pairs( models ) do
local IconLayoutItem = DIconLayout:Add( "DModelPanel" )
IconLayoutItem:SetModel( v )
IconLayoutItem:SetSize( 100, 100 )
IconLayoutItem:SetCamPos( Vector( 0, 0, 0 ) )
IconLayoutItem:SetLookAt( Vector( 0, 0, 0 ) )
end
[/CODE][/QUOTE]
Thanks!
I'm using the SWEP Construction Kit and trying to alter the colours of certains models depending on a function, however it doesn't do anything.
I've had issues in the past with this that can be solved using self:CallOnClient however that isn't working this time. Snippet of the offending code:
[code]
function SWEP:SecondaryAttack()
if CLIENT then return end
if self.FireMode == 4 then
self.FireMode = 1
else
self.FireMode = self.FireMode + 1
end
self:UpdateFireMode(self.FireMode)
print("Firemode Updated to "..self.FireMode)
self:CallOnClient("UpdateFireMode",self.FireMode)
self:SetNextSecondaryFire( CurTime() + 0.2)
end
function SWEP:UpdateFireMode(Fire)
self.FireMode = Fire
end
function SWEP:Think()
self:ChangeMode(self.FireMode)
end
function SWEP:ChangeMode(ZZZmode)
if ZZZmode == 1 then
self.VElements["IceBeamMDL"].size = Vector(0.001,0.001,0.001)
self.VElements["WaveBeamMDL"].size = Vector(0.001,0.001,0.001)
self.VElements["PlasmaBeamMDL"].size = Vector(0.001,0.001,0.001)
self.VElements["PowerBeamMDL"].size = Vector(1,1,1)
end
if ZZZmode == 2 then
self.VElements["IceBeamMDL"].size = Vector(0.001,0.001,0.001)
self.VElements["WaveBeamMDL"].size = Vector(1,1,1)
self.VElements["PlasmaBeamMDL"].size = Vector(0.001,0.001,0.001)
self.VElements["PowerBeamMDL"].size = Vector(0.001,0.001,0.001)
end
if ZZZmode == 3 then
self.VElements["IceBeamMDL"].size = Vector(1,1,1)
self.VElements["WaveBeamMDL"].size = Vector(0.001,0.001,0.001)
self.VElements["PlasmaBeamMDL"].size = Vector(0.001,0.001,0.001)
self.VElements["PowerBeamMDL"].size = Vector(0.001,0.001,0.001)
end
if ZZZmode == 4 then
self.VElements["IceBeamMDL"].size = Vector(0.001,0.001,0.001)
self.VElements["WaveBeamMDL"].size = Vector(0.001,0.001,0.001)
self.VElements["PlasmaBeamMDL"].size = Vector(1,1,1)
self.VElements["PowerBeamMDL"].size = Vector(0.001,0.001,0.001)
end
end
[/code]
And all it does is making the power beam model visible to start, and nothing changes.
Can someone figure out what I'm doing wrong?
How would i go about simulating a mouse click on a panel?
You could always [url=http://wiki.garrysmod.com/page/gui/SetMousePos]move the mouse[/url] and [url=http://wiki.garrysmod.com/page/gui/InternalMousePressed]click[/url].
Or just call a DoClick method, it is used as "on click" method for most panels. Or OnMousePressed.
How can I set a variable on a server, change it on the client, then have it also change on the server with the client?
[QUOTE=sackcreator54;45555570]How can I set a variable on a server, change it on the client, then have it also change on the server with the client?[/QUOTE]
net library.
[url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url]
Can you at least read my post? I need to simulate a mouse click, i do not want a hook. [QUOTE=Robotboy655;45555562]Or just call a DoClick method, it is used as "on click" method for most panels. Or OnMousePressed.[/QUOTE]
[QUOTE=TheBerryBeast;45555589]Can you at least read my post? I need to simulate a mouse click, i do not want a hook.[/QUOTE]
It would do exactly what you want, call the functions as if a mouse was pressed. But if that's not an option, use Otts method.
[QUOTE=Robotboy655;45555575]net library.
[url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url][/QUOTE]
Why can't I do this?
(Clientside)
[lua]
if CLIENT then
function ENT:Draw()
net.Start("UpdateEntPos")
net.WriteEntity(self)
net.WriteVector(self:GetPos())
net.SendToServer()
end
end
[/lua]
On server:
[lua]
net.Receive("UpdateEntPos" function(len, ply)
net.ReadEntity():SetPos(net.ReadVector())
end)
[/lua]
Because you are sending a net message every frame, it is way too often. Why do you even network position? It is networked by default and your implementation opens up exploits.
How can I tell when a ragdoll collides with an object?
Sorry, you need to Log In to post a reply to this thread.