Questions tagged [garrys-mod]

Garry's Mod is a sandbox game based around player created content. Only post questions relating to game modding. For questions relating to game play, see gaming.stackexchange.com.

Garry's Mod is a sandbox game that allows users to use the Lua scripting language to create custom addons, such as weapons, NPCs, etc.

Questions tagged with relate to creating addons for Garry's Mod using Lua.

198 questions
1
vote
2 answers

LUA Write contents of file to another (Garry's Mod)

local myvariable = print( file.Read( "dir1/file1.txt" ) ) file.Write( "dir2/file2.txt", "myvariable" ) This code will only write "myvariable" to file2.txt but I want the contents from file1.txt to be written to file2.txt. Can I make a "string" be…
user10087137
1
vote
1 answer

What's the correct way to access tables in lua?

I've decided to some fun activities with my free time to make some fun addons for Garry's Mod, roleplay. The addon I'm trying to make is allowing specific doors to be rentable, then when someone rents that door, the main owner will receive…
1
vote
0 answers

gui.openurl not working (no error)

The following code is for an escape menu in a garrys mod server. It's written in lua. I have no idea what the problem could be and I've been working at it for a very long time. There is absolutely no error returned. Here's the full thing: local…
1
vote
1 answer

Attempting to assign money to a user with a certain string in their steam name Glua

I'm making a reward based system for having a username in a steam name and I have got this far so far local XPTimer = 0 local XPTimer = CurTime() + 10 if(XPTimer <= CurTime()) then if string.find("SERVERNAME", ply:SteamName()) then …
Owen
  • 129
  • 1
  • 4
1
vote
2 answers

Garry's mod lua, attempt to call method error

I am testing out Garry's Mod Lua And a strange error keeps poping up! This error seems to be popping up whenever i use any Glua classes, Such as Player:kill! this is my error [ERROR] lua/test.lua:6: attempt to call method 'Kill' (a nil value) And…
1
vote
0 answers

Lua setfenv to exclude or include some methods

What I want to achieve is that Player:SetDeaths is not accessible while Player:Deaths will be accessible. local newgt = {print = print, player = LocalPlayer()} setmetatable(newgt, {}) setfenv(1, newgt) print(player:Deaths()) In the example above I…
Dunqan
  • 11
  • 2
1
vote
5 answers

Table keys and values in Lua - don't know how

I want make dynamic player table with two pieces of information. The player's SteamID, provided as a string, would be used as the key, and the value should be a number. Should look like table = { "ExampleSteamID" = 3, "ExampleSteamID2" = 4 } I found…
plsbx
  • 11
  • 1
  • 2
1
vote
1 answer

Steam Web API GetCollectionDetails not working

I'm attempting to output a list of addons from a steam workshop collection. Every time I do so, it does not work. Here is the api link I am using. Link:…
Quantum
  • 379
  • 3
  • 12
1
vote
1 answer

Garry's mod Expression 2 for loop

In a game called Garry's mod there an add on called wiremod. Inside wiremod there is expression 2 which is a conmand line basiced coding so execute commands. The command For loop I'm having issues with because I can't do variable inside a variable.…
Brett Nelson
  • 113
  • 3
  • 19
1
vote
1 answer

Attempting to move folders via batch script moving only contents

I wrote out this batch script to start up a dedicated source server for Garry's Mod in "test mode", where all of the non-essential filesystem addons are moved to a "--Disabled" folder, so that it does not load them into the game. Here's all of the…
1
vote
1 answer

How to create an rectangle in a 3d area via vector&angle

I have a 3d game where I will create an rectangle which is working as screen and the game itself works with vectors to positions. so I will create an rectangle and have only these parameters aviable: start position ->vector (x,y,z). Angle(rotation)…
ProJaCore
  • 11
  • 3
1
vote
1 answer

Garry's mod menu script (lua)

function Team_Swap() local Backg = vgui.Create( "DFrame" ) Backg:SetSize( ScrW() / 2, ScrH() / 2 ) Backg:SetPos ( ScrW() / 2, ScrH() / 2 ) Backg:SetTitle( "Swap Teams" ) Backg:SetVisible ( true ) Backg:SetDraggable ( true ) …
Newrecycle
  • 21
  • 1
  • 3
1
vote
1 answer

Using for in pairs to update table based on another table in Lua

The problem is on the client side code (src: cl_hob.lua) net.Receive("HobNetMsg", function(len) local Queue = {} Queue = net.ReadTable() for I = 1 , #Queue do local index = Queue[I]["index"] for Key , Value in…
Hobnob11
  • 80
  • 13
1
vote
1 answer

Gun Accuracy Leaderboard Calculation

I'm working on a leaderboard system for Garry's Mod and I have run into a slight problem to do with one of the statistics I'm tracking. I am tracking a lot of statistics including the number of bullet's shot and the number of bullets that actually…
Noojuno
  • 13
  • 1
  • 2
1
vote
1 answer

GLua check between vectors

I'm trying to create something in a game called Garry's Mod that uses Lua for addons. Basically I need to check if the player's cursor has entered a specific area. if _hitentity:GetClass() == "treasury" then draw.RoundedBox(0, 0, 0, 60, 20,…
Alana Stephens
  • 109
  • 1
  • 1
  • 8
1 2
3
13 14