So is using a texture for a stencil still not possible? Everything I’ve seen/tried so far is pointing in the impossible direction.
If I must... well if I can't handle health and/or armor as a float the damage scaling will get messed up... I can try to scale the damage manually but I think those times when taking 5 hits adds up to 1 point of damage can't exist like that. At least, not on the Armor... but if I must I guess I can handle all the damage scaling manually somehow...
Is it just me or is sound.PlayFile not working? Even the example given doesn't work. I've used it many times before and now nothing, no errors just nothing.
Anyway to stop the sound included when playing ACT_ENUM? Like reloading for example
Return true for event 3017 in a serverside WEAPON:FireAnimationEvent hook in your SWEP.
Hello,
I'm having problems with an addon that I bought (Gets a playermodel from workshop and applies to the game).
Just to start I already contact the developer of the addon. I used it for a long time, however gmod had an update don't know when, that broke part of the api. He said that the gmod needs to fix it instead of him so I'm not sure what to do, do I wait for an update to fix or it's the creator fault?
That error is way unhelpful if you don't provide the error itself or even the context
There's not that much to say, I think this Lua file just wants to know if that gma is malicious or something similar.
[ERROR] addons/wardrobe/lua/wardrobe/gmamalicious.lua:115: attempt to index local 'l' (a nil value)
1. getPlayerModels - addons/wardrobe/lua/wardrobe/gmamalicious.lua:115
2. unknown - addons/wardrobe/lua/wardrobe/wardrobe.lua:167
3. _performMount - addons/wardrobe/lua/wardrobe/workshop.lua:163
4. fn - addons/wardrobe/lua/wardrobe/workshop.lua:171
5. unknown - addons/ulib_557962238/lua/ulib/shared/hook.lua:109
-- Small code example
for i, entry in ipairs(gma:filesMatching("lua/autorun/.+%.lua")) do
local path = entry.name
local f = file.Open(path, "r", "GAME")
-- (...)
You didn't even post line 115 from gmamalicious.lua. We'd need to see the code around where the actual error is occurring.
[Lua] Lua Code / GMA malicious
Is better to post all the code, line 115 has this code:
local l = f:ReadLine()
Well, the one thing I see in this file is that
(...)
if (IsValid(file.Open(path, "r", "GAME"))) then
local f = file.Open(path, "r", "GAME")
end
if f then
(...)
at line 110 just won't work, ever. f is outside of the scope of the if-statement so that block of code that follows should never run. Change it to this:
(...)
local f
if (IsValid(file.Open(path, "r", "GAME"))) then
f = file.Open(path, "r", "GAME")
end
if f then
(...)
I guess it's fine now, thanks.
File objects don't have an `IsValid` method, running it through http://wiki.garrysmod.com/page/Global/IsValid will always return false.
Yeah, to check if a file "Is valid" use file.Exists
I just started to use Particle Editor and I realised that in Alien Swarm SDK I can render 3D models in particles, but in Gmod I can't, because it uses an older PCF version (Binary 2 PCF 1 not Binary 5 PCF 2). Is there any solution?
"but in Gmod I can't, because it uses an older PCF version" - you just answered your question there, mate
Thats kinda interesting script. It works when i press Use on a func_button it should write on the draw.SimpleText the name of the player who pressed the func_button where the entity is in near. But the script needs the init.lua
But i try to recreate it
--cl_init.lua--
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "cl_init.lua" )
include( "shared.lua" )
surface.CreateFont( "PressPad_Font_1", {
font = "Arial",
extended = false,
size = 55,
weight = 1000,
} )
surface.CreateFont( "PressPad_Font_2", {
font = "Arial",
extended = false,
size = 45,
weight = 1000,
} )
function ENT:Initialize()
self.Used = {}
end
local function isempty(tbl)
if ( table.Count(tbl) <= 0 ) then
return true
else
return false
end
end
net.Receive("PressPad_UpdateData", function()
local ent = net.ReadEntity()
local tbl = net.ReadTable()
ent.Used = tbl
end)
function ENT:Draw()
self:DrawModel()
local ply = LocalPlayer()
if ( self:GetPos():Distance(ply:GetPos()) < 1200 ) then
local Data = self.Used
local ang = self:GetAngles()
local pos = self:GetPos() - ( self:GetUp() * 1.7 )
ang:RotateAroundAxis( self:GetAngles():Up(), 180 )
ang:RotateAroundAxis( self:GetAngles():Right(), 180 )
cam.Start3D2D(pos, ang, 0.03)
draw.RoundedBox(4,-200,-400,400,800,Color(255,165,0,255))
draw.RoundedBox(4,-200+4,-400+4,400-8,800-8,Color(40,40,40,255))
surface.SetDrawColor(255,165,0,255)
surface.DrawRect(-200,-400,400,75)
draw.SimpleText("Benutzt von:","PressPad_Font_1",0,-390,Color(255,255,255), TEXT_ALIGN_CENTER)
local y = -300
if ( Data and !isempty(Data) ) then
for k, v in pairs(Data) do
surface.SetFont("PressPad_Font_2")
local tw, th = surface.GetTextSize(v)
if ( tw > 390 ) then
local v1 = string.Split(v, " ")
draw.SimpleText("?"..v1[1],"PressPad_Font_2",0,y,Color(255,0,0,255), TEXT_ALIGN_CENTER)
draw.SimpleText(v1[2],"PressPad_Font_2",0,y+50,Color(255,255,255), TEXT_ALIGN_CENTER)
draw.SimpleText(v1[3],"PressPad_Font_2",0,y+100,Color(255,255,255), TEXT_ALIGN_CENTER)
if ( v1[4] ) then
draw.SimpleText(v1[4],"PressPad_Font_2",0,y+150,Color(255,255,255), TEXT_ALIGN_CENTER)
y = y + 200
else
y = y + 150
end
else
draw.SimpleText("?"..v,"PressPad_Font_2",0,y,Color(255,0,0,255), TEXT_ALIGN_CENTER)
y = y + 50
end
end
end
cam.End3D2D()
end
end
--shared.lua
ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "Benutzerplatte"
ENT.Author = "Aden"
ENT.Contact = ""
ENT.Purpose = ""
ENT.Instructions = ""
ENT.Category = "SWRP"
ENT.Spawnable = true
ENT.AdminSpawnable = true
-- one server hook
if ( SERVER ) then
util.AddNetworkString("PressPad_UpdateData")
hook.Add("PlayerInitialSpawn", "PressPad_UpdateData", function(ply)
timer.Simple(4, function()
for k, v in pairs(ents.FindByClass("swrp_presspad")) do
net.Start("PressPad_UpdateData")
net.WriteEntity(v)
net.WriteTable(v.Used)
net.Send(ply)
end
end)
end)
end
This didn't get solved and I cant bump e.e
Math
I am trying to get a float between 0 and 1 from variables of a players position relative to the radius of a circle with a maximum length of 1024.
I know I need to use a mixture of math.ceil and math.Clamp. To limit the float volume between 0 and 1 using the players position relative to arena_size but I'm terrible with math
Been trying myself but gave up to ask for help so I can learn. Here's everything so far.
local arena_min = 5
local arena_max = 1024
local arena_time = 1
local arena_size = arena_min
local arena_pos = Vector(0,0,0)
local orangebox = CreateClientConVar("tast_arena_poor","0",true,false,"Switch from Material arena to orange arena.")
hook.Add( "Think", "ArenaDamage", function()
arena_size = math.Clamp(arena_size+arena_time,arena_min,arena_max)
if SERVER then
for k,v in pairs(player.GetAll()) do
if v:IsPlayer() and IsValid(v) and (v:GetPos():Distance(arena_pos)>arena_size) then
function DissolveIt( ent )
local d = DamageInfo()
d:SetDamage( .05 )
d:SetAttacker( ent )
d:SetDamageType( DMG_DISSOLVE )
ent:TakeDamageInfo( d )
end
DissolveIt( v )
end
end
end
-- set volume of arena sound based on distance from arena_max
end)
if CLIENT then
--[[
if IsValid(LocalPlayer()) then
sound.PlayFile( "sound/ambient/machines/combine_shield_loop3.wav", "mono", function( station, num, err )
if ( IsValid( station ) ) then
station:Play()
else
print(num,err)
end
end )
end--]]
hook.Add( "PostDrawOpaqueRenderables", "ArenaCFG", function()
chat.AddText(tostring( math.ceil(LocalPlayer():GetPos():Distance(arena_pos)-arena_size )))
cam.Start3D2D(arena_pos,Angle(0,0,0),1)
if orangebox:GetInt() == 1 then
render.SetColorMaterial()
render.DrawWireframeSphere(arena_pos,arena_size,30,30,Color(0,128,0,255),true)
render.DrawSphere(arena_pos,arena_size,30,30,Color(255,165,0,100))
else
render.SetMaterial(Material("models/props_combine/portalball001_sheet", "nocull"),true)
render.DrawSphere(arena_pos,arena_size,30,30,Color(255,165,0,100))
end
cam.End3D2D()
end)
end
I'm curious what CTakeDamageInfo:SetDamageCustom(n) does. It might be something useful for my creations that I never publish...and probably should publish some time lol.
It's used by some Source games to set custom damage types for death notifications, but it does nothing in GMod. I'll update the wiki page.
I made a custom TTT scoreboard and am having some problems making the player sorting error free. My current problem is that on what seems to be random occasion, I will get the following error:
[ERROR] gamemodes/terrortwo/gamemode/library/scoreboard/cl_panel_sbmain.lua:308: invalid order function for sorting
1. sort - [C]:-1
2. UpdateSorting - gamemodes/terrortwo/gamemode/library/scoreboard/cl_panel_sbmain.lua:308
3. UpdateScoreboard - gamemodes/terrortwo/gamemode/library/scoreboard/cl_panel_sbmain.lua:326
4. Init - gamemodes/terrortwo/gamemode/library/scoreboard/cl_panel_sbmain.lua:62
5. Create - lua/includes/extensions/client/panel/scriptedpanels.lua:37
6. Open - gamemodes/terrortwo/gamemode/library/scoreboard/sh_scoreboard.lua:58
7. unknown - gamemodes/terrortwo/gamemode/cl_init.lua:47
The following is the relevant piece of code, I marked line 308 for you guys.
local ascend = sortAscending:GetBool()
for i, group in ipairs(self.Groups) do -- line 308
table.sort(group.ContainnedRows, function(rowA, rowB)
local plyA, plyB = rowA:GetPlayer(), rowB:GetPlayer()
local retVal = sortFunction(plyA, plyB)
if not isbool(retVal) then
error("Non-boolean value returned for TTT Scoreboard sorting option with ID of '".. sort .."'")
end
if ascend then
return retVal
end
return not retVal
end)
end
I never get the error that retVal is a non-bool value, sortFunction is doing nothing but returning true, and I am ensuring that plyA and ply B are valid. What is going on? Thanks.
From my experiments, you will start getting that error when there are at least 4 values in the table and all you do is return true. You need to sort things in a specific way. Can't just return true all the time.
Lua 5.1 Reference Manual
I made a small script to strip the weapons of a player when the player presses a button in a Derma menu (thanks to the guys who helped me!), and I wish to always let it run when a Client Connects to the server. I put my Client.lua and Server.lua in my Autorun folder, but when I connect to a Singleplayer game, it does not let the Derma Menu popup, nothing special printed in console.
My Client Script (client.lua)
local frame = vgui.Create("DFrame")
frame:SetSize(600, 200)
frame:SetVisible(true)
frame:Center()
frame:MakePopup()
frame.Paint = function( self, w, h ) -- 'function Frame:Paint( w, h )' works too
draw.RoundedBox( 0, 0, 0, w, h, Color( 96, 96, 96, 255 ) ) -- Draw a red box instead of the frame
end
local Button = vgui.Create("DButton", frame)
Button.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue button
end
Button:SetText("Development?")
Button:SetTextColor( Color( 255, 255, 255 ) )
Button:SetSize(200, 50)
Button:Center()
Button.DoClick = function()
net.Start("StripWeapons")
net.WriteEntity(ply)
--Remember to read the stuff the same way you sent it
net.SendToServer()
end
Here is Server.lua (serverside)
util.AddNetworkString("StripWeapons")
net.Receive("StripWeapons", function(_, pPlayer)-- <-- HERE you are giving this variable name 'pPlayer'
pPlayer:StripWeapons() -- HERE, however, you're referencing 'Player', which is a different identifier
end)
I don't totally understand that, can you give any visual links / tutorials on it? I don't seem to find anything on the wiki.
And invalid entity? You mean the
net.WriteEntity(ply)
or am I mistaken?
So I've been trying to make an NPC here, but I can't get the pose right.
shared.lua
ENT.Type = "ai"
ENT.Base = "base_ai"
ENT.PrintName = "NPC Car Dealer"
ENT.Spawnable = true
ENT.AutomaticFrameAdvance = true -- This entity will animate itself.
function ENT:SetAutomaticFrameAdvance( bUsingAnim ) -- This is called by the game to tell the entity if it should animate itself.
self.AutomaticFrameAdvance = bUsingAnim
end
cl_init.lua
include("shared.lua")
init.lua
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/player/barney.mdl")
self:SetHullType(HULL_HUMAN)
self:SetHullSizeNormal()
self:SetSolid(SOLID_BBOX)
self:CapabilitiesAdd(bit.bor(CAP_ANIMATEDFACE, CAP_TURN_HEAD))
self:SetUseType(SIMPLE_USE)
end
On the left we have my custom NPC entity, on the right, the default Barney NPC (withtout weapons).
My current problem is getting rid of the Tpose. How should I do that? Thanks in advance for your time.
Yes, you should delete it since you never read an entity anyway. Your solution is to create all of the VGUI in a GM:Initialize hook.
I just realised I was using the playermodel, not the actual Barney model. A quick switch to "models/barney.mdl" fixed it. Thanks anyway.
I need help with this. I'm trying to get live playercount for my project with xPaw's Source Query. Here is the PHP in the index file. Not neccessarily asking for a fix but a better understanding.
<?php
require ('config.php');
require __DIR__ .'/inc/SourceQuery/bootstrap.php';
use xPaw\SourceQuery\SourceQuery;
define( 'SQ_SERVER_ADDR', '149.56.67.191' );
define( 'SQ_SERVER_PORT', 27015 );
define( 'SQ_TIMEOUT', 1 );
define( 'SQ_ENGINE', SourceQuery::SOURCE );
$Query = new SourceQuery( );
try
{
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );
print_r( $Query->GetInfo( ) );
print_r( $Query->GetPlayers( ) );
print_r( $Query->GetRules( ) );
}
catch( Exception $e )
{
$Exception = $e;
}
?>
And then I just want it to input a player count here.
<p class="'.$TextColor.'-text flow-text" style="font-weight:bold;">Playercount / Maxplayers</p>
Hi, I created a derma panel that is parented to a DButton and have pnl:SetMouseInputEnabled(true) when the panel is being created yet if you were to start clicking the panel, pnl.DoClick is called maybe 3 out of every 5 presses. Any ideas as to why this may be and how to make it be called consistently, every click.
Sorry, you need to Log In to post a reply to this thread.