Pivity

Passing on variables to different functions

Last read Never
#1

hook.Add( "PlayerSay", "Terrorcall", function( ply, text, public ) text = string.lower( text ) -- Make the chat message entirely lowercase if ( text == "!terror" ) then PrintMessage(HUD_PRINTCENTER, ply:Nick().." has started a terror!") ply:Freeze(false) timer.Simple( 3, terror ) return "" end end )

function terror(ply) ply:Freeze(false) end ................................. Im trying to send the ply variable to the next function...

Dumb x 2Funny x 1
#2

Stop asking questions in the support and bug reports. The first few times I overlooked it, but this is not the sub forum for this.

Agree x 4
#3
ByHandsome Patrickat 7th of July 2016 01:20:50
hook.Add( "PlayerSay", "Terrorcall", function( ply, text, public )text = string.lower( text ) -- Make the chat message entirely lowercaseif ( text == "!terror" ) thenPrintMessage(HUD_PRINTCENTER, ply:Nick().." has started a terror!")ply:Freeze(false)timer.Simple( 3, terror )return ""endend )function terror(ply)ply:Freeze(false)end.................................Im trying to send the ply variable to the next function...

You know face punch has a developer discussion page for this?

Agree x 1
#4

Well yes this is the wrong thread but hey heres the answer...

Create a function like this

function NewFunctHere(ply, othervar) print(ply:NIck().." HERES THE NAME!") end

and in your chat function do NewFunctHere(ply,othervar) and it will do that function!

#5

To simplify what he said, I'll just add it to your code. Change the

timer.Simple( 3, terror )

to

timer.Simple( 3, terror(ply) )

and move the terror function to the top (Could be an issue)

Dumb x 2
#6
function terror(ply)
ply:Freeze(false)
end

hook.Add( "PlayerSay", "Terrorcall", function( ply, text )
text = string.lower( text )
if ( text == "!terror" ) then

PrintMessage(HUD_PRINTCENTER, ply:Nick().." has started a terrorist attack!")

timer.Simple( 3, function()
terror( ply )
end )

return ""

end

end )

#7

Billy why have your callback call a function when your callback could just directly refer to terror(ply)???

Agree x 2Dumb x 1
#8

#making functions for 1 line of code.

Agree x 2Funny x 2Winner x 1
#9
ByPatat 10th of July 2016 22:47:33
Billy why have your callback call a function when your callback could just directly refer to terror(ply)???

Like how AppleDevDude did it? Because that doesn't work... it returns what the function returns when called you mong

And the one line of code is pointless but it's what he's asking for

function die(h)
print("kill me",h)
end

function meme(n,f)
f()
end

meme(5,die("yes"))
kill me yes

input:6: attempt to call a nil value (local 'f')

Dumb x 1
#10

Arh shit my bad. I usually just do function() code end instead of calling another function.

Also don't be so aggresive Billy

Dumb x 1
Users viewing this thread
Nobody