• Few questions:
    9 replies, posted
[B]1).[/B] I can't seem to find a think function that is active when a player sprints, and I really need this one for a Stamina thing for my gamemode. [B]2).[/B] How can I disable the toolgun when you are X units away from something? [B]3).[/B] I'd like to make a custom Scoreboard, but I can't disable the default Scoreboard for some reason, I tried [code] function GM:HUDDrawScoreboard() return false end [/code]
1. [lua]function CheckSprint() for _,v in ipairs(player.GetAll()) do if v:KeyDown(IN_RUN) then -- Do stuff end end end hook.Add("Think","CheckSprint",CheckSprint)[/lua]
Thanks, helped me a lot :D
3. [lua]function GM:ScoreboardShow() return true end[/lua] [url=http://wiki.garrysmod.com/?title=Gamemode.ScoreboardShow][img]http://wiki.garrysmod.com/images/9/90/NewerClient.png[/img] Gamemode.ScoreboardShow[/url]
2. [lua]local obj = Entity(1) -- Put your entity here local distance = 100 -- All players less than this units away can't tool function CheckDistance(pl,tr,tool) if obj:GetPos():Distance( pl:GetPos() ) < distance then return false end end hook.Add("CanTool","CheckDistance",CheckDistance)[/lua] [url]http://wiki.garrysmod.com/?title=Gamemode.CanTool[/url] Overv, is there an easy way of doing that fancy linkage?
[lua]local obj = Entity(1) -- Put your entity here local distance = 100 -- All players less than this units away can't tool function CheckDistance(pl,tr,tool) return obj:GetPos():Distance( pl:GetPos() ) >= distance end hook.Add("CanTool","CheckDistance",CheckDistance)[/lua]
[QUOTE=Entoros;18507172]Overv, is there an easy way of doing that fancy linkage?[/QUOTE] No, it appears everyone fancies typing it out manually. I'll see if I can write a greasemonkey script to do it.
[QUOTE=MakeR;18507311][lua]local obj = Entity(1) -- Put your entity here local distance = 100 -- All players less than this units away can't tool function CheckDistance(pl,tr,tool) return obj:GetPos():Distance( pl:GetPos() ) >= distance end hook.Add("CanTool","CheckDistance",CheckDistance)[/lua][/QUOTE] Wouldn't that override/conflict with other hooks, though?
[QUOTE=Entoros;18529158]Wouldn't that override/conflict with other hooks, though?[/QUOTE] That's right. If we don't want to disallow it we shouldn't return anything (or simply nil).
[QUOTE=Entoros;18529158]Wouldn't that override/conflict with other hooks, though?[/QUOTE] Yep, my bad. [editline]07:57PM[/editline] I wasn't thinking about it in context, it's just that when I see this: [lua]if var then return true else return false end[/lua] I think it would be better to do this: [lua]return var[/lua]
Sorry, you need to Log In to post a reply to this thread.