[QUOTE=MPan1;48872063]What are you trying to do exactly?[/QUOTE]
make a nade that scares people in the radius of it
it only gets one player though, i dont know whether its ordered by player index id or closest to the entity, but its only affecting one player
[QUOTE=roastchicken;48872037]Your variable 'frame' is a local variable. It is declared in the BetFrame function. Local variables can only be accessed within the block that they were declared. In this case, frame was declared in BetFrame so it can only be accessed within BetFrame.[/QUOTE]
The new code:
[CODE]function ChatCommand( ply, text, public )
if ( string.sub(text, 1, 4) == "!bet" ) then
BetFrame:SetVisible( true )
end
end
function BetFrameFunction()
BetFrame = vgui.Create( "DFrame" )
BetFrame:SetPos( 100, 100 )
BetFrame:SetSize( 300, 200 )
BetFrame:SetTitle( "Bet Panel" )
BetFrame:SetDraggable( true )
end
hook.Add( "PlayerSay", "ChatCommand", ChatCommand )[/CODE]
The result:
[CODE]
[ERROR] addons/bet system/lua/autorun/bet_system.lua:3: attempt to index global 'BetFrame' (a nil value)
1. v - addons/bet system/lua/autorun/bet_system.lua:3
2. unknown - lua/includes/modules/hook.lua:84
[/CODE]
Same error, only this time with BetFrame
How do you get rid of something you draw on the screen (like draw.RoundedBox or draw.SimpleText). I want to use it for a really simple box of text to appear and then go away. I've gotten Derma working for what I need but drawing custom stuff would look much nicer
-snippedydoodah-
[QUOTE=MPan1;48871440]I asked this before, but I'd really like an answer- where can I find some functions that'd work with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/Derma_Anim]Global.Derma_Anim[/url] like the inQuad function in the example on the page of it?[/QUOTE]
maybe follow that hyperlink that I put there?
*sigh* Okay, apparently scripted sequences don't trigger EntityEmitSound. Now, this is a huge setback in my gamemode. Is there any way to basically use this code
[code]function MoveToPosition( npc, ent )
if ( !IsValid( npc ) or !IsValid( ent ) ) then return end
npc:SetSaveValue( "m_vecLastPosition", ent:GetPos() )
npc:SetSchedule( SCHED_FORCED_GO_RUN )
end
function GM:EntityEmitSound( tbl )
if tbl.Entity:IsPlayer() then
for k, v in pairs( ents.GetAll() ) do
if v:IsNPC() then
MoveToPosition( v, tbl.Entity )
print( "NPC heard a sound!" )
end
end
end
end[/code]
with a different hook? of course it would need some tweeking for the other hook, but I'm wondering what I can try.
[QUOTE=Becomeimp;48873078]How do you get rid of something you draw on the screen (like draw.RoundedBox or draw.SimpleText). I want to use it for a really simple box of text to appear and then go away. I've gotten Derma working for what I need but drawing custom stuff would look much nicer[/QUOTE]
By not drawing it in the first place. If you draw something, it will be removed. That's why you put drawing stuff in hooks for drawing: so that they redraw after being removed. Just add an if statement in your drawing hook.
Currently working on a VGUI/Derma Menu.
[IMG]https://einfach-gmod.de/images/gtawards.png[/IMG]
How would I be able to paint the columns of that DListView, paint the selected tab (currently blue) and change the text color(currently grey)?
-snip I'm dumb-
[QUOTE=roastchicken;48871988]For the position stuff I have no idea, I can try to test it with different vectors but honestly angles and vectors still confuse the shit out of me.
The one problem I can help you with though, is your function. First of all, you're passing a fifth argument "train" to timer.Create. I'm not sure why this isn't giving an error, but according to the wiki timer.Create only takes four arguments, the last one being the function to be called.
The fifth argument doesn't seem to do anything, but you also have an argument for the function that is called. timer.Create doesn't pass any arguments to the function it calls, it just calls it. Since the argument train is declared in the function, whereas the actual train entity is declared outside of the function, then the train argument will be used when you refer to train. Since the argument is nil, the Remove() will do nothing. If you remove the argument from the function in timer.Create then the train should be removed.[/QUOTE]
So it should do
[Lua]function() train:Remove() end, train ) end[/lua]
??
[QUOTE=Astr0niiX;48872022]So I am working on the begineer Lua challange of creating a betting system. I don't really like command based stuff, that's why I would like to have a panel for it.
My code:
The error [B](blue)[/B]:
<error>[/QUOTE]
By blue I'm assuming you mean the error text color, which means it's a serverside error. Derma only exists clientside.
Move the script to 'lua/autorun/client' if your code is going to be all clientside, otherwise do this:
[CODE]if CLIENT then
-- put clientside code
end[/CODE]
[QUOTE=P4sca1;48874378]Currently working on a VGUI/Derma Menu.
[IMG]https://einfach-gmod.de/images/gtawards.png[/IMG]
How would I be able to paint the columns of that DListView, paint the selected tab (currently blue) and change the text color(currently grey)?[/QUOTE]
[code]
for _,line in pairs(DListView.Lines) do
line:SetTextColor(Color(255,255,255)) --untested
function line:Paint(w,h)
--paint code
end
end
[/code]
EDIT: In the paint code, do:
[code]
if DListView:GetSelectedLine() == line then
--paint here, don't paint outside of this
end
[/code]
What's a good way to check if an NPC is dead? !IsValid( NPC ), NPC:GetActivity() == ACT_DIERAGDOLL, NPC:Health() == 0, and NPC:GetSaveTable().health == 0 don't work.
[code]function HandleSquads()
if GAMEMODE.CombineSquad then
for key, comb in pairs( GAMEMODE.CombineSquad ) do
if comb:GetActivity() == ACT_DIERAGDOLL then
print("okay")
GAMEMODE.CombineSquad[comb:EntIndex()] = nil
end
end
end
end
function GM:Think()
HandleSquads()
end[/code]
"okay" never prints and entities are never removed from the table...
[QUOTE=Nekomi;48875703]So it should do
[Lua]function() train:Remove() end, train ) end[/lua]
??[/QUOTE]
That looks right, except you can remove the ", train " at the end because it does nothing.
[QUOTE=UnknownFusion;48875650]I am still having the problem, where my HUD's health bar goes up instead of down when I take damage :/[/QUOTE]
You need to subtract DrawHealth * 110 from HUD.PosY (At least I think):
[CODE]
if Health != 0 then
draw.RoundedBox( 6, HUD.PosX + 375, HUD.PosY - 5 - ( 110 * DrawHealth ), 40, ( 110 ) * DrawHealth, HUD.HealthColor)
end
[/CODE]
It's because the origin of a RoundedBox is the top-left corner, so when you subtract the height, you need to subtract Y (or perhaps you need to add it, I don't remember since I can't test your code, just try both)
[QUOTE=LUModder;48875866][code]
for _,line in pairs(DListView.Lines) do
line:SetTextColor(Color(255,255,255)) --untested
function line:Paint(w,h)
--paint code
end
end
[/code]
EDIT: In the paint code, do:
[code]
if DListView:GetSelectedLine() == line then
--paint here, don't paint outside of this
end
[/code][/QUOTE]
This sadly does not work.
Does anyone know a good way to stop your code from looking insanely large and hurting your eyes? I wrote a 584-line script but looking at it makes me want to stop working on it.
[QUOTE=MPan1;48877285]Does anyone know a good way to stop your code from looking insanely large and hurting your eyes? I wrote a 584-line script but looking at it makes me want to stop working on it.[/QUOTE]
Adjust your editor's zoom level. It's usually CTRL + and -
does anybody know of a real good method of networking variables not on an entity? i'm trying to make an entity with different modules loaded from separate lua files and the modules need their own 'NetworkVar' function. i'd add something in the module loader that moves module variables over to entity vars, but i've learned from past experiences that putting lots of networked vars on an entity isn't a very good idea.
using the net.* library would involve a real complicated way of networking data to players that don't have it yet (like joining the server) which is something i [i]really[/i] don't want to have to do. any advice would be nice.
[QUOTE=mitterdoo;48877566]does anybody know of a real good method of networking variables not on an entity? i'm trying to make an entity with different modules loaded from separate lua files and the modules need their own 'NetworkVar' function. i'd add something in the module loader that moves module variables over to entity vars, but i've learned from past experiences that putting lots of networked vars on an entity isn't a very good idea.[/QUOTE]
Would [url=https://github.com/Chessnut/NutScript/blob/1.1/gamemode/core/libs/sv_networking.lua]Chessnut's NetVar library do what you had in mind?[/url]
[QUOTE=Z0mb1n3;48877578]Would [url=https://github.com/Chessnut/NutScript/blob/1.1/gamemode/core/libs/sv_networking.lua]Chessnut's NetVar library do what you had in mind?[/url][/QUOTE]
sort of. the modules are tables instead of entities, but i can probably make my own code learning from this and make it work. thanks
[code]function SWEP:OnDrop()
if CLIENT then
if (self.Owner == LocalPlayer()) then
timer.Simple(1, function()
LocalPlayer():GetViewModel():SetMaterial("")
end)
end
end
return true
end[/code]
i want the viewmodel to change back to normal when the swep is dropped, but i have a feeling it's not working because once it's called self.Owner doesn't exist and so it's not changing the viewmodel
is there anyway to change it so it changes the viewmodel before it drops? or get the player who dropped the weapon? thanks
I make a popup box with text entry, how do I make the field already highlighted so all I have to do is type in?
[QUOTE=Blakestr;48881184]I make a popup box with text entry, how do I make the field already highlighted so all I have to do is type in?[/QUOTE]
[URL="http://wiki.garrysmod.com/page/Panel/RequestFocus"]Panel.RequestFocus[/URL]
still having some problems with networking modules to players. how would i have a client determine if a variable is not up to date? for example, the server lags and the client doesn't get a net message that says a variable changed.
[QUOTE=zerf;48873809]maybe follow that hyperlink that I put there?[/QUOTE]
Sorry for the late reply, didn't notice your post. Going to that page just shows the easing in CSS, SCSS and JavaScript (but it doesn't show it in a way that Lua could understand)... where can I find some code that ACTUALLY WORKS in Lua?
I tried looking at all kinds of lua easing scripts, but all of them have a D variable for duration (which the example on the wiki didn't), and even typing in the duration (as in 1 second) doesn't work whatsoever for me.
[QUOTE=Shenesis;48878090]If you are changing the viewmodel's material, you could use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/render/MaterialOverride]render.MaterialOverride[/url] with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/WEAPON/PreDrawViewModel]WEAPON/PreDrawViewModel[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/WEAPON/PostDrawViewModel]WEAPON/PostDrawViewModel[/url]. Just set the material to whatever IMaterial in PreDrawViewModel and then reset it in PostDrawViewModel. That way you don't have to bother with the SetMaterial stuff.
[editline]11th October 2015[/editline]
An example of mine:
[lua]
local mat = Material("models/shiny")
function SWEP:PreDrawViewModel()
render.MaterialOverride(mat)
end
function SWEP:PostDrawViewModel()
render.MaterialOverride(nil)
end
[/lua][/QUOTE]
hold on, isn't postdrawviewmodel called after it's drawn? why would that make a difference if the material is applied pre-draw? last time i messed with postdrawviewmodel it was being called probably as often as Think.
[QUOTE=343N;48884141]hold on, isn't postdrawviewmodel called after it's drawn? why would that make a difference if the material is applied pre-draw? last time i messed with postdrawviewmodel it was being called probably as often as Think.[/QUOTE]
That's the point. In PreDrawViewModel, the material is set. The viewmodel is then drawn, but that material is applied to it. PostDrawViewModel is then called, which stops the material override from applying to other things.
applying to other things?
i am confused as all hell
[editline]12th October 2015[/editline]
[code]function SWEP:PreDrawViewModel()
render.MaterialOverride("effects/prisonmap_disp")
end
function SWEP:PostDrawViewModel()
render.MaterialOverride(nil)
end[/code]
does nothing
[editline]dicks and ass[/editline]
this works, nvm
[code]function SWEP:PreDrawViewModel()
render.MaterialOverride(Material("effects/prisonmap_disp"))
end
function SWEP:PostDrawViewModel()
render.MaterialOverride(nil)
end
[/code]
Sorry, you need to Log In to post a reply to this thread.