[code]hook.Add( "PostDrawOpaqueRenderables", "f", function()
render.ClearStencil()
render.SetStencilEnable( true )
render.SetStencilWriteMask( 3 )
render.SetStencilTestMask( 3 )
render.SetStencilReferenceValue( 2 )
render.SetStencilCompareFunction( STENCIL_ALWAYS )
render.SetStencilPassOperation( STENCIL_REPLACE )
render.SetStencilFailOperation( STENCIL_KEEP )
render.SetStencilZFailOperation( STENCIL_KEEP )
render.SetBlend( 0 )
Model:DrawModel()
render.SetBlend( 1 )
render.SetStencilCompareFunction( STENCIL_EQUAL )
--[[
render.SetMaterial( rt_mat )
render.DrawScreenQuad()
]]
cam.Start2D()
surface.SetDrawColor( color_white )
surface.SetMaterial( rt_mat )
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() )
cam.End2D()
render.SetStencilEnable( false )
end )[/code]
[del]
Is render.DrawScreenQuad() broken or some shit? The commented out code simply renders the entire render target to the screen, but surface code below it works exactly as intended. Model is a clientsidemodel and rt_mat is just a material linked to a rendertarget sized to the screen resolution.[/del]
Nevermind, RenderScreenQuad isn't for what I think it's for.
So I'm making a shotgun. It uses the C_SHOTGUN model, the Half-Life 2 model, vanilla. I don't want to recompile it, but I have a problem. When it animates, it doesn't play its sounds. Thanks to that, I use EmitSound. The problem is, if I pump the shotgun, and then reload, the pump sound will also play when I fire. I've verified it, and not a single function is being run other than PrimaryAttack when that happens... which means the model itself is emitting the sound. How can I stop this?
Can you create a single particle in gmod besides having some pre-rendered effect?
I was looking at this but I am confused on how to actually spawn said particle: [url]http://wiki.garrysmod.com/page/Category:EFFECT_Hooks[/url]
[url]http://wiki.garrysmod.com/page/util/Effect[/url]
Just searching the wiki helps dude
Anyone know how I would go about implementing aim assist?
[QUOTE=jaooe;48003240]Anyone know how I would go about implementing aim assist?[/QUOTE]
Do a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/TraceHull]util.TraceHull[/url] on the entity the player is looking at and add a small amount to the mins and maxs, then [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/SetEyeAngles]Player:SetEyeAngles[/url] at the center of the player or something.
-snip-
Is there anything that can cause SetPData to not save properly? With the same script on multiple different hosts it just seems that at one of them, SetPData doesn't save at all sometimes
[QUOTE=Busan1;48004925]Is there anything that can cause SetPData to not save properly? With the same script on multiple different hosts it just seems that at one of them, SetPData doesn't save at all sometimes[/QUOTE]
Could be something to do with file permissions, SetPData saves to sv.db so if it doesn't have permission to, maybe that's the cause?
[QUOTE=meharryp;48003433]Do a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/TraceHull]util.TraceHull[/url] on the entity the player is looking at and add a small amount to the mins and maxs, then [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/SetEyeAngles]Player:SetEyeAngles[/url] at the center of the player or something.[/QUOTE]
Wouldn't it be best to do the trace hull just to find the entity? Then it comes to finding the nearest hitbox, and rotating EyeAngles to better aim towards it. Only problem is, if anything is even close to the crosshair, and closer than your target, and still passes the filter, it won't work.
[editline]19th June 2015[/editline]
Or... if not trying to aim at hitboxes, just the entity, which is a player, raise the target's Z pos by 56 units to aim at the heart, or 64 to aim at head.
[editline]19th June 2015[/editline]
48 units for gut I believe.
Does anyone know how to reload an entities collision box after changing it's model?
Using Entity:PhysicsInit works but it removes the constraints attached to the entity and also has the old model's shadow.
Is there an easy way to reload the collision box and the shadow?
[QUOTE=Jazzelhawk;48005948]Does anyone know how to reload an entities collision box after changing it's model?
Using Entity:PhysicsInit works but it removes the constraints attached to the entity and also has the old model's shadow.
Is there an easy way to reload the collision box and the shadow?[/QUOTE]
You can't change the collision box without breaking all constraints (without recreating the physics obj ).
Is there a way to get the constraints and then re apply them after recreating the physics object?
Anyone know how I could play a sound if a player has fallen a certain distance? Like if I jump off a cliff, if I fall a certain distance then I play a sound.
[QUOTE=A Fghtr Pilot;48008547]Anyone know how I could play a sound if a player has fallen a certain distance? Like if I jump off a cliff, if I fall a certain distance then I play a sound.[/QUOTE]
Do you mean in mid-air?
I'm using this to change the skin of my object when E is pressed on it
[CODE]function ENT:Use( activator, caller )
local skin = self:GetSkin()
self:SetSkin( ( skin + 1) )
if skin == 4 then
self:SetSkin( 0 )
end
end[/CODE]
The model DOES switch skins (I can tell by holding C, the then right-clicking on it), and there are NO errors in console, but the actual model does not visually change..
If I spawn just the prop version then change it manually, the skins work. Do I need to precache the skins, like with sounds? Or another way of telling Lua that the materials in the .qc and /materials/ are in fact skins?
[QUOTE=zeaga;48009367]Do you mean in mid-air?[/QUOTE]
Yep
following this thread [url]http://facepunch.com/showthread.php?t=1395008[/url]
what would i need to add to the code to have a max of 10 zombies in the map at any one time
being a lua noob i didnt realize the above code stopped wen te player left the server
and i have a work around atm which is a kill counter to reload the map when all the zombies are killed,
Alright, I've already asked this on another thread, but this is my last resort for doing something like this, as noone is helping me...
I want to make a 3 round burst code. I've heard of using a delay variable in a think hook, though I have no idea how I'd use that. Please, help...
[QUOTE=A Fghtr Pilot;48010648]Alright, I've already asked this on another thread, but this is my last resort for doing something like this, as noone is helping me...
I want to make a 3 round burst code. I've heard of using a delay variable in a think hook, though I have no idea how I'd use that. Please, help...[/QUOTE]
[url]http://facepunch.com/showthread.php?t=1409069[/url] might help
I'm trying to make a money printer for my sandbox server's money system. The problem is I have multiple values set in the entity (time,maxtime,ink,value and cash). Time gets set just fine in the think hook but Ink and Cash only get set clientside and not serverside making it so I can't get money.
Code:
[code]
AddCSLuaFile()
easylua.StartEntity("fbox_money_printer") --for testing, ignore
ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.Category = "Utilities"
ENT.PrintName = "Money Printer"
ENT.Author = "Flex"
ENT.Purpose = "MONEY MONEY MONEY"
ENT.Model = "models/props_c17/consolebox01a.mdl"
ENT.Spawnable = true
ENT.AdminOnly = true
ENT.Time = 0
ENT.MaxTime = 600
ENT.Ink = 100
ENT.Value = 50
ENT.Cash = 0
function ENT:Think()
local owner = self.Owner
if SERVER then
if IsValid(self) then
self:SetModel(self.Model)
end
end
self.Time = self.Time + 1
if self.Time == self.MaxTime then
self.Time = 0
if self.Ink > 0 then
self.Ink = self.Ink - 10
self.Cash = self.Cash + self.Value
if SERVER then
self.Ink = self.Ink - 10
self.Cash = self.Cash + self.Value
end
elseif self.Ink < 0 then
if SERVER then
owner:PrintMessage(3,"[FPrinter] Your money printer has ran out of ink and caught on fire!")
self:Ignite(100,10)
timer.Simple(600,function()
owner:PrintMessage(3,"[FPrinter] Your money printer has overheated and exploded!")
self:Remove()
end)
end
end
end
end
function ENT:Use( activator, caller )
local owner = self.Owner
if self.Cash < 0 then
if owner.GiveMoney then
owner:GiveMoney(self.Cash) --Give money if my money system
elseif owner.GiveCoins then
owner:GiveCoins(self.Cash,"Money Printer") --Give coins if Meta's money system
end
self.Cash = 0
owner:PrintMessage(3,"[FPrinter] You took $"..self.Cash.." from your money printer")
end
end
function ENT:Draw()
self:DrawModel()
local owner = self:CPPIGetOwner()
local pos = self:GetPos()
local ang = self:GetAngles()
ang:RotateAroundAxis(ang:Right(),90)
ang:RotateAroundAxis(ang:Forward(),180)
ang:RotateAroundAxis(ang:Up(),-90)
cam.Start3D2D(pos+ang:Up()*17,ang,0.15)
draw.RoundedBox(0,-98,-70,200,64,Color(0,0,0,200))
draw.SimpleTextOutlined("Owner: "..owner:RealName().." ("..owner:GetUserGroup()..")","default",-90,-64,Color(0,255,0),nil,nil,2,color_black)
draw.SimpleTextOutlined("Value: "..self.Value,"default",-90,-52,Color(0,128,255),nil,nil,2,color_black)
draw.SimpleTextOutlined("Ink: "..self.Ink,"default",-32,-52,color_white,nil,nil,2,color_black)
draw.SimpleTextOutlined("Next Print: "..self.Time.."/"..self.MaxTime,"default",-90,-40,Color(255,0,0),nil,nil,2,color_black)
draw.SimpleTextOutlined("Stored Cash: $"..self.Cash,"default",-90,-28,Color(255,128,0),nil,nil,2,color_black)
cam.End3D2D()
end
function ENT:Initialize()
if SERVER then
self:SetModel( self.Model )
self:SetModelScale(1)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetUseType(3)
self.Owner = self:CPPIGetOwner()
local phys = self:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
end
end
easylua.EndEntity(false,true) --for testing, ignore
[/code]
is it possible to use a module in the menu state?
[QUOTE=PortalGod;48011798]is it possible to use a module in the menu state?[/QUOTE]
Prefix it with gmsv_. The code for require() is similar to:
[code]
function require( name )
local prefix = "gmsv_"
if CLIENT then
prefix = "gmcl_"
end
require_internal( prefix .. name .. suffix )
end
[/code]
Is there a method to retrieve the IP address of the server you're currently playing on? I am on my dedicated and using GetConVarString("ip") just returns localhost
[QUOTE=NiandraLades;48012933]Is there a method to retrieve the IP address of the server you're currently playing on? I am on my dedicated and using GetConVarString("ip") just returns localhost[/QUOTE]
[url]http://facepunch.com/showthread.php?t=1160598&p=38629185&viewfull=1#post38629185[/url]
I'm making an addon that adds custom spawnlists into the spawnmenu. The problem I'm running into is that I have 2 of these addons, one for Portal 2 items, and one for Left 4 Dead 2 items, and the issue is that they can't be used together at the same time. (i.e. one has to be disabled for the other one to show up in the spawnmenu.) I don't know much about lua at the moment (noob), but I was wondering if someone could give me a pointer about why that is happening, and any advice on how to solve the issue.
Left 4 Dead 2 code in left4dead2list_init.lua located in \lua\autorun\
[lua]
if SERVER then
AddCSLuaFile( "left4dead2list/spawnlist/800-left4dead2.lua" )
AddCSLuaFile( "left4dead2list/spawnlist/801-characters.lua" )
AddCSLuaFile( "left4dead2list/spawnlist/802-weapons.lua" )
AddCSLuaFile( "left4dead2list/spawnlist/803-propsaf.lua" )
AddCSLuaFile( "left4dead2list/spawnlist/804-propsgm.lua" )
AddCSLuaFile( "left4dead2list/spawnlist/805-propsnt.lua" )
AddCSLuaFile( "left4dead2list/spawnlist/806-propsuz.lua" )
else
CreateClientConVar( "left4dead2list_autolist", 1 )
local function MenuPopulate()
if not tobool( LocalPlayer():GetInfoNum( "left4dead2list_autolist", 1 ) ) then return end
local ListTable = file.Find( "left4dead2list/spawnlist/*.lua", "LUA" )
for _, TempList in pairs( ListTable ) do
local ListData = util.KeyValuesToTable( CompileFile( "left4dead2list/spawnlist/" .. TempList )() )
spawnmenu.AddPropCategory( "settings/spawnlist/" .. TempList, ListData.name, ListData.contents, ListData.icon, ListData.id, ListData.parentid )
end
end
hook.Add( "PopulatePropMenu", "StopStealingMahDamnedHooks", MenuPopulate )
end[/lua]
Portal 2 code in portal2list_init.lua located in \lua\autorun\
[lua]
if SERVER then
AddCSLuaFile( "portal2list/spawnlist/700-portal2.lua" )
AddCSLuaFile( "portal2list/spawnlist/701-characters.lua" )
AddCSLuaFile( "portal2list/spawnlist/702-portalprops.lua" )
AddCSLuaFile( "portal2list/spawnlist/703-props.lua" )
else
CreateClientConVar( "portal2list_autolist", 1 )
local function MenuPopulate()
if not tobool( LocalPlayer():GetInfoNum( "portal2list_autolist", 1 ) ) then return end
local ListTable = file.Find( "portal2list/spawnlist/*.lua", "LUA" )
for _, TempList in pairs( ListTable ) do
local ListData = util.KeyValuesToTable( CompileFile( "portal2list/spawnlist/" .. TempList )() )
spawnmenu.AddPropCategory( "settings/spawnlist/" .. TempList, ListData.name, ListData.contents, ListData.icon, ListData.id, ListData.parentid )
end
end
hook.Add( "PopulatePropMenu", "StopStealingMahDamnedHooks", MenuPopulate )
end[/lua]
it's happening because you're using the same hook name for both files (StopStealingMahDamnedHooks)
[QUOTE=PortalGod;48015591]it's happening because you're using the same hook name for both files (StopStealingMahDamnedHooks)[/QUOTE]
Ah ok thx, so I simply need to change that to per-say "StopStealingMahDamnedHooksTwo" or something like that in one of the lua files.
Anyone know why IN_ATTACK2 isn't working? Jump and attack seem to work fine though.
[lua]hook.Add( "KeyPress", "doThatStuff", function( ply, key )
local spwnKeys = { IN_JUMP, IN_ATTACK, IN_ATTACK2 }
if spwnKeys[key] then
doStuff()
end
end )[/lua]
Also, here is a nice bump:
[QUOTE=YourStalker;47986349]You know how right after you die for a few seconds (or until you click a button) your camera goes third person around your corpse? How could I check when a player enters/exits that. GetObserverMode/Target both don't work. Mode will always return 0 and Target wont return anything.[/QUOTE]
Sorry, you need to Log In to post a reply to this thread.