how do i place an additional model relative to the model set in my gamemode entity? do i have to create a separate entity or what?
(im trying to make a entity platform have a flag model placed on top relative to where it spawns, basically parented to the model in my entity.)
[lua]function Ply:LsResetSuit()
local hash = self.suit
hash.env = {}
hash.air = 200 --100
hash.energy = 200 --100
hash.coolant = 200 --100
hash.recover = 0
self.suit = hash
hash = {}
hash.temperature = 288
hash.air = true
hash.inspace = false
self.airused = false
self.highpressure = false
self.caf.custom.ls = hash[/lua]
I have an error in my console which is
[lua][ERROR] addons/sb3/lua/caf/addons/server/lifesupport.lua:383: attempt to index local 'hash' (a nil value)
1. LsResetSuit - addons/sb3/lua/caf/addons/server/lifesupport.lua:383
2. v - addons/sb3/lua/caf/addons/server/lifesupport.lua:43
3. unknown - lua/includes/modules/hook.lua:75[/lua]
First: how do I make a value, or does there need to be a nil value? Also, what is "unknown...hook.lua:75" ??????
I'll continue fixing other errors but hope you guys can be of help.
[editline]4th November 2012[/editline]
Also: [lua]CAF_Hooks, Message: Think3 Error: addons/sb3/lua/caf/addons/server/lifesupport.lua:460: attempt to index field 'ls' (a nil value)[/lua]
[lua]self.caf.custom.ls.temperature = self.environment:GetTemperature(self)[/lua]
?????
Can someone post an example of render.MaterialOverride? The render library and I don't get along too well.
I am having problems with this script. The error:
[CODE]
[ERROR] ...ghts_designer/lua/weapons/ironsights_designer/shared.lua:332: attempt to index local 'cmd' (a nil value)
1. unknown - ...ghts_designer/lua/weapons/ironsights_designer/shared.lua:332
Player:GetCurrentCommand called outside of command/prediction
[/CODE]
The function it refers to in the script:
[CODE]
295: function SWEP:Think ()
296: if SERVER then return end
297:
298: if self.Owner:KeyPressed (IN_ATTACK2) then self:SecondaryAttack() end
299: if self.Owner:KeyDown (IN_JUMP) then self:ToggleIronsights() else self.IronsToggleDown = false end
300: if self.Owner:KeyDown (IN_SPEED) then self:ToggleMenu() else self.MenuToggleDown = false end
301:
302: if self.Owner:KeyDown (IN_RELOAD) then
303: if self.Owner:KeyPressed (IN_USE) then
304: self:MenuResetAllAxes()
305: return
306: elseif self.Owner:KeyPressed (IN_RELOAD) then
307: self:MenuResetSelectedAxes()
308: end
309: end
310:
311: if self.Owner:KeyPressed (IN_USE) and self.LastPrintOut + 0.2 < CurTime() then
312: self:MenuPrintIronsightFunctions ()
313: self.LastPrintOut = CurTime()
314: end
315:
316: if self.Owner:KeyPressed (IN_ATTACK) then
317: self.Dragging = true
318: elseif self.Owner:KeyReleased (IN_ATTACK) then
319: self.Dragging = false
320: end
321:
322: local flipMul = 1
323: if self.ViewModelFlip then flipMul = -1 end
324:
325: if self.Dragging then
326: local cmd = self.Owner:GetCurrentCommand()
327: local mode = self.AnglesModes[self.AnglesMode]
328: if mode[1] then
329: self[mode[1][1]][mode[1][2]] = math.floor ((self[mode[1][1]][mode[1][2]] + cmd:GetMouseX() * self.Sensitivity * flipMul * mode[1][3]) * 10000) / 10000
330: end
331: if mode[2] then
332: self[mode[2][1]][mode[2][2]] = math.floor ((self[mode[2][1]][mode[2][2]] + cmd:GetMouseY() * self.Sensitivity * -1 * mode[2][3]) * 10000) / 10000
333: end
334: end
335:
336: if not IDSTBKeys then return end
337: IDSTBKeys["Pos"]:SetText ("- Ironsight Pos: "..VectorString (self.IronsPos))
338: IDSTBKeys["Ang"]:SetText ("- Ironsight Ang: "..VectorString (self.IronsAng))
339: end
[/CODE]
Thanks in advance!
What do you guys use to record videos inside gmod and upload them as .webm?
[QUOTE=ollie;38317732]What do you guys use to record videos inside gmod and upload them as .webm?[/QUOTE]
gm_video in your console
[editline]4th November 2012[/editline]
then just puush the webm file in garrysmod/videos
Oh thank you!
[vid]www.riotservers.net/slow.webm[/vid]
Walkspeed in my gamemode is inexplicably slow - Only for that team.
Tried manually setting the walkspeed/runspeed/crouchspeed of the player through console, No change whatsoever. Checking it afterwards returns what i apparently set it to, so the gamemode isnt manually changing it. It's perfectly fine for other teams though.
What the hell? any ideas on whats going on?
How do I simply disable the creations menu in my server?
I have used lua before (computercraft) but never in gmod. I am hoping to make a simple whitelist plugin for my server. I know it should be something using an "if" statement to check if the steam ID is on the whitelist. Where should I get started? The new wiki is somewhat bare on the basics.
Hello.
I've done a lua brush and put it into hammer.
This is the error I get when loading the map:
[code]Attempted to create unknown entity type brush_hpres!
Can't init brush_hpres[/code]
This is the code for my brush:
[lua]
/* Life-Giving entity by Blackfire */
ENT.StorTable = {}
function ENT:Initialize()
end
function ENT:StartTouch(ent)
if ent:IsPlayer() then
for k, v in pairs(player.GetAll()) do
v:ChatPrint(ent:GetName().." touched the magical entity!")
end
end
end
function ENT:EndTouch(ent)
if ent:IsPlayer() then
for k, v in pairs(player.GetAll()) do
v:ChatPrint(ent:GetName().." stopped touching the magical entity!")
end
end
end
[/lua]
No, nothing happens when I spawn, stop touching it, start touching it, ect.
The map: [url]https://dl.dropbox.com/u/42016379/test_ctf.bsp[/url]
The VMF: [url]https://dl.dropbox.com/u/42016379/test_ctf.vmf[/url]
(don't go EWW OMG SO BAD, it's just a test map.)
i'd like to strip myself of weapons while in single player
is there some code i can run in the console with lua_run or lua_run_cl to do so?
[QUOTE=Quark:;38320760]i'd like to strip myself of weapons while in single player
is there some code i can run in the console with lua_run or lua_run_cl to do so?[/QUOTE]
[code]
lua_run Entity(1):StripWeapons()
[/code]
Does anyone know why my texture is flashing white pixels around the edges every now and again? The alpha channel is good, and there are no transparent pixels anyone. In the VMT I also added "$translucent" 1. Which helps, but those edges still flashing.
[QUOTE=DoubleElite;38321156]Does anyone know why my texture is flashing white pixels around the edges every now and again? The alpha channel is good, and there are no transparent pixels anyone. In the VMT I also added "$translucent" 1. Which helps, but those edges still flashing.[/QUOTE]
Select the transparent part of your image.
Go to Select<Modify<Contract..
Select a 1-2px radius.
SHIFT + CTRL + I to inverse your selection.
Filter<Blur<Blur.
Make your VTF.
[QUOTE=brandonj4;38321389]Select the transparent part of your image.
Go to Select<Modify<Contract..
Select a 1-2px radius.
SHIFT + CTRL + I to inverse your selection.
Filter<Blur<Blur.
Make your VTF.[/QUOTE]
It didn't work, at least not completely.
[URL=http://imgur.com/UbFQK][IMG]http://i.imgur.com/UbFQK.jpg[/IMG][/URL]
It should be:
[URL=http://imgur.com/UJNku][IMG]http://i.imgur.com/UJNku.jpg[/IMG][/URL]
By the way, this is the same image and code. But when I looked to the right the white lines appeared again.
[QUOTE=TylerB;38321117][code]
lua_run Entity(1):StripWeapons()
[/code][/QUOTE]
Thank you very much :smile:
-snip-
[QUOTE=Feihc;38317163]Can someone post an example of render.MaterialOverride? The render library and I don't get along too well.[/QUOTE]
render.MaterialOverride( Material( "yourshittyfolder/yourshittymaterial" ) )
It's usually a good idea to call it before you render, then call it after you render with
render.MaterialOverride( 0 ) (Not sure if that still works, in Gm12 it cleared the current overriden material)
[QUOTE=Archemyde;38318095][vid]www.riotservers.net/slow.webm[/vid]
Walkspeed in my gamemode is inexplicably slow - Only for that team.
Tried manually setting the walkspeed/runspeed/crouchspeed of the player through console, No change whatsoever. Checking it afterwards returns what i apparently set it to, so the gamemode isnt manually changing it. It's perfectly fine for other teams though.
What the hell? any ideas on whats going on?[/QUOTE]
Are you modifying it by the :SetRunSpeed() and etc functions?
If so, and you're on a custom gamemode, try modifying move speed using the gamemode hook SetPlayerSpeed( player, walkspeed, runspeed )
(The GM12 hook for that can be found here, i'm not sure if it has changed at all in the GM13 update: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexf99b.html[/url])
Alternatively, try looking around the gamemode to see if this is being called at all, or if anything else is calling constant player speed functions.
[QUOTE=brandonj4;38316857]Repost since I was at the bottom..
I'm having an issue with [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4bfa.html"]Parenting[/URL].
It always turns out like this and i'm pretty sure I have to parent it. I'm using TTT's DeerStalker hat as an example template.
[your hats picture]
[lua]
function WearHat(self, cmd, args)
if IsValid(self) then
local hat = ents.Create(arg1)
if not IsValid(hat) then return end
hat:SetPos(self:GetPos() + Vector(0,0,70))
hat:SetAngles(self:GetAngles())
hat:SetParent(self)
self.hat = hat
hat:Spawn()
self:SaveHats()
end
end
concommand.Add("self_wear_hat", WearHat)
[/lua]
Thanks.[/QUOTE]
Ok so the thing is, you're trying to create a hat and attach it to a players head, and if i'm correct, parenting doesn't really work that way. When i've used parenting in the past, parenting to a player simply moves an entity with a players torso, and not their head. The best thing i can recommend is setting the position and angles to their head bone ([url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1685.html[/url] - This will help you in doing so), you can then parent it to the player and call hat:AddEffects( EF_BONEMERGE ) (on the client side), which causes the entity to merge with the nearest bones or something like that.
Alternatively, you can saved a networked variable for each of the hats position/angle and then have the client constantly refresh the position from that position/angle.
If you don't understand what i'm saying, you should probably get a bit more experience before you go ahead and try something that difficult
[QUOTE=mtt_asch;38317187]I am having problems with this script. The error:
[CODE]
[ERROR] ...ghts_designer/lua/weapons/ironsights_designer/shared.lua:332: attempt to index local 'cmd' (a nil value)
1. unknown - ...ghts_designer/lua/weapons/ironsights_designer/shared.lua:332
Player:GetCurrentCommand called outside of command/prediction
[/CODE]
The function it refers to in the script:
[CODE]
swep code
[/CODE]
Thanks in advance![/QUOTE]
It's possible that the error about getcurrentcommand being called outside of command/prediction is coming from the fact that it's not being called inside any hook that would normally pass a CUserCMD.
If it's purely on the client that you're trying to use it, you could create a local variable thats scope is of the entire script, then call a createmove hook and get the CUserCMD of the player, just a suggestion.
Something like
[code]
-- Top of SWEP clientside code
local cmd
if CLIENT then
hook.Add( "CreateMove", "GetUserCMD", function( CUserCMD )
cmd = CUserCMD
end )
end
[/code]
[QUOTE=DoubleElite;38321850]It didn't work, at least not completely.
[URL="http://imgur.com/UbFQK"][IMG]http://i.imgur.com/UbFQK.jpg[/IMG][/URL]
It should be:
[URL="http://imgur.com/UJNku"][IMG]http://i.imgur.com/UJNku.jpg[/IMG][/URL]
By the way, this is the same image and code. But when I looked to the right the white lines appeared again.[/QUOTE]
just make the whole texture black, then make the shape of the texture inside the alpha layer (white on black)
How to get true center of entity?
GetPos() is off with some models.
[QUOTE=rute;38325938]How to get true center of entity?
GetPos() is off with some models.[/QUOTE]
This is how E2 does it:
[code]e2function vector entity:boxCenter()
if not IsValid(this) then return {0,0,0} end
return this:OBBCenter()
end
e2function vector entity:boxCenterW()
if not IsValid(this) then return {0,0,0} end
return this:LocalToWorld(this:OBBCenter())
end[/code]
Just change this to work for what you need it for.
What net library datatype should be used for a number between 0 and 100?
The tutorial on wiki is rather confusing since it would seem "Byte" would be fine, however it only shows Read/Write Bye in example. Assuming this was replaced by Read/Write Bit?
Or would Int be fine?
[url]http://wiki.garrysmod.com/page/Lua/Tutorials/Using_the_net_library[/url]
Why did garry remove a lot of stuff without mentioning it in garrysmod.org?
GM.GetTeamScoreInfo() and _R.Player:GetScriptedVehicle() are removed, and i can't find any documents of them..
Hey, having some trouble with meshes, when i spawn the entity i just get spammed by errors, ive tried both these codes and get the same error:
[ERROR] gamemodes/dev/entities/entities/entitytest2/cl_init.lua:30: attempt to index field 'mesh' (a nil value)
1. unknown - gamemodes/dev/entities/entities/entitytest2/cl_init.lua:30
code A is:
[code]
function ENT:Initialize()
self.mesh = NewMesh();
local meshexample = {}
--top left triangle
meshexample[1] = { pos = Vector(-1, -1,-1), normal = Vector(0,-2,2), u=0, v=0 }
meshexample[2] = { pos = Vector(-1, -1, 1),normal = Vector(0,-2,2), u=0, v=1 }
meshexample[3] = { pos = Vector( 1,-1 , 1), normal = Vector(0,-2,2), u=1, v=1 }
--bottom right triangle , we change the normal so you can see the 2 triangles better
meshexample[4] = { pos = Vector(-1, -1, -1 ),normal = Vector(0,-2,0), u=0, v=0 }
meshexample[5] = { pos = Vector( 1,-1,1), normal = Vector(0,-2,0), u=1, v=1 }
meshexample[6] = { pos = Vector(1,-1,-1), normal = Vector(0,-2,0), u=1, v=0 }
-- normal is where the light source is located, think of this as positioning the sun
-- u is the horizontal texture cord , v is the vertical, they are floats
-- u = 0 , v = 0 would be the bottom left of the texture , 0,1 is top left
self.mesh:BuildFromTriangles(meshexample);
end
function ENT:Draw()
self:DrawModel();
local scale = 50;
mat = Matrix();
mat:Translate( self:GetPos() );
mat:Rotate(Angle(0,0,-45));
mat:Scale( Vector( 1, 1, 1 ) * scale );
render.SetMaterial( Material("models/props_wasteland/wood_fence01a") );
cam.PushModelMatrix ( mat );
self.mesh:Draw();
cam.PopModelMatrix();
end
[/code]
Code B is:
[code]
function MeshCube( size, texturescale, pos )
pos = pos or Vector(0,0,0)
return {
// Top
Vertex( Vector( size, size, size ) + pos, texturescale, texturescale ),
Vertex( Vector( size, -size, size ) + pos, texturescale, 0 ),
Vertex( Vector( -size, -size, size ) + pos, 0, 0 ),
Vertex( Vector( -size, size, size ) + pos, 0, texturescale ),
Vertex( Vector( size, size, size ) + pos, texturescale, texturescale ),
Vertex( Vector( -size, -size, size ) + pos, 0, 0 ),
// Bottom
Vertex( Vector( -size, -size, -size ) + pos, 0, 0 ),
Vertex( Vector( size, -size, -size ) + pos, texturescale, 0 ),
Vertex( Vector( -size, size, -size ) + pos, 0, texturescale ),
Vertex( Vector( size, -size, -size ) + pos, texturescale, 0 ),
Vertex( Vector( size, size, -size ) + pos, texturescale, texturescale ),
Vertex( Vector( -size, size, -size ) + pos, 0, texturescale ),
// LEFT
Vertex( Vector( size, size, size ) + pos, texturescale, texturescale ),
Vertex( Vector( size, size, -size ) + pos, texturescale, 0 ),
Vertex( Vector( size, -size, -size ) + pos, 0, 0 ),
Vertex( Vector( size, -size, size ) + pos, 0, texturescale ),
Vertex( Vector( size, size, size ) + pos, texturescale, texturescale ),
Vertex( Vector( size, -size, -size ) + pos, 0, 0 ),
// RIGHT
Vertex( Vector( -size, -size, -size ) + pos, 0, 0 ),
Vertex( Vector( -size, size, -size ) + pos, texturescale, 0 ),
Vertex( Vector( -size, -size, size ) + pos, 0, texturescale ),
Vertex( Vector( -size, size, -size ) + pos, texturescale, 0 ),
Vertex( Vector( -size, size, size ) + pos, texturescale, texturescale ),
Vertex( Vector( -size, -size, size ) + pos, 0, texturescale ),
// FRONT
Vertex( Vector( size, -size, size ) + pos, texturescale, texturescale ),
Vertex( Vector( size, -size, -size ) + pos, texturescale, 0 ),
Vertex( Vector( -size, -size, -size ) + pos, 0, 0 ),
Vertex( Vector( -size, -size, size ) + pos, 0, texturescale ),
Vertex( Vector( size, -size, size ) + pos, texturescale, texturescale ),
Vertex( Vector( -size, -size, -size ) + pos, 0, 0 ),
// BACK
Vertex( Vector( -size, size, -size ) + pos, 0, 0 ),
Vertex( Vector( size, size, -size ) + pos, texturescale, 0 ),
Vertex( Vector( -size, size, size ) + pos, 0, texturescale ),
Vertex( Vector( size, size, -size ) + pos, texturescale, 0 ),
Vertex( Vector( size, size, size ) + pos, texturescale, texturescale ),
Vertex( Vector( -size, size, size ) + pos, 0, texturescale ),
}
end
function ENT:Initialize()
local insaneMesh = Mesh()
insaneMesh:BuildFromTriangles(MeshCube( 10, 1, Vector(-1329.870361, -932.460815, 33.912895) ))
end
function ENT:Draw()
insaneMesh:Draw()
end
[/code]
[QUOTE=Lukikot;38312677]Hello, I still got this error:
[ERROR] --- attempt to index local 'pl' (a nil value)
[LUA]function GM:SetPlayerSpeed(pl, walk)
pl.WalkSpeed = walk --Here--
pl:SetWalkSpeed(walk)
pl:SetRunSpeed(walk)
end[/LUA]
Another problem:
[ERROR] --- attempt to index a nil value
[LUA]function GM:ZombieHUD(MySelf)
local entityhealth = math.max(MySelf:Health(), 0)
local maxhealth = ZombieClasses[MySelf.Class].Health --Here--
local percenthealth = entityhealth / maxhealth
...[/LUA]
[/QUOTE]
Can somebody help me please? :(
-snippsy
-snip-
[QUOTE=UnrealFlix;38326718]What net library datatype should be used for a number between 0 and 100?
The tutorial on wiki is rather confusing since it would seem "Byte" would be fine, however it only shows Read/Write Bye in example. Assuming this was replaced by Read/Write Bit?
Or would Int be fine?
[URL]http://wiki.garrysmod.com/page/Lua/Tutorials/Using_the_net_library[/URL][/QUOTE]
net.WriteInt(100, 7) would work I think, the 7 denotes that it uses 7 bits, because 100 in binary is 1100100 (7 numbers)
[B]Question of my own[/B]
What magic is needed to get constraint.Rope to rope to correct bones? I'm trying to get a rope to connect to bone "ValveBiped.Bip01_R_UpperArm" and "ValveBiped.Bip01_L_UpperArm" but they just keep attaching to the ragdoll's foot and knee. Doing ragdoll:GetBoneName(ragdoll:LookupBone("ValveBiped.Bip01_L_UpperArm")) returns the same, what am I doing wrong?
SOLVED
Turns out that the rope constraint uses ragdoll's physbones and not regular bones!
I'm having trouble getting my message of the day to show up when people join my server, can anyone have a look?
[CODE]
IncludeClientFile("autorun/client/motd.lua")
function ShowMOTD( ply )
ply:ConCommand( "motd" )
end
hook.Add( "PlayerInitialSpawn", "show_motd", ShowMOTD );
[/CODE]
Sorry, you need to Log In to post a reply to this thread.