How would I set the player's view to somewhere else temporarily? Kinda like how the camera tool does it.
--
Found my solution, it was CalcView
New question though, is it possible to outline richtext text?
Just wanting some clarification on the "proper" way to modify a gamemode (ttt in this case.)
Say for example I want to extend the weapon's base to allow weapons to be easily configurable as to whether they show up visibly player's backs when they aren't actively holding them.
The proper way to do this would be a create a separate addon or file named something like weapon_ttt_base_holstering.lua or something instead of directly modifying weapon_tttbase.lua, right? Or is direct modification fine? Though I assume not because merging from git might cause problems even with merge tools helping
[QUOTE=thelurker1234;52507593]Just wanting some clarification on the "proper" way to modify a gamemode (ttt in this case.)
Say for example I want to extend the weapon's base to allow weapons to be easily configurable as to whether they show up visibly player's backs when they aren't actively holding them.
The proper way to do this would be a create a separate addon or file named something like weapon_ttt_base_holstering.lua or something instead of directly modifying weapon_tttbase.lua, right? Or is direct modification fine? Though I assume not because merging from git might cause problems even with merge tools helping[/QUOTE]
Updates might break the shit you change, if you make it in addon form there is less chance your shit will break.
Anybody know how i can prevent particle trails and make all particles follow the object it is attached to via
ParticleEffectAttach("Big_titanEng",PATTACH_ABSORIGIN_FOLLOW,self,0)?
[url]http://www.directupload.net/file/d/4794/ub7yezq9_jpg.htm[/url]
But it should always look like this: [url]http://www.directupload.net/file/d/4794/3jf49tf7_jpg.htm[/url]
I'm having problems with derma text. Probably a basic issue but I hate doing derma and I'm taking way too long to push this update.
The text cuts out with ... at the end for some reason. I've already tested it and it isn't the APC model that's causing the issue, the text isn't too long either as I've tried shortening it.
Here is what happens:
[IMG]http://i.imgur.com/JEIDMzF.png[/IMG]
Here is the clientside code for all of this so far:
[url]https://pastebin.com/FbaHCS9m[/url]
Thanks for any assistance you can provide.
[QUOTE=Shadow02;52509011]DLabel problem[/QUOTE]
You've either got to set the size of the DLabel (with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/SetSize]Panel:SetSize[/url] or [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/SetWidth]Panel:SetWidth[/url]
or use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/SizeToContents]Panel:SizeToContents[/url] to adjust the DLabel to its contents.
Use [code] DLabel:SetWrap(true) [/code] if the text is too big for the frame/panel
Entity:SetBonePosition( number bone, Vector pos, Angle ang )
Is there something similiar for Server side?
If not, how can i do else?
Thanks for the contributions but I am still getting the same issue. Could it be something to do with the font I'm using?
[lua]
surface.CreateFont( "TheDefaultSettings", {
font = "Arial", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
extended = false,
size = 25,
weight = 100,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
} )
[/lua]
[QUOTE=lafrog;52509900]Entity:SetBonePosition( number bone, Vector pos, Angle ang )
Is there something similiar for Server side?
If not, how can i do else?[/QUOTE]
You shouldn't have to do this serverside -- there is SetBoneMatrix but it has a huge network overhead. Can you describe what you're trying to do?
I have an ragdoll turret with an x axis and an z axis. I want to change their angles.
[QUOTE=lafrog;52510154]I have an ragdoll turret with an x axis and an z axis. I want to change their angles.[/QUOTE]
Do it for everyone clientside in a BuildBonePositions callback.
Had to do with it before and it didnt work. ([url]https://facepunch.com/showthread.php?t=1569911[/url])
You were even the one who recommed it to me.
Using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/PhysicsInitSphere]Entity:PhysicsInitSphere[/url] what would be the best way to get collisions on this? Using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetCollisionBounds]Entity:SetCollisionBounds[/url] obviously makes a box, is it possible to make a sphere collider?
Basically, I want to be able to check with StartTouch if they have entered the sphere.
Is there an in_enum for the voice key? if not how would I go about detecting if a player hit their mic button?
[QUOTE=xDoomx;52510551]Is there an in_enum for the voice key? if not how would I go about detecting if a player hit their mic button?[/QUOTE]
There is this - [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerStartVoice]GM:PlayerStartVoice[/url]
but that's CL side only. So net message.
There isn't an enumeration for the talk/voice key. :)
[editline]27th July 2017[/editline]
Quick question. Is there any way to hook into another addons function without editing the code manually within that file?
I know this exists: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/AddCallback]Entity:AddCallback[/url], but an older thread(2013) I just read through said that this function is only used for [URL="https://wiki.garrysmod.com/page/Entity_Callbacks"]these callbacks[/URL] and what I need here isn't possible.
Is it still not possible? Or can Entity:AddCallback use other hooks as well besides the 3 I linked above. (Those won't help me)
You're going to have to provide a specific example: there are a lot of ways. AddCallback will not work, however.
Ok, so I am trying to make something for fun. Specifically, something that allows you set the range on CW:2 weapons and adjusts the bullets initial angle when it spawns. However, I don't see any way of doing this without editing the CW2 function that finalizes bullet structure.
Just for reference, it looks like this: [CODE] function CustomizableWeaponry:finalizePhysicalBulletStructure(wep, data)
data.initialVelocity = data.velocity
data.initialShotPosition = data.position * 1
data.directionAngle = data.direction:Angle()
if wep then
CustomizableWeaponry.callbacks.processCategory(wep, "finalizePhysicalBullet", data)
end
end [/CODE]
I would just add something after the directionAngle that would adjust the bullets path.
He did not add any sort of hook that would allow me to make a last second adjustment before the bullet launches. Which is why I am asking this question.
So those are the specifics. :)
You can either override the function or do some metatable magic on the data table.
I am currently working with player scaling and it doesn't appear that the two functions GM:PlayerFootstep and GM:PlayerStepSoundTime are called when the player is at ultra slow speeds.
To test this I have Sandbox clone which has print( "PlayerStepSoundTime" ) and print( "PlayerFootstep" ) appended to the GM:PlayerStepSoundTime and GM:PlayerFootstep functions respecitvley.
when the player is moving around normally neither of the functions are called but when the player jumps and lands or gets moving fast enough ( by bunny hopping ) the functions are called and the console prints out as it should. Under normal conditions at standard player scale the two functions are called in succession with "PlayerStepSoundTime" being the first called followed by "PlayerFootstep".
I can't seem to find anything on the two functions anywhere. Any help or insight would be helpful.
Does not change class when you press the button but if you just use the command in the console it works...
[code]
local classButton = vgui.Create("DButton")
classButton:SetParent(Menu)
classButton:SetText("")
classButton:SetSize(100, 50)
classButton:SetPos(0, 127)
classButton.Paint = function()
surface.SetDrawColor(244, 75, 66, 255) -- color of button
surface.DrawRect(0, 0, classButton:GetWide(), classButton:GetTall())
surface.SetDrawColor(221, 72, 64, 255) -- color of borders
surface.DrawRect(0, 49, classButton:GetWide(), 1)
surface.DrawRect(99, 0, 1, classButton:GetTall())
draw.DrawText("Class", "DermaDefaultBold", classButton:GetWide() /2, 17, Color(255, 255, 255, 255), 1)
end
classButton.DoClick = function(classButton)
local classPanel = Menu:Add("ClassPanel")
classPanel.Paint = function()
surface.SetDrawColor(50,50,50,255)
surface.DrawRect(0,0,classPanel:GetWide(),classPanel:GetTall())
surface.SetTextColor(255, 255, 255, 255)
surface.CreateFont("HeaderFont", {font="default", size=35, weight=1000})
surface.SetFont("HeaderFont")--nothing is written it is just ready to be written
surface.SetTextPos(0, 0)
surface.DrawText("Choose your class")
if LocalPlayer():Team() == 1 then -- alien
local aliensolider = vgui.Create("DButton")
aliensolider:SetParent(classPanel)
aliensolider:SetText("")
aliensolider:SetSize(100, 50)
aliensolider:SetPos(0, 50)
aliensolider.Paint = function()
surface.SetDrawColor(80, 244, 66, 255) -- color of button
surface.DrawRect(0, 0, aliensolider:GetWide(), aliensolider:GetTall())
surface.SetDrawColor(0, 0, 0, 255) -- color of borders
surface.DrawRect(0, 49, aliensolider:GetWide(), 1)
surface.DrawRect(99, 0, 1, aliensolider:GetTall())
draw.DrawText("Solider LV 4", "DermaDefault", aliensolider:GetWide() /2, 17, Color(255, 255, 255, 255), 1)
aliensolider.DoClick = function()
RunConsoleCommand("set_class", 4)
end
end
elseif LocalPlayer():Team() == 2 then -- robot
elseif LocalPlayer():Team() == 3 then --human
end
end
end
[/code]
[quote=Reaper3;52522306]Does not change class when you press the button but if you just use the command in the console it works...
[lua]-- snip --
if LocalPlayer():Team() == 1 then -- alien
local aliensolider = vgui.Create("DButton")
aliensolider:SetParent(classPanel)
aliensolider:SetText("")
aliensolider:SetSize(100, 50)
aliensolider:SetPos(0, 50)
aliensolider.Paint = function()
surface.SetDrawColor(80, 244, 66, 255) -- color of button
surface.DrawRect(0, 0, aliensolider:GetWide(), aliensolider:GetTall())
surface.SetDrawColor(0, 0, 0, 255) -- color of borders
surface.DrawRect(0, 49, aliensolider:GetWide(), 1)
surface.DrawRect(99, 0, 1, aliensolider:GetTall())
draw.DrawText("Solider LV 4", "DermaDefault", aliensolider:GetWide() /2, 17, Color(255, 255, 255, 255), 1)
aliensolider.DoClick = function()
RunConsoleCommand("set_class", 4)
end
end
-- snip --[/lua][/QUOTE]
I assume you mean the "aliensoldier" button in the part I kept in the quote above. To be honest I don't see why it wouldn't work if you actually see the button, but I also see that you're setting the DoClick function inside the Paint function. You should move that part to outside the Paint function, like so:
[lua]local aliensolider = vgui.Create("DButton")
-- aliensolider:SetStuff(...)
aliensolider.Paint = function()
surface.SetDrawColor(80, 244, 66, 255) -- color of button
surface.DrawRect(0, 0, aliensolider:GetWide(), aliensolider:GetTall())
surface.SetDrawColor(0, 0, 0, 255) -- color of borders
surface.DrawRect(0, 49, aliensolider:GetWide(), 1)
surface.DrawRect(99, 0, 1, aliensolider:GetTall())
draw.DrawText("Solider LV 4", "DermaDefault", aliensolider:GetWide() /2, 17, Color(255, 255, 255, 255), 1)
end
aliensolider.DoClick = function()
RunConsoleCommand("set_class", 4)
end[/lua]
As for your actual problem: are you sure that set_class is a clientside console command? Can you try to make a Lua function that does the same thing (and make the console command call that function, and this button call the function directly instead of going through the console command)?
I have made this lua funcation to create the console command if that is what you mean?
[code]
function ChangeMyClass(ply, cmd, args)
ply:SetNWInt("playerClass", tonumber(args[1]))
ply:KillSilent()
end
concommand.Add( "set_class", ChangeMyClass )
[/code]
[QUOTE=Reaper3;52522564]I have made this lua funcation to create the console command if that is what you mean?
[code]
function ChangeMyClass(ply, cmd, args)
ply:SetNWInt("playerClass", tonumber(args[1]))
ply:KillSilent()
end
concommand.Add( "set_class", ChangeMyClass )
[/code][/QUOTE]
set_class is a [b]serverside[/b] console command.
RunConsoleCommand happens [b]clientside[/b].
The reason it works when you type it into the console is that you're an admin in your listen server, you're actually running it in the server console (not the client console) but the server also know that you are the one who ran the command which is why the player argument is populated. It's kind of dumb.
What you need to do is rewrite this set_class function to work via the [url=http://wiki.garrysmod.com/page/Net_Library_Usage]net library[/url] and not a console command.
[editline]30th July 2017[/editline]
Feel free to post further questions if you're running into trouble or don't understand what I said
[QUOTE=NeatNit;52522811]set_class is a [b]serverside[/b] console command.
RunConsoleCommand happens [b]clientside[/b].
The reason it works when you type it into the console is that you're an admin in your listen server, you're actually running it in the server console (not the client console) but the server also know that you are the one who ran the command which is why the player argument is populated. It's kind of dumb.
What you need to do is rewrite this set_class function to work via the [url=http://wiki.garrysmod.com/page/Net_Library_Usage]net library[/url] and not a console command.
[editline]30th July 2017[/editline]
Feel free to post further questions if you're running into trouble or don't understand what I said[/QUOTE]
What on earth are talking about. Console commands are not restricted at all how you say they are. Sure RunConsoleCommand can be used clientside but that doesn't mean you are restricted to using it to run clientside console commands only. If the console command does not exist clientside it simply atempts to have the player run it serverside. Witch happens because of how console commands work. Unless you specifically set the command to be server/or admin only all players will be able to execute it. Changing to a net message would do exactly the same thing.
say I have a bunch of objects called "xyz_01, xyz_02, xyz_02, ... xyz_n" is there any way in lua to get them by name like in hammer with "xyz_*" ?
[editline]a[/editline]
Its worth mentioning that I do not know how those objects are being called as theyre being assigned ""completly random"" name extensions
[QUOTE=TheEmp;52523018]What on earth are talking about. Console commands are not restricted at all how you say they are. Sure RunConsoleCommand can be used clientside but that doesn't mean you are restricted to using it to run clientside console commands only. If the console command does not exist clientside it simply atempts to have the player run it serverside. Witch happens because of how console commands work. Unless you specifically set the command to be server/or admin only all players will be able to execute it. Changing to a net message would do exactly the same thing.[/QUOTE]
I went in-game and tested some stuff before posting that. Go ahead and try it. I just did it again to get some copy-pasta for you:
[code]] lua_run concommand.Add("foo_bar", print)
> concommand.Add("foo_bar", print)...
] foo_bar
Player [1][NeatNit] foo_bar table: 0x3d165a58
] foo_bar a b c
Player [1][NeatNit] foo_bar table: 0x250c6b20 a b c
] lua_run RunConsoleCommand("foo_bar", "aaaaaa")
> RunConsoleCommand("foo_bar", "aaaaaa")...
Player [1][NeatNit] foo_bar table: 0x3d1be0d8 "aaaaaa"
] lua_run_cl RunConsoleCommand("foo_bar", "aaaaaa")[/code]
That last command generated no output. Show me code that works?
[editline]31st July 2017[/editline]
[QUOTE=KingPommes;52523186]say I have a bunch of objects called "xyz_01, xyz_02, xyz_02, ... xyz_n" is there any way in lua to get them by name like in hammer with "xyz_*" ?
[editline]a[/editline]
Its worth mentioning that I do not know how those objects are being called as theyre being assigned ""completly random"" name extensions[/QUOTE]
Some context would help. It's weird that you're in this situation in the first place - it sounds like you should have a table for those objects instead of whatever you have now.
That said, if they are global variables, you can loop through the global table [b]_G[/b] like so:
[lua]for k, v in pairs(_G) do
if k:StartWith("xyz_") then
-- your code
end
end[/lua]
From your description I can't tell if they're global vars or something else.
[QUOTE=NeatNit;52523299]-snip-
Some context would help. It's weird that you're in this situation in the first place - it sounds like you should have a table for those objects instead of whatever you have now.
That said, if they are global variables, you can loop through the global table [b]_G[/b] like so:
[lua]for k, v in pairs(_G) do
if k:StartWith("xyz_") then
-- your code
end
end[/lua]
From your description I can't tell if they're global vars or something else.[/QUOTE]
Thanks that already helps I think (Im really just mapping so lua is a bit scary at first). And yes reading back my post is very confusing if you dont know the context.
Basically Im trying to change a specific texture globally. This cant be done in Hammer.
So every brush should be changed to another texture. sadly when compiling a map each face gets a new texture name so instead of "texture_abc" it becoms something like "texture_abc-4556_54454_4565" and that is done for every face. Only sharing the name at the start.
[editline]a[/editline] hold on I think only cubemap data is stored that weirdly. the texture that will be changed into has the same bump map etc so i might not need that weird naming stuff
[editline]a[/editline] Ok the solution was pretty simple. I just got the way source handels textures confused. the whole naming thing is indeed only for cubemaps.
[CODE]local mat = Material( "kingpommes/venator/interior/corridor/corridor_wall_lamps" )
mat:SetTexture( "$basetexture", "kingpommes/venator/interior/corridor/corridor_lights" )
[/CODE]
is there a discord or some kind of chat for all things related to garry's mod coding? i know that's what this thread and section is exactly for but i won't feel as dumb making frequent posts in a chatbox as opposed to a forum
anyways, i'm just starting out with lua (and basically any type of coding in general) and i'm following the tutorial on the wiki
[QUOTE=NeatNit;52523299]I went in-game and tested some stuff before posting that. Go ahead and try it. I just did it again to get some copy-pasta for you:
[code]] lua_run concommand.Add("foo_bar", print)
> concommand.Add("foo_bar", print)...
] foo_bar
Player [1][NeatNit] foo_bar table: 0x3d165a58
] foo_bar a b c
Player [1][NeatNit] foo_bar table: 0x250c6b20 a b c
] lua_run RunConsoleCommand("foo_bar", "aaaaaa")
> RunConsoleCommand("foo_bar", "aaaaaa")...
Player [1][NeatNit] foo_bar table: 0x3d1be0d8 "aaaaaa"
] lua_run_cl RunConsoleCommand("foo_bar", "aaaaaa")[/code]
That last command generated no output. Show me code that works?
[/QUOTE]
I'm assuming that your running that on a listen server right? I booted up GMod and started up a listen server and everything worked as expected?
[IMG]https://i.gyazo.com/f273bd6a25f092a13977f4af08bbcc83.png[/IMG]
Obviously it won't print clientside and would only print in the serverside console as to be expected. But the ability to execute a serverside console command from the clientside is there.
Sorry, you need to Log In to post a reply to this thread.