• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
[QUOTE=Bull29;52076759]for inherent player properties such as rank that need to be accurate and displayed on scoreboards and such on clients, it's much better to use nw/nw2 vars rather than manually networking it every time. [URL="https://github.com/garrynewman/garrysmod/blob/784cd57576d85712fa13a7cea3a9523b4df966b0/garrysmod/lua/includes/extensions/player_auth.lua"]see here for example[/URL][/QUOTE] Since the rank only needs to be changed when the player spawns or when the player gets given admin isn't it more efficient not to use NWVars since the value won't really change after it's networked?
[QUOTE=bilbasio;52076782]Since the rank only needs to be changed when the player spawns or when the player gets given admin isn't it more efficient not to use NWVars since the value won't really change after it's networked?[/QUOTE] Sounds like you're networking the player's rank before _G.LocalPlayer is valid.
[QUOTE=Derek_SM;52077105]Sounds like you're networking the player's rank before _G.LocalPlayer is valid.[/QUOTE] After testing it out it seems that the error is in PlayerInitialSpawn [code]function GM:PlayerInitialSpawn(ply) ply.Inventory = ply:CreateInventory() ply:SetTeam(1) ply:SetNWInt('jointime', CurTime()) ply:LoadProfile() <----Setting the rank inside this function print(ply.Rank) <---- Nil ply:SendInventory() --ply:SetRank(self.Rank) end concommand.Add("testdb2", function(ply) print(ply.Rank) <-----6(my rank) end)[/code] How is this possible? [editline]8th April 2017[/editline] Also, how could I wait until Localplayer is valid? Just create a simple timer on initialspawn?
[QUOTE=bilbasio;52077139]After testing it out it seems that the error is in PlayerInitialSpawn [code]function GM:PlayerInitialSpawn(ply) ply.Inventory = ply:CreateInventory() ply:SetTeam(1) ply:SetNWInt('jointime', CurTime()) ply:LoadProfile() <----Setting the rank inside this function print(ply.Rank) <---- Nil ply:SendInventory() --ply:SetRank(self.Rank) end concommand.Add("testdb2", function(ply) print(ply.Rank) <-----6(my rank) end)[/code] How is this possible? [editline]8th April 2017[/editline] Also, how could I wait until Localplayer is valid? Just create a simple timer on initialspawn?[/QUOTE] a safe bet for localplayer validity clientside is once hudpaint starts running. do it in a temp hudpaint hook
[QUOTE=Bull29;52077193]a safe bet for localplayer validity clientside is once hudpaint starts running. do it in a temp hudpaint hook[/QUOTE] Ok, thank you. Got any ideas for the bug in PlayerInitialSpawn?
LocalPlayer is valid in the clientside InitPostEntity
[QUOTE=bilbasio;52077219]Ok, thank you. Got any ideas for the bug in PlayerInitialSpawn?[/QUOTE] With Ply.Rank being nil? What does LoadProfile() do?
[QUOTE=Banana Lord.;52077597]With Ply.Rank being nil? What does LoadProfile() do?[/QUOTE] [code]function Player:LoadProfile() local goodid = self:GetGoodID() local q2 = "SELECT * FROM players WHERE steamid = '"..goodid.."'" function SetData(str) if str[1] == nil then self:CreateProfile() else self:SetNWInt('money', str[1].money) self:SetNWInt('playtime', str[1].playtime) self:SetNWString('name', str[1].name) self:SetRank(str[1].rank) -- Value of 6 local savestring = str[1].inventory local savetable = string.Explode(";", savestring) local db = { } for i=1,table.Count(savetable) do db[i] = string.Explode("=", savetable[i]) end --for i=1,table.Count(db) do --self:GiveItem( db[i][1], db[i][2], db[i][3] ) --end end end GetDataQuery(q2, SetData) end[/code] [editline]9th April 2017[/editline] Maybe the fact that I use a callback for loading the data means it doesn't have time to set the rank before I print it in initialspawn?
is it possible to make a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/CompileString]CompileString[/url] func accept named parameters?
[QUOTE=Bull29;52078093]is it possible to make a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/CompileString]CompileString[/url] func accept named parameters?[/QUOTE] Yeah, [code] local str = [[ local a, b = ... print(a + b) ]] local func = CompileString(str, 'randomidorsomeshit') func(1, 2) [/code] Output: [quote] 3 [/quote] Edit: Guessing this is what you mean, if not please explain
[QUOTE=bigdogmat;52078123]Yeah, [code] local str = [[ local a, b = ... print(a + b) ]] local func = CompileString(str, 'randomidorsomeshit') func(1, 2) [/code] Output: Edit: Guessing this is what you mean, if not please explain[/QUOTE] you're amazing; that's exactly what i meant, thank you so much! i never knew varargs could directly output vars like that; i always thought they had to be wrapped in a table first
Is there a way to attach a valve biped model to another one without using the bonemerge effect? I need that so I can resize the bones independently and mix body parts from both models.
[QUOTE=MaxShadow;52084659]Is there a way to attach a valve biped model to another one without using the bonemerge effect? I need that so I can resize the bones independently and mix body parts from both models.[/QUOTE] You can set each bone position in a BuildBoneMatrix callback.
Any way to make vgui clickable when holding C (for hud buttons) whilst also having the context menu open?
[QUOTE=code_gs;52084959]You can set each bone position in a BuildBoneMatrix callback.[/QUOTE] Thanks!
-snip- read badly
-snip-
:snip: read that wrong
Given DFrame2 is a child of DFrame1, how do I keep DFrame2 always rendered and focused on top of DFrame1? Because the only solution I've found to work is having DFrame2 constantly spam MakePopup() so that it always remains on top however that leads to certain Derma controls not working and is an unsatisfactory fix. If DFrame2 is smaller than its parent and you click on its parent, DFrame2 goes behind DFrame1 and is unreachable nevermind I found the solution while writing this out, I just hadn't searched for the keyword 'front' on the wiki [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/MoveToFront]Panel:MoveToFront[/url] Scratch that, that function still breaks DComboBoxes... Any other ideas? [HR][/HR] Placed in a Think function: [code] if not self:HasFocus() then self:MoveToFront() end [/code]
How would I go about preventing a [URL="http://wiki.garrysmod.com/page/Category:DMenu"]DMenu [/URL]from removing/closing itself after I press an option?
[QUOTE=Fillipuster;52089141]How would I go about preventing a [URL="http://wiki.garrysmod.com/page/Category:DMenu"]DMenu [/URL]from removing/closing itself after I press an option?[/QUOTE] Maybe menu:SetDeleteSelf( false )? [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/vgui/dmenu.lua#L20[/url] [editline]11th April 2017[/editline] I think the menu gets closed by its DMenuOption calling [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/CloseDermaMenus]CloseDermaMenus[/url]
I am trying to create a derma button with a model on it. I looked at [url=https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/vgui/dmodelpanel.lua]DModelPanel[/url] to give me an idea of how to do this but it doesn't seem to work on my side. Here's my code : [code]local PANEL = {} function PANEL:Init() self.BColor = Color(64, 64, 64, 255) --self.ID = 0 self.Entity = nil self.x, self.y = self:GetPos() end function PANEL:SetModel(model) self.Entity = ClientsideModel(model, RENDERGROUP_OPAQUE) print("Created entity"..self.Entity:GetModel()) if not IsValid(self.Entity) then return end --self.Entity:SetNoDraw( false ) --self.Entity:SetIK( false ) end function PANEL:PerformLayout() if self.ID ~= 0 then self:SetModel( ITEM_DB[self.ID].Model) end end function PANEL:Paint() if self.ID ~= 0 then --cam.Start3D() --self.Entity:DrawModel() --cam.End3D() surface.SetDrawColor(self.BColor) surface.DrawRect(0, 0, 64, 64) else surface.SetDrawColor(self.BColor) surface.DrawRect(0, 0, 64, 64) end end [/code] [code] for i=1,8 do local itembutton = vgui.Create("ItemButton", frame) itembutton:SetPos((70*i), 25) itembutton:SetSize(64, 64) itembutton.ID = GAMEMODE.PlayerInventory[i].ID itembutton:SetModel(ITEM_DB[itembutton.ID].Model) print("Created button with ID"..itembutton.ID) end[/code] When I open my the frame, it prints out the model name so that's working but the model is not showing on the button. I tried using cam.Start3D but I have absolutely no idea how to use it. Do I have to use cam.Start3D or is there an easier way to draw a model on a panel?
[QUOTE=bilbasio;52092010]I am trying to create a derma button with a model on it. I looked at [url=https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/vgui/dmodelpanel.lua]DModelPanel[/url] to give me an idea of how to do this but it doesn't seem to work on my side.[/QUOTE] Use DModelPanel directly.
Hello, I want to know how I can add weapons in the f4 menu, so players can buy them everywhere
Anyone know what the humming-like static sound is called?
[QUOTE=Arkander;52093003]Hello, I want to know how I can add weapons in the f4 menu, so players can buy them everywhere[/QUOTE] [url]http://wiki.darkrp.com/index.php/DarkRP:CustomShipmentFields[/url]
[QUOTE=JasonMan34;52093180]Anyone know what the humming-like static sound is called?[/QUOTE] You may have some luck [URL="https://wiki.garrysmod.com/page/Player/SetDSP"]here[/URL] if you're looking for a sound filter, otherwise I suggest the [URL="https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8f77.html"]Half-Life 2 Sound List[/URL] if not. I would help you to find the sound but I don't exactly know what you are looking for, you're just going to have to experiment with those.
[QUOTE=bilbasio;52092010]DModelButton[/QUOTE] As NeatNit said; use a dmodelpanel directly; [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/SetMouseInputEnabled]Panel:SetMouseInputEnabled[/url] to true, then override .DoClick
[QUOTE=Bull29;52093397]As NeatNit said; use a dmodelpanel directly; [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/SetMouseInputEnabled]Panel:SetMouseInputEnabled[/url] to true, then override .DoClick[/QUOTE] I tried using dmodelpanel but I had some issues related to it. Is there really no other way than using dmodelpanel? EDIT:Just fixed my issues with dmodelpanel. Does anyone have an idea on how to remove the zone before the dnumslider where you click to be precise? [url]http://imgur.com/a/aWQFH[/url]
sorry I made a thread for that [url]https://facepunch.com/showthread.php?t=1560262&p=52095078#post52095078[/url] but then somebody told me post it here What does this Error downloading file! [37] mean? Why does it even exist?
Sorry, you need to Log In to post a reply to this thread.