• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=Robotboy655;47296228]It is actually 5, I have tested it on the Jeep. It is also 5 in the source code which gives you ammo, so..[/QUOTE] So... why does 5 not work on my end but 3 does?
[QUOTE=The Commander;47297958]So... why does 5 not work on my end but 3 does?[/QUOTE] What model are you using? [editline]11th March 2015[/editline] [QUOTE=The Commander;47297958]So... why does 5 not work on my end but 3 does?[/QUOTE] Actually the example on the wiki was incorrect, I just tested it and fixed it: [code] hook.Add( "PlayerUse", "some_unique_name", function( ply, ent ) if ( !IsValid( ent ) or !ent:IsVehicle() ) then return end if ( ply:GetEyeTrace().HitGroup == 5 ) then return false end end )[/code] It is HitGroup, not HitBox. You should change your code too, because HitBox is dependent on the model.
How do I loop a CSoundPatch?
[QUOTE=Aleks6010;47298140]How do I loop a CSoundPatch?[/QUOTE] [url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1c1f.html[/url] [url]http://wiki.garrysmod.com/page/Global/SoundDuration[/url] [lua] timer.Create("Loopsound",0,SoundDuration(soundname),function() cSound:Play() end) [/lua]
What's the simplest way to scale a certain player model?
[QUOTE=Aleks6010;47298140]How do I loop a CSoundPatch?[/QUOTE] I strongly recommend looping the sound file itself if it is a custom sound. I can write a tutorial for it if you need it. [editline]11th March 2015[/editline] [QUOTE=Gamz365;47298607]What's the simplest way to scale a certain player model?[/QUOTE] SetModelScale?
[QUOTE=Robotboy655;47298714] SetModelScale?[/QUOTE] Thanks, wasn't aware there was a function
Hey guys I need some help with setting a material. So I've already defined what material I want but how do I define where to put it ._. Thanks
[QUOTE=GoldTrigger;47299040]Hey guys I need some help with setting a material. So I've already defined what material I want but how do I define where to put it ._. Thanks[/QUOTE] What do you mean? Texture paths? Like where do you put your textures to?
[QUOTE=Robotboy655;47299148]What do you mean? Texture paths? Like where do you put your textures to?[/QUOTE] I mean like the position of the texture :P
I posted this in the Next Update thread but didn't receive any responses. Basically since the dev branch was made live, my servers have [B]stopped automatically restarting when they crash[/B]. The typical message about writing out to a minidump is displayed but there is no longer a '[I]SRCDS.exe has stopped working[/I]' popup dialog box. Serverdoc isn't picking up on the fact that SRCDS has crashed, so the server will just hang there until I check on it hours later to manually restart it. I'd just like to know if anyone else is experiencing this issue or not. It's happening to my 2 sandbox servers, both of which run entirely different systems. [IMG]http://i.imgur.com/d3o7GQu.png[/IMG]
[QUOTE=GoldTrigger;47299172]I mean like the position of the texture :P[/QUOTE] You want to draw a part of the texture on screen? If that is the case, you will need to use surface.DrawTexturedRectUV. If not, can you explain properly, what do you want?
Anyone have any idea why this piece of code: [lua]if self.Owner:Crouching() then print( "some code here" ) end[/lua] Would be saying that method Crouching is a nil value? The code is shared btw.
[QUOTE=YourStalker;47299371]Anyone have any idea why this piece of code: if self.Owner:Crouching() then print( "some code here" ) end Would be saying that method Crouching is a nil value? The code is shared btw.[/QUOTE] Is self.Owner valid? [code]lua_run print( Entity(1):Crouching() ) > print( Entity(1):Crouching() )... false lua_run print( NULL:Crouching() ) > print( NULL:Crouching() )... [ERROR] lua_run:1: attempt to call method 'Crouching' (a nil value) 1. unknown - lua_run:1 [/code]
[QUOTE=Mista Tea;47299380]Is self.Owner valid? [code]lua_run print( Entity(1):Crouching() ) > print( Entity(1):Crouching() )... false lua_run print( NULL:Crouching() ) > print( NULL:Crouching() )... [ERROR] lua_run:1: attempt to call method 'Crouching' (a nil value) 1. unknown - lua_run:1 [/code][/QUOTE] I ran those two commands and got the same results. (thats what you wanted me to do right?) This only seems to happen when the player commits suicide by shooting something like a explosive barrel.
[QUOTE=YourStalker;47299422]I ran those two commands and got the same results. (thats what you wanted me to do right?) This only seems to happen when the player commits suicide by shooting something like a explosive barrel.[/QUOTE] Wherever you are using the code you provided, it sounds like you need to add an IsValid check. [code] if IsValid( self.Owner ) then if self.Owner:Crouching() then print( "some code here" ) end end[/code] It nearly sounds like this is in a STool, since when the player dies the gmod_tool SWEP is removed and will cause issues with STools that try to use hooks and the like.
[QUOTE=Mista Tea;47299449]Wherever you are using the code you provided, it sounds like you need to add an IsValid check. [code] if IsValid( self.Owner ) then if self.Owner:Crouching() then print( "some code here" ) end end[/code][/QUOTE] Yeah, kinda figured that once I thought about it a little. Thanks tho :)
[QUOTE=Mista Tea;47299449]Wherever you are using the code you provided, it sounds like you need to add an IsValid check. [code] if IsValid( self.Owner ) then if self.Owner:Crouching() then print( "some code here" ) end end[/code] It nearly sounds like this is in a STool, since when the player dies the gmod_tool SWEP is removed and will cause issues with STools that try to use hooks and the like.[/QUOTE] [code] if IsValid( self.Owner ) && self.Owner:Crouching() then print( "some code here" ) end[/code] No need to multiply ifs.
[QUOTE=Robotboy655;47299524][code] if IsValid( self.Owner ) && self.Owner:Crouching() then print( "some code here" ) end[/code] No need to multiply ifs.[/QUOTE] I fixed your bad code. [lua] if IsValid( self.Owner ) and self.Owner:Crouching() then print( "some code here" ) end[/lua]
[QUOTE=bobbleheadbob;47299540]I fixed your bad code. [lua] if IsValid( self.Owner ) and self.Owner:Crouching() then print( "some code here" ) end[/lua][/QUOTE] I made your fixed version of my bad code better. [lua] if ( IsValid( self.Owner ) and self.Owner:Crouching() ) then print( "some code here" ) end[/lua]
I need to check every entity to see if it's sleeping. I've tried this code; [code]for i,e in ipairs(ents.GetAll()) do a = e:GetModel() b = e:GetPhysicsObject() if not (a == nil or b == nil) then PrintMessage(2, "Printing thing " .. i) PrintMessage(2, tostring(a)) PrintMessage(2, tostring(b)) end end [/code] But it throws this error: "Tried to use invalid object (type IPhysicsObject)"
Use !IsValid( variable ) instead of variable == nil for entities, players, panels and physics objects.
Thanks, I replaced the line with "if IsValid(b) then" and it no longer throws errors.
[QUOTE=Robotboy655;47299301]You want to draw a part of the texture on screen? If that is the case, you will need to use surface.DrawTexturedRectUV. If not, can you explain properly, what do you want?[/QUOTE] Okay sorry let me be a little more in depth. So you know how you can position text on a specific part of the screen using ScrH, ScrW, or just plain numbers? Well I want to put an icon (the texture) on a certain position on the screen. I was wondering how I would lay it out. For example: Let's say my text is at 100 , ScrH() - 165 How would I put my icon at let's say 100, SchH() - 180 Thanks again
Also, how do you change the blame of a player death? Say, when a player is killed by a physics prop, that your plugin knows was thrown by another player, how do you change the death message in the feed so that it displays "Player A <death> Player B" instead of "Physics Prop <death> Player B"?
I'm trying to make a real-time decal editor and I'm not entirely sure what I'm doing. It's the first time I've tried anything like this on the client. Heres what I have so far (It doesnt error but it doesnt do anything either): [lua] function vehicleDecal(sModel) local decals = { {"icon32/folder.png", 128, 0} }; local frame = vgui.Create("DFrame"); frame:SetSize(1024, 512); frame:Center(); frame:ShowCloseButton(true); frame:MakePopup(); //frame:SetDraggable(false); local model = vgui.Create("DModelPanel", frame); model:SetModel(sModel); model.Entity:SetSubMaterial(0, "phoenix_storms/stripes"); model:SetSize(512 - 5, 256); model:SetPos(5, 29); model:SetCamPos(Vector(-256, -20, 50)); model.PaintOver = function(s, w, h) surface.SetDrawColor(0, 0, 0, 255); surface.DrawOutlinedRect(0, 0, w, h); end local submatList = vgui.Create("DListView", frame); submatList:SetPos(0, 29); submatList:MoveRightOf(model, 5); submatList:SetSize(model:GetWide() - 10, model:GetTall()); submatList:AddColumn("Real Index"); submatList:AddColumn("Sub-Material"); submatList:SetMultiSelect(false); submatList:SetSortable(false); submatList.OnRowSelected = function(s, index, row) local mat = Material(row:GetValue(2), "vertexlitgeneric nocull smooth"); local matWidth = 512; local matHeight = 512; local xName = "vehicle_decal"; local newRT = GetRenderTarget("rt_" .. xName, 512, 512, false); hook.Add("HUDPaint", "BuildVehicleDecals", function() local oldRT = render.GetRenderTarget(); local oldWidth = ScrW(); local oldHeight = ScrH(); render.SetRenderTarget(newRT); render.SetViewPort(0, 0, matWidth, matHeight); render.Clear(0, 0, 0, 255); render.SetMaterial(mat); render.DrawScreenQuadEx(0, 0, matWidth, mat:Height()); for k,v in SortedPairs(decals) do local decal = Material(v[1], "vertexlitgeneric nocull smooth"); render.SetMaterial(decal); render.DrawScreenQuadEx(v[2], v[3], decal:Width(), decal:Height()); end render.SetViewPort(0, 0, oldWidth, oldHeight); render.SetRenderTarget(oldRT); hook.Remove("HUDPaint", "BuildVehicleDecals"); end); local newMat = CreateMaterial(xName, "VertexLitGeneric", { ["$basetexture"] = newRT, ["$model"] = "1" }); model.Entity:SetSubMaterial(0, newMat:GetName()); end for k, v in SortedPairs(model.Entity:GetMaterials()) do submatList:AddLine(k - 1, v); end end [/lua] For reference, I'm more or less trying to do what EthanTheGreat is doing, except his works and mine doesnt. The way I'm going about it is to get a new render target, draw a rect with the base material, draw more rects with the decal materials then create a new material with the "$basetexture" of the render target. Any help would be appreciated. [b]EDIT:[/b] I've updated the code and found out that a material is actually being created but I'm unable to set it to an entity either by :SetMaterial or :SetSubMaterial. Any ideas?
[code]-- Derive from drive_base (see lua/drive/drive_base.lua DEFINE_BASECLASS( "drive_base" ) drive.Register( "drive_ball", { -- -- Calculates the view when driving the entity -- CalcView = function( self, view ) view.origin = Vector( 0, 0, 0 ) view.angles = Angles( 0, 0, 0 ) view.drawhud = true end, -- -- Called before each move. You should use your entity and cmd to -- fill mv with information you need for your move. -- StartMove = function( self, mv, cmd ) end, -- -- Runs the actual move. On the client when there's -- prediction errors this can be run multiple times. -- You should try to only change mv. -- Move = function( self, mv ) end, -- -- The move is finished. Use mv to set the new positions -- on your entities/players. -- FinishMove = function( self, mv ) end, }, "drive_base" )[/code] I can't seem to modify anything about the CalcView, regardless if the thirdperson thing is in there or not. It actually also doesn't work if I test drive_base or the drive_example on the wiki
[QUOTE=GoldTrigger;47300160]Okay sorry let me be a little more in depth. So you know how you can position text on a specific part of the screen using ScrH, ScrW, or just plain numbers? Well I want to put an icon (the texture) on a certain position on the screen. I was wondering how I would lay it out. For example: Let's say my text is at 100 , ScrH() - 165 How would I put my icon at let's say 100, SchH() - 180 Thanks again[/QUOTE] Just saying, but you shouldn't ever use static numbers when dealing with drawing on client. Always use variables, such as ScrH() - ScrH() * 0.05
[QUOTE=GoldTrigger;47300160]Okay sorry let me be a little more in depth. So you know how you can position text on a specific part of the screen using ScrH, ScrW, or just plain numbers? Well I want to put an icon (the texture) on a certain position on the screen. I was wondering how I would lay it out. For example: Let's say my text is at 100 , ScrH() - 165 How would I put my icon at let's say 100, SchH() - 180 Thanks again[/QUOTE] It depends on your text align, but just put the position into surface.DrawTexturedRect? I honestly can't understand your problem. If you don't know how to draw an icon, you can an example here: [url]http://wiki.garrysmod.com/page/surface/DrawTexturedRect[/url]
So i'm thinking of creating a login system, that will basically let a mod run if a valid serial key is put in the config file. So when a server uses it I could http.Post and change the status to "in use", but I want it so when the server is down or going down to change the status on my hosting to "not in use". How does one do it?
Sorry, you need to Log In to post a reply to this thread.