Can anyone tell me why this may not be working? Using player classes to change movement but for some reason it won't work with IN_MOVELEFT or IN_MOVERIGHT. I've tried SetButtons on both cmd and mv but still nothing.
[code]
function PLAYER:StartMove( mv, cmd )
if cmd:KeyDown( IN_JUMP ) then
if cmd:GetMouseX() < 0 then
mv:SetButtons( bit.bor( mv:GetButtons(), IN_MOVELEFT ) )
elseif cmd:GetMouseX() > 0 then
mv:SetButtons( bit.bor( mv:GetButtons(), IN_MOVERIGHT ) )
end
end
end
[/code]
When I print GetButtons() in FinishMove it shows them as being active but still doesn't actually do anything.
[QUOTE=Ilyaaa;52803385]Can anyone tell me why this may not be working? Using player classes to change movement but for some reason it won't work with IN_MOVELEFT or IN_MOVERIGHT. I've tried SetButtons on both cmd and mv but still nothing.
:snip:
When I print GetButtons() in FinishMove it shows them as being active but still doesn't actually do anything.[/QUOTE]
Changing the buttons here won't affect anything, use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CMoveData/SetForwardSpeed]CMoveData:SetForwardSpeed[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CMoveData/SetSideSpeed]CMoveData:SetSideSpeed[/url]
[QUOTE=bigdogmat;52803474]Changing the buttons here won't affect anything, use [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/CMoveData/SetForwardSpeed"]CMoveData:SetForwardSpeed[/URL] and [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/CMoveData/SetSideSpeed"]CMoveData:SetSideSpeed[/URL][/QUOTE]
Thank you, did not know this. Weird how that doesn't work, but this autohop does...
[code]
function PLAYER:StartMove( mv, cmd )
if not self.Player:IsOnGround()
and self.Player:WaterLevel() < 2
and self.Player:GetMoveType() != MOVETYPE_LADDER then
mv:SetButtons( bit.band( mv:GetButtons(), bit.bnot( IN_JUMP ) ) )
end
end
[/code]
and again this doesn't
[code]
function PLAYER:StartMove( mv, cmd )
if mv:KeyDown( IN_MOVELEFT ) then
mv:SetButtons( bit.band( mv:GetButtons(), bit.bnot( IN_MOVELEFT ) ) )
end
if mv:KeyDown( IN_MOVERIGHT ) then
mv:SetButtons( bit.band( mv:GetButtons(), bit.bnot( IN_MOVERIGHT ) ) )
end
end
[/code]
[editline]20th October 2017[/editline]
edit: Actually, I can see how...
Is it better to use the word 'general' or 'generic' when referring to something in general?
Garry's Mod seems to use 'generic', but I don't know if that is correct.
[QUOTE=MPan1;52804006]Is it better to use the word 'general' or 'generic' when referring to something in general?
Garry's Mod seems to use 'generic', but I don't know if that is correct.[/QUOTE]
Could you give an example?
[QUOTE=code_gs;52804067]Could you give an example?[/QUOTE]
[url]https://github.com/MysteryPancake/Rule-Book/blob/master/README.md#general-1[/url]
[QUOTE=MPan1;52804006]Is it better to use the word 'general' or 'generic' when referring to something in general?
Garry's Mod seems to use 'generic', but I don't know if that is correct.[/QUOTE]
A lotta the times, they're interchangeable. They mean pretty much the same thing. However, some cases, they are not interchangeable, like when you are referring to an unbranded drug like aspirin or ibuprofen, you'll say generic. If you are saying something like "In general", its a little weird to say "Generically, " even tho it still works. And also has slightly different connotations. To refer to something in general, just use in general.
A little off topic, but why does your rule book say "No unnecessary local foo = foo." when the link that the line points to says to use it? And general shouldn't ALWAYS be used. Depends on context which one to use.
[QUOTE=MelonShooter;52804092]A lotta the times, they're interchangeable. They mean pretty much the same thing. However, some cases, they are not interchangeable, like when you are referring to an unbranded drug like aspirin or ibuprofen, you'll say generic. If you are saying something like "In general", its a little weird to say "Generically, " even tho it still works. And also has slightly different connotations. To refer to something in general, just use in general.
A little off topic, but why does your rule book say "No unnecessary local foo = foo." when the link that the line points to says to use it? And general shouldn't ALWAYS be used. Depends on context which one to use.[/QUOTE]
What about NOTIFY_GENERIC? Shouldn't that then technically be NOTIFY_GENERAL?
[editline]21st October 2017[/editline]
[QUOTE=MelonShooter;52804092]A little off topic, but why does your rule book say "No unnecessary local foo = foo." when the link that the line points to says to use it?[/QUOTE]
It's a mess. I just thought that it looks bad really
[QUOTE=Shendow;52802874]When creating the avatar, call [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/SetPaintedManually]Panel:SetPaintedManually[/url] so it only draws when you tell it to with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/PaintManual]Panel:PaintManual[/url], aka when [i]av[/i] exists.
Here's some example code:
[lua]
local av
hook.Add("HUDPaint", "test", function()
if (IsValid(av)) then
av:PaintManual()
else
av = vgui.Create("AvatarImage")
av:SetPlayer(LocalPlayer())
av:SetPaintedManually(true)
end
end)
[/lua]
You cannot remove a weapon defined with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/weapons/Register]weapons.Register[/url]. Why would you even need to do that?
To embed wiki pages you just have to press on the link button next to the realm:
[t]https://vgy.me/Jqtnrv.png[/t]
To rate posts I believe you need a certain amount of posts. Ratings should appear on the bottom-right of a post when hovering it.[/QUOTE]
I feel as if you could maybe using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/weapons/GetStored]weapons.GetStored[/url]
It's late so, I might edit this but if anyone has a way to unregister a weapon please, do tell.. I have need to do so.
[QUOTE=MPan1;52804117]What about NOTIFY_GENERIC? Shouldn't that then technically be NOTIFY_GENERAL?
[editline]21st October 2017[/editline]
It's a mess. I just thought that it looks bad really[/QUOTE]
Well, a generic notification and general notification pretty much have the exact same meaning and connotation so it wouldn't matter. Just use which one sounds better. If they both sound ok, just either one.
Hello. Got this small problem that needs fixing. I need an entity to rotate while having its angles and position be set to another entities angle and position.
So this works:
[code]
self:GetPhysicsObject():AddAngleVelocity( self.parent:GetUp() * 10 ) -- for testing
[/code]
But I need to set angles from this entity to match another, and using :SetAngles() renders the above code useless.
Anyone got any ideas on how I can use the two together?
Currently I'm trying to make a HUD that "jiggles" slightly as you look around. However, The HUD moves wildly around my screen completely ignoring ClampX and ClampY. Anyone know what I'm doing wrong?
[CODE]CurAng = EyeAngles()
if not OldAng then
OldAng = CurAng
end
if not AngDiff then
AngDiff = { x=0, y=0 }
end
local clampX,clampY = 20 , 20
AngDiff.x = math.Approach(AngDiff.x,math.Clamp((CurAng.y - OldAng.y)/(FrameTime()/2.1),-clampX,clampX),FrameTime()*65)
AngDiff.y = math.Approach(AngDiff.y,math.Clamp((CurAng.p - OldAng.p)/(FrameTime()/2.1),-clampY,clampY),FrameTime()*65)
OldAng = CurAng
if AngDiff then
posx = posx + (AngDiff.x/1.5 or 0)
posy = posy - (AngDiff.y/1.5 or 0)
end
[/CODE]
EDIT cleaned up the code a bit, but now I have a problem where the HUD is stuck at the 0,0 coordinates on my screen
[CODE]
local posx = ScrW() / 10
local posy = ScrH() - 53
// make HUD jiggle a bit
CurAng = EyeAngles()
local clampX,clampY = 20 , 20
posx = math.Approach(math.Clamp(posx, -clampX, clampX), CurAng.x, FrameTime()*65)
posy = math.Approach(math.Clamp(posy, -clampY, clampY), CurAng.y, FrameTime()*65)
[/CODE]
How do you get the height of an entity in units (while also taking scale into consideration)?
[QUOTE=CKlidify;52814099]How do you get the height of an entity in units (while also taking scale into consideration)?[/QUOTE]
OBBMaxs.z - OBBMins.z
Anyone know how to increase the Y axis spacing of the children in a DListLayout? I can't use DIconLayouts because those don't work with collapsible catergories.
-EDIT-
Found the fix.
Is there a way to override the default ringing and deafening effect when you take explosive damage?
[QUOTE=residualgrub;52815082]Is there a way to override the default ringing and deafening effect when you take explosive damage?[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/OnDamagedByExplosion]GM:OnDamagedByExplosion[/url]
[QUOTE=residualgrub;52815082]Is there a way to override the default ringing and deafening effect when you take explosive damage?[/QUOTE]
Try setting the effect flags to 0x4 (TE_EXPLFLAG_NOSOUND).
[QUOTE=code_gs;52815090]Try setting the effect flags to 0x4 (TE_EXPLFLAG_NOSOUND).[/QUOTE]
Or just
[CODE]
hook.Add( "OnDamagedByExplosion", "DisableSound", function()
return true
end )
[/CODE]
How do you guys usually do huds? Use the surface and draw library or the vgui derma library and a lot of paint functions?
[QUOTE=Zer0nix;52815119]How do you guys usually do huds? Use the surface and draw library or the vgui derma library and a lot of paint functions?[/QUOTE]
Most people use the [URL="https://wiki.garrysmod.com/page/Category:surface"]surface[/URL] and [URL="https://wiki.garrysmod.com/page/Category:draw"]draw[/URL] libraries in a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/HUDPaint]GM:HUDPaint[/url] hook, but it's possible to use to use separate vgui elements like the engine does.
Really, if you are creating a gamemode, you should use vgui elements to separate out everything you need and allow addons to decide whether to draw them or not. If it's for an addon, in most cases, you should use HUDPaint.
[QUOTE=Zer0nix;52815119]How do you guys usually do huds? Use the surface and draw library or the vgui derma library and a lot of paint functions?[/QUOTE]
You can do it either way.
I usually use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/HUDPaint]GM:HUDPaint[/url] because with that it's easy to update something every frame, but if you want to use vgui then you need to remember not to create a panel every single frame, because it'll never get removed.
[editline]24th October 2017[/editline]
ninja'd
Also, the draw library uses the surface library internally, so the surface library is the fastest you can get. The draw library is easier for text though.
How would I move a player to a certain location as if they were walking there?
I understand you can use SetupMove to change how the player movement is, but let's say I wanted to make a player 'walk' to a location that's clicked on the screen, how would I do this?
[QUOTE=DahDestroyer;52815495]How would I move a player to a certain location as if they were walking there?
I understand you can use SetupMove to change how the player movement is, but let's say I wanted to make a player 'walk' to a location that's clicked on the screen, how would I do this?[/QUOTE]
Rotate their angle to the desired destination ([img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CUserCmd/SetViewAngles]CUserCmd:SetViewAngles[/url]), then apply the forward movement in StartCommand or SetupMove.
Edit: Nevermind
I am making a module for darkrp and I did everything accordingly but it fails at this point
[CODE]net.Receive("rs_initialize",function(len, ply)
ply:ChatPrint("Send to client and ready for derma magic")
end)[/CODE]
I networked correctly i think:
[CODE]if args == "" and ply:GetPData("rs_test_queue", 0) then
ply:SetPData("rs_test_queue",1)
net.Start("rs_initialize")
net.Send(ply)
end
[/CODE]
I get this error but I am not sure why?
[CODE]
[ERROR] addons/darkrpmodification-master/lua/darkrp_modules/roguesystem/cl_rsystem.lua:2: attempt to index local 'ply' (a nil value)
1. func - addons/darkrpmodification-master/lua/darkrp_modules/roguesystem/cl_rsystem.lua:2
2. unknown - lua/includes/extensions/net.lua:32
[/CODE]
[QUOTE=MGFear;52815611]I am making a module for darkrp and I did everything accordingly but it fails at this point
:snip:
I networked correctly i think:
:snip:
I get this error but I am not sure why?
:snip:[/QUOTE]
The second argument for the [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Receive]net.Receive[/url] callback is only valid server side, you're using it client side. You can use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/LocalPlayer]LocalPlayer[/url].
Also, [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/ChatPrint]Player:ChatPrint[/url] is a shared function, unless you're sending the net message for another reason, you can simply do this server side.
Hi, ive been trying to create an addon for TTT whereby the Traitor can suicide and then 20 seconds later will be revived. however this is not currently working and i am getting an error in game. i have used code from the suicide knife addon as well as Respawn from TTT and the TTT config from badkings AK.
[CODE]if ( SERVER ) then
AddCSLuaFile( "shared.lua" )
SWEP.HoldType = "melee"
end
SWEP.Base = "weapon_tttbase"
if ( CLIENT ) then
SWEP.PrintName = "The Ghoster"
SWEP.Author = "DJ Bat"
SWEP.ViewModelFOV = 70
SWEP.WepSelectIcon = surface.GetTextureID( "weapons/suicideknife" )
SWEP.Category = Other
end
-----------------------Main functions----------------------------
function SWEP:Think() --Called every frame
end
local v = self.Owner
function SWEP:PrimaryAttack()
//play animation
self.Weapon:SendWeaponAnim( ACT_VM_FIDGET )
//die after 1.3 seconds
timer.Simple(1.3, function() v:ConCommand( "kill" ) end )
print (v)
timer.Simple(20 function() end)
spawntheplayer()
end
function spawntheplayer (v)
if not GetConVarString("gamemode") == "terrortown" then print("Wrong gamemode. Please switch to TTT for this to work.")
end
if v:Alive() then return end
local corpse = corpse_find(v)
if corpse then corpse_remove(corpse) end
v:SpawnForRound( true )
v:SetCredits( ( (v:GetRole() == ROLE_INNOCENT) and 0 ) or GetConVarNumber("ttt_credits_starting") )
end
function corpse_find(v)
for _, ent in pairs( ents.FindByClass( "prop_ragdoll" )) do
if ent.uqid == v:UniqueID() and IsValid(ent) then
return ent or false
end
end
end
function corpse_remove(corpse)
CORPSE.SetFound(corpse, false)
if string.find(corpse:GetModel(), "zm_", 6, true) then
corpse:Remove()
elseif corpse.player_ragdoll then
corpse:Remove()
end
end
function corpse_identify(corpse)
if corpse then
local ply = player.GetByUniqueID(corpse.uqid)
ply:SetNWBool("body_found", true)
CORPSE.SetFound(corpse, true)
end
end
function SWEP:SecondaryAttack()
//Same as primary fire see
self:PrimaryAttack()
end
-------------------------------------------------------------------
------------General Swep Info---------------
SWEP.Author = "DJ Bat"
SWEP.Contact = ""
SWEP.Purpose = "Ghosting"
SWEP.Instructions = "Die and talk to the dead"
SWEP.Spawnable = false
SWEP.AdminSpawnable = true
-----------------------------------------------
------------Models---------------------------
SWEP.ViewModel = "models/weapons/v_knife_suicide.mdl"
SWEP.WorldModel = "models/weapons/w_knife_t.mdl"
-----------------------------------------------
-------------Primary Fire Attributes----------------------------------------
SWEP.Primary.Delay = 5
SWEP.Primary.Recoil = 0
SWEP.Primary.Damage = 0
SWEP.Primary.NumShots = 1
SWEP.Primary.Cone = 0
SWEP.Primary.ClipSize = 1
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none" --Ammo Type
-------------End Primary Fire Attributes------------------------------------
-------------Secondary Fire Attributes-------------------------------------
SWEP.Secondary.Delay = 5
SWEP.Secondary.Recoil = 0
SWEP.Secondary.Damage = 0
SWEP.Secondary.NumShots = 1
SWEP.Secondary.Cone = 0
SWEP.Secondary.ClipSize = 1
SWEP.Secondary.DefaultClip = 1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
-------------End Secondary Fire Attributes--------------------------------
--- TTT config values
-- Kind specifies the category this weapon is in. Players can only carry one of
-- each. Can be: WEAPON_... MELEE, PISTOL, HEAVY, NADE, CARRY, EQUIP1, EQUIP2 or ROLE.
-- Matching SWEP.Slot values: 0 1 2 3 4 6 7 8
SWEP.Kind = WEAPON_ROLE
-- If AutoSpawnable is true and SWEP.Kind is not WEAPON_EQUIP1/2, then this gun can
-- be spawned as a random weapon. Of course this AK is special equipment so it won't,
-- but for the sake of example this is explicitly set to false anyway.
SWEP.AutoSpawnable = false
-- The AmmoEnt is the ammo entity that can be picked up when carrying this gun.
SWEP.AmmoEnt = ""
-- CanBuy is a table of ROLE_* entries like ROLE_TRAITOR and ROLE_DETECTIVE. If
-- a role is in this table, those players can buy this.
SWEP.CanBuy = { ROLE_TRAITOR }
-- InLoadoutFor is a table of ROLE_* entries that specifies which roles should
-- receive this weapon as soon as the round starts. In this case, none.
SWEP.InLoadoutFor = nil
-- If LimitedStock is true, you can only buy one per round.
SWEP.LimitedStock = true
-- If AllowDrop is false, players can't manually drop the gun with Q
SWEP.AllowDrop = false
-- If IsSilent is true, victims will not scream upon death.
SWEP.IsSilent = true
-- If NoSights is true, the weapon won't have ironsights
SWEP.NoSights = true
-- Equipment menu information is only needed on the client
if CLIENT then
-- Path to the icon material
SWEP.Icon = "VGUI/ttt/icon_myserver_ak47"
-- Text shown in the equip menu
SWEP.EquipMenuData = {
type = "Weapon",
desc = "Example custom weapon."
};
end
-- Tell the server that it should download our icon to clients.
if SERVER then
-- It's important to give your icon a unique name. GMod does NOT check for
-- file differences, it only looks at the name. This means that if you have
-- an icon_ak47, and another server also has one, then players might see the
-- other server's dumb icon. Avoid this by using a unique name.
resource.AddFile("materials/VGUI/ttt/icon_myserver_ak47.vmt")
end[/CODE]
Error when i try to add the 20sec timer into it:
[CODE][ERROR] addons/suicide_knife_(swep)_153328251/lua/weapons/suicideknife/shared.lua:30: ')' expected near 'function'
1. unknown - addons/suicide_knife_(swep)_153328251/lua/weapons/suicideknife/shared.lua:0
[/CODE]
error when i take out the timer:
[CODE][ERROR] addons/suicide_knife_(swep)_153328251/lua/weapons/suicideknife/shared.lua:23: attempt to index global 'self' (a nil value)
1. unknown - addons/suicide_knife_(swep)_153328251/lua/weapons/suicideknife/shared.lua:23
[/CODE]
any help would be appreciated this is my first attempt at a script
getting this error but only in darkrp, no clue what to do with it
[CODE]Failed to retrieve player information from the database.
Hints:
- This means your database or the connection to your database is fucked.
- This is the error given by the database:
database is locked
[/CODE]
[QUOTE=MPan1;52815085][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/OnDamagedByExplosion]GM:OnDamagedByExplosion[/url][/QUOTE]
No clue how I missed that one. Thanks a ton!
Sorry, you need to Log In to post a reply to this thread.