• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
Does anybody know how to stop a sound created with sound.PlayURL? This is the code I'm using: [lua] sound.PlayURL( "someurl", "3d", function( station ) if ( IsValid( station ) ) then station:SetPos( pos ) station:Play() end end) [/lua] [editline]14th January 2015[/editline] nvm, used a local variable and copied the "station" to it and used the local variable to play/stop the sound
[QUOTE=Revenge282;46928788]Does anyone know if [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Panel/Dock"]Panel:Dock[/URL] is able to do something like PANEL:Dock(BOTTOM+RIGHT), or is it strictly only able to dock something to one constraint? Looking at the enums for it, it doesn't seem so. Are there any alternatives other than manually sizing and placing if this is the case?[/QUOTE] Dock it inside a docked subpanel.
[QUOTE=bobbleheadbob;46934424]Dock it inside a docked subpanel.[/QUOTE] Genius.
-snip-
[QUOTE=Willox;46932851]It's out of scope because you defined it locally after another function which attempts to use it.[/QUOTE] <snip> Oh, you mean I should define it BEFORE I call it... cus it runs in order
[QUOTE=WalkingZombie;46935851]-pre-snip-[/QUOTE] Try these 2: [url]http://www.lua.org/cgi-bin/demo[/url] This fails [code]local function test1( ) print( "yay" ) end local function test2( ) test3( ) end local function test3( ) test1( ) end test3( ); test2( ); test1( ); [/code] While this works: [code]function test1( ) print( "yay" ) end function test2( ) test3( ) end function test3( ) test1( ) end test3( ); test2( ); test1( ); [/code] The only decent way I can think to explain the scope is: With a locally defined function the scope extends downward while a global extends outward. Examples: If we move test3 in example 1 to before test2 then all works fine. If we remove local in example 1 from test3 then it all works too. So, any local functions used in a local function must exist prior to the creation of the local function meaning it must be higher up in the file.
Thank you... now 1000 other errors with my code for which I ask no help with. (yet) [editline]14th January 2015[/editline] [QUOTE=Acecool;46935920]So, any [B]local [/B]functions used in a [B]local [/B]function must exist prior to the creation of the [B]local [/B]function meaning it must be higher up in the file.[/QUOTE] That's a lot of [B]local[/B]s.
[QUOTE=Acecool;46935920]Try these 2: [URL]http://www.lua.org/cgi-bin/demo[/URL] This fails [code]local function test1( ) print( "yay" ) end local function test2( ) test3( ) end local function test3( ) test1( ) end test3( ); test2( ); test1( ); [/code] While this works: [code]function test1( ) print( "yay" ) end function test2( ) test3( ) end function test3( ) test1( ) end test3( ); test2( ); test1( ); [/code] The only decent way I can think to explain the scope is: With a locally defined function the scope extends downward while a global extends outward. Examples: If we move test3 in example 1 to before test2 then all works fine. If we remove local in example 1 from test3 then it all works too. So, any local functions used in a local function must exist prior to the creation of the local function meaning it must be higher up in the file.[/QUOTE] Obviously you can't call non existent function test3() from function test2(). ( first code )
You can also declare your local variables before setting them to a function. [lua] local internal_do_shit function do_shit() internal_do_shit() end function internal_do_shit() ... end [/lua] Lua's lexical scoping is super simple to understand. [url]http://www.lua.org/pil/4.2.html[/url]
Using DListView I know you can do DListView.paint to target the main body, but how can you target the headers/each line with the paint function?
[QUOTE=Adzter;46938508]Using DListView I know you can do DListView.paint to target the main body, but how can you target the headers/each line with the paint function?[/QUOTE] you could do: [code] local tmpCol = yourListView:AddColumn("column name") tmpCol.Paint = function(self) end [/code] Or if you need to reference it or other things after creation in a different way [code] yourListView.Columns yourListView:GetCanvas() yourListView:GetLines() [/code] I'm not sure why there isn't a GetColumns(). I ended up getting annoyed by these things in a recent project so I just snagged all the derma controls I needed to do something with and renamed them so I could get some stuff done. It's a pretty smash and grab style way to do it but it work
[QUOTE=Willox;46938153]You can also declare your local variables before setting them to a function. [lua] local internal_do_shit function do_shit() internal_do_shit() end function internal_do_shit() ... end [/lua] Lua's lexical scoping is super simple to understand. [url]http://www.lua.org/pil/4.2.html[/url][/QUOTE] That example is how a lot of people write C++, by declaring everything on a single line, typically to keep main at the top ( under the declarations ) and the functions used below main although they aren't needed if things are rearranged.
[QUOTE=Adzter;46938508]Using DListView I know you can do DListView.paint to target the main body, but how can you target the headers/each line with the paint function?[/QUOTE] Read the source code of DListView, located in lua/vgui/dlistview.lua, to see how the individual parts of the DListView are kept track of. You can access them manually without an accessor function if you know how they are saved.
"warning agenda made incorrectly there is no manager failed to load" I get this error when I die when I am playing a class that doesn't even have an agenda assigned to it? Any ideas? [CODE]/*--------------------------------------------------------------------------- /*--------------------------------------------------------------------------- DarkRP Agenda's --------------------------------------------------------------------------- Agenda's can be set by the agenda manager and read by both the agenda manager and the other teams connected to it. HOW TO MAKE AN AGENDA: AddAgenda(Title of the agenda, Manager (who edits it), {Listeners (the ones who just see and follow the agenda)}) ---------------------------------------------------------------------------*/ AddAgenda("Government Agenda", TEAM_MAYOR, {TEAM_CHIEF, TEAM_POLICE, TEAM_FBI, TEAM_SS}) AddAgenda("Tactical Response Team Agenda", TEAM_TACRESTEAMCO, {TEAM_TACRESTEAM}) AddAgenda("Russian Mafia Agenda", TEAM_RUSSIANMOBBOS, {TEAM_RUSSIANMOBSTER}) AddAgenda("Wog Agenda", TEAM_WOGLEADER, {TEAM_WOG})[/CODE] Nothing seems wrong to me?
Make sure these jobs exist, [lua] TEAM_MAYOR TEAM_TACRESTEAMCO -- wot? TEAM_RUSSIANMOBBOS TEAM_WOGLEADER[/lua]
[QUOTE=Author.;46939126]Make sure these jobs exist, [lua] TEAM_MAYOR TEAM_TACRESTEAMCO -- wot? TEAM_RUSSIANMOBBOS TEAM_WOGLEADER[/lua][/QUOTE] Found the issue "TEAM_RUSSIANMOBBOS" Typo on the word "BOSS" (BOS)
[QUOTE=Author.;46939126]Make sure these jobs exist, [lua] TEAM_MAYOR TEAM_TACRESTEAMCO -- wot? TEAM_RUSSIANMOBBOS TEAM_WOGLEADER[/lua][/QUOTE] T-Acre Steam Company?
I'm also having another issue, if anyone can help.. [CODE][ERROR] lua/autorun/fastdl.lua:5: attempt to call field 'AddWorkshop' (a nil value) 1. unknown - lua/autorun/fastdl.lua:5[/CODE] [CODE]--FastDL, workshop and local files. resource.AddWorkshop("234464092") --Holden resource.AddWorkshop("104996105") --Downtown resource.AddWorkshop("225739642") --Fallout 3 resource.AddWorkshop("107411755") --FBI resource.AddWorkshop("239531104") --Gopniks resource.AddWorkshop("112806637") --GMod Legs resource.AddWorkshop("200318235") --ArcBankContent resource.AddWorkshop("133401340") --Fallout 3 Models[/CODE]
[QUOTE=Yumaglo;46939557]I'm also having another issue, if anyone can help.. [CODE][ERROR] lua/autorun/fastdl.lua:5: attempt to call field 'AddWorkshop' (a nil value) 1. unknown - lua/autorun/fastdl.lua:5[/CODE] [CODE]--FastDL, workshop and local files. resource.AddWorkshop("234464092") --Holden resource.AddWorkshop("104996105") --Downtown resource.AddWorkshop("225739642") --Fallout 3 resource.AddWorkshop("107411755") --FBI resource.AddWorkshop("239531104") --Gopniks resource.AddWorkshop("112806637") --GMod Legs resource.AddWorkshop("200318235") --ArcBankContent resource.AddWorkshop("133401340") --Fallout 3 Models[/CODE][/QUOTE] add [code]if not SERVER then return end[/code] to the top of that file.
[QUOTE=Dgc2002;46939601]add [code]if not SERVER then return end[/code] to the top of that file.[/QUOTE] [CODE]--FastDL, workshop and local files. if not SERVER then return end resource.AddWorkshop("234464092") --Holden resource.AddWorkshop("104996105") --Downtown resource.AddWorkshop("225739642") --Fallout 3 resource.AddWorkshop("107411755") --FBI resource.AddWorkshop("239531104") --Gopniks resource.AddWorkshop("112806637") --GMod Legs resource.AddWorkshop("200318235") --ArcBankContent resource.AddWorkshop("133401340") --Fallout 3 Models[/CODE] Like that?
[QUOTE=Yumaglo;46939606][CODE]--FastDL, workshop and local files. if not SERVER then return end resource.AddWorkshop("234464092") --Holden resource.AddWorkshop("104996105") --Downtown resource.AddWorkshop("225739642") --Fallout 3 resource.AddWorkshop("107411755") --FBI resource.AddWorkshop("239531104") --Gopniks resource.AddWorkshop("112806637") --GMod Legs resource.AddWorkshop("200318235") --ArcBankContent resource.AddWorkshop("133401340") --Fallout 3 Models[/CODE] Like that?[/QUOTE] Yes. This is working off of the guess that the error you posted was received clientside and popped up in the server console as well. If that's not the case a bit more detail would help.
[QUOTE=Dgc2002;46939737]Yes. This is working off of the guess that the error you posted was received clientside and popped up in the server console as well. If that's not the case a bit more detail would help.[/QUOTE] That fixed the LUA error, I placed the file so it downloads client and server, thanks for the fix :)
[QUOTE=Yumaglo;46939756]That fixed the LUA error, I placed the file so it downloads client and server, thanks for the fix :)[/QUOTE] The file doesn't need to be downloaded on the client in this case. The server can do all that work and the clients will get the correct files. That's why you can't run those functions on the client.
Is there any hacky way to do draw stuff (specifically 3D lines/effects) from the server, rather than directly on the client? I'm trying to draw a laser on a nextbot that shows where they're looking, but apparently nextbots don't initialize on the client, so I'm a bit SOL on that. I'd rather not have to make a separate script that has to be included along with the NPC's to handle doing it, but I guess if it comes down to it I'll have to, I just wanted to check here first to see if anyone had any ideas.
ply:SendLua() for simple shit. EDIT: No that would be a fucking nightmare every frame. Use networking. EDIT: OR!!! If the file isn't initialized on client, SendLua the networking stuff and then network the shit over.
[QUOTE=Ericson666;46940658]Is there any hacky way to do draw stuff (specifically 3D lines/effects) from the server, rather than directly on the client? I'm trying to draw a laser on a nextbot that shows where they're looking, but apparently nextbots don't initialize on the client, so I'm a bit SOL on that. I'd rather not have to make a separate script that has to be included along with the NPC's to handle doing it, but I guess if it comes down to it I'll have to, I just wanted to check here first to see if anyone had any ideas.[/QUOTE] Take a look at this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/render_lasers_rendering_cubes.lua.html[/url] Now, if you use ENT:Draw ( client ) you should be able to get their looking position and because Draw is a render hook you would basically copy and paste a draw beam line into it. If you want to network the thing, I'd recommend sending data every 0.25 seconds to 1 second with data on the entire npc ( then draw a ghost image on the client using ClientsideModel posed like the model was at the time the snapshot was taken with a beam )... Don't use SendLua ( it is limited to 255 chars, and it is hacky.. it is better to use hooks already available to us and ENT:Draw should work perfectly fine unless you need the server snapshot ( whereby you'd network at small intervals and you could even draw 2 CSMs to compare client vs server positioning... if they're equal then you know you only need 1, the client )
[QUOTE=Acecool;46940809]Take a look at this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/render_lasers_rendering_cubes.lua.html[/url] Now, if you use ENT:Draw ( client ) you should be able to get their looking position and because Draw is a render hook you would basically copy and paste a draw beam line into it. If you want to network the thing, I'd recommend sending data every 0.25 seconds to 1 second with data on the entire npc ( then draw a ghost image on the client using ClientsideModel posed like the model was at the time the snapshot was taken with a beam )... Don't use SendLua ( it is limited to 255 chars, and it is hacky.. it is better to use hooks already available to us and ENT:Draw should work perfectly fine unless you need the server snapshot ( whereby you'd network at small intervals and you could even draw 2 CSMs to compare client vs server positioning... if they're equal then you know you only need 1, the client )[/QUOTE] He just explained how Nextbots don't have clientside hooks and you are suggesting him to use ENT:Draw...
[QUOTE=Robotboy655;46940842]He just explained how Nextbots don't have clientside hooks and you are suggesting him to use ENT:Draw...[/QUOTE] I totally missed that, whoops.. but it is possible to create your own hooks... I, for example, made a managed list of vehicles which I use to create PreVehicleDraw ( called before vehicle is drawn ), PostVehicleDraw ( after a vehicle is drawn ), BeginVehicleDraw ( executed once when the vehicle enters PVS and starts being drawn, perfect for sounds to be started ), EndVehicleDraw ( executed once when vehicle is about to leave PVS, perfect to stop sounds etc ) The same thing can be done for next-bots... On Entity Created if npc /next-bot then add to managed list. On Entity Removed, remove from managed list. Set up same structure and then there would be hooks to use.
[QUOTE=Acecool;46940874]I totally missed that, whoops.. but it is possible to create your own hooks... I, for example, made a managed list of vehicles which I use to create PreVehicleDraw ( called before vehicle is drawn ), PostVehicleDraw ( after a vehicle is drawn ), BeginVehicleDraw ( executed once when the vehicle enters PVS and starts being drawn, perfect for sounds to be started ), EndVehicleDraw ( executed once when vehicle is about to leave PVS, perfect to stop sounds etc ) The same thing can be done for next-bots... On Entity Created if npc /next-bot then add to managed list. On Entity Removed, remove from managed list. Set up same structure and then there would be hooks to use.[/QUOTE] He's saying also that he doesn't want to include another file, packaging it just as a serverside nextbot file.
How do I delete the players dead body from a "PlayerDeath" hook?
Sorry, you need to Log In to post a reply to this thread.