• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
[QUOTE=ROFLBURGER;52346079]-snip-[/QUOTE] Thinking about it, using whatever method I gave would mean that the crosshair wouldn't actually be circle. The x axis would be wider than the height of the y axis on the crosshair
How would I set the environment of a file and everything run by that file such as RunString, include, require, etc? If I do [code]setfenv(1, newenvironment)[/code] code run using RunString the code's environment is _G instead of newenvironment; but if I use CompileString and set the environment of the function to newenvironment global functions used by functions in the CompileString code will still use _G instead of newenvironment (like http.Fetch will use the global HTTP, and cvars.Bool will use the global cvars.Number). Using include and require from newenvironment won't add the newly created functions to it, they'll add them to _G instead. I could combat this by detouring them both and using CompileFile and setting the environment that way but then the issue mentioned earlier still persists.
Set the file's environment to a metatable that overrides include, RunString, CompileFile, and CompileString to use an environment-friendly version of CompileFile/CompileString. require can't be overrided without breaking C++ module support, unless you want to go super hacky and make a copy of _G before running require to test for changes.
[QUOTE=>>oubliette<<;52347984]Thinking about it, using whatever method I gave would mean that the crosshair wouldn't actually be circle. The x axis would be wider than the height of the y axis on the crosshair[/QUOTE] Yeah which was going to be an additional question but I decided to keep it because it's not much of a difference. My spray pattern ends up being square shape which isn't a huge deal but it would be nice to somehow clamp the direction so it fits within a circle. No clue how I would do that. It will be easy though since I have a custom cone system. It's calculated twice, once by method of additional modifiers that would affect the cone (heat, movement) and then finally with self.primary.cone. This is so that shotguns keep their spray pattern. [QUOTE=code_gs;52346472]Don't forget that player FOV and weapon FOV are different.[/QUOTE] Yes, weapon FOV is the viewmodel's FOV. I'm using the player's FOV.
[QUOTE=code_gs;52348629]Set the file's environment to a metatable that overrides include, RunString, CompileFile, and CompileString to use an environment-friendly version of CompileFile/CompileString. require can't be overrided without breaking C++ module support, unless you want to go super hacky and make a copy of _G before running require to test for changes.[/QUOTE] Thanks for the help, but I'm unsure what you mean. Could you elaborate? As for the require stuff I did some reading and realised I could make my own special module function. [code]module = function(mod) local M = {} local env = getfenv() env[mod] = M local newenv = setmetatable({}, { __index = function(tbl, key) return M[k] or env[k] end, __newindex = M, }) setfenv(2, newenv) end [/code]
What is the proper way to stabilize an entity's angles using ApplyForceOffset?
[QUOTE=Austin1346;51657049]Does it matter if i use ply:SteamID() or ply:SteamID64()? Is either one better than the other?[/QUOTE] ply:SteamID() returns the STEAM_ Steam ID. ply:SteamID64() returns the 64 bit Steam ID (the one with a bunch of numbers). They're both for returning Steam IDs; it just depends on preference and what you are using it for. --------------------------- [editline]12th June 2017[/editline] Yesterday I asked a question regarding making a player nocollided with the world. I have had issue implementing this code, and I'm looking for anybody who could help me with this issue. [U][B]What I Would Like To Achieve[/B][/U] I would like the player to be nocollided with the world just like props that are nocollided using the Nocollide World SWEP. This means that the player would be floating freely or free-falling through the map. [U][B]What I am Not Looking To Do[/B][/U] I do not want the player to be in movetype noclip or in any form of noclip. [U][B]What I've Tried[/B][/U] I tried changing the player's movetype to ones that make props go through the map, to no avail.
[QUOTE=ROFLBURGER;52350207]What is the proper way to stabilize an entity's angles using ApplyForceOffset?[/QUOTE] Apply the negative vector of force
[QUOTE=Moat;52351491]Could you use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetCollisionGroup]Entity:SetCollisionGroup[/url] on the player with COLLISION_GROUP_IN_VEHICLE?[/QUOTE] I will give this a try, thank you.
im having an issue with Player:SetModel(). issue is the model is being set on the server, but i guess it's not being synced up with the client. GetModel() returns the model i set the player to on the server, but when i u run GetModel() on the client it returns models/player.mdl (the grey motherfucker no one likes). i'm keeping it super simple with this code: [code] function GM:PlayerSpawn(pl) self.BaseClass:PlayerSpawn(pl) pl:SetModel 'models/humans/Group03/male_02.mdl' end [/code] here's the what outputs on server and client (ran same time :D) server: [img]https://i.gyazo.com/d8483cc0e7d7afc26185302ae36563b0.png[/img] client: [img]https://i.gyazo.com/a1897bcbda0f3dfd5a17c3635ce21a2b.png[/img] thanks bois ;) edit: and yes, I've ran the code on other hooks (PlayerSetModel, PlayerSpawn, PlayerLoadout, etc...)
Try in a shared player_spawn gameevent.
-snip- this was retarded code lol
[QUOTE=Spamppa2;52346059]would it be possible to make loading screen for custom gamemode or does it have to be always made in server?[/QUOTE] anyone?
[QUOTE=Spamppa2;52351789]anyone?[/QUOTE] I guess your could [URL="[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/RunConsoleCommand]RunConsoleCommand[/url]"]run sv_loadingurl[/URL] [URL="[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PostGamemodeLoaded]GM:PostGamemodeLoaded[/url]"]once the gamemode has loaded[/URL]. But I'm not sure people would like to have their stuff overridden
[QUOTE=Robotboy655;52340852][url]http://wiki.garrysmod.com/page/Global/ParticleEffect[/url] ? You can't. You can however do use this: [url]http://wiki.garrysmod.com/page/CNewParticleEffect/Render[/url][/QUOTE] Using that on entities does this: [t]http://meharryp.xyz/s/hl2_2017-06-13_16-22-42.png[/t] This is the line of code that makes that, am I doing something wrong? [lua]local particle = ply:CreateParticleEffect(data.effect, ply:LookupAttachment("eyes"))[/lua] [editline]a[/editline] Nevermind, [lua]local particle = CreateParticleSystem(ply, data.effect, PATTACH_POINT_FOLLOW, ply:LookupAttachment("eyes"))[/lua] works fine instead.
[QUOTE=Spamppa2;52346059]would it be possible to make loading screen for custom gamemode or does it have to be always made in server?[/QUOTE] Yeah, it is. [lua]RunConsoleCommand("sv_loadingurl","<site>")[/lua] If that doesn't work then try it in a hook.
-automerge-
I'm trying to replace a map material's texture where I can't really change the material. To do this I'm using [code] Material('mymapmaterialpath'):SetTexture('$basetexture', Material('someothermaterial'):GetTexture('$basetexture')) [/code] This works fine. Now I'm interesting in hiding an object which isn't a targetable entity and the only way seems to be by replacing the texture with some invisible one. The problem is, that changing the texture with a translucent one will cause the texture to error. I've tried setting some vars on the material first like $translucent with :SetInt but it doesn't seem to have any effect. Even after a :Recompute call on the original material. What to do?
[QUOTE=Moat;52351491]Could you use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetCollisionGroup]Entity:SetCollisionGroup[/url] on the player with COLLISION_GROUP_IN_VEHICLE?[/QUOTE] It did not work, unfortunately.
Is there a problem with [URL="http://wiki.garrysmod.com/page/video/Record"]video.Record[/URL]? It doesn't save the video anywhere and when I try to use CaptureVideo or StartRecording after the first record my game crashes. [code]local config = { container = "webm", video = "vp8", audio = "vorbis", quality = 50, bitrate = 200, fps = 30, lockfps = 30, name = "Test", width = 1280, height = 720 } local iVideoWriter = video.Record( config ) iVideoWriter:SetRecordSound( true ) local function Record() iVideoWriter:AddFrame( FrameTime(), true ) end function StartRecording() hook.Add( "DrawOverlay", "Record", Record ) end function StopRecording() hook.Remove( "DrawOverlay", "Record" ) iVideoWriter:Finish() print"Stopped video!" end function CaptureVideo(time) print"Started video!" StartRecording() timer.Simple(time or 5, StopRecording) end CaptureVideo() [/code]
[QUOTE=Sean Bean;52360431]Is there a problem with [URL="http://wiki.garrysmod.com/page/video/Record"]video.Record[/URL]? It doesn't save the video anywhere and when I try to use CaptureVideo or StartRecording after the first record my game crashes. [code]local config = { container = "webm", video = "vp8", audio = "vorbis", quality = 50, bitrate = 200, fps = 30, lockfps = 30, name = "Test", width = 1280, height = 720 } local iVideoWriter = video.Record( config ) iVideoWriter:SetRecordSound( true ) local function Record() iVideoWriter:AddFrame( FrameTime(), true ) end function StartRecording() hook.Add( "DrawOverlay", "Record", Record ) end function StopRecording() hook.Remove( "DrawOverlay", "Record" ) iVideoWriter:Finish() print"Stopped video!" end function CaptureVideo(time) print"Started video!" StartRecording() timer.Simple(time or 5, StopRecording) end CaptureVideo() [/code][/QUOTE] Might wanna put brackets around that which you are [URL="http://wiki.garrysmod.com/page/Global/print"]print[/URL]ing. [CODE]print("Hello awesome world!")[/CODE]
[QUOTE=CryptAlchemy;52360819]Might wanna put brackets around that which you are [URL="http://wiki.garrysmod.com/page/Global/print"]print[/URL]ing. [CODE]print("Hello awesome world!")[/CODE][/QUOTE] It isn't necessary, and in fact, a lot of people send in single strings and tables into functions like that.
is it dumb to store meta tables on server and send to client when changed (changed frequently)
[QUOTE=Tupac;52361159]is it dumb to store meta tables on server and send to client when changed (changed frequently)[/QUOTE] Could you post an example of what you mean?
[QUOTE=code_gs;52361275]Could you post an example of what you mean?[/QUOTE] okay. so i'm working on a gamemode, which uses a team system that is constantly changed throughout the round (players added, removed, team getting deleted, etc), but i want to contain the code that should be server-sided on the server-side. on the server-side is where the team changes would be handled, but the client needs to know some of the information about the teams. sorry if you couldn't understand meh lol, but you should get the gist of it :P
Just send to the client what they need to know. If there's a way to avoid networking with shared code, do so.
[QUOTE=code_gs;52361473]Just send to the client what they need to know. If there's a way to avoid networking with shared code, do so.[/QUOTE] yea, that's prolly a better option for me. thanks mayne
I'm trying to make a gamemode that has a fixed camera, with an object that moves around the frame based on where your mouse is, but I can't get it working. I have the screenclicker enabled and I want to set the ship's position to gui.MouseX() and gui.MouseY(), with a fixed Z, but it has wildly large numbers, or extremely small numbers. What's the proper way to do this?
[QUOTE=Sean Bean;52360431]Is there a problem with [URL="http://wiki.garrysmod.com/page/video/Record"]video.Record[/URL]? It doesn't save the video anywhere and when I try to use CaptureVideo or StartRecording after the first record my game crashes. [code]local config = { container = "webm", video = "vp8", audio = "vorbis", quality = 50, bitrate = 200, fps = 30, lockfps = 30, name = "Test", width = 1280, height = 720 } local iVideoWriter = video.Record( config ) iVideoWriter:SetRecordSound( true ) local function Record() iVideoWriter:AddFrame( FrameTime(), true ) end function StartRecording() hook.Add( "DrawOverlay", "Record", Record ) end function StopRecording() hook.Remove( "DrawOverlay", "Record" ) iVideoWriter:Finish() print"Stopped video!" end function CaptureVideo(time) print"Started video!" StartRecording() timer.Simple(time or 5, StopRecording) end CaptureVideo() [/code][/QUOTE] It appears that this is a Linux issue. Everything works fine on Windows.
Ok, so if any of you are familiar with the SWEP Creation Kit this question is for you: I'm wanting to change the bone of an attached quad or at least be able to work out the weapon parent without having to manually do it for every weapon, is there any way to do this? I've managed to change the bone but nothing changes, I assume its something to do with the render order but I just can't work it out. Here is my code for it thus far: [t]https://i.gyazo.com/baa2268600eec4e4592b37a8ce53857a.png[/t] (Yes I am aware my tabbing is atrocious.)
Sorry, you need to Log In to post a reply to this thread.