• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=ShadowRanger;45608123]What would be a good way of getting the direction of a location with two vectors; the first vector being the position from where the direction is being measured from and the second vector being the position from where the direction is retrieved from. E.g - Finding the direction of Vector( 0, 50, 0 ) from Vector( 0, 0, 0 ).[/QUOTE] ( FirstV - LastV ):Length() will get how far away they are :smile: You might need to math.abs( that ) but I'm not 100% sure... ( FirstV - LastV ):Forward() should get the direction. It could also be normalized [editline]6th August 2014[/editline] On another note [QUOTE=WalkingZombie;45604021]So I made two weapons with detachable silencers on them. Is there a way I can hide the primaryattack from NPC's? (they don't hear sound) I'm pretty sure I can imitate the effect of a real silencer by changing the sound level, but otherwise I can't get primaryattack to run anything clientside?[/QUOTE] [editline]6th August 2014[/editline] Alright... now two or three questions :suicide: Is there a way I can hide SWEP:PrimaryAttack() from standard NPC's? (they don't hear sound) Also, that function isn't calling on CLIENT, is there a way to call CLIENT code from that function without making net vars? I'm trying to use the entity 'sniperbullet' and it does spawn, but it won't move. The code is only slightly modified from the Flechette gun's code. [code] local ent = ents.Create( "sniperbullet" ) -- The entity fired from npc_sniper if ( IsValid( ent ) ) then ent:SetPos( self.Owner:GetShootPos() + Forward * 24 ) ent:SetAngles( self.Owner:EyeAngles() ) ent:Spawn() ent:SetVelocity( Forward * cvars.Number( "bulletspeed" ) ) print( cvars.Number( "bulletspeed" ) ) -- Prints '6000' in the console. ent:SetOwner( self.Owner ) self:TakePrimaryAmmo( 1 ) end[/code] ( I have also tried putting a number there instead of loading the cvar, still doesn't work )
So I'm trying to spawn a ragdoll of the player and for some reason it's just being a complete dick on my gamemode, the bone angles refuse to get set properly for some reason: [url]http://www.youtube.com/watch?v=1Ncc537wO6A[/url] Works just fine in sandbox: [url]http://www.youtube.com/watch?v=XQqMYVvflSo[/url] Code (Shamelessly copied from TTT's corpse): [code] concommand.Add("penis", function(ply) local ragdoll = ents.Create("prop_ragdoll") ragdoll:SetModel(ply:GetModel()) ragdoll:SetSkin(ply:GetSkin()) ragdoll:SetMaterial(ply:GetMaterial()) ragdoll:SetColor(ply:GetColor()) ragdoll:SetPos(ply:GetPos()) ragdoll:SetAngles(ply:GetAngles()) ragdoll:SetCollisionGroup(COLLISION_GROUP_WEAPON) ragdoll:Spawn() ragdoll:Activate() for i = 0, ragdoll:GetPhysicsObjectCount()-1 do local bone = ragdoll:GetPhysicsObjectNum(i) if IsValid(bone) then local pos, ang = ply:GetBonePosition(ragdoll:TranslatePhysBoneToBone(i)) if (pos and ang) then bone:SetPos(pos + ply:GetAngles():Forward() * 64) bone:SetAngles(ang) print(i, ang) end bone:EnableMotion(false) end end end) [/code] Any clues as to what's wrong with this thing? :l [editline]penis[/editline] [del] And from out of fucking nowhere, ragdoll jesus made it work.[/del] [editline]penis[/editline] It stopped working again :v:
Any ideas on how to reward players once-per day for joining the server? An example would be nice
Is there a plugin/script available that counts the number of times a map is played on a server?. I need to save some disk space on a server and would like to see which is the least played maps and remove them.
-found it-
Is there a method to check if a game is mounted on a client? Ex. entity displays a TF2 model if client has TF2 content, CSS model if not. Silly me. Tired, forgot to check the wiki.:v:
[QUOTE=zerf;45620115]Is there a method to check if a game is mounted on a client? Ex. entity displays a TF2 model if client has TF2 content, CSS model if not.[/QUOTE] [url]http://wiki.garrysmod.com/page/engine/GetGames[/url]
IsMounted()
[B]i fixed dont bother answering me, the wiki is wrong[/B] halp [CODE] function setuptable() if sql.TableExists("lat_players") then PMsg("LAT server has initialized successfully. \n") PMsg("SQL Tables set up successfully. \n") else query = "CREATE TABLE lat_players ( unique_id string, ip string, steamid string, rank string, immunity int, ban int, banreason string )" result = sql.Query(query) if (sql.TableExists("lat_players")) then PMsg("Tabes created and set up successfully. \n") else PMsg("Something went wrong with creating the tables! \n") PMsg( sql.LastError( result ) .. "\n" ) end end end function setupdatatables( ply ) setupnewp(ply) PMsg(ply:Nick() .. " joined for the first time. \n") end function setupnewp( ply ) query1 = "INSERT INTO lat_players ( unique_id, ip, steamid, rank, immunity, ban, banreason ) VALUES ( unique_id = '" .. ply:UniqueID() .. "', ip = '" .. ply:IPAddress() .. "', steamid = '" .. ply:SteamID() .. "', rank = 'guest', immunity = 0, ban = 0, banreason = 'You were permanently banned.' )" result1 = sql.Query(query1) PMsg( sql.LastError( result1 ) .. "\n" ) PMsg( sql.LastError( result ) .. "\n" ) PMsg("New player set up. \n") end [/CODE] no such table unique_id
I set a global variable in the shared file of my game-mode but for some reason I can not access the table from the client side. [lua] song_list = { {"https://www.youtube.com/watch?v=Iv-Xmv2yjjQ", "John Legend - all of me", 0}, {"https://www.youtube.com/watch?v=MaQmm9IDPV4","Rebecca Black - Friday",0} } [/lua] Ignore Rebecca black I am using this to torture people. Code on client side [lua] for i,info in pairs(song_list) do [/lua] Error: [lua] bad argument #1 to 'pairs' (table expected, got nil) [/lua]
How can I create a sound on a SWEP, adjust the volume when holstered/deployed, and also changed pitch on fire?
-snip-
[QUOTE=HunterFP;45611267]How can i get if a player is on thirdperson or not? EDIT: Why this code dont give a knife to the players? [CODE] OnStart = function(p,g) p:SetColor(Color(255,0,0,255)) g:SetColor(Color(255,0,0,255)) p:StripWeapons(); g:StripWeapons(); if not p:Crouching() then g:SetPos(p:GetPos()); end if SERVER then p:Give("jb_knife"); g:Give("jb_knife"); end end, OnGuardDied = function(self) activeLR:End(); end, OnPrisonerDied = function(self) activeLR:End(); end[/CODE][/QUOTE] Anyone?
[QUOTE=WalkingZombie;45614238]Is there a way I can hide SWEP:PrimaryAttack() from standard NPC's? (they don't hear sound) Also, that function isn't calling on CLIENT, is there a way to call CLIENT code from that function without making net vars? I'm trying to use the entity 'sniperbullet' and it does spawn, but it won't move. The code is only slightly modified from the Flechette gun's code. [code] local ent = ents.Create( "sniperbullet" ) -- The entity fired from npc_sniper if ( IsValid( ent ) ) then ent:SetPos( self.Owner:GetShootPos() + Forward * 24 ) ent:SetAngles( self.Owner:EyeAngles() ) ent:Spawn() ent:SetVelocity( Forward * cvars.Number( "bulletspeed" ) ) print( cvars.Number( "bulletspeed" ) ) -- Prints '6000' in the console. ent:SetOwner( self.Owner ) self:TakePrimaryAmmo( 1 ) end[/code] ( I have also tried putting a number there instead of loading the cvar, still doesn't work )[/QUOTE] Could someone please help me out? [b]EDIT[/b] Maybe it's impossible to hide the shot from NPC's, but it has to be possible to make the 'sniperbullet' entity work?
Have you tried to Wake the entity?
This code closes the game without any error [code] for k, v in pairs(ents.FindByClass("npc_*")) do print(v:IsLineOfSightClear(pl)) if v:IsLineOfSightClear(pl) and IsEnemyEntityName(v:GetClass()) then status = 2 end end [/code] [del]It's a dynamic music addon I'm making, but every now and then it just closes down. I think it might be the LineOfSight thing, but I'm not aware of any alternative.[/del] Definitely this part... Any ideas?
Is there a hook or something that allows for easy muting of a whole select team? --------------------------- Also were timers recently broken again? For some reason this timer I am setting for 80 seconds is going of way to early.
[QUOTE=gonzalolog;45624489]Have you tried to Wake the entity?[/QUOTE] I can't, I just tried. It doesn't have a physics object. ( please note, this is a default source entity )
Well, i need help... [LUA] surface.CreateFont( "FancyTitle", { font = "Lobster 1.4", size = 32, weight = 500 } ) [/lua] I'm trying to use the Lobster font...But...When i try to use custom files fonts, i can't...This just use the default until i open the font and press "Install" Before install: [t]http://i.imgur.com/hD9Ee0s.jpg[/t] After install: [T]http://i.imgur.com/RL5a0JZ.jpg[/t] I don't think that people will download the font for install this one if they want to see the font
2d3d isnt drawing properly when using surface.DrawText() and I don't know why it would do this. The text position seems to be being altered by other effects, and it only seems to actually draw the text when there are other things being rendered such as the tab menu, flashlights, C menu, and oddly enough the Q menu but only when mousing over an item so that its model path is displayed (though in that case it is darkened and janky at best.) [quote] [img]http://i.imgur.com/DYzjcCw.jpg[/img] [img]http://i.imgur.com/g5CdYse.jpg[/img] [img]http://i.imgur.com/eRdSes2.jpg[/img] [img]http://i.imgur.com/CNmwKxt.jpg[/img] [img]http://i.imgur.com/ZVdhbDf.jpg[/img] [/quote] I need some answers 'cause I don't want to resign myself to using draw.SimpleText() or something equivalent if I can use surface.DrawText() [code]function ENT:Draw() self:DrawModel() cam.Start3D2D(self:GetPos() + self:GetAngles():Up() * 11.5, self:GetAngles(), 1) surface.SetFont("default") surface.DrawText("Dildos") draw.SimpleText("DIIIIIICKS") cam.End3D2D() end[/code]
[QUOTE=a1steaksa;45626081]2d3d isnt drawing properly when using surface.DrawText() and I don't know why it would do this.[/QUOTE] Your issues sound very similar to some weird issues I've been seeing with cam.Start2D3D and surface.DrawText. Basically my text wouldn't draw at all unless I had some other menu open, like scoreboard, console, etc. And when it did draw, it was black even though I was specifically setting it to white. It may be worth looking for/posting a GitHub issue on the Facepunch GitHub page, since this doesn't appear to be a singular issue.
[QUOTE=Mista Tea;45626102]Your issues sound very similar to some weird issues I've been seeing with cam.Start2D3D and surface.DrawText. Basically my text wouldn't draw at all unless I had some other menu open, like scoreboard, console, etc. And when it did draw, it was black even though I was specifically setting it to white. It may be worth looking for/posting a GitHub issue on the Facepunch GitHub page, since this doesn't appear to be a singular issue.[/QUOTE] If this is a bigger issue than just me being bad at understanding 2d3d then I'll likely make an actual post instead of a reply to just this thread and a github issue on it as well.
How would I go around drawing a line on the screen and making it point in a direction according to a number given. Basically I want to try and get a simple compass but I'm having trouble finding a way to point a line (using surface.DrawLine) in a certain direction from a number. Could someone please help me and point me in the right direction? Thanks in advance.
Do you want to make a radial menu? You can learn something from the same wiki, it's just some trigonometric calcs [url]http://en.wikipedia.org/wiki/Polar_coordinate_system[/url]
[QUOTE=gonzalolog;45626909]Do you want to make a radial menu? You can learn something from the same wiki, it's just some trigonometric calcs [url]http://en.wikipedia.org/wiki/Polar_coordinate_system[/url][/QUOTE]I want to make a simple compass, nothing too advanced. That page from the link looks complicated, hmm.
[QUOTE=ShadowRanger;45626836]How would I go around drawing a line on the screen and making it point in a direction according to a number given. Basically I want to try and get a simple compass but I'm having trouble finding a way to point a line (using surface.DrawLine) in a certain direction from a number. Could someone please help me and point me in the right direction? Thanks in advance.[/QUOTE] what kind of number? degrees? radians?
[QUOTE=PortalGod;45627055]what kind of number? degrees? radians?[/QUOTE]Degrees.
[QUOTE=a1steaksa;45626163]If this is a bigger issue than just me being bad at understanding 2d3d then I'll likely make an actual post instead of a reply to just this thread and a github issue on it as well.[/QUOTE] Well I can tell you, you're not doing surface.SetTextPos so any calls that anything makes will screw up the text you're drawing, and the other guy probably has the same problem with surface.SetDrawColor. Just add a surface.SetTextPos and surface.SetDrawColor call before your surface.DrawText. The reason draw.SimpleText is working is because it has other arguments which are a font, a position, a color, etc. which all have default settings that are being used because you're not calling the arguments. Also with surface.Set<whatever> it's like it's setting a variable, it would sort of look like this in the source code, maybe if you see this you'll understand what it's doing: [lua]local DRAWCOLOR = Color(255, 255, 255, 255) function surface.SetDrawColor(col) DRAWCOLOR = col end local DRAWFONT = "Default" function surface.SetFont(font) DRAWFONT = font end local DRAWX, DRAWY = 0, 0 function surface.SetTextPos(x, y) DRAWX, DRAWY = x, y end function surface.DrawText(text) draw.SimpleText(text, DRAWFONT, DRAWX, DRAWY, DRAWCOLOR) end[/lua] So if I call a surface.DrawText function without setting the pos, the font, or the color beforehand, whatever draw operations are called are setting those variables and so whenever you open a menu all the derma and hud code is calling these functions and setting the colors/fonts/positions.
[QUOTE=ShadowRanger;45627158]Degrees.[/QUOTE] first, you'll have to convert any degrees to radians with [url=http://wiki.garrysmod.com/page/math/rad]math.rad[/url] then all you have to do is [lua] local endx = startx + math.cos(rad)*distance local endy = starty + math.sin(rad)*distance [/lua]
[QUOTE=OzymandiasJ;45627348]words[/QUOTE] The 'other guy' is using surface.SetTextColor and surface.SetTextPos already. [CODE] surface.SetTextColor( MyColor ) surface.SetTextPos( 0, 0 ) surface.SetFont( "My font" ) surface.DrawText( "My text" )[/CODE] I'm not literally doing that ^ but you get the point. I am calling the appropriate functions within cam.Start3D2D/cam.End3D2D. But I'm totes down for any other suggestions though.
Sorry, you need to Log In to post a reply to this thread.