-
Notifications
You must be signed in to change notification settings - Fork 4
Example
Linus edited this page Jul 29, 2018
·
15 revisions
A simple panel you can open and close with a chat command.
@persist Frame:dframe
if(first()) {
runOnChat(1)
#add all players to the default list
vguiDefaultPlayers(players())
Frame = dframe(1)
Frame:setSize(150,150)
Frame:center()
Frame:setVisible(0) #set invisible on create
Frame:setDeleteOnClose(0) # only hides the panel when the close button is pressed
Frame:makePopup()
Frame:create()
}
if(chatClk()) {
if(lastSaid()=="menu") {
local Visible = Frame:isVisible(lastSpoke()) #get the current visible status for the player
Frame:setVisible(!Visible) #inverse the status
Frame:modify(array(lastSpoke())) #apply changes only to the player who executed the command
}
}
A simple menu that shows to to interact with buttons.
@persist Main:dframe [Button Button2]:dbutton
if(first()) {
runOnChat(1) runOnVgui(1)
vguiDefaultPlayers(players())
Main = dframe(1)
Main:setTitle("Menu")
Main:setPos(60,300)
Main:setColor(255,120,120)
Main:makePopup()
Main:setDeleteOnClose(0)
Main:enableKeyboardInput(0)
Main:setVisible(0)
Main:create()
Button = dbutton(2,1)
Button:setPos(15,25)
Button:setText("Change Color")
Button:setIcon("icon16/arrow_refresh.png")
Button:setSize(110,40)
Button:create()
Button2 = dbutton(3,1)
Button2:setPos(15,70)
Button2:setText("Spawn Prop")
Button2:setIcon("icon16/package_add.png")
Button2:setSize(110,40)
Button2:create()
}
if(chatClk()) {
if(lastSaid() == "open") {
Main:setVisible(!Main:isVisible(lastSpoke()))
Main:modify(array(lastSpoke()))
}
}
if(vguiClk()) {
local ID = vguiClkPanelID()
switch(ID) {
case 2, #
Main:setColor(randvec(0,255))
Main:modify(array(vguiClkPlayer()))
break
case 3,
local AimPos = vguiClkPlayer():aimPos()
propSpawn("models/props_junk/cardboard_box001a.mdl",AimPos + vec(0,0,50),0)
break
}
}