[QUOTE=Bo98;46909238]Not serverside AFAIK. There's the clientside hook InitPostEntity which runs later but I don't know if it's after the loading screen.
Why do you need this?[/QUOTE]
Nevermind, just used a timer
[QUOTE=Ylsid;46905897]Is it possible you could hack together a basic car please? This has me stumped and I might better understand the concept if I saw it done on something other than a noclip[/QUOTE]
I did make something simple such as a controllable bird, but that's about it, hope this helps.
[url]http://pastebin.com/Ve1D3jC8[/url]
There's some shitty code in there, and I made that when I didn't fully grasp what prediction is, so there might be some errors.
As for a car, that's not as easy, you need to take into account gravity, more complex collisions and etc.
I believe another facepuncher has made a car entirely with the drive system, but I haven't seen a release yet.
[QUOTE=wauterboi;46909158]Is it possible to restrict the movement of an entity to be completely on two axes instead of three? I want to do make a 2.5D platformer and don't want the player to end up moving towards or away from the screen.[/QUOTE]
Look into CreateMove, SetupMove, Move, etc... Create/SetupMove hooks are there to modify the move command before is happens ( CreateMove is where you can modify it clientside before it gets sent to the server, while the others are shared.
CLIENT
PRE [url]http://wiki.garrysmod.com/page/GM/CreateMove[/url] ( Called prior to sending the move command to the server )
SHARED
PRE [url]http://wiki.garrysmod.com/page/GM/SetupMove[/url] ( Use this to modify movement behavior )
DURING [url]http://wiki.garrysmod.com/page/GM/Move[/url] ( This can be used for certain tasks; avoid others because it'll cause jittering or other issues )
POST [url]http://wiki.garrysmod.com/page/GM/FinishMove[/url] ( called after; this can be used to track, etc... Don't modify in this hook )
You can either alter the velocity or set the move angle then change the side / forward speed based on keys...
[code]hook.Add( "SetupMove", "2D.5MovementTest", function( _p, _move, _cmd )
// Method 1, forcing move direction and terminating side speed
// Set one move direction ( based on map or position on map )
_move:SetMoveAngles( Angle( 0, 90, 0 ) );
// Kill one axis
_move:SetSideSpeed( 0 );
end );[/code]
[code]hook.Add( "SetupMove", "2D.5MovementTest", function( _p, _move, _cmd )
// Method 2, forcing move direction and terminating forward speed
// Set one move direction ( based on map or position on map )
_move:SetMoveAngles( Angle( 0, 90, 0 ) );
// Kill one axis
_move:SetForwardSpeed( 0 );
end );[/code]
[code]hook.Add( "SetupMove", "2D.5MovementTest", function( _p, _move, _cmd )
// Method 3, force move direction and allowing 2 buttons to control one direction
// Apply one move direction
_move:SetMoveAngles( Angle( 0, 90, 0 ) );
// Do this so that we control speed regardless of keys and can map whatever speed ( based on keys ) to other directions
local _speed = math.Max( math.abs( _move:GetSideSpeed( ) ), math.abs( _move:GetForwardSpeed( ) ) );
// Kill one axis ( based on map, or position )
_move:SetForwardSpeed( 0 );
// Get Keys
local _bLeft = _move:KeyDown( IN_MOVELEFT );
local _bRight = _move:KeyDown( IN_MOVERIGHT );
local _bForward = _move:KeyDown( IN_FORWARD );
local _bBack = _move:KeyDown( IN_BACK );
// Map keys to direction..
if ( _bLeft || _bBack ) then
// Apply speed to other axis ( based on map, or position )
_move:SetSideSpeed( _speed );
elseif ( _bForward || _bRight ) then
// Apply speed to other axis ( based on map, or position )
_move:SetSideSpeed( -_speed );
end
end );[/code]
The last example lets you use 2 keys per direction and if you map it to map or map position then you can do some nice tricks with the camera when you get to an edge ( switch move direction and move the camera around ) which would give an interesting effect on cube maps... I may release something like that on my dev base once it is ready for "games".
Hopefully these help!
[editline]12th January 2015[/editline]
[QUOTE=Ylsid;46905897]Is it possible you could hack together a basic car please? This has me stumped and I might better understand the concept if I saw it done on something other than a noclip[/QUOTE]
JVS Is right; creating a car is much more difficult because you have a lot more to take into consideration. It is easier to modify prop_vehicle_jeep behavior based on input / binds than it is to create a new system.
Take a look at SCars, they use a prop / model as a vehicle body, spawn seats and define actions for those seats so they can be used, spawn 4 or so wheels, define how the sound works, etc... They basically duplicate the method for creating cars in Sandbox with Lua ( all the code exists in Sandbox for spawning each individual component and some for controlling individual components )
snip, figured out.
Thanks Acecool! I'm working on two game ideas at the same time, which brings me to a new problem:
I want a trace to go through a prop_static fence. I have no idea how to make it ignore just fences. Checking the texture results in "**studio**", which makes sense, but it apparently doesn't count as the world either. In that case, what the hell do I do? I'm getting real sad, man.
[editline]12th January 2015[/editline]
[QUOTE=wauterboi;46910441]Thanks Acecool! I'm working on two game ideas at the same time, which brings me to a new problem:
I want a trace to go through a prop_static fence. I have no idea how to make it ignore just fences. Checking the texture results in "**studio**", which makes sense, but it apparently doesn't count as the world either. In that case, what the hell do I do? I'm getting real sad, man.[/QUOTE]
NEVER MIND. I was being a dope:
[code] local chTr2 = util.TraceLine( {
start = offset,
endpos = offset + ( cam.Ang:Forward( ) * 32768 ),
ignoreworld = true
} )[/code]
You can also use filter ( things to avoid ) and mask ( combination based on enums ) portions of trace data: [url]http://wiki.garrysmod.com/page/Structures/Trace[/url]
How can I get the position between two vectors?
[QUOTE=_FR_Starfox64;46912471]How can I get the position between two vectors?[/QUOTE]
Did you do math in school? Have you tried googling?
[url]http://stackoverflow.com/questions/2886092/finding-coordinates-of-a-point-between-two-points[/url]
[QUOTE=Robotboy655;46912493]Did you do math in school? Have you tried googling?
[url]http://stackoverflow.com/questions/2886092/finding-coordinates-of-a-point-between-two-points[/url][/QUOTE]
We do dumb peoples maths at my school. I thought there would be a specific way of doing it in gmod.
[QUOTE=_FR_Starfox64;46912563]We do dumb peoples maths at my school. I thought there would be a specific way of doing it in gmod.[/QUOTE]
Math is math, that's the beauty. It doesn't change between languages.
[sp]Obvious Mean Girls reference is obvious...:suicide:[/sp]
Uh, is this actually a thing
[url]http://wiki.garrysmod.com/page/Player/IsTyping[/url]
Tried printing for it, always says false and there's fuck all on it
Is there a hook or some way I could prevent a player from moving a vehicle without turning the engine off and with it still running?
[QUOTE=ShadowRanger;46913420]Is there a hook or some way I could prevent a player from moving a vehicle without turning the engine off and with it still running?[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/VehicleMove]GM/VehicleMove[/url]
You guys are really bad with this whole wiki searching stuff...
[QUOTE=NiandraLades;46913142]Uh, is this actually a thing
[url]http://wiki.garrysmod.com/page/Player/IsTyping[/url]
Tried printing for it, always says false and there's fuck all on it[/QUOTE]
[code]
function GM:GrabEarAnimation( ply )
ply.ChatGestureWeight = ply.ChatGestureWeight or 0
-- Don't show this when we're playing a taunt!
if ( ply:IsPlayingTaunt() ) then return end
if ( ply:IsTyping() ) then
ply.ChatGestureWeight = math.Approach( ply.ChatGestureWeight, 1, FrameTime() * 5.0 )
else
ply.ChatGestureWeight = math.Approach( ply.ChatGestureWeight, 0, FrameTime() * 5.0 )
end
if ( ply.ChatGestureWeight > 0 ) then
ply:AnimRestartGesture( GESTURE_SLOT_VCD, ACT_GMOD_IN_CHAT, true )
ply:AnimSetGestureWeight( GESTURE_SLOT_VCD, ply.ChatGestureWeight )
end
end
[/code]
[url]https://github.com/garrynewman/garrysmod/blob/28b7be5cda7fdde1a19c59d43408dcb2df357fd8/garrysmod/gamemodes/base/gamemode/animations.lua#L232[/url]
[QUOTE=NiandraLades;46913142]Uh, is this actually a thing
[url]http://wiki.garrysmod.com/page/Player/IsTyping[/url]
Tried printing for it, always says false and there's fuck all on it[/QUOTE]
It does work, at least with default chatbox. It may not work with custom chatbox.
[QUOTE=Revenge282;46913504][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/VehicleMove]GM/VehicleMove[/url]
You guys are really bad with this whole wiki searching stuff...[/QUOTE]Hmm, I did briefly try that hook but I couldn't manage to utilise it properly and get to work. I'll try it again and see if I can get it working this time. Thanks.
[QUOTE=ShadowRanger;46913420]Is there a hook or some way I could prevent a player from moving a vehicle without turning the engine off and with it still running?[/QUOTE]
There is an inconsistent and bad way of doing this by using:
[url]http://wiki.garrysmod.com/page/GM/PlayerBindPress[/url]
[editline]13th January 2015[/editline]
Why do you need to do it without turning off the engine though?
[QUOTE=NiandraLades;46913142]Uh, is this actually a thing
[url]http://wiki.garrysmod.com/page/Player/IsTyping[/url]
Tried printing for it, always says false and there's fuck all on it[/QUOTE]
Apparently it returns a number? The fuck?
[QUOTE=zeaga;46913918]Apparently it returns a number? The fuck?[/QUOTE]
Wiki was incorrect, fixed.
How to reset player bones?
[QUOTE=NiandraLades;46913142]Uh, is this actually a thing
[url]http://wiki.garrysmod.com/page/Player/IsTyping[/url]
Tried printing for it, always says false and there's fuck all on it[/QUOTE]
Some gamemodes use it I think. Look at the code which makes the player's arm go to their head while typing. It's an ACT_ gesture.
Not so much a problem as just I need help and it really doesn't need it's own thread.
How can I give this; (or any shape) a dropshadow?
[code]
draw.RoundedBox( 10, 0, 0, w, h, Color(231, 76, 60, 255) )
[/code]
I figured just make another RoundedBox and stick it a few pixels under it, but that seems kinda edgy.
Was also curious as to how I could centre Derma text? I've got this and I'm trying to centre the text above the line at the top.
[code]
Menu.Paint = function( self, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color(31,31,31,200) )
draw.SimpleTextOutlined( "Menu", "DebugFixed", 0, 0, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, Color(0,0,0,255))
surface.SetDrawColor( 0,0,0,255 )
Menu:DrawOutlinedRect()
surface.DrawOutlinedRect( 0, 0, w, 25 )
end
[/code]
(The text is in the top left when it should be centred?)
[url]http://puu.sh/erHvN/a40873fe45.jpg[/url]
Also, Is there a way you can customise the close button?
Thanks :)
When I join my Murder server I'm finding is that when a knife is thrown and hits someone, the server crashes. In console I get this error:
[code][ERROR] addons/ulx/lua/ulx/log.lua:219: Tried to use a NULL entity!
1. GetClass - [C]:-1
2. fn - addons/ulx/lua/ulx/log.lua:219
3. unknown - addons/ulib/lua/ulib/shared/hook.lua:183[/code]
That refers to this line:
[code]ulx.logString( string.format( "%s killed %s using %s", killer:Nick(), victim:Nick(), weapon:GetClass() ) )[/code]
I assume the knife is returning as null, but idk why. If anyone could help it would be amazing.
I updated ULX and ULIB after this problem was showing. But It is still crashing the server.
[QUOTE=Pan7h3r;46915228]When I join my Murder server I'm finding is that when a knife is thrown and hits someone, the server crashes. In console I get this error:
[code][ERROR] addons/ulx/lua/ulx/log.lua:219: Tried to use a NULL entity!
1. GetClass - [C]:-1
2. fn - addons/ulx/lua/ulx/log.lua:219
3. unknown - addons/ulib/lua/ulib/shared/hook.lua:183[/code]
That refers to this line:
[code]ulx.logString( string.format( "%s killed %s using %s", killer:Nick(), victim:Nick(), weapon:GetClass() ) )[/code]
I assume the knife is returning as null, but idk why. If anyone could help it would be amazing.
I updated ULX and ULIB after this problem was showing. But It is still crashing the server.[/QUOTE]
Have you got any type of additional Log addons installed or anything like that? Or just pure ULX/ULIB?
[QUOTE=HyperShifter;46915301]Have you got any type of additional Log addons installed or anything like that? Or just pure ULX/ULIB?[/QUOTE]
The host does provide logging, could that be causing a clash?
How can I grab the server's tickrate with lua? I want to use it with my SWEPS and Tick doesn't exist on sweps it seems
[IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/engine/TickInterval"]engine.TickInterval[/URL]
Then network it to the client - only needs done once.
[QUOTE=Robotboy655;46913816]There is an inconsistent and bad way of doing this by using:
[url]http://wiki.garrysmod.com/page/GM/PlayerBindPress[/url]
[editline]13th January 2015[/editline]
Why do you need to do it without turning off the engine though?[/QUOTE]I want the engine start sound of vehicles played when the engine is turned on to play fully before the vehicle can actually be driven. Currently you can essentially skip the sound before it has finished by just moving the vehicle once it has been turned on. I'll try out that hook though, might be able to use it. Thanks.
How do I use resource.AddWorkshop on a collection?
I remember someone once posted something like that here...
Using engine.GetAddons() is returning a wsid of 0 for some addons
[QUOTE=GGG KILLER;46916083]How do I use resource.AddWorkshop on a collection?
I remember someone once posted something like that here...
Using engine.GetAddons() is returning a wsid of 0 for some addons[/QUOTE]
Go onto your server. Lua > Autorun > Server > Make a file called 'insertnamehere.lua'
The addons you want to use resource.AddWorkshop on, just get the number id from the URL.
[url]http://steamcommunity.com/sharedfiles/filedetails/?id=198142365[/url]
The one for this would be '198142365'
Then just do resource.AddWorkshop('198142365') in the file. :)
I might be a bit wrong on some places so you will have to double check.
Sorry, you need to Log In to post a reply to this thread.