I’ve recently decided to code a game mode, after having taken a break from coding SWEPs and learning supporter programming languages (C++, C#, Java). There are a lot of little qwerks and minor details I’m trying to figure out, since I haven’t had formal education in Lua programming.
Here’s a list of the things I’m trying to accomplish:
Temporarily darken a player's screen Display, then erase text after a certain time limit Prevent players from spawning Randomly select a player to be part of a certain team
Thats all that springs to mind at the moment. I’ve tried trudging through the GMod Lua Wiki but nothing in there seems to indicate any of my above problems except the last one. I managed to figure something out, I was hoping you could provide some debugging assistance with it so I don’t hopelessly run GMod 50 times until I find one problem.
function GM:PlayerSpawn ( ply ) RunConsoleCommand("team_1") if isOver = true then local table_Winner = player.GetAll() local num = math.random(1,table.count(table_Winner)) for x = 0, table.Count(table_Winner) do table_ID[x] = ply:GetByID(x) end timer.Create("random selection timer", 15, 1, function() if table_ID[num] = table_Winner[num] then RunConsoleCommand("team_2") else ply:Give("weapon_crowbar") end if end) end if end
isOver is a boolean for determining if a new round has started or not, since a player can join a game and “initially” spawn, but then spawn subsequent times after a round ends.
Unfortunately, the logic for dealing with players as a whole and assuring that the effects I want are going to the right player doesn’t sit well with me.
I have made text print on the screen, I just can’t find a function to clear it (and any other possible text) from the user’s screen.
I also have no clue how to change their overlay alpha / RGB.
If you could provide any clearing up of that, the listed issues, and my posted code, I would be incredibly grateful!
tl;dr: Need some coding help, please read/help
<3 for anyone who helps me!