[QUOTE=Drakehawke;47450067]What's the easiest way to make an entity not collide with anything but players?[/QUOTE]
When you alter collision groups you may need to use this: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/EnableCustomCollisions]Entity:EnableCustomCollisions[/url]
You could use ShouldCollide hook ( since it is a static rule you plan on adding... ) Check that ent2 collision group is PLAYER. IF so, if ent1 is world or player then return true, else return false although there should be a collision group that works: [url]http://wiki.garrysmod.com/page/Enums/COLLISION[/url]
[editline]3rd April 2015[/editline]
[QUOTE=TFA;47450083]Does anyone know how I could use CreateMaterial? I'm trying to create some dummy materials for rendertargets.[/QUOTE]
[url]http://wiki.garrysmod.com/page/Global/CreateMaterial[/url]
[url]https://developer.valvesoftware.com/wiki/Category:List_of_Shader_Parameters[/url]
[url]http://wiki.garrysmod.com/page/Category:Shaders[/url]
So: local _mat = CreateMaterial( "blah", "ShatteredGlass", { [ "$basetexture" ] = "icon16/heart.png" } );
You can create custom names if you set up base-texture, etc...
[QUOTE=G4MB!T;47450053]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.[/QUOTE]
Second one worked, thanks! This is brutal looking
[img]http://i.gyazo.com/97a50f90c0f693c74d7ebe12958af208.png[/img]
[QUOTE=Acecool;47450487]When you alter collision groups you may need to use this: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/EnableCustomCollisions]Entity:EnableCustomCollisions[/url]
You could use ShouldCollide hook ( since it is a static rule you plan on adding... ) Check that ent2 collision group is PLAYER. IF so, if ent1 is world or player then return true, else return false although there should be a collision group that works: [url]http://wiki.garrysmod.com/page/Enums/COLLISION[/url]
[/QUOTE]
Yeah this is what I'm currently doing
[lua]
ent:SetCustomCollisionCheck( true )
local index = ent:EntIndex()
hook.Add( "ShouldCollide", "NoCollide_" .. index, function( e, f )
if not IsValid( e ) or not IsValid( f ) then return end
if e:EntIndex() == index and not f:IsPlayer() then return false end
if f:EntIndex() == index and not e:IsPlayer() then return false end
end )[/lua]
Just seems to be an awful way of doing it.
[editline]3rd April 2015[/editline]
I haven't yet found a collision group that achieves it though.
[QUOTE=Exho;47450542]Second one worked, thanks! This is brutal looking
[t]http://i.gyazo.com/97a50f90c0f693c74d7ebe12958af208.png[/t][/QUOTE]
Looks sick as. Also looks like you have a head crab leg as a weapon.
[QUOTE=Acecool;47450487]-snip-
local _mat = CreateMaterial( "blah", "ShatteredGlass", { [ "$basetexture" ] = "icon16/heart.png" } );
[/QUOTE]
Unfortunately, this doesn't work with SetSubMaterial in my tests. I was using VertexLitGeneric as my shader and set the base texture to a RT that I verified was working, as it worked when using Material("somepath").
[QUOTE=Robotboy655;47450381] :GetInt() [/QUOTE]
Doesn't work. It simply doesn't return anything on certain parameters e.g. mat:GetInt("$translucent").
[QUOTE=Sonickblast;47448503]I am using PostPlayerDraw as my hook.
[/QUOTE]
A few things... PostPlayerDraw is clientside, you don't need if CLIENT then...
You're setting ply to LocalPlayer( ) but you're using ply:IsValid ( use IsValid( ply ), even though technically LocalPlayer( ) will return NULL, an empty entity, if the player hasn't been initialized yet.. it's nice to keep the IsValids uniform.. )
Code is not organized and isn't human-friendly ( no tabs meaning you can't take a quick glance and understand everything; you have to read and see where the ifs start, the ends etc... )
You're setting all vars as > 100 then 100... You should use the max vars such as... local _health = _p:Health( );
local _health_mod = _health / _p:GetMaxHealth( ); -- creates 0-1 modifier you multiply by your boxes
And, you can clamp the var if need be but it is unlikely the player will every exceed the max value of the var, or they shouldn't anyway. But, if so just grab the modifier and clamp if needed... You could also use ternary to shorten the code a bit.
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/hud/basic_healthbar.lua.html[/url]
You define vars such as wep but you end up not even using it and re-type the GetActiveWeapon stuff over and over...
You're deliberately using logic which tabs inward when inverse logic can clean up the code...
You're not layering the hud in sequence ( so health can display, then armor, then weapon, etc... you're grabbing all at once and hoping no errors occur )...
The code isn't standardized at all.. you have spaces in random places, variables named differently, etc... there's no sense of style...
etc etc etc etc..
Take a look at this - mandatories example 2: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/hud/proper_hud_creation.lua.html[/url]
I rewrote it real quick in my coding standards ( sorry ), added config, removed useless code, etc.. I didn't add everything to config, and I didn't verify the code but I should have copied all var data properly...
[code]//
//
//
//
//
//
CreateClientConVar( "third_person_hud", "0", true, false )
local hud_config = {
// Pos = x, y; Size = w, h; Buffer / Border = b; Foreground Color = fg_color;
// Background color = bg_color; Display Text = text;
hp = {
text = {
font = "Default";
x, y = -10, 30;
text = "Health: %d%";
color = Color( 256, 256, 256, 256 );
};
corner, b = 4, 0;
x, y, w, h = -18, -5, -5, 100;
fg_color = Color( 256, 50, 50, 150 );
bg_color = Color( 100, 100, 100, 150 );
};
// Pos = x, y; Size = w, h; Buffer / Border = b; Foreground Color = fg_color;
// Background color = bg_color; Display Text = text;
ap = {
text = {
font = "Default";
x, y = -10, 40;
text = "Armor: %d%";
color = Color( 256, 256, 256, 256 );
};
corner, b = 0.2, -5;
x, y, w, h = -15, -5, -5, 100;
fg_color = Color( 50, 50, 256, 256 );
};
//
mag1 = {
text = {
font = "Default";
x, y = -10, 60;
text = "Mag: %d%";
color = Color( 256, 256, 256, 256 );
};
corner, b = 0.2, 0;
x, y, w, h = -23, -5, -5, 100;
fg_color = Color( 50, 256, 50, 256 );
};
//
mag2 = {
text = {
font = "Default";
x, y = -10, 60;
text = "Sec: %d%";
color = Color( 256, 256, 256, 256 );
};
corner, b = 0.2, 0;
x, y, w, h = -22, -5, -5, 100;
fg_color = Color( 0, 0, 0, 256 );
};
//
ammo2 = {
text = {
font = "Default";
x, y = -10, 60;
text = "Sec: %s";
color = Color( 256, 256, 256, 256 );
};
corner, b = 0.2, 0;
x, y, w, h = -22, -5, -5, 100;
fg_color = Color( 0, 0, 0, 256 );
};
};
//
//
//
hook.Add( "PostPlayerDraw", "third_person_hud_hook", function( )
// Check player setting first..
if ( GetConVarNumber( "third_person_hud" ) == 0 ) then return; end
// Player mandatory check
local _p = LocalPlayer( );
if ( !IsValid( _p ) || !_p:Alive( ) ) then return; end
//
local _cfg = hud_config;
//
local _pos = _p:GetPos( );
local _ang = _p:GetAngles( );
//
local _offset = Vector( 0, 0, -3 );
local _ang_offset = Angle( 5, -110, 90 );
local _pos_bone = _p:GetBonePosition( 4 );
local _pos_draw = _pos_bone + _offset;
local _ang_draw =_ang + _ang_offset;
--3D Draw Panel
cam.Start3D2D( _pos_draw + _ang:Up( ) * 16.5, _ang_draw, 0.2 );
draw.RoundedBox( 10, -20, 25, 70, 50, Color( 0, 0, 0, 70 ) );
// Health
local _hp = _p:Health( );
if ( _hp > 0 ) then
local _hp_mod = _hp / _p:GetMaxHealth( );
draw.RoundedBox( _cfg.hp.corner, _cfg.hp.x, _cfg.hp.y, _cfg.hp.w, _cfg.hp.h, _cfg.hp.bg_color );
draw.RoundedBox( _cfg.hp.corner, _cfg.hp.x, _cfg.hp.y, _cfg.hp.w, _cfg.hp.h * _hp_mod, _cfg.hp.fg_color );
local _text = string.format( _cfg.hp.text.text, math.Round( _hp_mod * 100, 0 ) );
draw.SimpleText( _text, _cfg.hp.text.font, _cfg.hp.text.x, _cfg.hp.text.y, _cfg.hp.text.color );
end
// Armor
local _ap = _p:Armor( );
if ( _ap > 0 ) then
local _ap_mod = _ap / ( ( _p.GetMaxArmor ) && _p:GetMaxArmor( ) || 100 );
draw.RoundedBox( _cfg.ap.corner, _cfg.ap.x, _cfg.ap.y, _cfg.ap.w, _cfg.ap.h * _ap_mod, _cfg.ap.fg_color );
local _text = string.format( _cfg.ap.text.text, math.Round( _ap_mod * 100, 0 ) );
draw.SimpleText( _text, _cfg.ap.text.font, _cfg.ap.text.x, _cfg.ap.text.y, _cfg.ap.text.color );
end
// Weapon mandatory check - after displaying other data first
local _w = _p:GetActiveWeapon( );
if ( !IsValid( _w ) || !_w.Clip1 ) then return; end
//
_ang:RotateAroundAxis( _ang:Up( ), 270 );
_ang:RotateAroundAxis( _ang:Forward( ), 70 );
// Primary Ammo data
local _mag1 = math.min( _w:Clip1( ), 100 );
local _mag1_mod = _mag1 / 100;
local _ammo_type1 = _w:GetPrimaryAmmoType( );
local _ammo1 = math.min( _p:GetAmmoCount( _ammo_type1 ), 999 );
local _ammo1_mod = _ammo1 / 999;
// Secondary Ammo data
local _mag2 = math.min( _w:Clip2( ), 100 );
local _mag2_mod = _mag2 / 100;
local _ammo_type2 = _w:GetSecondaryAmmoType( );
local _ammo2 = math.min( _p:GetAmmoCount( _ammo_type2 ), 999 );
local _ammo2_mod = _ammo2 / 999;
// Primary Magazine
if ( _mag1 > -1 ) then
draw.RoundedBox( _cfg.mag1.corner, _cfg.mag1.x, _cfg.mag1.y, _cfg.mag1.w, _cfg.mag1.h *_mag1_mod, _cfg.mag1.fg_color );
draw.SimpleText( "Clip: " .. tostring( _mag1 ).. "/".. tostring( _ammo1 ), _cfg.mag1_bar.text.font, _cfg.mag1.text.x, _cfg.mag1.text.y, _cfg.mag1.text.color );
end
// Secondary Magazine
if ( _mag2 > 0 ) then
draw.RoundedBox( _cfg.mag2.corner, _cfg.mag2.x, _cfg.mag2.y, _cfg.mag2.w, _cfg.mag2.h *_mag2_mod, _cfg.mag2.fg_color );
draw.SimpleText( "Sec: " .. tostring( _mag2 ), _cfg.mag2_bar.text.font, _cfg.mag2.text.x, _cfg.mag2.text.y, _cfg.mag2.text.color );
end
// Spare Secondary Ammo
if ( _ammo2 > 0 ) then
draw.RoundedBox(_cfg.ammo2.corner, _cfg.ammo2.x, _cfg.ammo2.y, _cfg.ammo2.w, _cfg.ammo2.h * _ammo2_mod, _cfg.ammo2.fg_color );
local _text = string.format( _cfg.ammo2.text.text, _ammo_type2 );
draw.SimpleText( _text, _cfg.ammo2.text.font, _cfg.ammo2.text.x, _cfg.ammo2.text.y, _cfg.ammo2.text.color );
end
cam.End3D2D( );
end );
[/code]
[editline]3rd April 2015[/editline]
[QUOTE=Drakehawke;47450544]Yeah this is what I'm currently doing
[lua]
ent:SetCustomCollisionCheck( true )
local index = ent:EntIndex()
hook.Add( "ShouldCollide", "NoCollide_" .. index, function( e, f )
if not IsValid( e ) or not IsValid( f ) then return end
if e:EntIndex() == index and not f:IsPlayer() then return false end
if f:EntIndex() == index and not e:IsPlayer() then return false end
end )[/lua]
Just seems to be an awful way of doing it.
[editline]3rd April 2015[/editline]
I haven't yet found a collision group that achieves it though.[/QUOTE]
Use the collision group to your advantage though... Set the collision group and use it in ShouldCollide...
Here's what I do to ensure noclipping players can phase through things ( ie physgunned players )
[cod
Hi,
Am trying to hide the "browse" option on the spawn menu of my server
[IMG]http://i.imgur.com/1QNs0o0.png[/IMG]
Do you know any way to do this?
Thanks
@Acecool Yeah I haven't learned too much in the way of coding. I'll look at the recode and see what I can learn from it.
I understand organizing things with tables, but I don't get why you use underscores before your hook vars. Is it because they are more readable that way?
[QUOTE=Drakehawke;47450067]What's the easiest way to make an entity not collide with anything but players?[/QUOTE]
COLLISION_GROUP_PLAYER should work
[QUOTE=Drakehawke;47450280]Doesn't work[/QUOTE]
Maybe it only works on brushes.
Hello.
So i got a weapon in a shared file, and in the weapon i am creating a table.
How would i use that table in another file?
P.S. its all clientside.
Make it global or make it part of the weapon's data table, then you can use it anywhere the weapon exists. If you make it global, it will only be valid for a single weapon (Which ever accessed it last), if you tie it to the weapon, it will be valid per weapon.
[QUOTE=G4MB!T;47452463]Make it global or make it part of the weapon's data table, then you can use it anywhere the weapon exists. If you make it global, it will only be valid for a single weapon (Which ever accessed it last), if you tie it to the weapon, it will be valid per weapon.[/QUOTE]
well u cant make it a GlobalTable, and how would i make it on the weapon's datatable?
[QUOTE=tzahush;47452513]well u cant make it a GlobalTable, and how would i make it on the weapon's datatable?[/QUOTE]
When you are creating the table do self.Tbl = {} instead of Tbl = {}
Make sure you are setting it in a function that has self defined as the weapon.
[QUOTE=AnonTakesOver;47452554]When you are creating the table do self.Tbl = {} instead of Tbl = {}
Make sure you are setting it in a function that has self defined as the weapon.[/QUOTE]
and then how would i call it through the cilents file?
[QUOTE=tzahush;47452579]and then how would i call it through the cilents file?[/QUOTE]
ent.Tbl and that'll be the table you defined.
If ent is your weapon.
[QUOTE=AnonTakesOver;47452595]ent.Tbl and that'll be the table you defined.
If ent is your weapon.[/QUOTE]
Is that the only way of transsfering a table?
There's nothing else?
[QUOTE=tzahush;47452739]Is that the only way of transsfering a table?
There's nothing else?[/QUOTE]
What else would you want!?
Well i mean, isn't there any other way of transferring the table from a file to another file? maybe even including?
[QUOTE=tzahush;47452885]Well i mean, isn't there any other way of transferring the table from a file to another file? maybe even including?[/QUOTE]
You make it global, so at the top of one file do:
myVarName = "whatever"
Then whenever you edit that var, so in file1 in a function you do
myVarName = 25, file2 whenever it checks what myVarName is, it'll be 25
[QUOTE=AnonTakesOver;47452900]You make it global, so at the top of one file do:
myVarName = "whatever"
Then whenever you edit that var, so in file1 in a function you do
myVarName = 25, file2 whenever it checks what myVarName is, it'll be 25[/QUOTE]
that is with or without including?
[QUOTE=tzahush;47452923]that is with or without including?[/QUOTE]
Without
[QUOTE=AnonTakesOver;47452936]Without[/QUOTE]
How would I go about attaching an EffectData to a weapon attachment? I'm trying to recreate the stun baton, and I have my effect created, but it doesn't seem to want to be in the right place, nor have the right angles.
[QUOTE=Ghost_Sailor;47452951]How would I go about attaching an EffectData to a weapon attachment? I'm trying to recreate the stun baton, and I have my effect created, but it doesn't seem to want to be in the right place, nor have the right angles.[/QUOTE]
Show code please
[QUOTE=AnonTakesOver;47453149]Show code please[/QUOTE]
[code]local v = self.Owner
local efct = EffectData()
efct:SetEntity(v)
efct:SetScale(.3)
efct:SetMagnitude(1)
local viewm = v:GetViewModel()
local muzzlepos = viewm:GetAttachment( 1 )
efct:SetOrigin(muzzlepos["Pos"])
efct:SetAngles(muzzlepos["Ang"])
efct:SetStart(muzzlepos["Pos"])
--util.Effect("TeslaZap",efct)
util.Effect("TeslaHitBoxes",efct)[/code]
[QUOTE=Ghost_Sailor;47453168][code]local v = self.Owner
local efct = EffectData()
efct:SetEntity(v)
efct:SetScale(.3)
efct:SetMagnitude(1)
local viewm = v:GetViewModel()
local muzzlepos = viewm:GetAttachment( 1 )
efct:SetOrigin(muzzlepos["Pos"])
efct:SetAngles(muzzlepos["Ang"])
efct:SetStart(muzzlepos["Pos"])
--util.Effect("TeslaZap",efct)
util.Effect("TeslaHitBoxes",efct)[/code][/QUOTE]
Are you sure the muzzlepos position and angle is valid? Try printing the muzzlepos position and angle
[QUOTE=AnonTakesOver;47453253]Are you sure the muzzlepos position and angle is valid? Try printing the muzzlepos position and angle[/QUOTE]
PrintTable(muzzlepos) returns
[code]Ang = 17.960 -87.512 71.616
Pos = -756.552063 1296.075439 39.263687[/code]
What am I doing wrong thats causing my HoldTypes to not take effect? The base SWEP also has its hold type set to "melee"
[code]
if SERVER then
AddCSLuaFile()
end
SWEP.PrintName = "Trash Axe"
SWEP.Author = "Exho"
SWEP.Base = "weapon_sc_baseaxe"
SWEP.HoldType = "melee"
SWEP.DrawAmmo = true
SWEP.DrawCrosshair = true
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.Primary.Ammo = "none"
SWEP.Primary.Damage = 10
SWEP.Primary.Delay = 0.5
SWEP.Primary.Automatic = true
SWEP.Secondary.Ammo = "none"
SWEP.Secondary.Delay = 1
SWEP.VElements = {
["Lamp"] = { type = "Model", model = "models/props_interiors/Furniture_Lamp01a.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(3, 2, -6), angle = Angle(7, 0, 180), size = Vector(0.5, 0.5, 0.5), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
SWEP.WElements = {
["Lamp"] = { type = "Model", model = "models/props_interiors/Furniture_Lamp01a.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(2.596, 1.5, -9), angle = Angle(-5.844, 0, 175.156), size = Vector(0.5, 0.5, 0.5), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
[/code]
[t]http://i.gyazo.com/01a07a822b3cedd7b5936437673211eb.png[/t]
SWEP.HoldType is no longer used. Instead, you need to manually set the hold type with SWEP:SetWeaponHoldType(self.HoldType) in SWEP:Initialize (Make the call shared).
[editline]4th April 2015[/editline]
Also I cant see you setting SWEP.WorldModel in that snippet?
[QUOTE=RocknRolla513;47451642]Hi,
Am trying to hide the "browse" option on the spawn menu of my server
[IMG]http://i.imgur.com/1QNs0o0.png[/IMG]
Do you know any way to do this?
Thanks[/QUOTE]
Hiding it will not prevent people from spawning the props inside.
How can I get if an entity is not inside a box
(the opposite of this)
[code]for id,ply in pairs(ents.FindInBox(DMDefine.Locations.pos1,DMDefine.Locations.pos2)) do[/code]
Trying to make a defined deathmatch area but want it to god people outside of the area
(this is in a think hook so)
Sorry, you need to Log In to post a reply to this thread.