• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=TFA;48541529]Is there an easy way to change the inactive/active/pressed colors on a DButton, or write a custom paint function for the text? Overwriting the button.Paint function only overrides the button itself.[/QUOTE] I am assuming when you say colors you are talking about the text color. This is basic, you might wanna do a simple cache to ensure that the SetTextColor function doesn't get spammed. [lua] btn.Think = function( btn ) if( btn.Depressed )then DLabel.SetTextColor( btn, Color( 255, 0 0 ) ); end end [/lua] If you're talking about the actual button color though, just overwrite the paint function.
I was wondering, is there a function to draw something ON TOP of everything when hovered over a panel? (Other than toying with SetDrawOnTop()) I need to draw a tooltip but I don't want to use the default DToolTip one.
Not sure if this is worthy of a thread or not but is there any possible way of getting the length of a .mp3? SoundDuration() only works with .wav apparently
[QUOTE=Pigsy;48545139]Not sure if this is worthy of a thread or not but is there any possible way of getting the length of a .mp3? SoundDuration() only works with .wav apparently[/QUOTE] There's two options you have:. 1) Write a variable to hold the time-duration(in seconds) // Like: local timeOfSound_001 = 4.3;//sec 2) Convert mp3 to wav // Time consuming, seriously depending on quantity. I suggest option 1)
[QUOTE=EthanTheGreat;48545551]There's two options you have:. 1) Write a variable to hold the time-duration(in seconds) // Like: local timeOfSound_001 = 4.3;//sec 2) Convert mp3 to wav // Time consuming, seriously depending on quantity. I suggest option 1)[/QUOTE] I don't quite get what you mean by number 1. Can I have another example in code?
Anyone knows any API that could show me how many players a server currently has?
Hey guys I've been trying to make a lock-on script (the end goal is something sorta like dark souls). The code [i]works[/i] but it doesn't stay locked on, it just forces your view on the enemy for a split second. Theres more in the script than this, but this is the code in question for it calling the lock on [lua]locktarget = nil locktoggle = false function Lock_On(ply) if locktoggle == true then locktoggle = false return else locktoggle = true local ent = GetClosest(ply) locktarget = ent-- != 0 and ent or nil if locktarget != nil then ply:SetEyeAngles((GetEnemyPos(locktarget) - ply:GetShootPos()):Angle()) end end end[/lua] (It's called by a console command, meant to be bound to a key) I've tried making an if statement for when locktoggle == true outside a function, putting a loop inside the function on SetEyeAngles, among a couple other things but no dice. Anyone know how I could make the camera/your view stay aimed at the enemy until you press the bound key a second time? (I'm thinking a way to repeatedly call "ply:SetEyeAngles((GetEnemyPos(locktarget) - ply:GetShootPos()):Angle())" but that may not be the best way) It could be something obvious but I just can't figure it out, figured this didn't deserve it's own thread.
well, you are doing it right for the most part. you need a think hook or something to constantly set the user's eye angles otherwise the player can just modify them. i suggest using a CalcView hook instead, and just override the angles if the locktarget and locktoggle are valid.
[QUOTE=Icebrigade;48553021]Hey guys I've been trying to make a lock-on script (the end goal is something sorta like dark souls). The code [i]works[/i] but it doesn't stay locked on, it just forces your view on the enemy for a split second. Theres more in the script than this, but this is the code in question for it calling the lock on [lua]locktarget = nil locktoggle = false function Lock_On(ply) if locktoggle == true then locktoggle = false return else locktoggle = true local ent = GetClosest(ply) locktarget = ent-- != 0 and ent or nil if locktarget != nil then ply:SetEyeAngles((GetEnemyPos(locktarget) - ply:GetShootPos()):Angle()) end end end[/lua] (It's called by a console command, meant to be bound to a key) I've tried making an if statement for when locktoggle == true outside a function, putting a loop inside the function on SetEyeAngles, among a couple other things but no dice. Anyone know how I could make the camera/your view stay aimed at the enemy until you press the bound key a second time? (I'm thinking a way to repeatedly call "ply:SetEyeAngles((GetEnemyPos(locktarget) - ply:GetShootPos()):Angle())" but that may not be the best way) It could be something obvious but I just can't figure it out, figured this didn't deserve it's own thread.[/QUOTE] You need to use hooks. Either set a variable and have the hook check for that or remove the hook when there is no target and add it when there is again.
-snip-
I have a HUD element (ammo counter) and I need it to only show when holding either weapon_pistol or weapon_smg1. The problem is that adding 1 string (weapon) works, but adding 2 doesn't. I'm not sure how to add two of them. If I add two - it either NEVER shows the ammo counter or always shows it, depends on whether I use != or ==. I tried at least five different methods (that are probably so stupid that I won't even post them) and nothing worked. [CODE] local playerwep = LocalPlayer():GetActiveWeapon():GetClass(); if playerwep != "weapon_pistol" or playerwep != "weapon_smg1" then return end [/CODE] This is the closest I got to it working, except the thing is I need SMG in there too, not just pistol. [CODE] local playerwep = LocalPlayer():GetActiveWeapon():GetClass(); if playerwep != "weapon_pistol" then return end [/CODE] Also, when the player dies it shows the "Tried to use NULL entity" error because there is no weapon when the player is dead? How should I fix that? if Player:Alive()?
[QUOTE=Twistai;48559606]I have a HUD element (ammo counter) and I need it to only show when holding either weapon_pistol or weapon_smg1. The problem is that adding 1 string (weapon) works, but adding 2 doesn't. I'm not sure how to add two of them. If I add two - it either NEVER shows the ammo counter or always shows it, depends on whether I use != or ==. I tried at least five different methods (that are probably so stupid that I won't even post them) and nothing worked. [CODE] local playerwep = LocalPlayer():GetActiveWeapon():GetClass(); if playerwep != "weapon_pistol" or playerwep != "weapon_smg1" then return end [/CODE] This is the closest I got to it working, except the thing is I need SMG in there too, not just pistol. [CODE] local playerwep = LocalPlayer():GetActiveWeapon():GetClass(); if playerwep != "weapon_pistol" then return end [/CODE] Also, when the player dies it shows the "Tried to use NULL entity" error because there is no weapon when the player is dead? How should I fix that? if Player:Alive()?[/QUOTE] This should do it: [code] local wep = LocalPlayer():GetActiveWeapon() if not IsValid(wep) then return end local c = wep:GetClass() if c ~= "weapon_pistol" and c ~= "weapon_smg1" then return end [/code]
[QUOTE=mijyuoon;48559670]This should do it: [code] local wep = LocalPlayer():GetActiveWeapon() if not IsValid(wep) then return end local c = wep:GetClass() if c ~= "weapon_pistol" and c ~= "weapon_smg1" then return end [/code][/QUOTE] Works like a charm now! Thank you so much! Would've never figured it out on my own. (probably)
Is there a way to make this with the surface library? [IMG]http://i.imgur.com/uPZMXeN.jpg[/IMG] Or do I have to make it as a material and go from there? The issue is the bottom right clipped corner.
[QUOTE=wranders;48560365]Is there a way to make this with the surface library? [IMG]http://i.imgur.com/uPZMXeN.jpg[/IMG] Or do I have to make it as a material and go from there? The issue is the bottom right clipped corner.[/QUOTE] I guess you could do a big box, smaller box, and a triangle but that sounds like it wouldn't be a much better option than a material.
Hi, Long time ago I did some GLUA-Coding, maybe someone can help me here I'm using [URL="http://facepunch.com/showthread.php?t=1230568"]this[/URL] and can't figure out how to pass a metatable function to a hook [CODE] local Player = FindMetaTable("Player") function Player:setMoney(amount) print(amount) -- nil print(self) -- The value which should be in "amount" self.money = amount end netstream.Hook("SetMoney", Player.setMoney) -- Is there any way I can put a metatable function in here? [/CODE] [editline]28th August 2015[/editline] This seems to work, but is there are more cleaner version of it? [CODE] netstream.Hook("SetMoney", function(amount) Player.setMoney(LocalPlayer(), amount) end) [/CODE]
[QUOTE=wranders;48560365]Is there a way to make this with the surface library? [IMG]http://i.imgur.com/uPZMXeN.jpg[/IMG] Or do I have to make it as a material and go from there? The issue is the bottom right clipped corner.[/QUOTE] [url]http://wiki.garrysmod.com/page/surface/DrawPoly[/url]
[QUOTE=johnnyaka;48560491] This seems to work, but is there are more cleaner version of it? [CODE] netstream.Hook("SetMoney", function(amount) Player.setMoney(LocalPlayer(), amount) end) [/CODE][/QUOTE] netstream.Hook("SetMoney", function(amount) LocalPlayer():setMoney(amount) end) why you are using a setmoney function for the client instead of just going like mymoney = amount is beyond me but whatever
The following does not work: function serversCommand( pl, text, teamonly ) if (text == "!servers") then ply:ConCommand( "serverslist" ) end end end hook.Add( "PlayerSay", "Chat", serversCommand ) I type in the command in chat and it recognizes the chat command, but it doesnt execute the console command.
[QUOTE=PopeFaggotini;48561140]The following does not work: function serversCommand( pl, text, teamonly ) if (text == "!servers") then ply:ConCommand( "serverslist" ) end end end hook.Add( "PlayerSay", "Chat", serversCommand ) I type in the command in chat and it recognizes the chat command, but it doesnt execute the console command.[/QUOTE] The argument is pl but you are using ply
[QUOTE=James xX;48561158]The argument is pl but you are using ply[/QUOTE] Oops, I fixed that but it still doesn't work. I swear I'm blind today, I had an extra 'end' Thanks!
1. Open context menu that has a dtextentry parented to it 2. Click in the input box to write 3. Let go of C (context menu) 4. Now it's impossible to exit out of the menu or gmod (the menu doesn't respond to anything) 5. what do?
What is this error finally about? :( [IMG]http://puu.sh/jS0pL/2b361fcede.png[/IMG] I just installed some new addons and some clients are crashing with this error appearing? Could anybody help me out with this? [editline]28th August 2015[/editline] Can this be caused by a map?
[QUOTE=P4sca1;48563013]What is this error finally about? :( [IMG]http://puu.sh/jS0pL/2b361fcede.png[/IMG] I just installed some new addons and some clients are crashing with this error appearing? Could anybody help me out with this? [editline]28th August 2015[/editline] Can this be caused by a map?[/QUOTE] I've noticed this happens when a decal is applied to a high poly car, such as a lot of those existing on the workshop. For example, when bug bait was thrown at one of these cars, all the players around it would crash.
[QUOTE=Jeezy;48563086]I've noticed this happens when a decal is applied to a high poly car, such as a lot of those existing on the workshop. For example, when bug bait was thrown at one of these cars, all the players around it would crash.[/QUOTE] The crash often happens on TTT for me, with no cars installed. Is there a fix for this?
[QUOTE=P4sca1;48563111]The crash often happens on TTT for me, with no cars installed. Is there a fix for this?[/QUOTE] Are you using any custom player models by chance? I could be wrong but poorly created collision models could be at play here.
[QUOTE=Jeezy;48563136]Are you using any custom player models by chance? I could be wrong but poorly created collision models could be at play here.[/QUOTE] Yes, I am. I figured out that the crashes are more often on a specific map. Maybe the map is the problem ^^
[QUOTE=P4sca1;48563155]Yes, I am. I figured out that the crashes are more often on a specific map. Maybe the map is the problem ^^[/QUOTE] Not sure about that, could just be a coincidence, but then again I don't know. If it becomes unbearable, I'd suggest removing all the custom player models, and adding them in one by one until the crashes begin to happen again. After figuring out the culprit(s), maybe the author(s) will attempt to fix it. [IMG]http://www.facepunch.com/fp/ratings/rainbow.png[/IMG]
[QUOTE=Jeezy;48563175]Not sure about that, could just be a coincidence, but then again I don't know. If it becomes unbearable, I'd suggest removing all the custom player models, and adding them in one by one until the crashes begin to happen again. After figuring out the culprit(s), maybe the author(s) will attempt to fix it. [IMG]http://www.facepunch.com/fp/ratings/rainbow.png[/IMG][/QUOTE] Okay, thanks for your help! :)
[QUOTE=P4sca1;48563225]Okay, thanks for your help! :)[/QUOTE] What map, it could be either custom models in that map or they are/were shitty mappers and managed to fuck up badly. I don't think I've ever gotten this before in TTT.
Sorry, you need to Log In to post a reply to this thread.