[QUOTE=VIoxtar;47445333]Sorry, I was being unclear. By force limits, I meant constraint force limits, such as welds, ropes, and the like. How does a rope know when to tear, or how does a weld know when to break? Where can I find the code that handles these?[/QUOTE]
Those are written in C++ too. You may be able to find it on the Source SDK 2013 github repo though.
[editline]2nd April 2015[/editline]
[QUOTE=Sheeplie;47445356]Now I'm trying to make it so that GM:OnPlayerChat, it will make the player's text red.
I've put this in addons/playerchat/lua/autorun/client
[CODE]
function GM:OnPlayerChat( player, text, bTeamOnly, bIsdead )
chat.AddText( player, ": ", Color( 192, 57, 43, 255 ), text )
end[/CODE]
I usually get an error saying that GM is a nil value.[/QUOTE]
GM:* functions are for GAMEMODES!
You must use hook.Add in addons:
[url]http://wiki.garrysmod.com/page/hook/Add[/url]
Okay, now is there any way to get rid of the old OnPlayerChat function? I'm using this on sandbox and when I speak this basically happens.
[IMG]http://i.imgur.com/8eWSB8E.jpg[/IMG]
return true.
[del]Ok apparently client-side when I call a function that does a timer.Create(), 'Create' is thrown as nil. I originally had it set as a DoClick which threw it as nil, but if I place it outside of a function it works. What am I doing wrong or not seeing?[/del]
K I'm retarded. Had a var named timer that I didn't delete earlier. >.>
[QUOTE=Robotboy655;47445626]return true.[/QUOTE]
I'm not sure exactly what you mean.
I still gave it a shot with something, but I don't think I'm on the right page because it didn't work.
Sorry if I sound spoon-hungry, I would like to learn.
[QUOTE=Sheeplie;47445763]I'm not sure exactly what you mean.
I still gave it a shot with something, but I don't think I'm on the right page because it didn't work.
Sorry if I sound spoon-hungry, I would like to learn.[/QUOTE]
[lua]
hook.Add("OnPlayerChat", "eeeh", function(whatever)
-- if your code is activated
-- do stuff
return true
-- end
end)
[/lua]
[editline]2nd April 2015[/editline]
On the wiki pages, if you can return something to block a function in a hook it will be listed in "Returns" (since that will be returned by hook.Call)
Why doesnt this code work ?
[code]
if SERVER and tr.Hit and tr.HitNonWorld and IsValid(hitEnt) then
if hitEnt:IsPlayer() then
-- knife damage is never karma'd, so don't need to take that into
-- account we do want to avoid rounding error strangeness caused by
-- other damage scaling, causing a death when we don't expect one, so
-- when the target's health is close to kill-point we just kill
if hitEnt:Health() < (self.Primary.Damage + 10) then
self:StabKill(tr, spos, sdest)
else
local dmg = DamageInfo()
dmg:SetDamage(100)
dmg:SetAttacker(self.Owner)
dmg:SetInflictor(self.Weapon or self)
dmg:SetDamageForce(self.Owner:GetAimVector() * 5)
dmg:SetDamagePosition(self.Owner:GetPos())
dmg:SetDamageType(DMG_SLASH)
self.Owner:StripWeapon(self.Owner:GetActiveWeapon():GetClass())
hitEnt:DispatchTraceAttack(dmg, spos + (self.Owner:GetAimVector() * 3), sdest)
end
end
end
[/code]
It shows no errors and is part of the TTT knife script, which can be found @ [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_knife.lua[/url]
The part that doesnt work is the strip weapon.
-snip late-
Hey jog my memory really quick; does gmod accept .otf fonts or just .ttf?
Hey, does anyone know how I can bonemanipulate a clientside model using lua?
[QUOTE=NiandraLades;47447268]Hey jog my memory really quick; does gmod accept .otf fonts or just .ttf?[/QUOTE]
.ttf for sure, I think I might've used an .oft before but I cant remember
I try this in console.
[CODE]
lua_run_cl surface.PlaySound("items/ammo_pickup.wav")[/CODE]
[I]Nothing[/I] Happens. ;-;
[QUOTE=Sheeplie;47448028]I try this in console.
[CODE]
lua_run_cl surface.PlaySound("items/ammo_pickup.wav")[/CODE]
[I]Nothing[/I] Happens. ;-;[/QUOTE]
sv_allowcslua needs to be set to 1
[QUOTE=NiandraLades;47447268]Hey jog my memory really quick; does gmod accept .otf fonts or just .ttf?[/QUOTE]
GMod does accept .otfs. (Verified today)
[QUOTE=man with hat;47448081]sv_allowcslua needs to be set to 1[/QUOTE]
Thanks, sometimes I forget the simplest tricks.
I'm trying to make a simple third person HUD with 3d2d
When other players are on screen the 3d2d doubles and the double is on a different angle.
[IMG]http://i.imgur.com/lbe3D7G.png[/IMG]
I'm not using HUDPaint yet because I wanted the default hud still usable when the third person hud is off.
I'm running this through the PostPlayerDraw hook.
I lock the hud to a bones position to make it follow the player.
I also have an angle offset to get the hud where i want it though and I wonder if that could cause some issues.
I have another function added to the hook as well for other player hp and armor.
My related variables and my cam.Start line
[Lua]local offset = Vector( 0, 0, -3 )
local AngOffset = Angle(5,-110,90)
local BonePos = ply:GetBonePosition( 4 )
local drawPos = BonePos + offset
local playAng =ply:GetAngles()
local drawAng =playAng + AngOffset
playAng:RotateAroundAxis(playAng:Up(), 270)
playAng:RotateAroundAxis(playAng:Forward(), 70)
cam.Start3D2D( drawPos + playAng:Up() * 16.5,drawAng, 0.2 )
[/Lua]
[QUOTE=Sonickblast;47448356]I'm trying to make a simple third person HUD with 3d2d
When other players are on screen the 3d2d doubles and the double is on a different angle.
[IMG]http://i.imgur.com/lbe3D7G.png[/IMG]
I'm not using HUDPaint yet because I wanted the default hud still usable when the third person hud is off.
I'm running this through the PostPlayerDraw hook.
I lock the hud to a bones position to make it follow the player.
I also have an angle offset to get the hud where i want it though and I wonder if that could cause some issues.
I have another function added to the hook as well for other player hp and armor.
My related variables and my cam.Start line
[Lua]local offset = Vector( 0, 0, -3 )
local AngOffset = Angle(5,-110,90)
local BonePos = ply:GetBonePosition( 4 )
local drawPos = BonePos + offset
local playAng =ply:GetAngles()
local drawAng =playAng + AngOffset
playAng:RotateAroundAxis(playAng:Up(), 270)
playAng:RotateAroundAxis(playAng:Forward(), 70)
cam.Start3D2D( drawPos + playAng:Up() * 16.5,drawAng, 0.2 )
[/Lua][/QUOTE]
What hook are you using? Can you supply all the code necessary to run the script?
[QUOTE=Willox;47448480]What hook are you using? Can you supply all the code necessary to run the script?[/QUOTE]
I am using PostPlayerDraw as my hook.
[LUA] CreateClientConVar( "third_person_hud", "0", true, false )
hook.Add( "PostPlayerDraw", "third_person_hud_hook", function()
if GetConVarNumber( "third_person_hud" ) == 1 then
if CLIENT then
local ply = LocalPlayer()
if ply:IsValid() and ply:Alive() then
local armor = ply:Armor()
local health = ply:Health()
local offset = Vector( 0, 0, -3 )
local AngOffset = Angle(5,-110,90)
local BonePos = ply:GetBonePosition( 4 )
local drawPos = BonePos + offset
local playAng =ply:GetAngles()
local drawAng =playAng + AngOffset
local wep = ply:GetActiveWeapon()
local reserve = ply:GetAmmoCount(wep:GetPrimaryAmmoType())
local clip1 = ply:GetActiveWeapon():Clip1()
local clip2 = ply:GetActiveWeapon():Clip2()
local sec = ply:GetAmmoCount(LocalPlayer():GetActiveWeapon():GetSecondaryAmmoType())
playAng:RotateAroundAxis(playAng:Up(), 270)
playAng:RotateAroundAxis(playAng:Forward(), 70)
--3D Draw Panel
cam.Start3D2D( drawPos + playAng:Up() * 16.5,drawAng, 0.2 )
draw.RoundedBox(10, -20, 25, 70, 50, Color( 0,0,0,70) )
if health > 100 then health = 100 end
draw.SimpleText( "HP: " .. tostring(health), ChatFont, -10, 30, Color(256, 256, 256, 256))
draw.RoundedBox(4, -18, -5, -5, 100, Color( 100,100,100,150) )
draw.RoundedBox(4, -18, -5, -5, health, Color( 256,50,50,150) )
if armor > 0 then
if armor > 100 then armor = 100 end
draw.RoundedBox(.2, -15, -5, -5, armor, Color( 50,50,256,256) )
draw.SimpleText( "Armor: " .. tostring(armor), ChatFont, -10, 40, Color(256, 256, 256, 256))
end
if clip1 > -1 then
if clip1 > 100 then clip1 = 100 end
if reserve > 999 then reserve = 999 end
draw.RoundedBox(.2, -23, -5, -5, clip1, Color( 50,256,50,256) )
draw.SimpleText( "Clip: " .. tostring(clip1).. "/".. tostring(reserve), ChatFont, -10, 50, Color(256, 256, 256, 256))
end
if clip2 > 0 then
if clip2 > 100 then clip2 = 100 end
draw.RoundedBox(.2, -22, -5, -5, clip2, Color( 0,0,0,256) )
draw.SimpleText( "Sec: " .. tostring(clip2), ChatFont, -10, 60, Color(256, 256, 256, 256))
end
if sec> 0 then
if sec > 100 then sec = 100 end
draw.RoundedBox(.2, -22, -5, -5, sec, Color( 0,0,0,256) )
draw.SimpleText( "Sec: " .. tostring(sec), ChatFont, -10, 60, Color(256, 256, 256, 256))
end
cam.End3D2D()
end
end
end
end
)[/LUA]
[QUOTE=Sonickblast;47448503]I am using PostPlayerDraw as my hook.
[LUA] CreateClientConVar( "third_person_hud", "0", true, false )
hook.Add( "PostPlayerDraw", "third_person_hud_hook", function()
if GetConVarNumber( "third_person_hud" ) == 1 then
if CLIENT then
local ply = LocalPlayer()
if ply:IsValid() and ply:Alive() then
local armor = ply:Armor()
local health = ply:Health()
local offset = Vector( 0, 0, -3 )
local AngOffset = Angle(5,-110,90)
local BonePos = ply:GetBonePosition( 4 )
local drawPos = BonePos + offset
local playAng =ply:GetAngles()
local drawAng =playAng + AngOffset
local wep = ply:GetActiveWeapon()
local reserve = ply:GetAmmoCount(wep:GetPrimaryAmmoType())
local clip1 = ply:GetActiveWeapon():Clip1()
local clip2 = ply:GetActiveWeapon():Clip2()
local sec = ply:GetAmmoCount(LocalPlayer():GetActiveWeapon():GetSecondaryAmmoType())
playAng:RotateAroundAxis(playAng:Up(), 270)
playAng:RotateAroundAxis(playAng:Forward(), 70)
--3D Draw Panel
cam.Start3D2D( drawPos + playAng:Up() * 16.5,drawAng, 0.2 )
draw.RoundedBox(10, -20, 25, 70, 50, Color( 0,0,0,70) )
if health > 100 then health = 100 end
draw.SimpleText( "HP: " .. tostring(health), ChatFont, -10, 30, Color(256, 256, 256, 256))
draw.RoundedBox(4, -18, -5, -5, 100, Color( 100,100,100,150) )
draw.RoundedBox(4, -18, -5, -5, health, Color( 256,50,50,150) )
if armor > 0 then
if armor > 100 then armor = 100 end
draw.RoundedBox(.2, -15, -5, -5, armor, Color( 50,50,256,256) )
draw.SimpleText( "Armor: " .. tostring(armor), ChatFont, -10, 40, Color(256, 256, 256, 256))
end
if clip1 > -1 then
if clip1 > 100 then clip1 = 100 end
if reserve > 999 then reserve = 999 end
draw.RoundedBox(.2, -23, -5, -5, clip1, Color( 50,256,50,256) )
draw.SimpleText( "Clip: " .. tostring(clip1).. "/".. tostring(reserve), ChatFont, -10, 50, Color(256, 256, 256, 256))
end
if clip2 > 0 then
if clip2 > 100 then clip2 = 100 end
draw.RoundedBox(.2, -22, -5, -5, clip2, Color( 0,0,0,256) )
draw.SimpleText( "Sec: " .. tostring(clip2), ChatFont, -10, 60, Color(256, 256, 256, 256))
end
if sec> 0 then
if sec > 100 then sec = 100 end
draw.RoundedBox(.2, -22, -5, -5, sec, Color( 0,0,0,256) )
draw.SimpleText( "Sec: " .. tostring(sec), ChatFont, -10, 60, Color(256, 256, 256, 256))
end
cam.End3D2D()
end
end
end
end
)[/LUA][/QUOTE]
You're rendering an HUD on your LocalPlayer every time [b]any[/b] player has been drawn. Of course you're going to be getting more HUDs drawn than you want! An easy solution is to use the player parameter passed to the PostPlayerDraw hook and check if it is LocalPlayer before drawing.
-snip didnt read - (new to forum posting i think i did it right)
[QUOTE=Sonickblast;47448534]Oh ok I'll have to find another hook then. The only reason I wouldn't use HudPaint is because of needing the normal hud while not using third person (the addon can shut off hudpaint huds i think).[URL="http://steamcommunity.com/sharedfiles/filedetails/?id=108168164"]http://steamcommunity.com/sharedfiles/filedetails/?id=108168164[/URL][/QUOTE]
Looks like I edited my post a little too late.
"An easy solution is to use the player parameter passed to the PostPlayerDraw hook and check if it is LocalPlayer before drawing."
I just realised I could of set ply in the function paramaters after I looked up the hook. Thanks for your help. I got what you meant now. The problem is fixed on both bits of the code(My hud and the hud showing other players hp and armor).
How would I go about making this crowbar invisible so its replacement can be seen? I'm using the SWEP Construction kit.
[code]
SWEP.ViewModel = "models/weapons/c_crowbar.mdl"
SWEP.WorldModel = "models/weapons/w_crowbar.mdl"
SWEP.ViewModelFlip = false
SWEP.ShowViewModel = false
SWEP.ShowWorldModel = true
SWEP.ViewModelBoneMods = {}
SWEP.VElements = {
["Hook"] = { type = "Model", model = "models/props_junk/meathook001a.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(5, 2, -7.87), angle = Angle(2, 75.973, -6), size = Vector(0.5, 0.5, 0.5), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
[/code]
[IMG]http://i.gyazo.com/aa64e6ef9de0cd371bb0a0d7d19760d1.png[/IMG]
If you arent rendering your hook model in the viewmodel SWEP hook, you can use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/DrawViewModel]Player:DrawViewModel[/url].
I'm going to assume your are so instead you should be able to vm:SetMaterial( "engine/occlusionproxy" ) in PreDrawViewModel.
What's the easiest way to make an entity not collide with anything but players?
Does anyone know how I could use CreateMaterial? I'm trying to create some dummy materials for rendertargets.
[QUOTE=Drakehawke;47450067]What's the easiest way to make an entity not collide with anything but players?[/QUOTE]
ent:SetCollisionGroup(COLLISION_GROUP_PLAYER).
[QUOTE=G4MB!T;47450143]ent:SetCollisionGroup(COLLISION_GROUP_PLAYER).[/QUOTE]
Doesn't work
Found something interesting. GMod doesn't seem to let you pull bools from IMaterials. Is there any alternative to manually parsing the VMT?
[QUOTE=TFA;47450357]Found something interesting. GMod doesn't seem to let you pull bools from IMaterials. Is there any alternative to manually parsing the VMT?[/QUOTE]
GetInt() == 1?
Sorry, you need to Log In to post a reply to this thread.