derma stuff

[lua]include(“sv_spawnpoint.lua”)

function TPMenu()

local DButton2
local DButton1
local DComboBox2
local DComboBox3
local DPanel2
local DFrame2

DFrame2 = vgui.Create('DFrame')
DFrame2:SetSize(205, 305)
DFrame2:SetPos(10, 10)
DFrame2:SetTitle('Teleport Menu')
DFrame2:SetSizable(true)
DFrame2:SetDeleteOnClose(false)
DFrame2:MakePopup()

DPanel2 = vgui.Create('DPanel')
DPanel2:SetParent(DFrame2)
DPanel2:SetSize(195, 270)
DPanel2:SetPos(5, 30)

DComboBox3 = vgui.Create('DComboBox')
DComboBox3:SetParent(DPanel2)
DComboBox3:SetSize(60, 175)
DComboBox3:SetPos(130, 10)
DComboBox3:EnableHorizontal(false)
DComboBox3:EnableVerticalScrollbar(true)
DComboBox3.OnMousePressed = function() end
DComboBox3:SetMultiple(false)

DComboBox2 = vgui.Create('DComboBox')
DComboBox2:SetParent(DPanel2)
DComboBox2:SetSize(55, 175)
DComboBox2:SetPos(5, 10)
DComboBox2:AddItem("Teleport 1")
DComboBox2:AddItem("Teleport 2")
DComboBox2:AddItem("Teleport 3")
DComboBox2:EnableHorizontal(false)
DComboBox2:EnableVerticalScrollbar(true)
DComboBox2.OnMousePressed = function() end
DComboBox2:SetMultiple(false)

DButton1 = vgui.Create('DButton')
DButton1:SetParent(DPanel2)
DButton1:SetSize(55, 25)
DButton1:SetPos(5, 190)
DButton1:SetText('Set TP')
DButton1.DoClick = function() end

DButton2 = vgui.Create('DButton')
DButton2:SetParent(DPanel2)
DButton2:SetSize(60, 25)
DButton2:SetPos(130, 190)
DButton2:SetText('Teleport')
DButton2.DoClick = function() end

end

usermessage.Hook(“TPMenu”, TPMenu)

[/lua]

Questions I have here, again.

How would I go about checking which item is highlighted then use that to set the teleport point?
Im guessing something along the lines of ply:SetNWVector(1, ply:GetPos()) or something like that but have no idea how to get the current highlighted item and use the button to go to that teleport point

and would the same thing be done for checkboxes?

[lua]print( DComboBox3:GetSelectedItems()[1]:GetValue() )[/lua]

Prints the currently selected item for example.

Checkboxes work differently:

[lua]CheckBox:GetChecked()[/lua]

returns true or false

I see, thanks for the help man!

My current code atm:

cl_spawnpoint.lua
[lua]
include(“autorun/server/sv_spawnpoint.lua”)

function TPMenu()

local DButton2
local DButton1
local DComboBox2
local DComboBox3
local DPanel2
local DFrame2

DFrame2 = vgui.Create('DFrame')
DFrame2:SetSize(205, 305)
DFrame2:SetPos(10, 10)
DFrame2:SetTitle('Teleport Menu')
DFrame2:SetSizable(true)
DFrame2:SetDeleteOnClose(false)
DFrame2:MakePopup()

DPanel2 = vgui.Create('DPanel')
DPanel2:SetParent(DFrame2)
DPanel2:SetSize(195, 270)
DPanel2:SetPos(5, 30)

DComboBox3 = vgui.Create('DComboBox')
DComboBox3:SetParent(DPanel2)
DComboBox3:SetSize(60, 175)
DComboBox3:SetPos(130, 10)
DComboBox3:EnableHorizontal(false)
DComboBox3:EnableVerticalScrollbar(true)
DComboBox3.OnMousePressed = function() end
DComboBox3:SetMultiple(false)
DComboBox3:AddItem("Goto TP 1")
DComboBox3:AddItem("Goto TP 2")
DComboBox3:AddItem("Goto TP 3")

DComboBox2 = vgui.Create('DComboBox')
DComboBox2:SetParent(DPanel2)
DComboBox2:SetSize(60, 175)
DComboBox2:SetPos(5, 10)
DComboBox2:EnableHorizontal(false)
DComboBox2:EnableVerticalScrollbar(true)
DComboBox2.OnMousePressed = function() end
DComboBox2:SetMultiple(false)
DComboBox2:AddItem("Teleport 1")
DComboBox2:AddItem("Teleport 2")
DComboBox2:AddItem("Teleport 3")

DButton1 = vgui.Create('DButton')
DButton1:SetParent(DPanel2)
DButton1:SetSize(60, 25)
DButton1:SetPos(5, 190)
DButton1:SetText('Set TP')
DButton1.DoClick = function(ply) 
	if DComboBox2:GetSelectedItems()[1]:GetValue() == "Teleport 1" then
		tele1(ply)
	end	
end

DButton2 = vgui.Create('DButton')
DButton2:SetParent(DPanel2)
DButton2:SetSize(60, 25)
DButton2:SetPos(130, 190)
DButton2:SetText('Teleport')
DButton2.DoClick = function(ply)
	if DComboBox3:GetSelectedItems()[1]:GetValue() == "Goto TP 1" then
		tele1goto(ply)
	end
end

end

//print(DComboBox2:GetSelectedItems()[1]:GetValue())
usermessage.Hook(“TPMenu”, TPMenu)
[/lua]

sv_spawnpoint.lua
[lua]
AddCSLuaFile(“autorun/client/cl_spawnpoint.lua”)

function showTPMenu(ply)
SendUserMessage(“TPMenu”, ply)
end

function tele1(ply)
ply:SetNWVector(1, ply:GetPos())
ply:SetNWAngle(1, ply:EyeAngles())
end

function tele1goto(ply)
ply:SetPos(ply:GetNWVector(1))
ply:SetEyeAngles(ply:GetNWAngle(1))
end

concommand.Add(“tpmenu_show”, showTPMenu)
[/lua]

and it returns errors on the server’s side.


lua\autorun\server\sv_spawnpoint.lua:8: attempt to call method 'SetNWVector' (a nil value)
)lua\autorun\server\sv_spawnpoint.lua:13: attempt to call method 'GetNWVector' (a nil value)

Any help on this matter?

First off, you are calling a function “tele1” from the client, yet you have it declared serverside. To access it, use a console command.

Also,
[lua]
Button.DoClick = function () – if you want to get the player entity use LocalPlayer()
end
[/lua]