What do you need help with? V3

Hello,

For my addon, I’m trying to set a global on button press, but it’s 0 when I have the SWEP made, even if it’s set on that button press. I also store an npc in the array, and need the button’s text to change to what I stored. For some reason, it’s not working. Here’s my testing button (autorun):



if CLIENT then
 button = vgui.Create("DButton")
		
		button:SetParent(Panel)
		button:SetPos(25, 50)
		button:SetSize( 100, 30)
		--net.Receive("gotcha!", function () button:SetText("Pokeball " .. net.ReadString()) end)
		if not pokemoncaught[1] then
		button:SetText("Empty Pokeball 1")
		button.DoClick = function()
			net.Start("pokeball_give")
			net.SendToServer()
			buttons = 1
		end
		elseif pokemoncaught[1] then
			net.Start("give_monster")
			net.SendToServer()
			buttons = 1
			button:SetText(pokemoncaught[1]:GetClass())
		end

else

end

Trying to make my own version of ULX asay in a DarkRP server, because the ulx chat commands sometimes don’t work.

In main.lua:

[lua]local function AdminAssistance(ply, args)
if args == “” then return “” end

local DoSay = function(text)
	if text == "" then return end
	for k, v in pairs(player.GetAll()) do
	if v == ply:IsAdmin() or v == ply then
			GAMEMODE:TalkToPerson(v, col, "(HELP) " ..ply:Nick(), Color(255, 0, 0,255), text, ply)
		end
	end
end
return args, DoSay

end
AddChatCommand("/adminassist", AdminAssistance)[/lua]

Can’t get it to work.

Is there any default lua command that applies like the ent_fire !picker does (ex: where you looking at prop/entity/player etc.)?

player:GetAmmoCount( weapon:GetPrimaryAmmoType() )

?

[lua]local function AdminAssistance(ply, args)
if args == “” then return “” end

for k, v in pairs(player.GetAll()) do
	if v:IsAdmin() or v == ply then
		GAMEMODE:TalkToPerson(v, team.GetColor( ply:Team() ), "(HELP) " ..ply:Nick(), Color(255, 0, 0,255), args, ply)
	end
end
return ""

end
AddChatCommand("/adminassist", AdminAssistance)[/lua]

Doesn’t work for me. I’ve tried putting it in lua/autorun, lua/autorun/server, darkrp/gamemode/server

Does someone know why it isn’t working?

i cant seem to get this to work with the new function GetConVarNumber any help


		--plus the 1 we're spawning right now
			if ( founder:GetCount(cls) + 1 ) > server_settings.Int("sbox_max"..cv,0) then
				ent:Remove()
				founder:PrintMessage(HUD_PRINTCENTER, "Limit reached for ["..ename.."] !")
				return false
			end



			--plus the 1 we're spawning right now
			if ( founder:GetCount(cls) + 1 ) > GetConVarNumber("sbox_max") then
				ent:Remove()
				founder:PrintMessage(HUD_PRINTCENTER, "Limit reached for ["..ename.."] !")
				return false
			end

I can’t check at the moment, but maybe someone knows or could tell me.

If I resource.AddFile a model, will it’s related materials be included too?

It is cvars.Number(gm_your_cvar, default)

resource/AddFile

On the Additional Notes
If called for vmt or mdl files, all related files will be automatically added.

I’m guessing if you add a bleh.mdl file only the models bleh.vtx bleh.skn ect would get downloaded, but not the materials.

NinjaS is right, additionally if you AddFile a .vmt ONLY the vtf of the basetexture will be auto added to the list, no bumpmaps or stuff like that.

Hey ! The error is : attempt to perform arithmetic on field ‘dir’ (a nil value) ( Line 8 )



	 view = {}
        local vec = Vector( -200, -32, 400 )
        local dist = 64
         function CalcView( ply, origin, angles, fov )
                view.origin = net.ReadEntity(npc):GetPos() + vec
                view.angles = Angle(64,0,0)
                view.fov = fov
	        view.dir = LPCameraScreenToVector( gui.MouseX(), gui.MouseY(), ScrW(), ScrH(), view.angles, math.rad( view.fov ) )
		view.tr = util.QuickTrace( view.origin, view.dir * 2048 )
             return view
        end

LPCameraScreenToVector function.



function LPCameraScreenToVector( iScreenX, iScreenY, iScreenW, iScreenH, angCamRot, fFoV )
    -- This code works by basically treating the camera like a frustrum of a pyramid.
    -- We slice this frustrum at a distance "d" from the camera, where the slice will be a rectangle whose width equals the "4:3" width corresponding to the given screen height.
    local d = 4 * iScreenH / ( 6 * math.tan( 0.5 * fFoV ) ) ;
  
    -- Forward, right, and up vectors (need these to convert from local to world coordinates
    local vForward = angCamRot:Forward();
    local vRight   = angCamRot:Right();
    local vUp      = angCamRot:Up();
  
    -- Then convert vec to proper world coordinates and return it
    return ( d * vForward + ( iScreenX - 0.5 * iScreenW ) * vRight + ( 0.5 * iScreenH - iScreenY ) * vUp ):Normalize();
end


Thanks in advance.

Is gui.OpenURL working for anyone else, I’m sure I heard somewhere that he re-added it.
I run it clientside, gui.OpenURL(“google.com”). Nothing appears. The function exists because it doesn’t spew out any errors.

It works fine for me. Try prefixing using http://www. I know https doesn’t work.

Ahh that’s why, was trying to open a paypal URL. Cheers

Very new to this, but I am trying to figure out why this is returning a nil value. I’ve gone through the initialization of the inventory, and followed it back to the error that is being displayed. I heard that this may be a very simple one line fix, but I haven’t been able to figure out what that is.

[LUA][ERROR] …memode/schemas/global/plugins/inventory/cl_inventory.lua:384: attempt to index field ‘InventoryFrame’ (a nil value)

  1. closefunc - …memode/schemas/global/plugins/inventory/cl_inventory.lua:384
  2. CloseTabs - gamemodes/tiramisu/gamemode/cl_init.lua:522
    3. SetActiveTab - gamemodes/tiramisu/gamemode/cl_init.lua:529
    4. DoClick - gamemodes/tiramisu/gamemode/cl_binds.lua:49
    5. unknown - lua/vgui/dlabel.lua:206[/LUA]

Offending Code: https://github.com/kamaitama/Tiramisu/blob/master/gamemode/schemas/global/plugins/inventory/cl_inventory.lua#L383
[LUA]
function CloseInventory()
TIRA.InventoryFrame.Display = false
TIRA.InventoryFrame:SetKeyboardInputEnabled( false )
TIRA.InventoryFrame:SetMouseInputEnabled( false )
TIRA.InventoryFrame.CloseButton:SetVisible(false)
TIRA.InventoryFrame:RequestFocus()
end
[/LUA]

player:GetEyeTrace().Entity

I’m thinking about making a new version of my wanted addon (I suppose you use my former one).

-snip- Turns out as a whole the Inflictor variable in the bullet table doesn’t work as a whole, off I go to post a bug report.

I’m working on a gamemode similar to Killing Floor and games like it: randomly spawning waves of NPCs. I’ve been trying to get the prop_vehicle_apc and npc_apcdriver entities to work for use with it (i.e. an APC spawning around a corner and driving in your way).
So far, I’ve been able to get it to shoot at players and NPCs without any problems. It spawns successfully and without any errors. However…

http://cloud-2.steampowered.com/ugc/884094379080791371/4E7F9DA1194D08FBAEB4454E2FB0C10045ACE78E/

The assault begins, but with no causalities.

Neither the pulse gun mounted on the side or the rockets do any damage to any Rebel-aligned NPCs.

http://cloud.steampowered.com/ugc/884094379080789775/D80858A2989BA1B6C874BB913B30D1814DC74476/

http://cloud.steampowered.com/ugc/884094379080787628/A1F0590526DCECF8B0602A40E8282A52829B2D6E/

Poor Kleiners.

It’s not a problem with any of my code, because other NPCs can damage them just fine:

http://cloud-2.steampowered.com/ugc/884094379080788195/6104C383E556FEB68553C5F3FAE29069E518E971/

Even with the low HP of the Kleiner NPC, a Combine’s shotgun does more damage.

Also, players can still take damage, along with any NPC (that I’ve tested), just not the Rebels:

http://cloud-2.steampowered.com/ugc/884094379080790556/6249D3E39018EB1800C39466E09E48A5763D3D95/

I placed Gman there so the APC would have a target that wouldn’t die so the APC could accidentally shoot the Combine soldiers.

http://cloud-2.steampowered.com/ugc/884094379080792003/2AA12BB0FA4DA1468B993456481778A8A357F5F0/

I’m at a complete loss here.

Not only that, but I attempted to make the vehicle move using point_corners. It doesn’t move at all, even if I fire StartForward on the APC NPC.

Here’s the code I’m using to spawn it:



function ENT:Initialize()
	self.APC = ents.Create("prop_vehicle_apc")
	self.APC:SetModel("models/combine_apc.mdl")
	self.APC:SetPos(self:GetPos())
	self.APC:SetAngles(self:GetAngles())
	self.APC:SetName("CombineAPC" .. self:EntIndex())
	self.APC:SetKeyValue("vehiclescript", "scripts/vehicles/apc_npc.txt")
	self.APC:Spawn()
	self.APC:Activate()
	self.APCDriver = ents.Create("npc_apcdriver")
	self.APCDriver:SetPos(self:GetPos())
	self.APCDriver:SetName("CombineAPC" .. self:EntIndex() .. "Driver")
	self.APCDriver:SetKeyValue("vehicle", "CombineAPC" .. self:EntIndex())
	self.APCDriver:Spawn()
	self.APCDriver:Activate()
end


…And here’s the follow code (which works fine, all the prints fire, but it still doesn’t move):



function ENT:Think()
	if not IsValid(self.APC) or not IsValid(self.APCDriver) then
		self:Remove()
		return
	end
	local Pos = self.APC:OBBCenter()
	Pos:Rotate(self.APC:GetAngles())
	Pos = Pos + self.APC:GetPos()
	self:SetPos(Pos)
	self.APCDriver:SetPos(Pos)
	local ClosestDistance = math.huge
	for _, Ent in pairs(ents.GetAll()) do
		if Ent ~= self and Ent ~= self.APC and Ent ~= self.APCDriver and ((Ent:IsNPC() or Ent:IsPlayer()) and Ent:GetModel()) and Ent:Health() > 0 and self.APCDriver:Disposition(Ent) == D_HT then
			if util.TraceLine(
				{
					start = Pos,
					endpos = Ent:GetPos(),
					filter = {self, self.APC, self.APCDriver}
				}
			).Entity == Ent then
				local Distance = Ent:GetPos():Distance(Pos)
				if Distance < ClosestDistance then
					ClosestDistance = Distance
					self.Target = Ent
				end
			end
		end
	end
	if IsValid(self.Target) and self.Target ~= self.OldTarget and Pos:Distance(self.Target:GetPos()) > 500 and math.random(1, 2000) then
		print("Found an enemy.", self.Target, self.OldTarget)
		if not IsValid(self.Path) then
			print("Need to make a path.")
			self.Path = ents.Create("path_corner")
			self.Path:SetName("CombineAPC" .. self:EntIndex() .. "Target")
			self.Path:Spawn()
			self.Path:Activate()
			print("Firing GotoPathCorner.")
			self.APCDriver:Fire("GotoPathCorner", "CombineAPC" .. self:EntIndex() .. "Target")
		end
		print("Set pos.


")
		self.Path:SetPos(self.Target:GetPos())
		self.Path:SetParent(self.Target)
		self.OldTarget = self.Target
	end
end


My only guess as to why the follow code isn’t working is that I’m incorrectly using GotoPathCorner and/or path_corners. But all my research tells me I’m doing it correctly.

A huge thanks to any possible help on this quite trivial matter.

[editline]13th December 2012[/editline]

Also, my apologies if this has been addressed before and I just didn’t look hard enough.

[editline]13th December 2012[/editline]

Oh, and, yes, I have tried setting the position of the path_corner before I spawn it, no effect.