• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
Pink menu ? REALLY ?
[lua]ply:DrawWorldModel(false) ply:DrawViewModel(false) for _, w in pairs(ply:GetWeapons()) do w:SetNoDraw(true) end[/lua] How come the weapon is still visible? Really annoying.
[QUOTE=Giraffen93;46478865][lua]ply:DrawWorldModel(false) ply:DrawViewModel(false) for _, w in pairs(ply:GetWeapons()) do w:SetNoDraw(true) end[/lua] How come the weapon is still visible? Really annoying.[/QUOTE] I usually do several things when making something invisible. Rendermode Normal, Shadow destroy / remove / ..., plus: [code]_p:SetColor(Color( 0, 0, 0, 0 ) ); _p:SetNoDraw( true ); _p:DrawWorldModel( false );[/code]
Is it possible to use panel:MakePopup() but not have it get drawn in front of game menus (such as the escape menu)? I've tried panel:SetPopupStayAtBack( true ) but I either used it wrong or it didn't work. Any advice?
[QUOTE=Sereni;46479023]Is it possible to use panel:MakePopup() but not have it get drawn in front of game menus (such as the escape menu)? I've tried panel:SetPopupStayAtBack( true ) but I either used it wrong or it didn't work. Any advice?[/QUOTE] You could detect to see if the game menu / console is open, if so hide it temporarily until the menu closes. There are many ways to test for this. HUDPaint stops when console is open, but there are also functions for it: [url]http://wiki.garrysmod.com/page/gui/IsConsoleVisible[/url] and [url]http://wiki.garrysmod.com/page/gui/IsGameUIVisible[/url] You could also test for that and try sending it to the back when it opens. MakePopup tends to give it full focus / priority though which is why I suggested hiding depending on what the menu should do.
Not really a problem but a question, how do i check if a kill is a headshot?
[lua]function GM:PlayerDeath( victim, inflictor, attacker ) if ( victim:LastHitGroup() == HITGROUP_HEAD ) then print("Boom, Headshot.") end end[/lua] pseudooocode
[QUOTE=Tomelyr;46479761][lua]function GM:PlayerDeath( victim, inflictor, attacker ) if ( victim:LastHitGroup() == HITGROUP_HEAD ) then print("Boom, Headshot.") end end[/lua] pseudooocode[/QUOTE] Thanks
How do you remove a avatarimage once you make it appear?
[QUOTE=ColgateMaster;46480545]How do you remove a avatarimage once you make it appear?[/QUOTE] You can store the panel as a global variable (something that isn't likely to override other global variables) and then run methods on that variable.
[QUOTE=Internet1001;46480569]You can store the panel as a global variable (something that isn't likely to override other global variables) and then run methods on that variable.[/QUOTE]See the thing is that I've made a check if something is nil then it will disappear but it still won't work, the avatar image will still appear.
I would also stress not to use panel:ParentToHUD( ) because GetHUDPanel( ) [ similar to the game/world panel, but for vgui elements tied to the hud ] doesn't return children ( unless it has been fixed recently, I'll be looking into it soon ), so if you lose the reference then you can't remove it: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_utilities/concommand_clearvgui.lua[/url]
[QUOTE=ColgateMaster;46480595]See the thing is that I've made a check if something is nil then it will disappear but it still won't work, the avatar image will still appear.[/QUOTE] [code] avImage = nil; [/code] Or, where you're checking if it exists: [code] if( !avImage || !avImage.enabled ) then [/code] And where you're making it disappear: [code]avImage.enabled = false [/code]
[QUOTE=Giraffen93;46478865][lua]ply:DrawWorldModel(false) ply:DrawViewModel(false) for _, w in pairs(ply:GetWeapons()) do w:SetNoDraw(true) end[/lua] How come the weapon is still visible? Really annoying.[/QUOTE] Try NoDraw'ing the actual weapon itself, I frankly have never heard of ply:DrawWorld/ViewModel for First Person just get the player's viewmodel entity and set NoDraw on it.
[QUOTE=BFG9000;46481931]Try NoDraw'ing the actual weapon itself, I frankly have never heard of ply:DrawWorld/ViewModel for First Person just get the player's viewmodel entity and set NoDraw on it.[/QUOTE] never helped setting the rendermode and color on it finally fixed it, but the physgun sprite is still there
I'm not sure why the physgun does that. I haven't looked too deeply into it, but even when you return true in PrePlayerDraw to make the player invisible ( another thing I do ), it still draws. Although, setting the weapon color to all black may do it since the beam / particle uses the weapon color... Edit: [code]concommand.Add( "dev_wpcol", function( _p, _cmd, _args ) _p:SetWeaponColor( Vector( ( _args[ 1 ] || 0 ) / 255, ( _args[ 2 ] || 0 ) / 255, ( _args[ 3 ] || 0 ) / 255 ) ); end );[/code] Set weapon color to 0 0 0, all black and the sprite disappears. I figured as much because halos don't like black either.
Is there any way I can get what prop a player is holding, has picked up or dropped? I'm talking about props on the map, NOT stuff spawned in sandbox
[QUOTE=NiandraLades;46483472]Is there any way I can get what prop a player is holding, has picked up or dropped? I'm talking about props on the map, NOT stuff spawned in sandbox[/QUOTE] As in picked up by physgun / gravgun / +use pickup? Yeah, the target is there in the PhysgunPickup, PhysgunDrop hooks. You'd need to store that data somewhere to recall it, then clear it on PhysgunDrop / GravgunDropped because I don't see a function for Player:GetHeldObject which would be useful. Only option is to manage the data, or loop through all entities and see if the entity is held unless I'm missing something. function GM:PhysgunPickup( _p, _t ) function GM:PhysgunDrop( _p, _t ) [url]http://wiki.garrysmod.com/page/GM/PhysgunPickup[/url] [url]http://wiki.garrysmod.com/page/GM/PhysgunDrop[/url] [url]http://wiki.garrysmod.com/page/GM/GravGunOnPickedUp[/url] [url]http://wiki.garrysmod.com/page/GM/GravGunOnDropped[/url] [url]http://wiki.garrysmod.com/page/GM/GravGunPickupAllowed[/url] [url]http://wiki.garrysmod.com/page/GM/GravGunPunt[/url] And you can force the player to drop what they're holding by using: [url]http://wiki.garrysmod.com/page/Player/DropObject[/url] And if you want to target the entity specifically: [url]http://wiki.garrysmod.com/page/Global/DropEntityIfHeld[/url] To force pickup: [url]http://wiki.garrysmod.com/page/Player/PickupObject[/url] And to see if entity is being held: [url]http://wiki.garrysmod.com/page/Entity/IsPlayerHolding[/url]
Why doesn't this script work? Also do I need to use newowner rather than ply? [code] function SWEP:Equip(ply) ply:SetWalkSpeed( 20 ) end [/code]
[QUOTE=Acecool;46483536]As in picked up by physgun / gravgun / +use pickup? Yeah, the target is there in the PhysgunPickup, PhysgunDrop hooks. You'd need to store that data somewhere to recall it, then clear it on PhysgunDrop / GravgunDropped because I don't see a function for Player:GetHeldObject which would be useful. Only option is to manage the data, or loop through all entities and see if the entity is held unless I'm missing something. function GM:PhysgunPickup( _p, _t ) function GM:PhysgunDrop( _p, _t ) [url]http://wiki.garrysmod.com/page/GM/PhysgunPickup[/url] [url]http://wiki.garrysmod.com/page/GM/PhysgunDrop[/url] [url]http://wiki.garrysmod.com/page/GM/GravGunOnPickedUp[/url] [url]http://wiki.garrysmod.com/page/GM/GravGunOnDropped[/url] [url]http://wiki.garrysmod.com/page/GM/GravGunPickupAllowed[/url] [url]http://wiki.garrysmod.com/page/GM/GravGunPunt[/url] And you can force the player to drop what they're holding by using: [url]http://wiki.garrysmod.com/page/Player/DropObject[/url] And if you want to target the entity specifically: [url]http://wiki.garrysmod.com/page/Global/DropEntityIfHeld[/url] To force pickup: [url]http://wiki.garrysmod.com/page/Player/PickupObject[/url] And to see if entity is being held: [url]http://wiki.garrysmod.com/page/Entity/IsPlayerHolding[/url][/QUOTE] By pressing their E key, sorry I should've been more clear here. I basically need to get the specific model of the prop their holding. So, could I do something like if player is holding prop_dynamic/prop_phyics and model is this then do that?
Look through the Entity:GetSaveTable(), there are a lot of useful variables in there. I've shut down everything for today so I can't check myself.
[QUOTE=BlaBlaAccount;46483836]Why doesn't this script work? Also do I need to use newowner rather than ply? [code] function SWEP:Equip(ply) ply:SetWalkSpeed( 20 ) end [/code][/QUOTE] How you're calling that is fine according to the wiki. You set the "NewOwner" argument variable name to ply, so you can use ply. Now, It may not be working depending on a few things. WalkSpeed is typically when you hold ALT. It can also be based on the game-mode ( does it sprint / run all the time like TTT, or do you walk by default with shift for sprint? )... What game-mode are you running? An addon could be blocking it, or you may need to use different functions such as SetRunSpeed. [editline]14th November 2014[/editline] [QUOTE=NiandraLades;46483897]By pressing their E key, sorry I should've been more clear here. I basically need to get the specific model of the prop their holding. So, could I do something like if player is holding prop_dynamic/prop_phyics and model is this then do that?[/QUOTE] The functions do say that they work with gravgun / e pickup, but there doesn't seem to be a function that I saw to get the object that the player picked up. You can use the Entity:IsPlayerHolding( ) if you loop through entities near player ( picked up entity would be pretty close/ a small sphere could work ) As Giraffen says, definitely check the save table with an object lifted ( I don't have any ents I can lift or I'd look ), here is some of the output I got: Clientside [code][m_BoneAng] = Vector( 0, 0, 0 ) [m_BoneJiggle] = 0 [m_BonePos] = Vector( 0, 0, 0 ) [m_BoneScale] = Vector( 1, 1, 1 ) [m_ModelName] = [m_angAbsRotation] = Vector( 0, 0, 0 ) [m_fFlags] = 0 [m_rgflCoordinateFrame] = 1 [m_vecAbsOrigin] = Vector( 0, 0, 0 ) [m_ModelName] = [m_angAbsRotation] = Vector( 0, -3.0794882774353, 0 ) [m_fFlags] = 0 [m_rgflCoordinateFrame] = 0.99855595827103 [m_vecAbsOrigin] = Vector( 5520.6142578125, -5255.0805664063, 92.03125 ) [/code] Serverside ( looks promising ) [code][LightingOrigin] = [LightingOriginHack] = [ResponseContext] = [SetBodyGroup] = 0 [TeamNum] = 0 [avelocity] = Vector( 0, 0, 0 ) [basevelocity] = Vector( 0, 0, 0 ) [body] = 0 [classname] = weapon_css_hk_usp [cycle] = 0 [damagefilter] = [effects] = 129 [fademaxdist] = 0 [fademindist] = 0 [fadescale] = 0 [friction] = 1 [globalname] = [gravity] = 0 [hammerid] = 0 [health] = 0 [hitboxset] = 0 [ltime] = 0 [m_CollisionGroup] = 2 [m_GMOD_DataTable] = <UNHANDLED> [m_GMOD_EHANDLE] = Entity [0][worldspawn] [m_GMOD_QAngle] = Vector( 0, 0, 0 ) [m_GMOD_Vector] = Vector( 0, 0, 0 ) [m_GMOD_bool] = false [m_GMOD_float] = 0 [m_GMOD_int] = 0 [m_IdealActivity] = 0 [m_MoveCollide] = 0 [m_MoveType] = 0 [m_OverrideViewTarget] = Vector( 0, 0, 0 ) [m_angAbsRotation] = Vector( 0, 156.86047363281, 0 ) [m_angRotation] = Vector( 0, 0, 0 ) [m_bAltFireHudHintDisplayed] = false [m_bAltFiresUnderwater] = false [m_bAlternateSorting] = false [m_bAnimatedEveryTick] = false [m_bClientSideAnimation] = false [m_bClientSideFrameReset] = false [m_bFireOnEmpty] = false [m_bFiresUnderwater] = false [m_bInReload] = false [m_bLowered] = false [m_bReloadHudHintDisplayed] = false [m_bReloadsSingly] = false [m_bRemoveable] = false [m_bSequenceFinished] = false [m_bSequenceLoops] = false [m_bSimulatedEveryTick] = true [m_debugOverlays] = 0 [m_fBoneCacheFlags] = 0 [m_fFireDuration] = 0 [m_fFlags] = 0 [m_fMaxRange1] = 1500 [m_fMaxRange2] = 200 [m_fMinRange1] = 24 [m_fMinRange2] = 24 [m_flAnimTime] = -2378.576171875 [m_flDesiredShadowCastDistance] = 0 [m_flDissolveStartTime] = -28833.91015625 [m_flElasticity] = 1 [m_flEncodedController] = 0 [m_flGroundChangeTime] = -28833.91015625 [m_flGroundSpeed] = 0 [m_flHolsterTime] = -28833.91015625 [m_flHudHintMinDisplayTime] = -28833.91015625 [m_flHudHintPollTime] = -28833.91015625 [m_flLastEventCheck] = -28833.91015625 [m_flModelScale] = 1 [m_flMoveDoneTime] = 0 [m_flNavIgnoreUntilTime] = -28833.91015625 [m_flNextPrimaryAttack] = -2378.576171875 [m_flNextSecondaryAttack] = -2378.576171875 [m_flPoseParameter] = 0 [m_flPrevAnimTime] = -2378.576171875 [m_flRaiseTime] = -28833.91015625 [m_flSimulationTime] = -2378.576171875 [m_flTimeWeaponIdle] = -28833.91015625 [m_flUnlockTime] = -28833.91015625 [m_flVPhysicsUpdateLocalTime] = 0 [m_hDamageFilter] = Entity [0][worldspawn] [m_hEffectEntity] = Entity [0][worldspawn] [m_hGroundEntity] = Entity [0][worldspawn] [m_hLightingOrigin] = Entity [0][worldspawn] [m_hLightingOriginRelative] = Entity [0][worldspawn] [m_hLocker] = Entity [0][worldspawn] [m_hMoveChild] = Entity [0][worldspawn] [m_hMoveParent] = Player [1][Acecool][STEAM_0:1:4173055] [m_hMovePeer] = Weapon [371][weapon_css_colt_m4a1] [m_hOwner] = Player [1][Acecool][STEAM_0:1:4173055] [m_hOwnerEntity] = Player [1][Acecool][STEAM_0:1:4173055] [m_iAltFireHudHintCount] = 0 [m_iClip1] = 0 [m_iClip2] = 0 [m_iEFlags] = 46159872 [m_iIKCounter] = 0 [m_iName] = [m_iParentAttachment] = 0 [m_iPrimaryAmmoCount] = 0 [m_iPrimaryAmmoType] = 3 [m_iReloadHudHintCount] = 0 [m_iSecondaryAmmoCount] = 0 [m_iSecondaryAmmoType] = 3 [m_iState] = 1 [m_iSubType] = 0 [m_iTeamNum] = 1 [m_iszName] = [m_iszOverrideSubMaterials] = [m_lifeState] = 0 [m_nIdealSequence] = 0 [m_nLastThinkTick] = -78490 [m_nMuzzleFlashParity] = 0 [m_nNewSequenceParity] = 0 [m_nResetEventsParity] = 0 [m_nSimulationTick] = -78490 [m_nTransmitStateOwnedCounter] = 0 [m_nViewModelIndex] = 0 [m_nWaterType] = 0 [m_pBlocker] = Entity [0][worldspawn] [m_pBoneManipulator] = Entity [0][worldspawn] [m_pFlexManipulator] = Entity [0][worldspawn] [m_pParent] = Player [1][Acecool][STEAM_0:1:4173055] [m_rgflCoordinateFrame] = -0.91955059766769 [m_strOverrideMaterial] = 0 [m_strRealClassName] = 119 [m_takedamage] = 1 [m_vecAbsOrigin] = Vector( 5494.5493164063, -5468.9892578125, 56.03125 ) [m_vecAbsVelocity] = Vector( 0, 0, 0 ) [m_vecOrigin] = Vector( 0, 0, 0 ) [max_health] = 0 [model] = models/weapons/v_pist_usp.mdl [modelindex] = 568 [nextthink] = -951520 [parentname] = [playbackrate] = 0 [rendercolor] = 255 255 255 255 [renderfx] = 0 [rendermode] = 0 [sequence] = 0 [shadowcastdist] = 0 [skin] = 0 [spawnflags] = 1073741824 [speed] = 0 [target] = [texframeindex] = 0 [touchStamp] = 0 [velocity] = Vector( 0, 0, 0 ) [view_ofs] = Vector( 0, 0, 0 ) [waterlevel] = 0[/code] That was the pistol in my inventory. I decided to do one more output with me holding it with physgun [code]PICKED UP WITH PHYSGUN [LightingOrigin] = [LightingOriginHack] = [ResponseContext] = [SetBodyGroup] = 0 [TeamNum] = 0 [avelocity] = Vector( 0, 0, 0 ) [basevelocity] = Vector( 0, 0, 0 ) [body] = 0 [classname] = weapon_css_hk_usp [cycle] = 0 [damagefilter] = [effects] = 128 [fademaxdist] = 0 [fademindist] = 0 [fadescale] = 0 [friction] = 1 [globalname] = [gravity] = 1 [hammerid] = 0 [health] = 0 [hitboxset] = 0 [ltime] = 0 [m_CollisionGroup] = 2 [m_GMOD_DataTable] = <UNHANDLED> [m_GMOD_EHANDLE] = Entity [0][worldspawn] [m_GMOD_QAngle] = Vector( 0, 0, 0 ) [m_GMOD_Vector] = Vector( 0, 0, 0 ) [m_GMOD_bool] = false [m_GMOD_float] = 0 [m_GMOD_int] = 0 [m_IdealActivity] = 174 [m_MoveCollide] = 0 [m_MoveType] = 6 [m_OverrideViewTarget] = Vector( 0, 0, 0 ) [m_angAbsRotatio
[QUOTE=Acecool;46484246]How you're calling that is fine according to the wiki. You set the "NewOwner" argument variable name to ply, so you can use ply. Now, It may not be working depending on a few things. WalkSpeed is typically when you hold ALT. It can also be based on the game-mode ( does it sprint / run all the time like TTT, or do you walk by default with shift for sprint? )... What game-mode are you running? An addon could be blocking it, or you may need to use different functions such as SetRunSpeed. [/QUOTE] Yes I'm running TTT. So does the gamemode consider regular walking running then?
When the player picks something up, on their save table m_hMoveChild and m_hUseEntity are set to a player_pickup entity. The entity is stored in a private, inaccessible m_grabController object, so that's shot. So, the logical approach at this point would be a dirty hack: Catch the last entity the player tried to pickup in AllowPlayerPickup The next time a player_pickup is created in OnEntityCreated, on the next frame check if it is parented to the player. If it is, check if the last object the player tried to pickup is being held by a player with IsPlayerHolding - and make sure that this player_pickup is parented to the same player. So you'd have something like this: [code] local function AllowPlayerPickup( pl, ent ) pl.LastTriedToPickup = ent end local function OnEntityCreated( ent ) timer.Simple( 0, function( ) if IsValid( ent ) and ent:GetClass( ) == "player_pickup" and IsValid( ent:GetParent( ).LastTriedToPickup ) and ent:GetParent( ).LastTriedToPickup:IsPlayerHolding( ) then ent:GetParent( ).HeldEntity = ent:GetParent( ).LastTriedToPickup end end ) end local function EntityRemoved( ent ) if ent:GetClass( ) == "player_pickup" then ent:GetParent( ).HeldEntity = NULL end end --hook.Add for each [/code] Adjust and tinker as needed. Of course, if we had Player:GetHeldEntity life would be much simpler.
How do I fill a rounded rectangle without it looking like this? [img]http://i.imgur.com/2rpLTx9.png[/img]
[QUOTE=Ott;46485429]How do I fill a rounded rectangle without it looking like this? [img]http://i.imgur.com/2rpLTx9.png[/img][/QUOTE] Rounded rect only does that when the width / height is less than the size of the corners depth. Take a look: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/draw_roundedbox_shrink_down_instead_of_left.lua.html[/url] The 3 bars on the right are all the same in terms of corners. Make sure you don't use negative sizes. Set a start x and y, then use width and height from that start pos. Default 0, 0 is top-left of the object.
It's a progress bar.
How to make a build/kill mode? I mean, like 2 minutes to build something, and then 2 minutes to kill and survive on it
In what cases can I use panel:SizeToContents()? In my current situation I have a panel which I am using a frame (it's not a DFrame if that matters) and I'm placing x amount of DButtons into it. I want it to resize to accommodate as many buttons as I put in it. At the moment I have code like: [lua] local PANEL = {} function PANEL:Init() self:SetSize(480,320) -- Add my buttons self:SizeToContents() end vgui.Register("DOptionsMenu", PANEL) [/lua] Everything works as it should except that the panel doesn't resize to its contents which leads me to believe that I'm using it incorrectly. How do I fix this?
Was wondering if what I was doing was the right way to override a weapon's function [LUA] local SWEP = {} function SWEP:LolFunction() end weapons.Register(SWEP, "fas2_base") [/LUA]
Sorry, you need to Log In to post a reply to this thread.