Derma_StringRequest question

Hello people… so I have something like this



						SubPlayerViewOptions:AddOption( "Ban", function() 
							Derma_StringRequest(
								"Ban Reason",
								"Why do you want to ban this person?",
								"",
								function( text )
									Derma_StringRequest(
										"Ban Time",
										"How long do you want to ban this person? (Ban time is in minutes.)",
										"",
										function( text2 )
											RunConsoleCommand( "ulx", "ban", line:GetValue(1), text, text2)
										end,
									function( text2 ) end)
								end,
							function( text ) end)
						
						
							--RunConsoleCommand( "ulx", "ban", line:GetValue(1)) 
							timer.Simple(0.1, function()
							PlayerView:Clear()
								for k, v in pairs (player.GetAll()) do
									PlayerView:AddLine(v:Nick())
								end
							end)
						end ):SetImage( "icon16/exclamation.png" )


My question that I would like to ask, is why is it putting an error on the run console command here…



RunConsoleCommand( "ulx", "ban", line:GetValue(1), text, text2)


It gives an error with that line, doesn’t seem to work at all… line:GetValue(1) Grabs the players name from here…



								for k, v in pairs (player.GetAll()) do
									PlayerView:AddLine(v:Nick())
								end


Help would be appreciated.

what is your error?

Oh, my stupidity forgot to post that, one minute.

[editline]2nd July 2014[/editline]



[ERROR] addons/addon/lua/autorun/client/ui.lua:74: Tried to use invalid object (type Panel) (Object was NULL or not of the right type)
  1. GetValue - [C]:-1
   2. fnEnter - addons/addon/lua/autorun/client/ui.lua:74
    3. DoClick - lua/derma/derma_utils.lua:231
     4. unknown - lua/vgui/dlabel.lua:206


Is the error, line 74 being



RunConsoleCommand( "ulx", "ban", line:GetValue(1), text, text2)


shouldnt it be

as thats what the DListView is called…

If I have PlayerView:GetValue(1) it finds multiple targets, if I do line:GetValue(1) it gives that error (line:GetValue(1)) tends to work except for this for some reason.

Show us the definition of ‘line’.

It looks like ‘line’ is a Panel, but it’s a NULL Panel.

The “line” is defined here



PlayerView.OnClickLine = function( parent, line, something )


And a Custom line is added to the DListView from here



for k, v in pairs(player.GetAll()) do
	PlayerView:AddLine(v:Nick(), v:UserID())
end


The main reason i’m thinking it shouldn’t be a problem with line:GetValue(1) is because I have it do the same somewhere else in the script.



RunConsoleCommand( "ulx", "kick", line:GetValue(1))


And that works just fine, but whilst inside the Derma_StringRequest, it gives me problems for the ban.

You don’t want to use OnClickLine since that’s an internal function (wiki kinda makes it sound like it’s the callback you use).
You want to use #OnRowSelected(number lineID, panel line)

The thing is though, OnClickLine has worked just fine for me the entire time, why would I have to change it, not that I don’t want to, but i’m assuming I would have to change multiple things for what I have.

OnClickLine handles things like multi-selection, double clicking, clearing of previous lines, and then the calling of OnRowSelected.

You do have a point though, it should still work if you don’t need/use any of those.

I just don’t understand why PlayerView:GetValue(1) Works but not completely as it should, but line:GetValue(1) Returns an error, do you have the slightest idea on something I can do or something i’m doing wrong?

DListView#GetValue isn’t the same as DListView_Line#GetValue.
DListView#GetValue is on every panel (http://samuelmaddock.github.io/glua-docs/#?q=getvalue), and DListView_Line#GetValue is a method to get the value of a column on a line/row.

I have a feeling you might be trying to get the userid and using ‘1’ because most languages use 0 as the starting index.

Try using GetValue(2).

GetValue 1 gets the users name, therefore banning the user using the name, GetValue 2 gets the users UID, banning them by their UID, would I still be using GetValue(2) ?

[editline]2nd July 2014[/editline]

Yeah, it seems after putting it to line:GetValue(2) it still gives the error… help would be appreciated.