Hello fellow facepunch users, i need some help with lua (Cuz i'm a scrub).
[CODE]concommand.Add( "antirad", function( ply )
ply:SetArmor( 120 )
ply:SetHealth ( 120 )
ply:SetPlayerColor( Vector( 0, 255, 0 ) )
end )[/CODE]
I have made a small console command that once typed gives you some armor, some health and sets your color to green. HOWEVER, because of my low lua knowledge, i am asking you for some help. Is there anyway to make an entity, that once pressed E on it, activates the command ON the player that has pressed it?
P.S Please give me some [url]https://wiki.garrysmod.com[/url] links if you are mentioning any hooks, classes. etc.
If it's a custom entity, you could override its [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ENTITY/Use]ENT:Use[/url] function, if not, you could try hooking into [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerUse]GM:PlayerUse[/url]
[editline]6th June 2016[/editline]
Of course, to activate the command on the player that used the entity, you just need to use the activator variable of whatever function you're using and just run the command on that
[QUOTE=MPan1;50464235]If it's a custom entity, you could override its [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ENTITY/Use]ENT:Use[/url] function, if not, you could try hooking into [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerUse]GM:PlayerUse[/url]
[editline]6th June 2016[/editline]
Of course, to activate the command on the player that used the entity, you just need to use the activator variable of whatever function you're using and just run the command on that[/QUOTE]
Thanks a lot!
Sorry, you need to Log In to post a reply to this thread.