Derma Problem

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.

function LevelSystem( ply )
	local XPSystem = vgui.Create( 'DFrame' )
		XPSystem.SetSize( 210, 35 )
		XPSystem.MakePopup( true )
		XPSystem.ShowCloseButton( false )
		XPSystem.SetDraggable( false )
		XPSystem:Paint = function()
			draw.RoundedBox( Color( 0, 0, 0 ) )
	local progress = vgui.Create( 'DProgress' )
		progress:SetSize( 200, 25 )
		progress:SetParent( XPSystem )
concommand.Add( "Skills", LevelSystem )

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]

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: 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:

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

local progress = vgui.Create( 'DProgress', XPSystem )

So, I could use:

if ply:Team = TEAM_TRAITOR then
RunConsoleCommand( "giveXP", "100" )

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…


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

function GM:PlayerDeathThink( ply ) 
   if ply:Team() == TEAM_TRAITOR then

function ply:UpdateXP()
      umsg.Start( "UPDATEPROGRESS" )

Client Side

usermessage.Hook( "UPDATEPROGRESS", function( um ) 
	UpdateProgress( um:ReadLong() )

function UpdateProgress( Data )

        -- code goes here


[editline]18th March 2014[/editline]

Damn Ninja’d

What file would I put them in? The hooks file or the shared?