• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=RonanZer0;46222512][url=https://www.youtube.com/watch?v=zFnwXZhqMGk]This should help tremendously with polys[/url][/QUOTE] Ooh! Nifty! Thanks for sharing!
[QUOTE=zeaga;46223386]Ooh! Nifty! Thanks for sharing![/QUOTE] It seems to be broken for me, I got errors about vgui being nil so I threw it on the Clientside and then either the command didnt exist or the panel just didnt open
SOLVED. I get this error: [code] [ERROR] lua/autorun/client/phtm_client.lua:18: attempt to index local 'mPly' (a nil value) 1. v - lua/autorun/client/phtm_client.lua:18 2. Call - lua/includes/modules/hook.lua:84 3. DoClick - lua/autorun/client/phtm_client.lua:363 4. unknown - lua/vgui/dlabel.lua:206 [/code] On this code: [code]if ( CLIENT ) then local sWidth = ScrW() //Detects Player screen Width. local sHight = ScrH() //Detects Player screen Hight. local mPly = LocalPlayer() //Menu function phm_1(mPly) //Taunt Menu Page 1 if mPly:Alive() then //LINE 18 print("Received hook.call( taunt_p1 ) from player, opening menu page 1")//Debug Print local p1_base = vgui.Create( "DFrame")//Menu Frame [/code] Lime 363 error: [code] local p2_base_bPrv = vgui.Create( "DButton", p2_base ) //Previous Page Button p2_base_bPrv:SetSize(55, 25) p2_base_bPrv:SetPos(12, 535) p2_base_bPrv:SetText("Previous") p2_base_bPrv.DoClick = function() p2_base:Close() hook.Call("taunt_p1") end[/code] The hooks I created: [code] hook.Add("taunt_p1","Calling Taunt Menu Page 1",phm_1) hook.Add("taunt_p2","Calling Taunt Menu Page 2",phm_2) hook.Add("taunt_p3","Calling Taunt Menu Page 3",phm_3) [/code] It's a client side script and it worked... Ideas?
[QUOTE=Exho;46223403]It seems to be broken for me, I got errors about vgui being nil so I threw it on the Clientside and then either the command didnt exist or the panel just didnt open[/QUOTE] I haven't tried it out yet, but then again it is a year old. When in doubt, blame the July update. :v:
[QUOTE=zeaga;46224200]I haven't tried it out yet, but then again it is a year old. When in doubt, blame the July update. :v:[/QUOTE] I actually successfully used it yesterday. I just dropped in the (updated) lua file into my autorun/client (you can get the UPDATED version in [url=http://facepunch.com/showthread.php?t=1318416]the FP thread[/url], didn't know YouTube wasn't updated) and it worked fine.
Edit: Nevermind, fixed it
How would I make a keycombo with non IN_ keys?
not a direct code question, but i saw 2-3 times here an github of an Cam2D3D Lib. Does anybody still got that link? i can't find it anymore.
[QUOTE=Tomelyr;46227136]not a direct code question, but i saw 2-3 times here an github of an Cam2D3D Lib. Does anybody still got that link? i can't find it anymore.[/QUOTE] Cam3D2D is part of GMod...
Ahh finally found it. Sorry i forgott to attach vgui. [url]https://github.com/HandsomeMatt/3d2d-vgui[/url]
[QUOTE=LUModder;46227047]How would I make a keycombo with non IN_ keys?[/QUOTE] With this maybe: [url]http://wiki.garrysmod.com/page/Enums/KEY[/url]
How would i go about requesting data from the server? I currently have: Server: [LUA] net.Receive('NetworkString', function(len, ply) net.Start('NetworkString') net.WriteInt(1, 32) net.Send(ply) end) [/LUA] Client: [LUA] function GetInt() net.Start('NetworkString') net.SendToServer() local value = -1 print('before receive') net.Receive('NetworkString', function(len) value = net.ReadInt(32); print(value) end) print('after receive') return value end [/LUA] and its returning: [LUA] before receive after receive -1 1 [/LUA] how would i get it to return: [LUA] before receive 1 after receive 1 [/LUA]
The code inside net.Receive only runs if it receives that net message, which is why you are getting what you are seeing. [lua] net.Start('NetworkString') net.SendToServer() local value = -1 print('before receive') print(value) net.Receive('NetworkString', function(len) value = net.ReadInt(32); print('after receive') print(value) end) [/lua]
net messages are asyncronous and will take tens milliseconds to travel to server and back to client, while the rest of your code will run in few microseconds. You have to do it like this: [code] net.Start('NetworkString') net.SendToServer() local value = -1 print('before receive') net.Receive('NetworkString', function(len) value = net.ReadInt(32); print('after receive') print(value) -- will print 1 end) print(value) -- will print -1 [/code] That would print [code] before receive -1 after receive 1 [/code] So if you want to use "value" after it was updated by server, then just put your code (or call a function, or run a hook...) under the net.Receive
[QUOTE=Blasteh;46230002]The code inside net.Receive only runs if it receives that net message, which is why you are getting what you are seeing.[/QUOTE] [QUOTE=DEFCON1;46230018]net messages are asyncronous and will take tens milliseconds to travel to server and back to client, while the rest of your code will run in few microseconds.[/QUOTE] My bad i should have mentioned it was in a function and that value would be returned, I updated my post.
net.Receive must not be inside of any function :)
[QUOTE=DEFCON1;46230082]net.Receive must not be inside of any function :)[/QUOTE] I just decided to use a callback and it seems to work fine.
[QUOTE=DEFCON1;46230082]net.Receive must not be inside of any function :)[/QUOTE] There are situations where it can make sense to do this such as creating a receiver after sending a net message that requests data which is to be used with something only in the current scope. While a decent rule of thumb, it isn't strictly true..
Hey, I want to check every player for a specific weapon, I know I can do: GetActiveWeapon() but that gets their weapon in hand, is there any way i can check for a weapon on them? lets say if i check for a AK it will print everyone who has a AK on them?
[QUOTE=Invule;46232170]Hey, I want to check every player for a specific weapon, I know I can do: GetActiveWeapon() but that gets their weapon in hand, is there any way i can check for a weapon on them? lets say if i check for a AK it will print everyone who has a AK on them?[/QUOTE] Use [url=http://wiki.garrysmod.com/page/Player/HasWeapon]ply:HasWeapon[/url] or [url=http://wiki.garrysmod.com/page/Player/GetWeapon]ply:GetWeapon[/url]
Does anyone know how to make render.DrawSprite render over other props? [editline]14th October 2014[/editline] like this is what's happening [t]http://i.imgur.com/y4nLiSN.jpg[/t]
Why you're using drawsprite for smoke? Just use particle.
I want to check and see if a weapon has a function. Does the weapon have :Whateverthefuck() ? Yes = True, No = False
[QUOTE=WalkingZombie;46235374]I want to check and see if a weapon has a function. Does the weapon have :Whateverthefuck() ? Yes = True, No = False[/QUOTE] Just check for the index. [editline]14th October 2014[/editline] if YourWeaponHere.Whateverthefuck then return end
I said functions, not variables. Thanks for an answer though
[QUOTE=WalkingZombie;46235784]I said functions, not variables. Thanks for an answer though[/QUOTE] [lua]if isfunction(yourweapon.WhateverTheFuck) then yourweapon:WhateverTheFuck() end[/lua] isfunction is a garry function (not standard Lua) that looks like this: [lua]function isfunction(f) return type(f)=='function' end[/lua]
[QUOTE=WalkingZombie;46235784]I said functions, not variables. Thanks for an answer though[/QUOTE] Functions are variables.
[QUOTE=rebel1324;46235161]Why you're using drawsprite for smoke? Just use particle.[/QUOTE] I don't know how I would do that
[lua]timer.Create("VehicleCheck", 5, 0, function() tank1 = ents.Create("sent_sakarias_car_abrams") print( tank1:IsValid() ) if not tank1:IsValid() then tank1:SetPos(Vector(1984.000000, 192.000000, -3.750000)) tank1:Spawn() end end)[/lua] For some reason tank1:IsValid() returns true. How could I do this correctly?
[QUOTE=RonanZer0;46236289][lua]timer.Create("VehicleCheck", 5, 0, function() tank1 = ents.Create("sent_sakarias_car_abrams") print( tank1:IsValid() ) if not tank1:IsValid() then tank1:SetPos(Vector(1984.000000, 192.000000, -3.750000)) tank1:Spawn() end end)[/lua] For some reason tank1:IsValid() returns true. How could I do this correctly?[/QUOTE] I wouldn't recommend using :IsValid() unless you know 100% that the variable can't be nil. Use IsValid(var).
Sorry, you need to Log In to post a reply to this thread.