• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
Ok so basically I'm trying to send clientside messages to server Like I've been trying LocalPlayer():SetNWBool("ect",true) and that doesn't work. Is there a similar command that's like that which works clientside?
[b][url=http://gmodwiki.net/Lua/Libraries/net]Lua/Libraries/net[img]http://gmodwiki.net/favicon.ico[/img][/url][/b]
Does anyone know how to check if the player is jumping? ply:KeyPressed(KEY_SPACE) and ply:KeyPressed(IN_JUMP) doesn't seem to work
Avatar Images are not working very well for me. All I am asking it to do is create a avatar of a decent resolution and it gives me the pink and black checkerboard.. And yes, I have tried all sorts of wacky combinations of SetSize and SetPlayer but none seem to work like I wanted [code] function PANEL:Avatar(ply) self.Avatar = vgui.Create( "AvatarImage", self ) self.Avatar:SetPos( 7, 7 ) self.Avatar:SetSize(84, 84) self.Avatar:SetPlayer(ply, 64) [/code] The 64x64 image, low res and frankly quite ugly [IMG]http://i.gyazo.com/b6e3a1dcad03d3ea12020b97513b21f6.png[/IMG] Changing the SetPlayer(ply,64) to anything but 64. [IMG]http://i.gyazo.com/5626b51e805f4b59055ae00ad1b14a7c.png[/IMG]
[QUOTE=Exho;45772488]Avatar Images are not working very well for me. All I am asking it to do is create a avatar of a decent resolution and it gives me the pink and black checkerboard.. And yes, I have tried all sorts of wacky combinations of SetSize and SetPlayer but none seem to work like I wanted [code] function PANEL:Avatar(ply) self.Avatar = vgui.Create( "AvatarImage", self ) self.Avatar:SetPos( 7, 7 ) self.Avatar:SetSize(84, 84) self.Avatar:SetPlayer(ply, 64) [/code] The 64x64 image, low res and frankly quite ugly [IMG]http://i.gyazo.com/b6e3a1dcad03d3ea12020b97513b21f6.png[/IMG] Changing the SetPlayer(ply,64) to anything but 64. [IMG]http://i.gyazo.com/5626b51e805f4b59055ae00ad1b14a7c.png[/IMG][/QUOTE] Recommended to use a 2^ value, such as 32x32, 64x64, 128x128, 256x256 ect
I was going off the Gmod wikis reference numbers. Those still result in error
So basicly I just want a Derma window to open when I write a console command. I have no ide why this isn't working. server side script : [CODE]util.AddNetworkString('applyMenu') concommand.Add( "apply",function( ply ) net.Start('applyMenu') net.Send(ply) end )[/CODE] Client side script: [CODE]If CLIENT then net.Receive('applyMenu', function(ply) local Frame = vgui.Create( "DFrame" ) Frame:SetSize( ScrW() - 100, ScrH() - 150 ) Frame:SetTitle( "" ) Frame:SetVisible( true ) Frame:SetDraggable( false ) Frame:ShowCloseButton( false ) Frame:MakePopup() Frame:Center() Frame.Paint = function() draw.RoundedBox( 0, 0, 0, Frame:GetWide()-0, Frame:GetTall()-0, Color( 50, 50, 50, 255 ) ) draw.RoundedBox( 0, 2, 2, Frame:GetWide()-4, Frame:GetTall()-4, Color( 75, 75, 75, 255 ) ) end end) end[/CODE] They are both placed in the autorun folder.
[QUOTE=ROFLBURGER;45769908]Does anyone know how to check if the player is jumping? ply:KeyPressed(KEY_SPACE) and ply:KeyPressed(IN_JUMP) doesn't seem to work[/QUOTE]I made a simple function for that which you can use: [CODE] --[[--------------------------------------------------------- Determines if a player is jumping -----------------------------------------------------------]] function PLAYER:IsJumping( ) return self:GetTable().m_bJumping end [/CODE]
[QUOTE=AnonTakesOver;45772678]Recommended to use a 2^ value, such as 32x32, 64x64, 128x128, 256x256 ect[/QUOTE] Actually I did set it to 128 when I did that test. It just isnt working on any size other than 64
[QUOTE=Exho;45773694]Actually I did set it to 128 when I did that test. It just isnt working on any size other than 64[/QUOTE]I just used avatar image and it works for me.
[QUOTE=Wafflenstuff;45774817]I just used avatar image and it works for me.[/QUOTE] Send me the code you used please Not even do those numbers work for me [IMG]http://i.gyazo.com/3674a60b19e6ecce91e273ae17e44126.png[/IMG] [code] function PANEL:Avatar(ply) self.Avatar = vgui.Create( "AvatarImage", self ) self.Avatar:SetPos( 7, 7 ) self.Avatar:SetSize(128, 128) self.Avatar:SetPlayer(ply, 128) end [/code]
Hi, Jvs pointed me towards the [url=http://wiki.garrysmod.com/page/GM/PlayerTick]PlayerTick[/url] hook for using lag-compensation on things. It works well but I want to cover my bases: does anyone know of any circumstances where that hook doesn't run for a connected player? I'm using it to simulate bullets and having them hang in mid-air would be embarrassing!
Does [URL="http://wiki.garrysmod.com/page/file/Write"]file.Write[/URL] save data to the server or clients files ?
[QUOTE=sm69baller;45780292]Does [URL="http://wiki.garrysmod.com/page/file/Write"]file.Write[/URL] save data to the server or clients files ?[/QUOTE] It depends on the realm it is called in.
[QUOTE=Exho;45776436]Send me the code you used please Not even do those numbers work for me [IMG]http://i.gyazo.com/3674a60b19e6ecce91e273ae17e44126.png[/IMG] [code] function PANEL:Avatar(ply) self.Avatar = vgui.Create( "AvatarImage", self ) self.Avatar:SetPos( 7, 7 ) self.Avatar:SetSize(128, 128) self.Avatar:SetPlayer(ply, 128) end [/code][/QUOTE] Your last resource it's creating a HTML panel, get the json user data, translate it and you get the avatar
Apparently SetNWString and GetNWString stopped working. While setting works, if I attempt to get the string on client ( after setting it server-side ) it returns nothing. [lua] local sId = Format( "%d%d%d%d", math.random( 0, 9 ), math.random( 0, 9 ), math.random( 0, 9 ), math.random( 0, 9 ) ) print( sId, iId ) if tIds[ sId ] then while ( tIds[ sId ] ) do local sId = Format( "%d%d%d%d", math.random( 0, 9 ), math.random( 0, 9 ), math.random( 0, 9 ), math.random( 0, 9 ) ) end end v:SetNWString( "ID", sId ) tIds[ iId ] = v [/lua] And my code for getting it: [lua] local idP = tr.Entity:GetNWString( "ID" ) surface.SetFont( "TargetID" ) local wM, hM = surface.GetTextSize( idP ) surface.SetTextPos( iX - wM - 5, iY ) //print( iX - wM - 5, iY ) surface.SetDrawColor( Color( 200, 25, 25, 200 ) ) surface.DrawText( idP ) [/lua]
Maybe you should try more unique identifier than "ID"? [editline]24th August 2014[/editline] Also [code] if tIds[ sId ] then while ( tIds[ sId ] ) do local sId = Format( "%d%d%d%d", math.random( 0, 9 ), math.random( 0, 9 ), math.random( 0, 9 ), math.random( 0, 9 ) ) end end[/code] sId here will never override sId above the loop.
Could someone explain the anchor of DLabel? I got following code: [lua] unterzeile= vgui.Create("DLabel", fenster) unterzeile:SetPos(25, 80) unterzeile:SetSize(900, 450) unterzeile:SetVisible(true) unterzeile:SetText(langertext)[/lua] So following. i position it with 3 lines of text. When i now change the text to let us say, 7 lines, then it moves upwards. So i think the anchor of SetPos is the Middle, right? How can i change it to Top align, or does i need an extra function to recalculate the height of the text and setting the SetPos with the calculated offsets?
[QUOTE=Tomelyr;45784313]Could someone explain the anchor of DLabel? I got following code: [lua] unterzeile= vgui.Create("DLabel", fenster) unterzeile:SetPos(25, 80) unterzeile:SetSize(900, 450) unterzeile:SetVisible(true) unterzeile:SetText(langertext)[/lua] So following. i position it with 3 lines of text. When i now change the text to let us say, 7 lines, then it moves upwards. So i think the anchor of SetPos is the Middle, right? How can i change it to Top align, or does i need an extra function to recalculate the height of the text and setting the SetPos with the calculated offsets?[/QUOTE]Using unterzeile:SizeToContents() may help achieve better results in terms of having it sized/positioned properly. Give it a go at least and see how it works for you, it may not end up working how you like it but it's worth giving a try.
[QUOTE=Robotboy655;45784110]Maybe you should try more unique identifier than "ID"? [editline]24th August 2014[/editline] Also [code] if tIds[ sId ] then while ( tIds[ sId ] ) do local sId = Format( "%d%d%d%d", math.random( 0, 9 ), math.random( 0, 9 ), math.random( 0, 9 ), math.random( 0, 9 ) ) end end[/code] sId here will never override sId above the loop.[/QUOTE] Thanks, didn't even notice! Still doesn't work though, could it have something to do with me testing the script on a bot?
[QUOTE=ShadowRanger;45784724]Using unterzeile:SizeToContents() may help achieve better results in terms of having it sized/positioned properly. Give it a go at least and see how it works for you, it may not end up working how you like it but it's worth giving a try.[/QUOTE] this was the key element. Thanks a lot :) it helped so much
can somewanne explain what this does [lua] "autobrakeSpeedGain" "1.1" // 10% speed gain while coasting, put on the brakes after that "autobrakeSpeedFactor" "3.0" // Brake is this times the speed gain[/lua] it's from a vehicle but my english skills aren't great enough to understands it's meaning.
[QUOTE=frietje2008;45786761]can somewanne explain what this does [lua] "autobrakeSpeedGain" "1.1" // 10% speed gain while coasting, put on the brakes after that "autobrakeSpeedFactor" "3.0" // Brake is this times the speed gain[/lua] it's from a vehicle but my english skills aren't great enough to understands it's meaning.[/QUOTE] I don't think many people here have messed around with source vehicles, just try changing those values and see what they do.
[QUOTE=Exho;45772488]Avatar Images are not working very well for me. ... Changing the SetPlayer(ply,64) to anything but 64. [IMG]http://i.gyazo.com/5626b51e805f4b59055ae00ad1b14a7c.png[/IMG][/QUOTE] I have not tested this code, but you may be able to do some matrix scaling tricks to get the avatar to scale up to any size. [lua]local vecScale = Vector(0,0,0) function PANEL:Init() self.Avatar = vgui.Create( "Avatar", self ) end function PANEL:SetPlayer( ply ) self.Avatar:SetPlayer(ply) end function PANEL:SetSize( w, h ) Panel.SetSize(self, w, h) local scale if w > 128 then scale = w / 128 w = 128 h = 128 elseif w > 64 and w < 128 then scale = w / 64 w = 64 h = 64 else scale = 1 end vecScale.x = scale vecScale.y = scale self.Avatar:SetSize(w,h) end function PANEL:Paint( w, h ) local mat = Matrix() mat:SetScale(vecScale) cam.PushModelMatrix(mat) self._pushedMatrix = true end function PANEL:PaintOver() if self._pushedMatrix then cam.PopModelMatrix() self._pushedMatrix = nil end end[/lua] This will create a derma wrapper panel for the Avatar which will restrict itself to 64, 128, etc. The matrix will then do the scaling for any larger sizes.
[QUOTE=Robotboy655;45786841]I don't think many people here have messed around with source vehicles, just try changing those values and see what they do.[/QUOTE] [url]https://uk.answers.yahoo.com/question/index?qid=20100806052528AA6FMGD[/url] Maybe it has something to do with the maximum achievable speed when going downhill without pressing W or S?
How would I go about using the distance function as a replacement for ents.FindInBox? EDIT: I'm trying to check if players are in a certain area.
[QUOTE=Adzter;45786995]How would I go about using the distance function as a replacement for ents.FindInBox? EDIT: I'm trying to check if players are in a certain area.[/QUOTE] I believe that people were using [url=http://wiki.garrysmod.com/page/Vector/WithinAABox]Vector/WithinAABox[/url] with [url=http://wiki.garrysmod.com/page/Global/OrderVectors]OrderVectors[/url] for a more efficient method. Try this [lua]meta = FindMetaTable( "Player" ) local box = { Vector( 1, 1, 1 ), Vector( 2, 2, 2 ) } function meta:InBox( box ) OrderVectors( box[1], box[2] ) return self:GetPos():WithinAABox( box[1], box[2] ) end[/lua]
[QUOTE=Internet1001;45787179]I believe that people were using [url=http://wiki.garrysmod.com/page/Vector/WithinAABox]Vector/WithinAABox[/url] with [url=http://wiki.garrysmod.com/page/Global/OrderVectors]OrderVectors[/url] for a more efficient method. Try this [lua]meta = FindMetaTable( "Player" ) local box = { Vector( 1, 1, 1 ), Vector( 2, 2, 2 ) } function meta:InBox( box ) OrderVectors( box[1], box[2] ) return ply:GetPos():WithinAABox( box[1], box[2] ) end[/lua][/QUOTE] This is what I've got at the moment (it's hideous and I was lazy I know): [url]http://pastebin.com/KHHxbmbR[/url] So using the above function would I have to put that inside a player.GetAll loop?
[QUOTE=frietje2008;45786761]can somewanne explain what this does [lua] "autobrakeSpeedGain" "1.1" // 10% speed gain while coasting, put on the brakes after that "autobrakeSpeedFactor" "3.0" // Brake is this times the speed gain[/lua] it's from a vehicle but my english skills aren't great enough to understands it's meaning.[/QUOTE] Essentially it is how much speed you gain, or lose upon releasing the throttle button. So, SpeedGain 1.1 = 11% speed gain when you let go of W. ( It is best left at 0, otherwise it is like you quickly jabbed the accelerator ) As for SpeedFactor, it may be similar, but I haven't messed with that one, sorry.
[QUOTE=Adzter;45787261]This is what I've got at the moment (it's hideous and I was lazy I know): [url]http://pastebin.com/KHHxbmbR[/url] So using the above function would I have to put that inside a player.GetAll loop?[/QUOTE] Yeah, give something like this a shot [lua]meta = FindMetaTable( "Player" ) function meta:InBox( box ) OrderVectors( box[1], box[2] ) return self:GetPos():WithinAABox( box[1], box[2] ) end local areas = { { Vector(-1516.791748, 484.499115, -90.906036), Vector(-647.333740, 198.264969, 259.077789) }, { Vector(2304.849121, 1543.716187, -171.060242), Vector(2290.367432, 1532.299683, -274.706757) }, { Vector(2436.474854, 1469.197510, 317.418701), Vector(-2053.020752, 139.281845, 131.574936) }, } timer.Create( "KOSAreas", 0.25, 0, function() -- I suggest you don't use a Think hook for k, ply in pairs( player.GetAll() ) do local inKOSArea = false for k, box in pairs( areas ) do if ply:InBox( box ) then ply.InKOSArea = true inKOSArea = true umsg.Start( "EnterKOS", ply ) umsg.End() end end if not inKOSArea then ply.InKOSArea = false umsg.Start( "ExitKOS", ply ) umsg.End() end end end )[/lua]
Sorry, you need to Log In to post a reply to this thread.