I have been trying to make a SWRP buy menu but for some reason the console command isn't found and I am not getting any lua errors
[code]
function BuyMenu()
local ply = LocalPlayer()
local BackGround = vgui.Create( "Dframe" )
Background:SetSize( 200, 90 )
BackGround:SetPos ( (ScrW()/2)-BackGround:Getwide() , (ScrH()/2)-BackGround:GetTall() )
BackGround:SetTitle ( "Buy Menu" )
BackGround:SetVisible ( true )
BackGround:SetDraggable ( true )
BackGround:ShowCloseButton ( true )
BackGround:MakePopup()
local AButton = vgui.Create ( "DButton" , BackGround)
AButton:SetSize(160,40)
AButton:SetText( "Buy DC15a" )
AButton:SetPos( 20, 30 )
AButton.DoClick = function ()
ply:ConCommand("ply:Give("tfa_swch_dc15a")")
end
end
concommand.Add( "open_buymenu", BuyMenu )
[/code]
Firstly, it's not Dframe, it's DFrame (with a capital F).
Secondly, you didn't seem to define tfa_swch_dc15a at any point, and you're not concatenating it properly (if that's what you're trying to do).
Also, is this code being run serverside or clientside?
Also the string in ply:ConCommand is not even a concommand its lua.
[QUOTE=MPan1;51073387]
Secondly, you didn't seem to define tfa_swch_dc15a at any point, and you're not concatenating it properly (if that's what you're trying to do).?[/QUOTE]
I believe what he's trying to do is this:
[lua]ply:ConCommand('ply:Give("tfa_swch_dc15a")')[/lua]
Which won't work at all, because ply:Give is a function, not a console command - And it won't work anyways because it's client-sided (Assuming it is, he used LocalPlayer()...)
Also use local functions
Damm you ninjas and your ninja skills :v:
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/Give]Player:Give[/url] is server side command
use [url]https://wiki.garrysmod.com/page/Net_Library_Usage[/url]
[QUOTE=Gigabait;51078433][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/Give]Player:Give[/url] is server side command
use [url]https://wiki.garrysmod.com/page/Net_Library_Usage[/url][/QUOTE]
Oh, i just realized this was a Vgui
Why are you assigning LocalPlayer() to a value but not ScrW() or ScrH()? At least be consistent, man.
Sorry, you need to Log In to post a reply to this thread.