• Refreshing the Pointshop Storefront?
    8 replies, posted
I need to refresh the Pointshop storefront for reasons. Right now I'm doing it by killing it on an infinite timer to force it to regenerate, and this works for the most part until you use item modifications and close the menu before you close the modifications panel. Pretty much I'm just looking for a better way of "re-initializing" the storefront when need be.
Help?
Reload autorun/pointshop.lua and this will load everything
Will try that, thanks
It works, but it's slower than simply destroying it (for obvious reasons). Additionally it doesn't solve the issue of the "lingering modifier panel" that happens if you have it open and then you close the menu. I have tried CloseDermaMenus but it remains unaffected by it. [IMG]http://cloud-4.steampowered.com/ugc/34100756931207738/6653A930DD83E74002718EC44483C845172F7355/[/IMG] I figure it has something to do with it being indexed as a local variable... any way I can point to this damn thing using the vgui library so I can kill it?
Here you go: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_utilities/concommand_clearvgui.lua[/url] Typing clearvgui in console will kill/Remove all vgui elements active, except for those that are Parented to HUD because GetHUDPanel( ) doesn't have "children" / is bugged at the moment. So as long as it is a standard non-parented or parented to an existing vgui element element then this will remove it.
instead of using a timer why not only update when it changes? You can use the hook library for this, if you use a panel as the second argument instead of a name the hook is automatically removed once the panel is invalid. So you could do something like [lua] function PANEL:Init( ) hook.Add( "PS_ItemInfoChanged", self, self.OnItemInfoChanged ) end function PANEL:OnItemInfoChanged( newInfo ) self:SetText( newInfo.newText) self.label:SetColor( newInfo.bla and color_white or color_black ) end --somewhere else net.Receive( "PS_ItemInfoUpdate", function( len ) local newInfo = net.ReadTable() hook.Run( "PS_ItemInfoChanged", newInfo ) end ) [/lua] Instead of recreating everything you could just also remove/add children of the panel in the update method and call it once on initalize to do the inital fill up. This approach works fairly well for me.
[QUOTE=Acecool;46259378]Here you go: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_utilities/concommand_clearvgui.lua[/url] Typing clearvgui in console will kill/Remove all vgui elements active, except for those that are Parented to HUD because GetHUDPanel( ) doesn't have "children" / is bugged at the moment. So as long as it is a standard non-parented or parented to an existing vgui element element then this will remove it.[/QUOTE] Thanks! [editline]17th October 2014[/editline] [QUOTE=Kamshak;46259381]instead of using a timer why not only update when it changes? You can use the hook library for this, if you use a panel as the second argument instead of a name the hook is automatically removed once the panel is invalid. So you could do something like [lua] function PANEL:Init( ) hook.Add( "PS_ItemInfoChanged", self, self.OnItemInfoChanged ) end function PANEL:OnItemInfoChanged( newInfo ) self:SetText( newInfo.newText) self.label:SetColor( newInfo.bla and color_white or color_black ) end --somewhere else net.Receive( "PS_ItemInfoUpdate", function( len ) local newInfo = net.ReadTable() hook.Run( "PS_ItemInfoChanged", newInfo ) end ) [/lua] Instead of recreating everything you could just also remove/add children of the panel in the update method and call it once on initalize to do the inital fill up. This approach works fairly well for me.[/QUOTE] Wait, you can pass objects as hook identifiers?
Yeah... The second argument to hook.Call is the table the function gets called on... I wrote this for my networking system to run hooks on client; same thing: [code]// // Allow the server to network hooks without adding a specific receiver for each one... // networking:AddReceiver( "CallHook", function( _lp, _name, _table, ... ) local _upper = string.upper( _table ) local _hooks = hook.GetTable( ); local _bHookExists = _hooks[ _name ]; local _bGMHookExists = ( ( !_table || _upper == "GM" || _upper == "GAMEMODE" ) && _G[ _upper ][ _name ] ); local _bCustomHookExists = ( _table && _G[ _table ] && _G[ _table ][ _name ] ); if ( !_bHookExists && !_bGMHookExists && !_bCustomHookExists ) then networking:SendToServer( "Error", "Hook Not Found", _name, _table ); else hook.Call( _name, ( ( _table ) && _G[ _table ] || nil ), unpack( { ... } ) ); end end );[/code] Which works great for non-specific object hooks as they're identified by string. But, you could call a specific object by passing the table / reference in; I believe it is some-what how the player-class system works with the custom functions. It is just a different set of helper-functions.
Sorry, you need to Log In to post a reply to this thread.