• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=Gammanetwork;46819855]so I am trying to display the player's team in a HUD (deathrun) the only problem I have is that it will not update when the player dies/ changes teams. My quess is you have to hook it up to a loop or something to refresh it every tick, but I don't know how to do that. I would appreciate help. [CODE] ht = ScrH() - 165 local PlayerTeam = team.GetName(LocalPlayer():Team()) if PlayerTeam == "Death" then draw.SimpleText( PlayerTeam, "comicfont01Team", hx + border+ 20+ 30, ht + border, Color( 160, 0, 0, 255 ), TEXT_ALIGN_LEFT ) elseif PlayerTeam == "Runner" then draw.SimpleText( PlayerTeam, "comicfont01Team", hx + border+ 20+ 25, ht + border, Color( 3, 3, 160, 255 ), TEXT_ALIGN_LEFT ) elseif PlayerTeam == "Spectator" then draw.SimpleText( PlayerTeam, "comicfont01Team", hx + border+ 20+ 5, ht + border, Color(10,10,10,255), TEXT_ALIGN_LEFT ) else draw.SimpleText( PlayerTeam, "comicfont01Team", hx + 10, ht + border, Color(255,255,255,255), TEXT_ALIGN_LEFT ) end [/CODE][/QUOTE] Get rid of the if statements, team.GetName returns a string. And use team.GetColor for the color. [lua] local PlayerTeam = LocalPlayer():Team() local TeamName = team.GetName(PlayerTeam) local TeamColor = team.GetColor(PlayerTeam) draw.SimpleText(TeamName, ..., ..., ..., TeamColor, ...) [/lua] If you NEED to do something else depending on the team try ternary logic. Also make sure this is in the HUDPaint hook.
-snip
Hey guys. So im planning to spawn a world prop somewhere in my map, and was wondering what type of class is a world prop titled as? For example i wanna use this following code: [CODE]local ent = ents.Create("type of prop") ent:SetPos(position) ent:Spawn()[/CODE] What would the type be? world_prop or something? Thanks!
My viewmodel dissapears after stripping currnet weapon. To get it back I have to change weaopn. How to fix that?
[QUOTE=tzahush;46821172]Hey guys. So im planning to spawn a world prop somewhere in my map, and was wondering what type of class is a world prop titled as? For example i wanna use this following code: [CODE]local ent = ents.Create("type of prop") ent:SetPos(position) ent:Spawn()[/CODE] What would the type be? world_prop or something? Thanks![/QUOTE] prop_physics or prop_physics_multiplayer
[QUOTE=tzahush;46821172]Hey guys. So im planning to spawn a world prop somewhere in my map, and was wondering what type of class is a world prop titled as? For example i wanna use this following code: [CODE]local ent = ents.Create("type of prop") ent:SetPos(position) ent:Spawn()[/CODE] What would the type be? world_prop or something? Thanks![/QUOTE] Creating it as prop_physics and not setting an owner should work. Depends on your gamemode.
How do you draw 3d models/entities(?) in derma, I don't really know how to start. Example (the player model and inventory items etc) : [vid]http://ph129.net/i/wSAC02.mp4[/vid] Courtesy of [URL="http://facepunch.com/member.php?u=219375"]Phoenixf129[/URL]
[QUOTE=TheDoggy;46821599]How do you draw 3d models/entities(?) in derma, I don't really know how to start. Example (the player model and inventory items etc) : Courtesy of [URL="http://facepunch.com/member.php?u=219375"]Phoenixf129[/URL][/QUOTE] DModelPanel is what you need to use.
You'll want to use [url=http://wiki.garrysmod.com/page/Category:DModelPanel]DModelPanel[/url]
Is it better to make a scoreboard as a custom element? Using PANEL:Init() and other functions. i've seen a few free scoreboards use the method?
[QUOTE=a-cookie;46821679]You'll want to use [url=http://wiki.garrysmod.com/page/Category:DModelPanel]DModelPanel[/url][/QUOTE] [QUOTE=LUModder;46821678]DModelPanel is what you need to use.[/QUOTE] I don't know how I didn't see that before... cheers guys.
[QUOTE=AirBlack;46821182]My viewmodel dissapears after stripping currnet weapon. To get it back I have to change weaopn. How to fix that?[/QUOTE] Well, that happens any time the weapon you're holding is deleted or removed. You'll need to tell the player to [URL="http://wiki.garrysmod.com/page/Player/SelectWeapon"]select another weapon[/URL]. There may be a way to show a viewmodel without the gun, but it would look very weird... unless you have custom animations for being unarmed. If you're trying to make the player throw the gun out of their hands, dont strip the swep until it's not supposed to be in their hands anymore, and/or their hands are also retired.
[QUOTE=WalkingZombie;46823406]Well, that happens any time the weapon you're holding is deleted or removed. You'll need to tell the player to [URL="http://wiki.garrysmod.com/page/Player/SelectWeapon"]select another weapon[/URL]. There may be a way to show a viewmodel without the gun, but it would look very weird... unless you have custom animations for being unarmed. If you're trying to make the player throw the gun out of their hands, dont strip the swep until it's not supposed to be in their hands anymore, and/or their hands are also retired.[/QUOTE] Fixed it already with self.Owner:SelectWeapon()
[QUOTE=_Entity;46818390]Could anyone provide an example of [url]http://wiki.garrysmod.com/page/Global/Lerp[/url] in a HUD so the health or bar decreases and increases smoothy please? i'm too sure how to use it.[/QUOTE] I've got a home-grown version which does the same thing. With Lerp you pass in a float / fraction ( 0-1 ) with 0 being nothing and 1 being 100%. Just use the rounded box instead of the custom functions ( which I did put but cut out.. ) [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/hud/basic_healthbar.lua.html[/url] Here.. A stamina system with the home-grown Lerp: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/basic_stamina_system/sh_extended_stamina_system.lua.html[/url] Line 418: if ( CLIENT ) then You'll find // Lerp.. after there somewhere. That controls the smoothing without using the Lerp function.. When using the Lerp function you could get the fraction by using FrameTime( ) * MaxSpeed // per second; based on what the current value is and where the bar is currently. Clamp it from 0-1 and it should always move towards the end result without jerking. But the values that are in the Lerp will always be different so you'd need to understand what is happening. I am not a fan of using Lerp because it is typically used incorrectly.. and sometimes things are forgotten and instead of determining the fraction based on certain values it is manually set ( see the CS style weapon base which uses m and m * -1 when moving the weapon to iron sights and in reverse... Because of how it is done, instead of constantly moving towards an end result, it is set in stone and therefore when you click repeatedly it'll cause the animation to "jerk" )... Hope this helps. Edit: Just went to look for other posts to respond and saw there was a response for the Lerp which uses it correctly!
[QUOTE=Acecool;46824123]I've got a home-grown version which does the same thing. With Lerp you pass in a float / fraction ( 0-1 ) with 0 being nothing and 1 being 100%.[/QUOTE] this is a perfect acecool post, you didn't bother to see if anyone else answered the question, you didn't bother to even read the question, you just plugged your own bad code (which doesn't even use lerp (and has almost nothing to do with it)), then gave a confusing description with a million ellipses
I need to give weapons in my gamemode a value, how would I call that value from elsewhere? I.e PlayerDeath Something like this [code] SWEP.BaseValue = 100 [/code]
[QUOTE=PortalGod;46824517]this is a perfect acecool post, you didn't bother to see if anyone else answered the question, you didn't bother to even read the question, you just plugged your own bad code (which doesn't even use lerp (and has almost nothing to do with it)), then gave a confusing description with a million ellipses[/QUOTE] I did look but didn't see any response until I posted and looked again. My My "bad code" does do the same thing but it manages everything. The example posted before I posted actually uses Lerp correctly which I haven't seen it used correctly in the past. I made the Edit before you posted explaining that someone actually did post as it was a good response. You should've looked at that. [editline]31st December 2014[/editline] [QUOTE=NiandraLades;46824757]I need to give weapons in my gamemode a value, how would I call that value from elsewhere? I.e PlayerDeath Something like this [code] SWEP.BaseValue = 100 [/code][/QUOTE] There are several ways... You should be able to use attacker / victim:GetActiveWeapon( ).Var or attacker / victim:GetActiveWeapon( ):GetTable( ).Var for that particular swep if the value changes. Or you can use weapons.GetTable or weapons.GetStored if it is a generic/unchanging value.
[QUOTE=AirBlack;46823935]Fixed it already with self.Owner:SelectWeapon()[/QUOTE] Exactly what I recommended with that linked text :eng101: but bravo! You know, at this point I must have asked a thousand questions here that I immediately there after answered by myself.
Ok, so I have a question. If I write something on a HUD with draw.SimpleText is it a way to hock it up to a command to will remove the text when you type it? and how can I write a function that will delete the Text? thanks
[QUOTE=Gammanetwork;46825984]Ok, so I have a question. If I write something on a HUD with draw.SimpleText is it a way to hock it up to a command to will remove the text when you type it? and how can I write a function that will delete the Text? thanks[/QUOTE] You could incorporate HUDShouldDraw into the hud which has the text. You could also have an if statement to prevent it from drawing if some var is true / false. Then you'd just need to make a console command to control it, or a chat command.
[QUOTE=Acecool;46826044]You could incorporate HUDShouldDraw into the hud which has the text. You could also have an if statement to prevent it from drawing if some var is true / false. Then you'd just need to make a console command to control it, or a chat command.[/QUOTE] That is not what I mean. If the Text is allready drawn how can I remove it?
If you only draw it once then it'll flash too quickly to read. You'd want to keep it on screen for a few seconds. I do have a few examples ranging from receiving a net message to create a HUDPaint hook, then it removes itself 5 seconds after it was created to similar things... It all revolves around how to know time: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/time/understanding_time%20and_basic_time_calculations.lua.html[/url] To hide it just wrap it in an if or read a convar... [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/convars/creating_and_using_client_convars.lua.html[/url] Here's the initial spawn, create hud paint and only start the timer when the player has fully joined ( LocalPlayer isn't active for the first frames that the hook runs ): [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/display_something_on_initial_spawn.lua.html[/url] Hopefully these help.. We can only offer general advice without seeing what you've done and without knowing the intent such as... What causes the text to appear, will the text change, how long should it be drawn, etc...
Ok, I will try to be more spesific. I am making a Deathrun HUD. I want the player's team to be Displayed(either 'Runner' or 'Death'). This is not the problem. The problem is that when the player dies I want it to Display the team of the player he is spectating instead of his own team. But the Text does not dispear when he dies so it kinda overlaps with the original text. This is when the player is alive as a Runner: [url]http://i.imgur.com/9tHXwB5.jpg?1[/url] and this is when he is spectating another player when he is dead: [url]http://i.imgur.com/4fdWyjD.jpg?1[/url] this is the code for drawing the players team: [CODE] local PlayerTeam = team.GetName(LocalPlayer():Team()) if PlayerTeam == "Death" then draw.SimpleText( PlayerTeam, "comicfont01Team", hx + border+ 20+ 30, ht + border, Color( 160, 0, 0, 255 ), TEXT_ALIGN_LEFT ) elseif PlayerTeam == "Runner" then draw.SimpleText( PlayerTeam, "comicfont01Team", hx + border+ 20+ 25, ht + border, Color( 3, 3, 160, 255 ), TEXT_ALIGN_LEFT ) end[/CODE]
For the code for non-spectating just use: [code]if ( LocalPlayer( ):Alive( ) ) then -- .. Original code.. end[/code] Or [code]if ( !LocalPlayer( ):Alive( ) ) then return; end -- .. Original code..[/code]
[QUOTE=Acecool;46826553]For the code for non-spectating just use: [code]if ( LocalPlayer( ):Alive( ) ) then -- .. Original code.. end[/code] Or [code]if ( !LocalPlayer( ):Alive( ) ) then return; end -- .. Original code..[/code][/QUOTE] Man I was sure I tried that, but I quess not, since it works just fine. Thanks a lot!
How would you play facial expressions on players from a sound? (Like a speech or something)
[QUOTE=isnipeu;46826706]How would you play facial expressions on players from a sound? (Like a speech or something)[/QUOTE] If you use _p:EmitSound it is automatic. Also, take a look at gamemodes/base/gamemode/animations.lua : GM:MouthMoveAnimation( )
[QUOTE=Acecool;46826752]If you use _p:EmitSound it is automatic. Also, take a look at gamemodes/base/gamemode/animations.lua : GM:MouthMoveAnimation( )[/QUOTE] Didn't work, their mouth didn't move at all. But anyway here's another problem I'm having, I'm using the toolgun code to make the laser effect for primary fire but it's not attaching to the barrel of the gun: [code] function SWEP:DoShootEffect( hitpos, hitnormal, entity, physbone, bFirstTimePredicted ) self:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) self.Owner:SetAnimation( PLAYER_ATTACK1 ) if !bFirstTimePredicted then return end local effectdata = EffectData() effectdata:SetOrigin( hitpos ) effectdata:SetNormal( hitnormal ) effectdata:SetEntity( entity ) effectdata:SetAttachment( physbone ) util.Effect( "selection_indicator", effectdata ) local effectdata = EffectData() effectdata:SetOrigin( hitpos ) effectdata:SetStart( self.Owner:GetShootPos() ) effectdata:SetAttachment( 1 ) effectdata:SetEntity( self ) util.Effect( "ToolTracer", effectdata ) end function SWEP:PrimaryAttack() self:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) self:SetNextSecondaryFire( CurTime() + self.Primary.Delay ) local tr = util.GetPlayerTrace( self.Owner ) tr.mask = bit.bor( CONTENTS_SOLID, CONTENTS_MOVEABLE, CONTENTS_MONSTER, CONTENTS_WINDOW, CONTENTS_DEBRIS, CONTENTS_GRATE, CONTENTS_AUX ) local trace = util.TraceLine( tr ) if !trace.Hit then return end self:EmitSound( self.Primary.Sound ) self:DoShootEffect( trace.HitPos, trace.HitNormal, trace.Entity, trace.PhysicsBone, IsFirstTimePredicted() ) end [/code] Except the attachment isn't working in my gamemode, it just uses the ShootPos. [vid]http://puu.sh/dSQeD/e8aa9f479d.webm[/vid] [vid]http://puu.sh/dSQcJ/a65e9fe789.webm[/vid]
Shootpos is the center of the face.. For you to get the barrel of the world-model you'd need to use GetAttachment / LookupAttachment etc... Take a look at Robots viewer tool ( esp shows all attachpoints )
How should I rotate my view model in order for it to point toward the center of my line? I'm offsetting my view during a CalcView hook and it does weird stuff to the weapon angle etc: [QUOTE][IMG]http://cloud-4.steampowered.com/ugc/47618243736983128/0A19E25376609B8704F8F9F1D9B0B867029A40C2/[/IMG][/QUOTE]
Sorry, you need to Log In to post a reply to this thread.