This function (player:isRunning) does not seem to be returning propperly or not at all, though I have no errors coming off of it. Has an update made this break / changed it? if so how would I fix it?
Because IsRunning() is not valid.
Just do
[lua]if ( input.IsKeyDown( IN_RUN ) ) then
--stuff
end[/lua]
I believe input.IsKeyDown on works with KEY_* enums -- IN_* should be used with [b][url=http://wiki.garrysmod.com/?title=Player.KeyDown]Player.KeyDown [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b].
You could always do a velocity check coupled with a IsOnGround check.
[QUOTE=chief2493;24239573]This function (player:isRunning) does not seem to be returning propperly or not at all, though I have no errors coming off of it. Has an update made this break / changed it? if so how would I fix it?[/QUOTE]
[lua]
local MPlayer = FindMetaTable("Player")
function MPlayer:IsRunning()
if ( self:KeyDown( IN_RUN ) ) then
return true
end
end
[/lua]
Something like that.
[QUOTE=Cubar;24242423][lua]
local MPlayer = FindMetaTable("Player")
function MPlayer:IsRunning()
if ( self:KeyDown( IN_RUN ) ) then
return true
end
end
[/lua]
Something like that.[/QUOTE]
this could be useful to me, so I just use pl:IsRunning?
Yes
[lua]
function Running(ply)
if ply:IsRunning() then
ply:Kill()
end
end
concommand.Add("IsPlayerRunning", Running)
[/lua]
You can do other ways too like in a
[lua]
Hook.Add("Think", "IrRunning", function()
for k,v in pairs(player.GetAll()) do
if v:IsRunning() then
v:Kill() -- kills the player running
end
end
end)
[/lua]
Hope that helps. :wink:
Or just more simply...
[lua]function _R.Player:IsRunning() return self:KeyDown(IN_RUN) end[/lua]
You should make sure to return false if they aren't running. Although in Lua nil is evaluated as false in expressions, it's good practice.
Is there any way to create a function this one, for any variable before the :isPlayer?
[QUOTE=chief2493;24251453]Is there any way to create a function this one, for any variable before the :isPlayer?[/QUOTE]
[lua]local MPlayer = FindMetaTable("Player")
function MPlayer:IsRunning()
if ( self:KeyDown( IN_RUN ) ) then
return true
end
end [/lua]
That does it.
[lua]for k,v in pairs(player.GetAll()) do
if v:ISRunning() then v:Kick("No running!")
end
[/lua]
Do this instead:
ply:KeyDown( IN_RUN ) and ply:GetVelocity():Length() > 300 and ply:OnGround()
you might want to adjust the values, th
hmm this may not be my problem then... The stamina mount I have for my nexus game mode is not working but I can not figure out what is causing it, I thought it was this but maybe not, is there another solution I could try?
IN_RUN isnt valid, its IN_SPEED
[QUOTE=Wizey!;24263291]IN_RUN isnt valid, its IN_SPEED[/QUOTE]
[url]http://wiki.garrysmod.com/?title=IN_KEYS[/url]
SHARED | 0000000000004096 | 00000000000001000000000000 | RUN
[QUOTE=Cubar;24269267][url]http://wiki.garrysmod.com/?title=IN_KEYS[/url]
SHARED | 0000000000004096 | 00000000000001000000000000 | RUN[/QUOTE]
How strange... Never the less, sprinting is IN_SPEED.
[QUOTE=Wizey!;24269323]How strange... Never the less, sprinting is IN_SPEED.[/QUOTE]
It's the same.
Use IN_SPEED, probably some moron put IN_RUN on the wiki without knowing what he was doing
Sorry, you need to Log In to post a reply to this thread.