Questions from a beginner.

Hey there, hopefully by reading this, you may have some advice for me :3
Okay, so, I started to learn Lua a few days ago, and I think I have gotten to grips with it (kinda), so, my question is:

If I searched the wiki and found something I’d like on a server I administrate, what should I do then?

For example:

(This would be my first real try at Lua)
Thanks for reading. :smiley:

Umhh what?

**[Gamemode.DoPlayerDeath](** is a Gamemode hook, so you should define a function and then add it to
**[Gamemode.DoPlayerDeath](** with **[Hook.Add](**.

That way, whenever **[Gamemode.DoPlayerDeath](** is called, so will your function.

You could also override the function itself, but that wouldn’t be recommended unless you’re making your own gamemode.

That question was hard to state xD
Sorry if it is barely readable. Also, as I stated, I started to learn the very basics a few days ago.
So sorry if I’m not up to your standards in understanding this stuff…

Sorry if this sounds like a really idiotic question, but how would I override it? :3

DON"T DO IT MAN DON’T DO IT. :smithicide:

You’d just have to define the function again.
You’re better off hooking another function to it though, I think redefining the function causes it to ignore every function added to it with hook.Add.

(For reminders: I started learning Lua 2 days ago)
I have this so far:

function GM:DoPlayerDeath( ply, attacker, dmginfo )


ply:AddDeaths( 1 )

if ( attacker:IsValid() && attacker:IsPlayer() ) then

	if ( attacker == ply ) then
		attacker:AddFrags( -1 )
		attacker:AddFrags( 1 )


function GM:DoPlayerDeath(ply, attacker, dmginfo)
victim:PrintMessage(HUD_PRINTTALK,killer:Nick()…" killed you!

And when I try to test it, I get:
[lua\doplayerdeath.lua:25] function arguments expected near ‘)’

Any help would be appreciated! :smiley:

EDIT: I also tried a falldamage script:

[lua]function GM:GetFallDamage( ply, speed )
return ( speed / 8 )
hook.Add(“GetFallDamage”, GM:GetFallDamage)[/lua]

That is what I ended up with after asking for help from a few people, I get this when I test it:

“[lua\getfalldamage.lua:4] function arguments expected near ‘)’”

I have no idea about this…

This is a perfect example of what NOT to do.

First of all, you first override the gamemode hook. GM is the gamemode table, meaning that if you do:
[lua]function GM:GetFallDamage( ply, speed )
return ( speed / 8 )
You override the default falldamage hook.

If you do:
[lua]function AdjustFallDamage( ply, speed )
return ( speed / 8 )
hook.Add(“GetFallDamage”, “UniqueHookName”, AdjustFallDamage)[/lua]

It will first call GM:GetFallDamage and after that all hooked functions, so AdjustFallDamage.(It might be that the GM function is called first, I don’t really know)

There is not 25 lines in the code you posted, post the entire code please.

No need. I explained it to him and told him that this is where that error is coming from: