I am trying to port this: [url]http://www.garrysmod.org/downloads/?a=view&id=48931[/url]
to TTT and Garry's Mod 13. It is working fine but I keep getting this error:
[ERROR] lua/weapons/weapon_microwaverifle/shared.lua:1141: attempt to call method 'Fire' (a nil value)
1. unknown - lua/weapons/weapon_microwaverifle/shared.lua:1141Thanks guys!
Edit: Here is my shared.lua: [url]http://pastebin.com/ef3WBzwX[/url]
So I am trying to make a script that spawns zombies in random positions of which I set on a table however when I run my script...
I recieve this error.
[CODE]
[ERROR] gamemodes/newgamemode/gamemode/init.lua:11: attempt to index global 'ZombieTable' (a nil value)
[/CODE]
Here is the code
[lua]
timer.Create("zombie_spawner", 20, 0, function()
zombiespawner()
end)
local ZombieTables = {}
ZombieTable[1] = "3527.365967, -2822.148438, -12069.080078"
ZombieTable[2] = "1483.351318, -1285.041748, -12735.968750"
ZombieTable[3] = "321.259552, 1748.059326, -12735.968750"
ZombieTable[4] = "-601.159790, 1878.374146, -12735.968750"
ZombieTable[5] = "-158.738342, 2785.834229, -12735.968750"
ZombieTable[6] = "1707.709839, 1605.777588, -12735.968750"
function zombiespawner()
local ent = ents.Create("npc_zombie")
ent:SetPos(Vector(table.Random(tonumber(ZombieTables))))
ent:Spawn()
end
[/lua]
Thanks for any help in advance.
Edit: I fixed the table nil part, I was calling the tables "ZombieTable" and not "ZombiesTables", however now I am getting this error also sorry I forgot to post the original error at the top in my original post.
[CODE]
Timer Failed! [zombie_spawner][@gamemodes/newgamemode/gamemode/init.lua (line 6)]
[ERROR] lua/includes/extensions/table.lua:162: bad argument #1 to 'pairs' (table expected, got nil)
[/CODE]
[B]Edit:[/B] Got it all working now.
-snip nevermind you got it
[QUOTE=Sean C;39199356]-snip nevermind you got it[/QUOTE]
Yeah, I threw out the commas from the string and just removed the tonumber and it ended up working. You pretty much hit it spot on too.
Snapping a vector to a multiple of any number, how can I keep it aligned to the surface that I am looking at?
Hello !
I'm actually creating a Roleplay on Garry's mod. This is my first gamemode, and I have a question.
I want to put a commande like [B]/reboot <time>[/B]. This commande will create send a messages on the chat to everyplayer
[Reboot] I like trains !
I try this command:
[CODE]chat.AddText( Color( 0,0,200 ), "[Reboot]", Color( 255,255,255 ), "The server will restart in "..chattimecommand.. " minutes !" )[/CODE]
Problem? Only me see the messages :/
Any idea? Thank :)
[I][B]PS :[/B] Sorry for my bad english, i'm french.[/I]
[B][U]Steam:[/U][/B] imediam
-snip-
[QUOTE=RCRad;39200479]Why would this not work and give off this error?
[ERROR] gamemodes/darkrp/gamemode/other_scripts.lua:213: function arguments expected near 'or'
1. unknown - gamemodes/darkrp/gamemode/other_scripts.lua:0
[LUA]local function stopDemote(ply, args)
for k,v in pairs(player.GetAll()) do
if v:IsAdmin or v:GetUserGroup() == "trainee" or v:GetUserGroup() == "trainee-d" or v:GetUserGroup() == "moderator" or v:GetUserGroup() == "moderator-d" then
GAMEMODE:Notify(ply, 1, 4, "You can't demote someone when there is an admin online! Use @ to call them!")
return ""
end
end
end
hook.Add("Demote", "Stop demote", stopDemote)[/LUA][/QUOTE]
v:IsAdmin without parenthesis.
[QUOTE=vexx21322;39200502]v:IsAdmin without parenthesis.[/QUOTE]
Yup, just figured it out. Thanks haha.
1. How do I remove/round the corners on a PNG? For example, say I have a square PNG for my HUD, but I want to give it rounded corners.
2. Are there masking functions of some sort? Is it possible to make a curved health bar?
3. Is it just me or did lua_run_cl stop functioning in both singleplayer and multiplayer?
[code]] lua_run_cl print("test")
] lua_run_cl awefa;;;
] lua_run_cl )(
[/code]
4. How do I use silkicons with surface.SetTexture? Do I have to load it first using Material()? Are materials and textures the same thing?
3. sv_allowcslua 1
4. surface.SetMaterial, and yes you have to use Material().
concommand.Add("test_bar", function(ply, cmd, args) Material("icon16/camera.png", "unlitgeneric") hook.Add("HUDPaint", "inf_test_bar", function() draw.TexturedQuad{ color=Color(255,255,255,255), texture=surface.GetTextureID("icon16/camera"), w=1000, h=100, x=50, y=50, } draw.TexturedQuad{ color=Color(255,255,255,255), texture=surface.GetTextureID("gui/gradient"), w=1000, h=100, x=50, y=200, } end) end)
[code]Missing Vgui material icon16/camera
--- Missing Vgui material icon16/camera
--- Missing Vgui material icon16/camera[/code]
What am I doing wrong? I'm thorougly confused about what the IMaterial class does: [url]http://wiki.garrysmod.com/page/Classes/IMaterial[/url]
print(Material("icon16/camera.png", "unlitgeneric,nocull"):GetName()) returns "icon16/camera"
[QUOTE=infinitywrai;39200901][lua]concommand.Add("test_bar", function(ply, cmd, args)
Material("icon16/camera.png", "unlitgeneric")
hook.Add("HUDPaint", "inf_test_bar", function()
draw.TexturedQuad{
color=Color(255,255,255,255),
texture=surface.GetTextureID("icon16/camera"),
w=1000, h=100,
x=50, y=50,
}
draw.TexturedQuad{
color=Color(255,255,255,255),
texture=surface.GetTextureID("gui/gradient"),
w=1000, h=100,
x=50, y=200,
}
end)
end)[/lua]
[code]Missing Vgui material icon16/camera
--- Missing Vgui material icon16/camera
--- Missing Vgui material icon16/camera[/code]
What am I doing wrong? I'm thorougly confused about what the IMaterial class does: [URL]http://wiki.garrysmod.com/page/Classes/IMaterial[/URL][/QUOTE]
Material returns an IMaterial.
You only need to call it once.
You also don't need it for that code. You just need camera.png in icon16.
Also don't forget to add '.png' so the function knows it's not looking for camera.vtf.
Revised code didn't work:
[lua]concommand.Add("test_bar", function(ply, cmd, args)
--Material("icon16/camera.png", "unlitgeneric,nocull")
hook.Add("HUDPaint", "inf_test_bar", function()
print(Material("icon16/camera.png", "unlitgeneric,nocull"):GetName())
draw.TexturedQuad{
color=Color(255,255,255,255),
texture=surface.GetTextureID("icon16/camera.png"),
w=1000, h=100,
x=50, y=50,
}
draw.TexturedQuad{
color=Color(255,255,255,255),
texture=surface.GetTextureID("gui/gradient"),
w=1000, h=100,
x=50, y=200,
}
end)
end)
[/lua]
[code]--- Missing Vgui material icon16/camera.png[/code]
The old wiki said specifically to not include extension in surface.GetTextureID(). "icon16/camera.png" is included with Garrysmod, but I'm not sure if I need to create the material for it?
[QUOTE=infinitywrai;39201009]Revised code didn't work:
[lua]concommand.Add("test_bar", function(ply, cmd, args)
--Material("icon16/camera.png", "unlitgeneric,nocull")
hook.Add("HUDPaint", "inf_test_bar", function()
print(Material("icon16/camera.png", "unlitgeneric,nocull"):GetName())
draw.TexturedQuad{
color=Color(255,255,255,255),
texture=surface.GetTextureID("icon16/camera.png"),
w=1000, h=100,
x=50, y=50,
}
draw.TexturedQuad{
color=Color(255,255,255,255),
texture=surface.GetTextureID("gui/gradient"),
w=1000, h=100,
x=50, y=200,
}
end)
end)
[/lua]
[code]--- Missing Vgui material icon16/camera.png[/code]
The old wiki said specifically to not include extension in surface.GetTextureID(). "icon16/camera.png" is included with Garrysmod, but I'm not sure if I need to create the material for it?[/QUOTE]
You have to use the extension for png files when you use Material. That's what I was thinking.
I believe getTextureID only works for vtf textures. You have to use Material.
I don't think draw.TexturedQuad has been updated for the new png drawing system.
[QUOTE=infinitywrai;39201009]Revised code didn't work:
[lua]concommand.Add("test_bar", function(ply, cmd, args)
--Material("icon16/camera.png", "unlitgeneric,nocull")
hook.Add("HUDPaint", "inf_test_bar", function()
print(Material("icon16/camera.png", "unlitgeneric,nocull"):GetName())
draw.TexturedQuad{
color=Color(255,255,255,255),
texture=surface.GetTextureID("icon16/camera.png"),
w=1000, h=100,
x=50, y=50,
}
draw.TexturedQuad{
color=Color(255,255,255,255),
texture=surface.GetTextureID("gui/gradient"),
w=1000, h=100,
x=50, y=200,
}
end)
end)
[/lua]
[code]--- Missing Vgui material icon16/camera.png[/code]
The old wiki said specifically to not include extension in surface.GetTextureID(). "icon16/camera.png" is included with Garrysmod, but I'm not sure if I need to create the material for it?[/QUOTE]
[lua]local cammat = Material("icon16/camera.png")
concommand.Add("test_bar", function(ply, cmd, args)
hook.Add("HUDPaint", "inf_test_bar", function()
surface.SetDrawColor(Color(255,255,255,255))
surface.SetMaterial(cammat)
surface.DrawTexturedRect(50,50,1000,100)
draw.TexturedQuad{
color=Color(255,255,255,255),
texture=surface.GetTextureID("gui/gradient"),
w=1000, h=100,
x=50, y=200,
}
end)
end)[/lua]
You're going to want that.
Hey,
I'm currently creating my scoreboard but how do I sort players by alphabet or by ULX Groups?
Currently using darkrp teams:
cat:SetLabel(team.GetName(a).. " (".. #team.GetPlayers(a) ..")")
[QUOTE=smithy285;39198707]I am trying to port this: [url]http://www.garrysmod.org/downloads/?a=view&id=48931[/url]
to TTT and Garry's Mod 13. It is working fine but I keep getting this error:
[ERROR] lua/weapons/weapon_microwaverifle/shared.lua:1141: attempt to call method 'Fire' (a nil value)
1. unknown - lua/weapons/weapon_microwaverifle/shared.lua:1141Thanks guys!
Edit: Here is my shared.lua: [url]http://pastebin.com/ef3WBzwX[/url][/QUOTE]
It means that [I]tr.Entity[/I] isn't actually an entity. In other words, if [I]tr[/I] is a traceres (which I assume it is; can't be bothered to look through that mess), it means that the trace didn't hit an entity, so the [I]Entity[/I] field is [I]nil[/I].
Fix it by adding a check for whether tr.Entity is valid somewhere in the code:
[lua]if tr.Entity and tr.Entity:IsValid() then[/lua]
[QUOTE=luavirusfree;39202806][URL="http://facepunch.com/showthread.php?t=1239091&p=39197565"]This![/URL][/QUOTE]
you're probably getting a Lua error when you join and it's crashing you. Try setting sv_kickerrornum to 0 (but please fix the errors lol)
Is there anyway to detect when a player presses an element inside of a DModelSelect?
There is no documentation on it and [url=http://www.glua.me/bin/?path=/lua/vgui/dmodelselect.lua&plaintext=1]Source Code[/url] hasn't indicated that there's a way.
Will this work(?):
[CODE]
function GM:PlayerSpawn( ply )
ply:SetGravity( 0.5 )
ply:SetMaxHealth( 100, true )
ply:SetRunSpeed( 400 )
ply:SetFriction( 100 )
end
[/CODE]
(The code is for a gamemode)
And how can I set SetFriction, that it is for the player like sv_friction is -0.05?
autoit4you
Is there a way to add individual entities to a player's PVS list? I want each player to always be aware of other players' positions.
Has GLON been updated for GMod 13?
[QUOTE=fairy;39205026]Has GLON been updated for GMod 13?[/QUOTE]
[url=http://wiki.garrysmod.com/page/Libraries/util/JSONToTable]util.JSONToTable[/url]
[url=http://wiki.garrysmod.com/page/Libraries/util/TableToJSON]util.TableToJSON[/url]
I know that this has been asked thousands of times, but how do I use a non weapon model as v_model ?
@edit: Ignore it, I found out, just like any other model, just needs some placing and resizing
Help me with that, thx. [url]http://www.facepunch.com/showthread.php?t=1239284&p=39204637#post39204637[/url]
Swep fov overrides my fov I set on my playerspawn hook, is there a way to prevent that?
I have to use SetFOV on player spawn to change the fov because changing it in calcview messes with some traces I do. I also can't just call SetFOV on every think because setFov takes a time to transition value and even if I set it to zero a stutter is noticeable. (I think ScreenToVector, which I use in my calcview to find where the player is looking, takes in fov as a param and that causes some issues.)
-snip-
How does this function work? I don't understand what the last 4 parameters do: [url]http://wiki.garrysmod.com/page/Libraries/surface/DrawTexturedRectUV[/url]
What is U and V?
Sorry, you need to Log In to post a reply to this thread.