• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
so I noticed in sandbox you can right click a prop and turn off its gravity now is it possible to turn off gravity for multiple props (all named the same) in hammer with the lua_run command? for a ttt map if that matters, like a space map
[QUOTE=Rocketsurgery;49320379]so I noticed in sandbox you can right click a prop and turn off its gravity now is it possible to turn off gravity for multiple props (all named the same) in hammer with the lua_run command? for a ttt map if that matters, like a space map[/QUOTE] If you want it to all be done in Hammer, probably best to post in the Mapping thread, also, [URL="https://m.youtube.com/watch?v=oJ28n5b-OA0"]this might help.[/URL] If you want to do it with lua_run, you could try something like [CODE]lua_run "for k,v in pairs(ents.GetAll()) do local phys = v:GetPhysicsObject() if IsValid(phys) then phys:EnableGravity(false) end end" [/CODE] That code is untested though.
[QUOTE=Z0mb1n3;49320140]I'm having a bit of a brain aneurysm and cannot figure out how to calculate the degree of rotation difference between the player's forward direction and a nearby entity. Essentially, if this was a top-down view... [t]http://puu.sh/lW9Y2.jpg[/t] I've been using :Dot like this... [code] local norm = LocalPlayer():GetForward() local pos = LocalPlayer():GetPos() local dot for a, b in pairs(ents.FindByClass("npc_*")) do local vpos = b:GetPos() local slope = (Vector(vpos.x, vpos.y, 0) - Vector(pos.x, pos.y, 0)):GetNormalized() dot = norm:Dot(slope) end [/code] but unfortunately, the way this is working out is it only does from 1 - 50 degrees, 50 being if the player is looking straight at the entity, and 1 if the entity is directly to their left or right. I want a way to have a degree that is not mirrored, meaning something like: they are to my left if the dot is 180, to my right if 0 or 360, in front of me if 90, and behind me if 270, etc. EDIT: Nevermind, I got it. Subtracted the y of the player's angle from the angle of the normal between the player and the entity. EDIT2: Well that's providing fucky results, too, so maybe if someone else has a better idea?[/QUOTE] Dot Product essentially does this: |a| × |b| × cos(θ) So, what you want to do is this: [code] local norm = LocalPlayer():GetForward() local pos = LocalPlayer():GetPos() local dot local angle for a, b in pairs(ents.FindByClass("npc_*")) do local vpos = b:GetPos() local slope = (Vector(vpos.x, vpos.y, 0) - Vector(pos.x, pos.y, 0)):GetNormalized() dot = norm:Dot(slope) angle = math.acos( dot/(norm:Length()*slope:Length()) ) end [/code]
How do I send player info to a function that requires it?
[QUOTE=keeperman;49322088]:snip:[/QUOTE] Your question is very vague but by the looks of things you're using the wrong amount of arguments on net.Receive's callback. [url]http://wiki.garrysmod.com/page/net/Receive[/url] use: [CODE]function CreateChair( l, ply )[/CODE]
[QUOTE=BillyOnWiiU;49322098]Your question is very vague but by the looks of things you're using the wrong amount of arguments on net.Receive's callback. [url]http://wiki.garrysmod.com/page/net/Receive[/url] use: [CODE]function CreateChair( l, ply )[/CODE][/QUOTE] Well I'm very new to net and I dunno how to really say it, but I want it so you enter "CreateChair" into the console and it pops up a chair by the player and runs the other things in the function.
[QUOTE=CaptainFaggot;49318798]snip[/QUOTE] Figured it out. I had a * where I should have had +.
Is it possible to fetch the player models from C menu?
[QUOTE=keeperman;49329703]Is it possible to fetch the player models from C menu?[/QUOTE] [URL="http://wiki.garrysmod.com/page/player_manager/AllValidModels"]player_manager.AllValidModels()[/URL]
[QUOTE=BillyOnWiiU;49329809][CODE]player_manager.AllValidModels()[/CODE][/QUOTE] Thanks Bill
[QUOTE=geferon;49191482]Is there any good tutorial on how to make like good particles? Its just that i want to learn how to do them. But the good ones.[/QUOTE] Can somebody teach me or something please?
Can you still overwrite the ply:Nick() and ply:Name() functions? Every time I try to overwrite them it does nothing. [lua] local pmeta = FindMetaTable("Player") local OldNick = pmeta.Nick local OldName = pmeta.Name function pmeta:Nick() return self.FName or OldNick(self) end function pmeta:Name() return self.FName or OldNick(self) end concommand.Add("ChangeName", function( ply, cmd, args ) ply.FName = args[1] end) [/lua]
[QUOTE=bran92don;49334309]Can you still overwrite the ply:Nick() and ply:Name() functions? Every time I try to overwrite them it does nothing. [lua] local pmeta = FindMetaTable("Player") local OldNick = pmeta.Nick local OldName = pmeta.Name function pmeta:Nick() return self.FName or OldNick(self) end function pmeta:Name() return self.FName or OldNick(self) end concommand.Add("ChangeName", function( ply, cmd, args ) ply.FName = args[1] end) [/lua][/QUOTE] I would do [code] OldNick = OldNick or pmeta.Nick OldName = OldName or pmeta.Name [/code] but that probably has nothing to do with it. If you're retrieving a player's name on the server's end, this will work fine, but if you want client's to use the different name, I'd go with using NWStrings. [code] local pmeta = FindMetaTable("Player") OldNick = OldNick or pmeta.Nick OldName = OldName or pmeta.Name function pmeta:Nick() return self:GetNWString("FName", false) or OldNick(self) end function pmeta:Name() return self:GetNWString("FName", false) or OldNick(self) end concommand.Add("ChangeName", function( ply, cmd, args ) ply:SetNWString("FName", tostring(args[1])) end) [/code] The concommand part obviously would only go in the serverside file of whatever you're doing, while the others would go in both server and client or a shared file.
[QUOTE=Z0mb1n3;49334609]I would do [code] OldNick = OldNick or pmeta.Nick OldName = OldName or pmeta.Name [/code] but that probably has nothing to do with it. If you're retrieving a player's name on the server's end, this will work fine, but if you want client's to use the different name, I'd go with using NWStrings. [code] local pmeta = FindMetaTable("Player") OldNick = OldNick or pmeta.Nick OldName = OldName or pmeta.Name function pmeta:Nick() return self:GetNWString("FName", false) or OldNick(self) end function pmeta:Name() return self:GetNWString("FName", false) or OldNick(self) end concommand.Add("ChangeName", function( ply, cmd, args ) ply:SetNWString("FName", tostring(args[1])) end) [/code] The concommand part obviously would only go in the serverside file of whatever you're doing, while the others would go in both server and client or a shared file.[/QUOTE] OMG are you serious. I literally tried using a nw variable and it was not working. Thanks for the help.
Remember to network it and check if args[1] it's not null, also put a timer so player doesn't abuse it and check if that name it's not being used
Already made a thread for this but hoping for more exposure with my issue. Hey, I've been making an s-tool and I've come across this serverside error while trying to call a serverside function from a s-tool: [code]attempt to call field "CreateSpawnPoint" ( a nil value )[/code] the shared stool code where this is being called is here: [lua]if not self:GetOwner():IsSuperAdmin() then self:GetOwner():PrintMessage(3, "A tool this dangerous can only be used by superadmins.") return false end if ( trace.HitSky || !trace.HitPos ) then return false end if IsValid( trace.Entity ) then return false end if ( CLIENT ) then return true end local position = trace.HitPos local ang = trace.HitNormal:Angle() splerge_event.CreateSpawnPoint(position, ang, nil, tonumber(self:GetClientInfo( "setteam" )), self:GetOwner()) self:GetOwner():PrintMessage(3, "Created new spawn point for " .. readable_teams[tonumber(self:GetClientInfo( "setteam" ))]) return true [/lua] And here's the serverside code of the function I'm trying to call (This file did load correctly AFAIK: [lua] splerge_event = splerge_event or {} ....... function splerge_event.CreateSpawnPoint(pos, ang, regiment, job, ply) // not using ang yet, might not need to, trying to save time if job then local playerteam = neatteamnames[job] spawnpoints[playerteam] = spawnpoints[playerteam] or {} table.insert(spawnpoints[playerteam], pos) else spawnpoints[regiment] = spawnpoints[regiment] or {} table.insert(spawnpoints[regiment], pos) end net.Start("splerge_event_spawnpointsprops") net.WriteVector(pos) net.Send(ply) end [/lua] splerge_event does exist and is called at the start of the file, as seen above. Was wondering if anyone could help me with this, can provide more information doing PrintTable(splerge_event) just gives this: [lua]{ }[/lua]
What would be the best way to make a simplified version of darkrp jobs. They are 'player classes' for my gamemode, but I'm pretty bad with tables in general. Can anyone show some example? Team Classes are not what I'm looking for. EDIT: Well I know how to do it with tons of variables, but I'm afraid I will do it 'the hard way' then
[QUOTE=Skere_;49337272]What would be the best way to make a simplified version of darkrp jobs. They are 'player classes' for my gamemode, but I'm pretty bad with tables in general. Can anyone show some example? Team Classes are not what I'm looking for. EDIT: Well I know how to do it with tons of variables, but I'm afraid I will do it 'the hard way' then[/QUOTE]The only way is tables. And you'd have to create checks and override some functions like meta:Team()
How would I go about clamping an Angle gotten from GetEyeTrace? I've tried using math.Clamp but I'm not sure I'm doing it right. [CODE] angle.p = math.Clamp( angle.p, angle.p - 0.02 , angle.p + 0.02 ) angle.y = math.Clamp( angle.y, angle.y - 0.02 , angle.y + 0.02 ) angle.r = math.Clamp( angle.r, angle.r - 0.02 , angle.r + 0.02 )[/CODE] I feel like I'm on the right path but I'm not sure where I'm going wrong.
[QUOTE=CaptainFaggot;49338364]:snip:[/QUOTE] Are you trying to do something like [URL="http://wiki.garrysmod.com/page/Angle/SnapTo"]this[/URL]?
[QUOTE=BillyOnWiiU;49338512]Are you trying to do something like [URL="http://wiki.garrysmod.com/page/Angle/SnapTo"]this[/URL]?[/QUOTE] What I'm trying to do is, prevent a 3d2d hud from floating too far off the screen as the player turns their head, like this. [IMG]http://i.imgur.com/AliC0IR.gif[/IMG] Currently I have the speed at which it lerps high so that it doesn't fly off the screen when moving but it can be jerky if you have low fps. Idealy it would have a lower speed of lerp and just prevent it from moving too far.
[QUOTE=CaptainFaggot;49338571]:snip:[/QUOTE] Well, it looks like your code should work. What is it doing when you use that code?
[QUOTE=BillyOnWiiU;49338584]Well, it looks like your code should work. What is it doing when you use that code?[/QUOTE] It seems to be the same. I'm tried setting to extreme values but that doesn't seem to change it. Here is the relevant code, maybe i'm missing something. [CODE]hook.Add( "PostDrawTranslucentRenderables", "SCHHealth", function() -- hook.Add( "PostDrawOpaqueRenderables", "SCHHealth", function() if schHUDEnable:GetBool() == false then return end local ply = LocalPlayer() local hp = ply:Health() local ar = ply:Armor() local nrg = ply:getDarkRPVar("Energy") hpsmoothing = math.Approach( hpsmoothing, hp, 70*FrameTime()) arsmoothing = math.Approach( arsmoothing, ar, 70*FrameTime()) -- if nrg then -- hungsmoothing = math.Approach( arsmoothing, nrg, 100*FrameTime()) -- end HPmath = math.Clamp( hpsmoothing / 100, 0, 1) * 400 ARmath = math.Clamp( arsmoothing / 100, 0, 1) * 400 if nrg then HungerMath = math.Clamp( nrg / 100, 0, 1) * (-130 - height + 180) end angle = ply:GetEyeTraceNoCursor().Normal:Angle() angle.p = math.Clamp( angle.p, angle.p - 0.001 , angle.p + 0.001 ) angle.y = math.Clamp( angle.y, angle.y - 0.001 , angle.y + 0.001 ) angle.r = math.Clamp( angle.r, angle.r - 0.001 , angle.r + 0.001 ) angle:RotateAroundAxis( angle:Forward(), SlForward ) angle:RotateAroundAxis( angle:Right(), SlRight ) angle:RotateAroundAxis( angle:Up(), SlUp ) forwardhplerp = LerpVector( FrameTime() * speed, forwardhplerp, ply:GetEyeTraceNoCursor().Normal * 15 ) anglehplerp = LerpAngle( FrameTime() * speed, anglehplerp, angle ) cam.Start3D2D( EyePos() + forwardhplerp, anglehplerp, 0.014 ) 3d2d stuff [/CODE]
snip nevermind
[QUOTE=CaptainFaggot;49338797]It seems to be the same. I'm tried setting to extreme values but that doesn't seem to change it. Here is the relevant code, maybe i'm missing something. [CODE]hook.Add( "PostDrawTranslucentRenderables", "SCHHealth", function() -- hook.Add( "PostDrawOpaqueRenderables", "SCHHealth", function() if schHUDEnable:GetBool() == false then return end local ply = LocalPlayer() local hp = ply:Health() local ar = ply:Armor() local nrg = ply:getDarkRPVar("Energy") hpsmoothing = math.Approach( hpsmoothing, hp, 70*FrameTime()) arsmoothing = math.Approach( arsmoothing, ar, 70*FrameTime()) -- if nrg then -- hungsmoothing = math.Approach( arsmoothing, nrg, 100*FrameTime()) -- end HPmath = math.Clamp( hpsmoothing / 100, 0, 1) * 400 ARmath = math.Clamp( arsmoothing / 100, 0, 1) * 400 if nrg then HungerMath = math.Clamp( nrg / 100, 0, 1) * (-130 - height + 180) end angle = ply:GetEyeTraceNoCursor().Normal:Angle() angle.p = math.Clamp( angle.p, angle.p - 0.001 , angle.p + 0.001 ) angle.y = math.Clamp( angle.y, angle.y - 0.001 , angle.y + 0.001 ) angle.r = math.Clamp( angle.r, angle.r - 0.001 , angle.r + 0.001 ) angle:RotateAroundAxis( angle:Forward(), SlForward ) angle:RotateAroundAxis( angle:Right(), SlRight ) angle:RotateAroundAxis( angle:Up(), SlUp ) forwardhplerp = LerpVector( FrameTime() * speed, forwardhplerp, ply:GetEyeTraceNoCursor().Normal * 15 ) anglehplerp = LerpAngle( FrameTime() * speed, anglehplerp, angle ) cam.Start3D2D( EyePos() + forwardhplerp, anglehplerp, 0.014 ) 3d2d stuff [/CODE][/QUOTE] That clamp will not work. You are clamping the value within 0.001 units of whatever the value is. Example, If I clamp a number doing: [code]number = math.Clamp(number, number - 5, number + 5)[/code] if "number" is 10, the minimum value is then 5, while the max is 15. if "number" is 20, then the minimum is 15, max is 25. You need to set minimum and maximum values that are not dependent on the current value, else the number will never reach the minimum or maximum. I do hope that makes sense.
[QUOTE=Z0mb1n3;49340420]-snip-[/QUOTE] Thanks. I tried something else and it seems to be working.
Question, would it be possible to remove coroutines from a Nextbot code and just do everything in Think? Using coroutines (and the constant crashes you can get from mishandling them, got an issue that never even got solved related to them) can be really unorganized and hard.
[QUOTE=MaximLaHaxim;49345211]Question, would it be possible to remove coroutines from a Nextbot code and just do everything in Think? Using coroutines (and the constant crashes you can get from mishandling them, got an issue that never even got solved related to them) can be really unorganized and hard.[/QUOTE] The only crashes coroutines should cause are when calling in to 3rd party binary modules.
[QUOTE=Willox;49345340]The only crashes coroutines should cause are when calling in to 3rd party binary modules.[/QUOTE] Borrowed some code from this guy here, and had the same problems. [url]https://facepunch.com/showthread.php?t=1479933[/url]
Lines 230 and 231 can end the coroutine in his paste.
Sorry, you need to Log In to post a reply to this thread.