• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=HumbleTH;45683343]Anyone?[/QUOTE] you set the __index of mt to methods, which is empty just guessing, but you may have to do something like [lua] mt.__index = function(tab, key) return tab[key] or table[key] end [/lua]
[QUOTE=PortalGod;45683388]you set the __index of mt to methods, which is empty just guessing, but you may have to do something like [lua] mt.__index = function(tab, key) return tab[key] or table[key] end [/lua][/QUOTE] Huh, I first tried just using mt as the table, without the members table, which didn't work, so i tried to make it match with maurits' example on the old wiki. Will try this, thanks for the answer!
Been trying to work on this code to get it a certain way for Pointshop. It's a traitor/detective buy, I've been trying to add a cooldown for 10 rounds, also something that will autoholster it, and not allow the player to reholster until the 10 rounds are up, however it does not sell the item when it's used. I'm not familiar with PointShop. Halp. Please. Traitor --------- [CODE]ITEM.Name = 'Make Traitor' ITEM.Price = 20000 ITEM.Model = 'models/props_c17/SuitCase_Passenger_Physics.mdl' ITEM.OneUse = false function ITEM:OnEquip(ply, modifications) hook.Add("TTTBeginRound", ply:UniqueID() .. "_traitor", function() if ply:GetRoleString() != "traitor" then ply:SetRole(ROLE_TRAITOR) ply:AddCredits(GetConVarNumber("ttt_credits_starting")) end hook.Add("TTTEndRound") hook.Remove("TTTBeginRound", ply:UniqueID() .. "_traitor") end) end function ITEM:OnHolster(ply) hook.Remove("TTTBeginRound", ply:UniqueID() .. "_traitor") end function ITEM:OnSell(ply) hook.Remove("TTTBeginRound", ply:UniqueID() .. "_traitor") end[/CODE] Detective --------- [CODE]ITEM.Name = 'Make Detective' ITEM.Price = 15000 ITEM.Model = 'models/props_c17/SuitCase_Passenger_Physics.mdl' ITEM.OneUse = false function ITEM:OnEquip(ply, modifications) hook.Add("TTTBeginRound", ply:UniqueID() .. "_detective", function() if ply:GetRoleString() != "detective" then ply:SetRole(ROLE_DETECTIVE) ply:AddCredits(GetConVarNumber("ttt_credits_starting")) end hook.Remove("TTTBeginRound", ply:UniqueID() .. "_detective") end) end function ITEM:OnHolster(ply) hook.Remove("TTTBeginRound", ply:UniqueID() .. "_detective") end function ITEM:OnSell(ply) hook.Remove("TTTBeginRound", ply:UniqueID() .. "_detective") end[/CODE]
Is ULX the only way to set rank of offline players via steamids?
[QUOTE=Giraffen93;45687631]Is ULX the only way to set rank of offline players via steamids?[/QUOTE] It's only changing the rank in the database, you can do it in any admin mod if you can modify the data.
[QUOTE=Pandaman09;45687752]It's only changing the rank in the database, you can do it in any admin mod if you can modify the data.[/QUOTE] but considering it has to reload in realtime if the user is on anyway, using direct database access wouldn't work i think fadmin would work actually, seeing in the code
[QUOTE=HumbleTH;45683666]Huh, I first tried just using mt as the table, without the members table, which didn't work, so i tried to make it match with maurits' example on the old wiki. Will try this, thanks for the answer![/QUOTE] Now getting stack overflow [lua] [ERROR] lua/autorun/table-meta.lua:5: stack overflow 1. __index - lua/autorun/table-meta.lua:5 2. __index - lua/autorun/table-meta.lua:5 3. __index - lua/autorun/table-meta.lua:5 4. __index - lua/autorun/table-meta.lua:5 5. __index - lua/autorun/table-meta.lua:5 6. __index - lua/autorun/table-meta.lua:5 7. __index - lua/autorun/table-meta.lua:5 8. __index - lua/autorun/table-meta.lua:5 9. __index - lua/autorun/table-meta.lua:5 10. __index - lua/autorun/table-meta.lua:5 11. __index - lua/autorun/table-meta.lua:5 12. __index - lua/autorun/table-meta.lua:5 13. __index - lua/autorun/table-meta.lua:5 14. __index - lua/autorun/table-meta.lua:5 15. __index - lua/autorun/table-meta.lua:5 16. __index - lua/autorun/table-meta.lua:5 [/lua]
[QUOTE=HumbleTH;45687921]Now getting stack overflow [lua] [ERROR] lua/autorun/table-meta.lua:5: stack overflow 1. __index - lua/autorun/table-meta.lua:5 2. __index - lua/autorun/table-meta.lua:5 3. __index - lua/autorun/table-meta.lua:5 4. __index - lua/autorun/table-meta.lua:5 5. __index - lua/autorun/table-meta.lua:5 6. __index - lua/autorun/table-meta.lua:5 7. __index - lua/autorun/table-meta.lua:5 8. __index - lua/autorun/table-meta.lua:5 9. __index - lua/autorun/table-meta.lua:5 10. __index - lua/autorun/table-meta.lua:5 11. __index - lua/autorun/table-meta.lua:5 12. __index - lua/autorun/table-meta.lua:5 13. __index - lua/autorun/table-meta.lua:5 14. __index - lua/autorun/table-meta.lua:5 15. __index - lua/autorun/table-meta.lua:5 16. __index - lua/autorun/table-meta.lua:5 [/lua][/QUOTE] Of course you are; you're indexing your table within your __index metamethod, it's going to keep calling itself. Try using the rawget( table, index ) function. I imagine that's why those functions were made. [url]http://www.lua.org/pil/13.4.1.html[/url]
[QUOTE=Giraffen93;45687766]but considering it has to reload in realtime if the user is on anyway, using direct database access wouldn't work i think fadmin would work actually, seeing in the code[/QUOTE] You don't have to reload in real time if you are not reading from the database for every action. You should be using the database as a 'backup' with a lua table holding all of the information for realtime use. You can then either update the database when there is a change, number of changes, or after a set interval.
I need to remove a table out of a table. But I can't do that using table.remove(table, {ply, text, time}). How can I remove the table I want from the table?
[QUOTE=Darrell;45692204]I need to remove a table out of a table. But I can't do that using table.remove(table, {ply, text, time}). How can I remove the table I want from the table?[/QUOTE] Show your table structure
That is my whole table structure. table = {} function AddToTable(ply, text, time) table.insert(table, {ply, text, time}) end function RemoveFromTable(ply, text, time) table.remove(table, {ply, text, time}) end EDIT: Just caught the error. I was creating a new table. So, it got a new ID. I also switched table.remove to table.RemoveByValue Thanks anyway!
I have a table that describes difficulty settings for reasons. I want to know how I can get the name of the variable, rather than just the value. I'll explain more specifically; [code]Impossible = {} Impossible[ "sk_strider_num_missiles1" = 15 ] Impossible[ "sk_strider_num_missiles2" = 15 ] Impossible[ "sk_strider_num_missiles3" = 15 ] Impossible[ "sk_gunship_health_increments" = 13 ][/code] While doing a for loop through all values under the 'Impossible' table I want to figure out the name of the variable, not just the value. I don't want to find 13, I want to find "sk_gunship_health_increments" How do I find 'sk_gunship_health_increments' in my 'Impossible' table, and not just its value? Please don't tell me it's 'Impossible' My code is surely written wrong, but that's not the point.
[QUOTE=WalkingZombie;45692514]I have a table that describes difficulty settings for reasons. I want to know how I can get the name of the variable, rather than just the value. I'll explain more specifically; [code]Impossible = {} Impossible[ "sk_strider_num_missiles1" = 15 ] Impossible[ "sk_strider_num_missiles2" = 15 ] Impossible[ "sk_strider_num_missiles3" = 15 ] Impossible[ "sk_gunship_health_increments" = 13 ][/code] While doing a for loop through all values under the 'Impossible' table I want to figure out the name of the variable, not just the value. I don't want to find 13, I want to find "sk_gunship_health_increments" How do I find 'sk_gunship_health_increments' in my 'Impossible' table, and not just its value? Please don't tell me it's 'Impossible' My code is surely written wrong, but that's not the point.[/QUOTE] When you are doing: [code]for k, v in pairs ()[/code] Which is basically [code]for key, value in pairs ()[/code] key represents your name. Also a weird thing tho, it's the first time I am seeing someone register a table this way, aka by putting: tbl[ key = value ] I am not sure if it works.
[QUOTE=Netheous;45692565]When you are doing: [code]for k, v in pairs ()[/code] Which is basically [code]for key, value in pairs ()[/code] key represents your name. Also a weird thing tho, it's the first time I am seeing someone register a table this way, aka by putting: tbl[ key = value ] I am not sure if it works.[/QUOTE] You mean Table[ "key" = value ] ??? Just as insurance I've corrected it to be Table[ "key" ] = value, however I think that might be something to test... maybe ALSO: Thank you! Can't believe I overlooked that, but I assumed key would've just been the index? So it is NOT Impossible to utilize an 'Impossible' table! :smile:
[QUOTE=WalkingZombie;45692612]You mean Table[ "key" = value ] ??? Just as insurance I've corrected it to be Table[ "key" ] = value, however I think that might be something to test... maybe ALSO: Thank you! Can't believe I overlooked that, but I assumed key would've just been the index?[/QUOTE] No problem.
Is there any way to build a single entity out of multiple props (with only lua)?
[QUOTE=Larnecse;45692640]Is there any way to build a single entity out of multiple props (with only lua)?[/QUOTE] Yes, with parenting.
[QUOTE=Netheous;45692654]Yes, with parenting.[/QUOTE] Thanks.
[QUOTE=Larnecse;45692640]Is there any way to build a single entity out of multiple props (with only lua)?[/QUOTE] Parenting, as [URL="http://facepunch.com/member.php?u=225670"]Netheous[/URL] said, or I believe you can render models client-side, but they won't have any physics behavior at all. Post note, when something is parented to something else there is a little considerable lag between movements, over quite a few frames. I've heard about this thing called bone following, but that might not work with an average prop (although an average prop does technically have ONE bone)
[QUOTE=WalkingZombie;45692679]Parenting, as [URL="http://facepunch.com/member.php?u=225670"]Netheous[/URL] said, or I believe you can render models client-side, but they won't have any physics behavior at all. Post note, when something is parented to something else there is a little considerable lag between movements, over quite a few frames. I've heard about this thing called bone following, but that might not work with an average prop (although an average prop does technically have ONE bone)[/QUOTE] Actually, I've noticed that it doesn't occur on all servers, it might be their high tick causing it.
[QUOTE=Netheous;45692735]Actually, I've noticed that it doesn't occur on all servers, it might be their high tick causing it.[/QUOTE] Yet why take the risk?
I have no clue how to do this but how can I completely disable keyboard and mouse so I can reset the controls. I want to re-code the wasd to do my own custom functions and I don't want the mouse to have any part in aiming. I already know I will probably need to use the hook heavily: [url]http://wiki.garrysmod.com/page/GM/KeyPress[/url] --Just found what I think I was looking for: [url]http://wiki.garrysmod.com/page/GM/Move[/url]
is it possible to filter a player's voice to sound like its coming through a radio/telephone/etc ?
[QUOTE=Arizard;45694686]is it possible to filter a player's voice to sound like its coming through a radio/telephone/etc ?[/QUOTE] There are DSP effects you can play with, but they aren't really designed to do what you are specifically trying to do. They modify all of the sounds for things like tunnels, explosions, etc. I don't believe there is a way to specifically play with the voice channels.
[QUOTE=WalkingZombie;45693540]Yet why take the risk?[/QUOTE] How is that a risk lol?
How can I freeze a player's movement without freezing their third-person camera rotation? I've already figured out how to stop them from jumping, but moving around is still a problem. I tried Player:SetMaxSpeed( 0 ) but that did nothing. Will I need to use SetWalkSpeed and SetRunSpeed instead? It'd be much easier if there was some hook that controlled movement (and jumping?) I could just return a boolean to, but I haven't had any luck finding one.
[QUOTE=zeaga;45701408]How can I freeze a player's movement without freezing their third-person camera rotation? I've already figured out how to stop them from jumping, but moving around is still a problem. I tried Player:SetMaxSpeed( 0 ) but that did nothing. Will I need to use SetWalkSpeed and SetRunSpeed instead? It'd be much easier if there was some hook that controlled movement (and jumping?) I could just return a boolean to, but I haven't had any luck finding one.[/QUOTE] Move and CreateMove should work, I think
[QUOTE=HumbleTH;45702212]Move and CreateMove should work, I think[/QUOTE] I'm sorry, but I'm actually a bit confused as to how the drive library works. How would I use move data? Thanks for the help.
[QUOTE=zeaga;45702318]I'm sorry, but I'm actually a bit confused as to how the drive library works. How would I use move data? Thanks for the help.[/QUOTE] I meant the hooks, didn't even know those functions existed. Sorry for the confusion [url]http://wiki.garrysmod.com/page/GM/CreateMove[/url]
Sorry, you need to Log In to post a reply to this thread.