[QUOTE=Instant Mix;45514366]I was meaning as in I have no idea how to start using it. This is what I have now:
[/quote]
Something like this works. LookupAttachment turns the "name" of the attachment to the index to be used in GetAttachment which returns Pos and Ang. Typically you could use GetAttachment( 1 ) to get the muzzle, but it may not always work out that way.
[code] local _m = self.Owner:GetViewModel( )
local _muzzle = _m:LookupAttachment( "muzzle" );
if ( _muzzle == 0 ) then
_muzzle = _m:LookupAttachment( "1" );
end
local _attachment = _m:GetAttachment( _muzzle );[/code]
[QUOTE=wh1t3rabbit;45518653]Hopefully this isn't too late.
[URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/entities/effects/base.lua"]GetTracerShootPos[/URL] is a helper function that checks if the weapon the effect is on is the local players weapon.
If it is, it gets the attachment position from the players viewmodel entity.
If it isn't the local players weapon, it gets the attachment position on the weapon entity's world model.
To answer if its for spawning an entity just use their weapon and GetAttachment[/QUOTE]
Thank you for the reply, no it's quite alright.
I have tried implementing this however I appear to be getting the positions from their world model. How do I make it so it is the positions for the view model, as you have said?
Would the code help?
[QUOTE=camer0n;45504674]Possible to alert the player clientside even if they are alt-tabbed? An actual pop-up window? Currently I'm just making the client make a beeping noise but that's only useful if you want to listen to all the ambient sounds on GM.[/QUOTE]
I never got an answer for this :v:
[QUOTE=camer0n;45522699]I never got an answer for this :v:[/QUOTE]
[url=http://facepunch.com/showthread.php?t=1411111&p=45512381&viewfull=1#post45512381]Yes you did[/url]
[QUOTE=Cyberuben;45522732][url=http://facepunch.com/showthread.php?t=1411111&p=45512381&viewfull=1#post45512381]Yes you did[/url][/QUOTE]
I feel stupid. Overlooked that post, my bad.
Hi guys. I haven't posted on this website in *ages* so anyone who might remember me / put me on their death wish list.txt, please ignore any previous memories you may have of me as a 15 year old. That would be great.
So I'd really like to get into lua coding/programming/Logical Orchestra conducting but it seems every small stab I take to get started, I get the same error thrown back in my face.
[CODE]
[ERROR] addons/test/lua/hello.lua:1: '=' expected near '<eof>'
1. unknown - addons/test/lua/hello.lua:0
[/CODE]
Now I know what you're thinking.
[QUOTE]"'hello.lua', This man is a mad man! He can't possibly be trying to... print...HELLO WORLD?!"[/QUOTE]
You'd be correct in thinking that, and I realise the fatal consequences if I somehow manage to screw up this demonic ritual of print(), but I'm still going to try and summon the great Chthulu.
In saying that, My lua file is literally just
[CODE]if (SERVER) then
print("Hello World")
elseif (CLIENT) then
print("Hello Kayne")
end[/CODE]
If you're wondering why I have Client / Server variations, it's because SOME result is better than NO results.
Which is still what I got, Nothing. Even with narrowing the .lua file to "print("Oh man just work, please I beg you, just work")" or even trying the VERY taboo "Msg("Please for the love of god print something already in console. ANYTHING.")"
Now is it possible I'm storing the lua files in some odd, chaotic location? Yes, quite, but I followed the GarrysMod Wiki and so I can only assume that I've "just about" thrown a file (or ten.) in the right place(ish).
To clarify, that would be garrysmod/garrysmod/addons/Test/lua
Any help would be appreciated, I am using notepad++ but what ever Garrys mod lex luthor lexer I'm using, is apparently outdated by "A lot".
[QUOTE=CoKayne;45522962]Hi guys. I haven't posted on this website in *ages* so anyone who might remember me / put me on their death wish list.txt, please ignore any previous memories you may have of me as a 15 year old. That would be great.
So I'd really like to get into lua coding/programming/Logical Orchestra conducting but it seems every small stab I take to get started, I get the same error thrown back in my face.
[CODE]
[ERROR] addons/test/lua/hello.lua:1: '=' expected near '<eof>'
1. unknown - addons/test/lua/hello.lua:0
[/CODE]
Now I know what you're thinking.
You'd be correct in thinking that, and I realise the fatal consequences if I somehow manage to screw up this demonic ritual of print(), but I'm still going to try and summon the great Chthulu.
In saying that, My lua file is literally just
[CODE]if (SERVER) then
print("Hello World")
elseif (CLIENT) then
print("Hello Kayne")
end[/CODE]
If you're wondering why I have Client / Server variations, it's because SOME result is better than NO results.
Which is still what I got, Nothing. Even with narrowing the .lua file to "print("Oh man just work, please I beg you, just work")" or even trying the VERY taboo "Msg("Please for the love of god print something already in console. ANYTHING.")"
Now is it possible I'm storing the lua files in some odd, chaotic location? Yes, quite, but I followed the GarrysMod Wiki and so I can only assume that I've "just about" thrown a file (or ten.) in the right place(ish).
To clarify, that would be garrysmod/garrysmod/addons/Test/lua
Any help would be appreciated, I am using notepad++ but what ever Garrys mod lex luthor lexer I'm using, is apparently outdated by "A lot".[/QUOTE]
addons/test/lua/autorun/hello.lua
Also, that error doesn't match the code you gave
I'll try chuck it in autorun, but I very much doubt it will have any difference. Give me 3 minutes ;)
EDIT:
[CODE][ERROR] addons/test/lua/autorun/hello.lua:1: '=' expected near '<eof>'
1. unknown - addons/test/lua/autorun/hello.lua:0[/CODE]
Still the same :|
But thank you very much for offering to help, by the way.
By any chance, would the "Gmod Lua Lexer" that Notepad ++ is using be effecting this at all? To be honest I don't think it doesn't anything at the moment.
[QUOTE=CoKayne;45523135]I'll try chuck it in autorun, but I very much doubt it will have any difference. Give me 3 minutes ;)
EDIT:
[CODE][ERROR] addons/test/lua/autorun/hello.lua:1: '=' expected near '<eof>'
1. unknown - addons/test/lua/autorun/hello.lua:0[/CODE]
Still the same :|
But thank you very much for offering to help, by the way.
By any chance, would the "Gmod Lua Lexer" that Notepad ++ is using be effecting this at all? To be honest I don't think it doesn't anything at the moment.[/QUOTE]
The code looks fine, but try removing the brackets from SERVER and CLIENT
[QUOTE=Blasteh;45523215]The code looks fine, but try removing the brackets from SERVER and CLIENT[/QUOTE]
No change :x
[QUOTE=CoKayne;45523254]No change :x[/QUOTE]
Is that the contents of the whole file?
Cause that error makes no sense.
That's it. There is
a folder in the addons folder named "test"
A folder in that, named "lua"
A folder, created as mentioned above, in lua, named "autorun"
inside autorun, is a file named hello.lua
which has the previous mentioned code
[CODE]if SERVER then
print("Hello World")
elseif CLIENT then
print("Hello Kayne")
end[/CODE]
What i'm trying to say is, There is nothing more than I have done, than that. There are no other files, there are no other folders that haven't been mentioned. And this problem will occur with any script. Maybe I should write mumbo jumbo (if i'm not already) and see what it says.
So one mumbo-jumbo later, I can see that it's not the actual code that is the problem. What ever is the problem beats me as well, but even mumbo jumbo / gibberish returns the same error.
I have been tinkering around with the ParticleEmitter for the first time and I have a couple questions.
-How do you make it so you can't see the particles through walls?
-Once I remove my entity the particles still linger around until a map change. How would I go about removing them?
@CoKayne it's possible the changes in the file is not being applied, try a map change or restart your game.
[QUOTE=Internet1001;45523376]@CoKayne it's possible the changes in the file is not being applied, try a map change or restart your game.[/QUOTE]
Sadly I have been doing both of these, multiple times.
I'll nod off to sleep now, and allow other users to ask questions as I feel i'm just spamming this thread. Maybe I'll make a new thread so that I may whinge without affecting others too greatly.
is it possible to change the tickrate off a server if so what tickrate would you recommend,
normally it's at +- 66.6 but I would rather have it at 33 or something will this be to low or would it be idealistic?
[QUOTE=frietje2008;45523990]is it possible to change the tickrate off a server if so what tickrate would you recommend,
normally it's at +- 66.6 but I would rather have it at 33 or something will this be to low or would it be idealistic?[/QUOTE]
Depends what you are doing. Huge servers can sometimes swing a 16 tickrate, where 33 is generally the lowest you want to go. 100 being the highest you should go. Going in between will cause some issues depending on what you are doing. 16/33/66/100.
I'm making a scratch gamemode for about 50 to 76 people what would you reccomend?
ok I don't even know what I've done but I changed something in my code and now the damn thing doesn't work anymore ( as in the sinusodial motion )
code:
[code]
AddCSLuaFile()
ENT.Type = "anim"
ENT.PrintName = "Gays"
ENT.Author = "Upset"
ENT.Spawnable = false
ENT.AdminSpawnable = true
function ENT:Draw()
end
function ENT:OnRemove()
end
function ENT:Initialize()
if SERVER then
self.zapSnd = CreateSound( self, "ambient/machines/combine_shield_touch_loop1.wav" )
self:SetModel("models/items/AR2_Grenade.mdl")
self:SetCollisionGroup(COLLISION_GROUP_PROJECTILE)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_CUSTOM)
self:DrawShadow(false)
self.Time = 0
self.Div = math.pi*2/30
self.Radius = 256
self.Lifetime = CurTime() + 2
local sprite = ents.Create( "env_sprite" )
sprite:SetKeyValue( "rendercolor","94 0 149" )
sprite:SetKeyValue( "spriteProxySize","0.5" )
sprite:SetKeyValue( "HDRColorScale","0.5" )
sprite:SetKeyValue( "renderfx","14" )
sprite:SetKeyValue( "rendermode","3" )
sprite:SetKeyValue( "renderamt","255" )
sprite:SetKeyValue( "disablereceiveshadows","0" )
sprite:SetKeyValue( "mindxlevel","0" )
sprite:SetKeyValue( "maxdxlevel","0" )
sprite:SetKeyValue( "model","sprites/blueflare1.vmt" )
sprite:SetKeyValue( "spawnflags","0" )
sprite:SetKeyValue( "scale","1" )
sprite:Spawn()
sprite:SetParent( self.Entity )
sprite:SetPos( self.Entity:GetPos() )
local sprite1 = ents.Create( "env_sprite" )
sprite1:SetKeyValue( "rendercolor","230 120 200" )
sprite1:SetKeyValue( "spriteProxySize","2.0" )
sprite1:SetKeyValue( "HDRColorScale","2.0" )
sprite1:SetKeyValue( "renderfx","14" )
sprite1:SetKeyValue( "rendermode","3" )
sprite1:SetKeyValue( "renderamt","255" )
sprite1:SetKeyValue( "disablereceiveshadows","0" )
sprite1:SetKeyValue( "mindxlevel","0" )
sprite1:SetKeyValue( "maxdxlevel","0" )
sprite1:SetKeyValue( "model","sprites/glow01.vmt" )
sprite1:SetKeyValue( "spawnflags","0" )
sprite1:SetKeyValue( "scale","0.15" )
sprite1:Spawn()
sprite1:SetParent( self.Entity )
sprite1:SetPos( self.Entity:GetPos() )
util.SpriteTrail( self.Entity, 0, Color( 130, 110, 255 ), false, 24, 2, 0.4, 1, "trails/laser.vmt" )
util.SpriteTrail( self.Entity, 0, Color( 230, 120, 200 ), false, 6, 2, 0.2, 0.125/4, "trails/electric.vmt" )
local phys = self:GetPhysicsObject()
if IsValid(phys) then
phys:Wake()
phys:SetMass(1)
phys:EnableDrag(false)
phys:EnableGravity(false)
phys:SetBuoyancyRatio(0)
end
end
end
function ENT:PhysicsCollide(data, physobj)
local randomsounds = {
"ambient/energy/newspark09.wav",
"ambient/energy/newspark10.wav",
"ambient/energy/newspark11.wav",
}
local random = math.random(1, #randomsounds)
self:EmitSound(randomsounds[random],65,math.random(90,110))
data.HitEntity:TakeDamage(6, self.Entity:GetOwner())
local start = data.HitPos + data.HitNormal
local endpos = data.HitPos - data.HitNormal
util.Decal("ChargedWaveletDecal",start,endpos)
local effectdata = EffectData()
effectdata:SetOrigin( self:GetPos() )
util.Effect( "wavebeam_wavelet_death", effectdata, true, true )
self.zapSnd:Stop()
self:Explode()
return true
end
function ENT:Explode()
local effectdata = EffectData()
effectdata:SetOrigin( self:GetPos() )
util.Effect( "wavebeam_waveletdeathlight", effectdata, true, true )
self.zapSnd:Stop()
self:Remove()
end
function ENT:OnRemove()
if self.zapSnd then self.zapSnd:Stop() end
end
function ENT:MakeLightTrail()
local effectdata = EffectData()
effectdata:SetOrigin( self:GetPos() )
util.Effect( "wavebeam_waveletlight", effectdata, true, true )
end
function ENT:Think()
if SERVER then
self.Time = self.Time + self.Div
local phys = self:GetPhysicsObject()
if IsValid(phys) then
self.zapSnd:PlayEx( (math.sin(self.Time*2)/2+0.5)/4, math.sin(self.Time*2)*5+95 )
phys:SetVelocity(self:GetAngles():Forward() *700 +self:GetAngles():Up()*math.sin(self.Time*2)*self.Radius)
return true
end
end
self:NextThink( CurTime() + 0.01 )
end
[/code]
[QUOTE=Instant Mix;45525803]ok I don't even know what I've done but I changed something in my code and now the damn thing doesn't work anymore ( as in the sinusodial motion )
code:
[code]
no errors?
[/code][/QUOTE]
[QUOTE=frietje2008;45525834][/QUOTE]
Doesn't work though, have you tried triggering that effect?
no I didn't
Figured out the issue anyway, I shouldn't call return true in the IsValid(phys) condition.
Is it possible to render an effect in the "viewmodel" of a swep rather than in the world?
Is it possible to download a file from a URL in a clientside addon? It's an addon for a specific server, and that specific server has a typo somewhere that tries to play a sound with a ".waverse" extension instead of a ".wav"
When I replace the file on my client, it works, but I can't add that file to the addon (it won't allow it). Is there any work-around?
[QUOTE=AnonTakesOver;45521425][code]
hook.Add("PlayerDeath", "demote", function( ply )
ply:SetTeam( TEAM_CITIZEN )
end)
[/code]
?[/QUOTE]
Where would I put this? I tried putting it in the jobs file, but it didn't work. Thanks!
[QUOTE='[NLG] Wrath;45532012']Where would I put this? I tried putting it in the jobs file, but it didn't work. Thanks![/QUOTE]
any where that the server runs
lua/autorun/server/demote.lua
what is faster?
[lua]FindMetatable("something") or getmetatable("something") or _R = debug.getregistry() _R.Player[/lua]
[QUOTE=frietje2008;45532959]what is faster?
FindMetatable("something") or getmetatable("something") or _R = debug.getregistry() _R.Player
[/QUOTE]
It's so insignificant that it doesn't matter.
[QUOTE=Revenge282;45533281]It's so insignificant that it doesn't matter.[/QUOTE]
I did guess that but I wasn't sure so... thx for the reply
I am trying to do a hook.add on every vehicle that is spawned but the only hook I have seen pertaining to vehicles is: [url]http://wiki.garrysmod.com/page/SANDBOX/PlayerSpawnVehicle[/url]
I think this will only effect cars that the player spawns.
Does anyone know of a hook that gets called every-time something is created both server side and player side. This way i can just simply check if it is a vehicle or not and then do a hook.add on it.
Sorry, you need to Log In to post a reply to this thread.