• Derma Problem
    10 replies, posted
I'm currently creating a leveling system for a TTT server. I've got all down, except the part to make it "go" if they kill a traitor. Kind of like, if they kill someone, then it Sets the fraction to a little bit up the way. Can anyone help me out? It'd be appreciated! I've got the whole XP down and all, it's just the part where it goes. Nothing else. EDIT: The derma part is a progress bar. Sorry for not including that.
Could you show us your code?
PlayerDeath hook.
[CODE]function LevelSystem( ply ) local XPSystem = vgui.Create( 'DFrame' ) XPSystem.SetSize( 210, 35 ) XPSystem.Center XPSystem.MakePopup( true ) XPSystem.ShowCloseButton( false ) XPSystem.SetDraggable( false ) XPSystem:Paint = function() draw.RoundedBox( Color( 0, 0, 0 ) ) end local progress = vgui.Create( 'DProgress' ) progress:SetSize( 200, 25 ) progress:SetParent( XPSystem ) progress:Center() progress: end concommand.Add( "Skills", LevelSystem )[/CODE] I'm left blank at the last one. In most languages besides Lua it's like, progressbar.Increment(1) But, Lua is not like every other code xD [editline]18th March 2014[/editline] [QUOTE=Sm63;44278038]PlayerDeath hook.[/QUOTE] I have that down, all I need is how to make the Fraction of the progress bar "go"
Do what Sm63 said. On the PlayerDeath hook, which is server-side, or the game-event for death seen here: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/game_event_listeners.lua[/url] which is shared - make sure the attacker and victim are players, make sure the attacker is Traitor, make sure the Victim is NOT Traitor. Then send a net-message to the attacker with the relevant xp gain.. Basic / example of net-messages: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/networking/networking_booleans.lua[/url]
[QUOTE=Jelly Pancake;44278042][CODE]function LevelSystem( ply ) local XPSystem = vgui.Create( 'DFrame' ) XPSystem.SetSize( 210, 35 ) XPSystem.Center XPSystem.MakePopup( true ) XPSystem.ShowCloseButton( false ) XPSystem.SetDraggable( false ) XPSystem:Paint = function() draw.RoundedBox( Color( 0, 0, 0 ) ) end local progress = vgui.Create( 'DProgress' ) progress:SetSize( 200, 25 ) progress:SetParent( XPSystem ) progress:Center() progress: end concommand.Add( "Skills", LevelSystem )[/CODE] I'm left blank at the last one.[/QUOTE] You have a syntax error unless that's that stupid Facepunch bug. I don't know what line youre suppose to have here but you have "progress:" instead of something like "progress.Paint = function()" You don't have to do progress:SetParent as you can do it like [code]local progress = vgui.Create( 'DProgress', XPSystem )[/code]
So, I could use: [CODE]if ply:Team = TEAM_TRAITOR then RunConsoleCommand( "giveXP", "100" ) end[/CODE] If anyone is wondering the giveXP command is only if you kill someone. So don't worry. [editline]18th March 2014[/editline] How exactly would I make the progress bar move with Player Death hook?
When you use 1 = it is an assignment operator. It will always equate to true if it successfully assigns the reference to the value on the right to the name on the left. Use == for a comparison which checks if the two are equivalent. Use != for the inverse of ==. Use <= for less than or equal to, >= greater than or equal to, > greater than, < less than for numbers. Use || or or for OR operator when testing multiple boolean operations. Use && or and for AND operator when testing multiple boolean operations. Also, when calling a function using :, you must use ( ). If you want to see if that function exists, use . So [lua]if ( ply.Team && ply:Team( ) == TEAM_TRAITOR ) then ... end[/lua] would be a correct sequence of boolean operations..
[QUOTE=Acecool;44278246]When you use 1 = it is an assignment operator. It will always equate to true if it successfully assigns the reference to the value on the right to the name on the left. Use == for a comparison which checks if the two are equivalent. Use != for the inverse of ==. Use <= for less than or equal to, >= greater than or equal to, > greater than, < less than for numbers. Use || or or for OR operator when testing multiple boolean operations. Use && or and for AND operator when testing multiple boolean operations. Also, when calling a function using :, you must use ( ). If you want to see if that function exists, use . So [lua]if ( ply.Team && ply:Team( ) == TEAM_TRAITOR ) then ... end[/lua] would be a correct sequence of boolean operations..[/QUOTE] THANK YOU!!!
[QUOTE=Jelly Pancake;44278125]So, I could use: [CODE]if ply:Team = TEAM_TRAITOR then RunConsoleCommand( "giveXP", "100" ) end[/CODE] If anyone is wondering the giveXP command is only if you kill someone. So don't worry. [editline]18th March 2014[/editline] How exactly would I make the progress bar move with Player Death hook?[/QUOTE] What you would have to do is this. Once the player dies, using the PlayerDeathHook, use a networked message to send a string to the client, this string is how far progressed you want to progress bar to be. Here's some example code :- Server Side [code] function GM:PlayerDeathThink( ply ) if ply:Team() == TEAM_TRAITOR then self:UpdateXP() endif end function ply:UpdateXP() umsg.Start( "UPDATEPROGRESS" ) umsg.Long(100) umsg.End() end [/code] Client Side [code] usermessage.Hook( "UPDATEPROGRESS", function( um ) UpdateProgress( um:ReadLong() ) end) function UpdateProgress( Data ) -- code goes here end [/code] [editline]18th March 2014[/editline] [QUOTE=Haskell;44278324]What you would have to do is this. Once the player dies, using the PlayerDeathHook, use a networked message to send a string to the client, this string is how far progressed you want to progress bar to be. Here's some example code :- Server Side [code] function GM:PlayerDeathThink( Player ) if player:Team() == TEAM_TRAITOR then self:UpdateXP() endif end function ply:UpdateXP() umsg.Start( "UPDATEPROGRESS" ) umsg.Long(100) umsg.End() end [/code] Client Side [code] usermessage.Hook( "UPDATEPROGRESS", function( um ) UpdateProgress( um:ReadLong() ) end) function UpdateProgress( Data ) -- code goes here end [/code][/QUOTE] Damn Ninja'd
What file would I put them in? The hooks file or the shared?
Sorry, you need to Log In to post a reply to this thread.