• Get damaged by what class
    7 replies, posted
Hello, I'm making a stove script and I want the bread to be thrown at the player, and I want it to print a message when it will happen, this is what I have function GM:ScalePlayerDamage(ply,hitgroup,dmginfo) if StoveConfig.femaleScreamSpitBread == yes or true then if dmginfo:GetInflictor():GetClass() == "bread" then print("you get hurt by bread? what a fag") -- playsound ambient/voices/f_scream1.wav end end end This new code system is shit so ill rewrite is shit so ill rewrite it function GM:ScalePlayerDamage(ply,hitgroup,dmginfo) if StoveConfig.femaleScreamSpitBread == yes or true then if dmginfo:GetInflictor():GetClass() == "bread" then print("you got hurt by bread? what a faggot") end end end But I seem to be getting this error: attempt to index global 'GM' (a nil value) I also cant remove the stupid code box below this text VV
I read someone said something before that GM doesn't exist once the game is created or something, put GAMEMODE in its place.
Yeah use hook.Add() Also unless you're actually scaling damage you should use GM/EntityTakeDamage
Okay thanks! I wish I could use the GM functions, make life a bit easier
According to the wiki GM is only defined inside gamemode files
If you do: hook.Add("ScalePlayerDamage", "UniqueName", function(ply, hitgroup, dmginfo) -- YOUR CODE HERE -- end) It's the same as adding your code at the end of GM:ScalePlayerDamage function
They won't. You don't want to accidentally overwrite your main GM: functions. hook.Add works just as well with the added protection of not overwriting your gamemode stuff (unless, of course, you return true/false)
The hook system was made to make this modular, which is perfect for addons like the one you're making. Your code gets added onto whatever is set by the gamemode.
Sorry, you need to Log In to post a reply to this thread.