[QUOTE=Sweepyoface;51789375]When the velocity is greater than the max, simply set it back to the max.[/QUOTE]
Velocity doesn't work that way?
[url]http://wiki.garrysmod.com/page/Entity/SetVelocity[/url]
[QUOTE]Sets an entity's velocity with a given vector velocity.
Note: If applied to player, it will ADD velocity, not SET it.[/QUOTE]
Do something like:
[lua]local correctVelocity = ply:GetVelocity() - maxVelocity
ply:SetVelocity(-correctVelocity)[/lua]
[QUOTE=Moat;51788085]Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/ScrW]ScrW[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/ScrH]ScrH[/url].
Example:
[lua]
local scrW, scrH = ScrW(), ScrH()
surface.DrawTexturedRect(scrW-50,scrH-50,50,50)
[/lua][/QUOTE]
Thanks.
[QUOTE=nubpro;51789581]Velocity doesn't work that way?
[url]http://wiki.garrysmod.com/page/Entity/SetVelocity[/url][/QUOTE]
Try this: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CMoveData/SetMaxClientSpeed]CMoveData:SetMaxClientSpeed[/url]
[editline]7th February 2017[/editline]
Or perhaps this: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CMoveData/SetVelocity]CMoveData:SetVelocity[/url]
How do you ragdoll a model of a custom entity?
Trying to not use ents.Create("prop_ragdoll")
[QUOTE=YourStalker;51789725]Do something like:
[lua]local correctVelocity = ply:GetVelocity() - maxVelocity
ply:SetVelocity(-correctVelocity)[/lua][/QUOTE]
I'm trying to get an idea what maxVelocity would be in this case. *scratch head*
[QUOTE=SFArial;51790147]Try this: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CMoveData/SetMaxClientSpeed]CMoveData:SetMaxClientSpeed[/url]
[editline]7th February 2017[/editline]
Or perhaps this: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CMoveData/SetVelocity]CMoveData:SetVelocity[/url][/QUOTE]
SetMaxClientSpeed() only caps walking and running speed. It doesn't restricts bhopping.
Thank for the replies folks
Has the Marlett font changed? When I used to use it, 3 and 4 would be left and right arrows. Now they're a piece of paper and and a stack of paper. Maybe diff version of the font on my comp?
This is the char map I'm using.
[url]https://www.reactos.org/wiki/Marlett_Characters[/url]
Was accurate in the past.
[QUOTE=Ilyaaa;51790474]Has the Marlett font changed? When I used to use it, 3 and 4 would be left and right arrows. Now they're a piece of paper and and a stack of paper. Maybe diff version of the font on my comp?
This is the char map I'm using.
[url]https://www.reactos.org/wiki/Marlett_Characters[/url]
Was accurate in the past.[/QUOTE]
If you use Marlett, you're throwing cross-platform out the window.
[QUOTE=LegoGuy;51790513]If you use Marlett, you're throwing cross-platform out the window.[/QUOTE]
Gonna switch the font if the os isn't windows.
[QUOTE=Ilyaaa;51790545]Gonna switch the font if the os isn't windows.[/QUOTE]
Why not just use images?
[QUOTE=LegoGuy;51790560]Why not just use images?[/QUOTE]
Last resort. Don't want to add resources I don't really need and I need to be able change the color on the fly.
So apparently when using Marlett or Webdings as the font, it will default to Wingdings
[t]https://static1.squarespace.com/static/52b5f43ee4b02301e647b446/t/56242665e4b0b08cacee76ed/1445209702919/Webding+Wingding+Icon+Cheat+Sheet+Character+Map+Symbols[/t]
How can I detect if the player is in the escape menu or not? Specifically, I'm trying to only detect a custom keypress during normal gameplay (not interacting with vgui/derma )
I'm working on a paired player animation system, this means that both players involved need to be at the exact position and angle. This is problematic however because you can't just set the angle of a player's body, as setting their view angle just turns their head in that direction, resulting in misaligned animtions.
Does anone know a way to reset the player's model too make their body line up with their view angle? I thought you could reset their model, but that doens't seem to work anymore.
Semi-Properly Aligned:
[img]https://dl.dropboxusercontent.com/u/41867685/Sharex/pics022017/2017-02-07_17-18-24.gif[/img]
Compltely misaligned:
[img]https://dl.dropboxusercontent.com/u/41867685/Sharex/pics022017/2017-02-07_17-18-07.gif[/img]
Better Question*
Is it possible to do ENT:OnTakeDamage for a prop_ragdoll?
It seems like setting sv_maxvelocity would achieve my primary objective to cap bunnyhopping travelling speeds.
[QUOTE=pilot;51792403]Better Question*
Is it possible to do ENT:OnTakeDamage for a prop_ragdoll?[/QUOTE]
have you tried hooking in to EntityTakeDamage and checking if the damaged entity's class is prop_ragdoll?
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityTakeDamage]EntityTakeDamage[/url]
Haven't tried it myself, but it's at least something to go on.
[CODE]include("shared.lua")
function ENT:Draw()
self:DrawModel()
local rotate = self.rotate || 0;
local Pos = self:GetPos()
local Ang1 = Angle(0,0,90)
local Ang2 = Angle(0,0,90)
Ang1:RotateAroundAxis(Ang1:Right(), rotate)
Ang2:RotateAroundAxis(Ang2:Right(), rotate + 180)
cam.Start3D2D( Pos + Ang1:Up() * 0, Ang1, 0.2)
draw.DrawText("A gift from the gods. Use it wisely.", "Default", 0, -50, Color(0,0,0), TEXT_ALIGN_CENTER)
cam.End3D2D()
cam.Start3D2D(Pos + Ang2:Up() * 0, Ang2, 0.2)
draw.DrawText("A gift from the gods. Use it wisely.", "Default",0, -50, Color(0,0,0), TEXT_ALIGN_CENTER)
cam.End3D2D()
if (rotate > 359) then rotate = 0 end
self.rotate = rotate - (2*(self.lasttime||-SysTime() ) )
self.lasttime = SysTime()
end[/CODE]
I have the text rotating around the object I want, but it starts out slow then progressively speeds up until it's not legible.
How can I get it at a constant, slower speed?
[QUOTE=Meninist;51793483][CODE]include("shared.lua")
function ENT:Draw()
self:DrawModel()
local rotate = self.rotate || 0;
local Pos = self:GetPos()
local Ang1 = Angle(0,0,90)
local Ang2 = Angle(0,0,90)
Ang1:RotateAroundAxis(Ang1:Right(), rotate)
Ang2:RotateAroundAxis(Ang2:Right(), rotate + 180)
cam.Start3D2D( Pos + Ang1:Up() * 0, Ang1, 0.2)
draw.DrawText("A gift from the gods. Use it wisely.", "Default", 0, -50, Color(0,0,0), TEXT_ALIGN_CENTER)
cam.End3D2D()
cam.Start3D2D(Pos + Ang2:Up() * 0, Ang2, 0.2)
draw.DrawText("A gift from the gods. Use it wisely.", "Default",0, -50, Color(0,0,0), TEXT_ALIGN_CENTER)
cam.End3D2D()
if (rotate > 359) then rotate = 0 end
self.rotate = rotate - (2*(self.lasttime||-SysTime() ) )
self.lasttime = SysTime()
end[/CODE]
I have the text rotating around the object I want, but it starts out slow then progressively speeds up until it's not legible.
How can I get it at a constant, slower speed?[/QUOTE]
The problem is in these lines:
[lua] self.rotate = rotate - (2*(self.lasttime||-SysTime() ) )
self.lasttime = SysTime()[/lua]
Your calculation of self.rotate is incorrect. Try this instead:
[lua] self.rotate = rotate - ( 2 * ( SysTime() - self.lasttime ) )
self.lasttime = SysTime()[/lua]
As a side point, it's better to use RealTime instead of SysTime (they're nearly identical but serve a different purpose):
[lua] self.rotate = rotate - ( 2 * ( RealTime() - self.lasttime ) )
self.lasttime = RealTime()[/lua]
[editline]8th February 2017[/editline]
[QUOTE=bizzclaw;51792820]have you tried hooking in to EntityTakeDamage and checking if the damaged entity's class is prop_ragdoll?
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityTakeDamage]EntityTakeDamage[/url]
Haven't tried it myself, but it's at least something to go on.[/QUOTE]
Even better:
[lua]local function TakeDamage(self, target, dmg)
if target != self then return end
-- your code here
end
-- to apply to hook to a prop_ragdoll entity assigned to the variable 'rag'
hook.Add("EntityTakeDamage", rag, TakeDamage)[/lua]
untested
how to fix this error? [ERROR] lua/mining.lua:2: <name> or '...' expected near '4'
1. unknown - lua/mining.lua:0
here is code RunConsoleCommand("+attack")
timer.Simple(time, function(4) RunConsoleCommand("-attack") end)
[QUOTE=Spamppa2;51793922]how to fix this error? [ERROR] lua/mining.lua:2: <name> or '...' expected near '4'
1. unknown - lua/mining.lua:0
here is code RunConsoleCommand("+attack")
timer.Simple(time, function(4) RunConsoleCommand("-attack") end)[/QUOTE]
Identifiers can't start with a digit, also [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Simple]timer.Simple[/url] doesn't pass anything to the function so the 4 is there for no reason.
[QUOTE]Your calculation of self.rotate is incorrect. Try this instead:
[CODE]self.rotate = rotate - ( 2 * ( SysTime() - self.lasttime ) )
self.lasttime = SysTime()[/CODE][/QUOTE]
Thank you very much, since RealTime and SysTime are nearly identical do I gain or lose anything from the switch? What do you mean by they serve different purposes?
[QUOTE=bigdogmat;51794002]Identifiers can't start with a digit, also [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Simple]timer.Simple[/url] doesn't pass anything to the function so the 4 is there for no reason.[/QUOTE]
i am new i am geting now this error [ERROR] lua/mining.lua:2: bad argument #2 to 'Simple' (function expected, got nil)
1. Simple - [C]:-1
2. unknown - lua/mining.lua:2
Okay I am having trouble with some more code.
[CODE]include("shared.lua")
function ENT:Draw()
self:DrawModel()
local rotate = self.rotate || 0;
local Pos = self:GetPos()
local Ang1 = Angle(0,0,90)
local Ang2 = Angle(0,0,90)
Ang1:RotateAroundAxis(Ang1:Right(), rotate)
Ang2:RotateAroundAxis(Ang2:Right(), rotate + 180)
cam.Start3D2D( Pos + Ang1:Up() * 0, Ang1, 0.2)
draw.DrawText("A gift from the gods. Use it wisely.", "Default", 0,-50, Color(0,0,0), TEXT_ALIGN_CENTER)
cam.End3D2D()
cam.Start3D2D(Pos + Ang2:Up() * 0, Ang2, 0.2)
draw.DrawText("A gift from the gods. Use it wisely.", "Default",0,-50, Color(0,0,0), TEXT_ALIGN_CENTER)
cam.End3D2D()
if (rotate > 359) then rotate = 0 end
self.rotate-(2* ( RealTime()-(self.lasttime)))
self.lasttime = RealTime()
end[/CODE]
That is the code I am having trouble with, here is the error;
[CODE][ERROR] lua/entities/testent/cl_init.lua:26: '=' expected near '-'
1. unknown - lua/entities/testent/cl_init.lua:0
[/CODE]
Also, I cannot get this to work for some reason.
[CODE]function ENT:Use(a , c)
c:SetHealth(c:Health() + 1)
if c:Health() >= 101 then
c:SetHealth(1)
chat.AddText(Color(255,0,0), LocalPlayer(), ", Stop abusing the God's gift!")
end
end[/CODE]
I was getting an error saying 'chat' was a nil value.
[QUOTE=Meninist;51794159]Thank you very much, since RealTime and SysTime are nearly identical do I gain or lose anything from the switch? What do you mean by they serve different purposes?[/QUOTE]
SysTime is [i]slightly[/i] slower, so if you have hundreds of this entity rendered at once, you might get 19 fps instead of 20 fps :P
What I mean by different purpose is this: when the developers created these 2 functions, they imagined them being used for a particular purpose. RealTime was intended for the type of thing you're trying to do, to be able to display and render things in a way that moves at a constant rate (that is, independent of the framerate), without being affected by the game time scale (see CurTime). The intended purpose of SysTime, on the other hand, is to be extremely accurate, and mostly for benchmarking - to measure how much time it takes to execute a command 10,000 times for example. In general, released code shouldn't have to use SysTime.
However in practice, the difference between these two functions is so specific and small, that it's perfectly fine to use SysTime in a place where RealTime is usually used. It's just a semantic thing. It's not a mistake to use SysTime instead of RealTime.
[QUOTE=Spamppa2;51794188]i am new i am geting now this error [ERROR] lua/mining.lua:2: bad argument #2 to 'Simple' (function expected, got nil)
1. Simple - [C]:-1
2. unknown - lua/mining.lua:2[/QUOTE]
Post your code
[QUOTE=bigdogmat;51794311]Post your code[/QUOTE]
I am working whit him RunConsoleCommand("+attack")
timer.Simple( 4, time, function() RunConsoleCommand("-attack") end)
[QUOTE=RasmusG5;51794368]I am working whit him RunConsoleCommand("+attack")
timer.Simple( 4, time, function() RunConsoleCommand("-attack") end)[/QUOTE]
Look at the wiki page, [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Simple]timer.Simple[/url]. It takes 2 arguments, the delay, and the function to call.
[QUOTE=Meninist;51794206]
That is the code I am having trouble with, here is the error;
[CODE][ERROR] lua/entities/testent/cl_init.lua:26: '=' expected near '-'
1. unknown - lua/entities/testent/cl_init.lua:0
[/CODE][/QUOTE]
"self.rotate - (...)" should be "self.rotate = self.rotate - (...)"
[QUOTE]Also, I cannot get this to work for some reason.
[CODE]function ENT:Use(a , c)
c:SetHealth(c:Health() + 1)
if c:Health() >= 101 then
c:SetHealth(1)
chat.AddText(Color(255,0,0), LocalPlayer(), ", Stop abusing the God's gift!")
end
end[/CODE]
I was getting an error saying 'chat' was a nil value.[/QUOTE]
you're mixing client-only and server-only functions here -- ENT:Use() is a serverside hook and ply:SetHealth() only has an effect serverside, but the chat lib and LocalPlayer() only exist on the client. use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/PrintMessage]Player:PrintMessage[/url] instead.
Edit: Am dumb nvm.
[QUOTE=NeatNit;51793727]The problem is in these lines:
Even better:
[lua]local function TakeDamage(self, target, dmg)
if target != self then return end
-- your code here
end
-- to apply to hook to a prop_ragdoll entity assigned to the variable 'rag'
hook.Add("EntityTakeDamage", rag, TakeDamage)[/lua]
untested[/QUOTE]
Worked like a charm. Last question in my slew of questions!
What's a good workaround for LocalPlayer() in a serverside file?
Maybe a way to specify yourself using player.----?
Sorry, you need to Log In to post a reply to this thread.