• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
When adding a particle how will you know the name of it?..
I need help with net/return [lua]function CSSAskForCommand(command) local value = -1 net.Start("CSSAskForCommand") net.WriteString(command) net.SendToServer() net.Receive("CSSGetCommand", function(len,ply) value = net.ReadFloat() end) return value end[/lua] What I'm trying to do is make it return the float that was read from value in net.Recieve. I'm just trying to grab the server's current convar of something, it does return the correct value so that works. Or if there is an easier way of getting a convar from a server if you're a client, please let me know.
[QUOTE=ROFLBURGER;46557771]I need help with net/return [lua]function CSSAskForCommand(command) local value = -1 net.Start("CSSAskForCommand") net.WriteString(command) net.SendToServer() net.Receive("CSSGetCommand", function(len,ply) value = net.ReadFloat() end) return value end[/lua] What I'm trying to do is make it return the float that was read from value in net.Recieve. I'm just trying to grab the server's current convar of something, it does return the correct value so that works. Or if there is an easier way of getting a convar from a server if you're a client, please let me know.[/QUOTE] please don't do this.. if you really want to at least don't allow them to ask for ANY convar
Also having trouble with returning net stuff like done above. Printing the result works, but for example, pnl:RunJavascript( somefunction( net.ReadString()) ) does not work.
[QUOTE=MeepDarknessM;46557841]please don't do this.. if you really want to at least don't allow them to ask for ANY convar[/QUOTE] Well it's for certain commands only which is controlled by the serverside portion of the code... [editline]23rd November 2014[/editline] It's for a menu that only admins can access. They can modify settings from my swep pack without having to use rcon
[code] local currentcallback = function() end; net.Receive("CSSGetCommand", function() currentcallback(); end) function CSSGetCommand(name, callback) -- request stuff currentcallback = callback; end [/code] [code] CSSGetCommand("rcon_password", function() local str = net.ReadString(); -- stuff end) [/code]
So I'm betting that there is a really easy way to do this but I can't for the life of me figure out how to. Is there a way way for me to check what Material a world brush has. So for an example I want to be able to create a console Command aim and the ground and see what that Material is. -edit I'm dumb I found it. [url]http://wiki.garrysmod.com/page/Structures/TraceResult[/url]
[QUOTE=MeepDarknessM;46557928][code] local currentcallback = function() end; net.Receive("CSSGetCommand", function() currentcallback(); end) function CSSGetCommand(name, callback) -- request stuff currentcallback = callback; end [/code] [code] CSSGetCommand("rcon_password", function() local str = net.ReadString(); -- stuff end) [/code][/QUOTE] what
[QUOTE=ROFLBURGER;46557963]what[/QUOTE] that's how you are supposed to do it - as a callback. since lua strings/numbers are not passed by reference you can't just return a variable that's set in a callback
This is what I have on the serverside end [lua]net.Receive("CSSAskForCommand", function(len,ply) local command = net.ReadString() if string.sub(command, 1, 5) == "sv_css" then local value = GetConVarNumber(command) net.Start("CSSGetCommand") net.WriteFloat(value) net.WriteEntity(ply) net.Broadcast() end end) [/lua] 1. It can only retrieve numbers. Rcon Passwords are usually strings 2. it's only limited to commands that start with sv_css [editline]23rd November 2014[/editline] Idk I'm just really confused because I'm not sure if you're trying to convince me that my code is hackable or you're actually trying to help [editline]23rd November 2014[/editline] And I don't even understand the code that you pasted. I'm just going to relax for a few hours while I try to wrap my head around this
[QUOTE=ROFLBURGER;46557963]what[/QUOTE] the net library is asynchronous, which means that you can't expect it to be done in the same frame. most networking stuff is asynchronous, because if it wasn't it would stop your entire script from running while it waited for a response. because it isn't run in the same frame, in your code: [lua]function CSSAskForCommand(command) local value = -1 net.Start("CSSAskForCommand") net.WriteString(command) net.SendToServer() --though this gets sent this frame, the server will not receive it at the exact moment it's sent --because of this, it won't reply until it gets that message, and you won't get its reply until after that net.Receive("CSSGetCommand", function(len,ply) value = net.ReadFloat() --this will not be run for at least 2 frames end) return value --value is -1 end[/lua] the proper way to handle this is by using callbacks, like meep said: [lua] function CSSAskForCommand(command, callback) net.Start("CSSAskForCommand") net.WriteString(command) net.SendToServer() net.Receive("CSSGetCommand", callback) end [/lua] you might have to do more so that calling the function more than once doesn't overwrite the net.Receive, but I'm not sure
You can just create a convar with the FCVAR_REPLICATED flag on both the client and server. That way you can use the convar as normal clientside.
[QUOTE=PortalGod;46558030]the net library is asynchronous, which means that you can't expect it to be done in the same frame. most networking stuff is asynchronous, because if it wasn't it would stop your entire script from running while it waited for a response. because it isn't run in the same frame, in your code: [lua]function CSSAskForCommand(command) local value = -1 net.Start("CSSAskForCommand") net.WriteString(command) net.SendToServer() --though this gets sent this frame, the server will not receive it at the exact moment it's sent --because of this, it won't reply until it gets that message, and you won't get its reply until after that net.Receive("CSSGetCommand", function(len,ply) value = net.ReadFloat() --this will not be run for at least 2 frames end) return value --value is -1 end[/lua] the proper way to handle this is by using callbacks, like meep said: [lua] function CSSAskForCommand(command, callback) net.Start("CSSAskForCommand") net.WriteString(command) net.SendToServer() net.Receive("CSSGetCommand", callback) end [/lua] you might have to do more so that calling the function more than once doesn't overwrite the net.Receive, but I'm not sure[/QUOTE] It's going to be called within quick succession. When you open up this one derma menu, it will gather all the functions it needs to gather. [QUOTE=Willox;46558074]You can just create a convar with the FCVAR_REPLICATED flag on both the client and server. That way you can use the convar as normal clientside.[/QUOTE] I did this [code]CreateConVar("sv_css_damage_scale", "1", FCVAR_REPLICATED + FCVAR_ARCHIVE , "This is the value that all damage from CSS weapons is multiplied. Default is 1." )[/code] What do you mean "as normal clientside". When I posted this problem before someone told me to use net so here I am.
[QUOTE=ROFLBURGER;46558108]It's going to be called within quick succession. When you open up this one derma menu, it will gather all the functions it needs to gather. I did this [code]CreateConVar("sv_css_damage_scale", "1", FCVAR_REPLICATED + FCVAR_ARCHIVE , "This is the value that all damage from CSS weapons is multiplied. Default is 1." )[/code] What do you mean "as normal clientside". When I posted this problem before someone told me to use net so here I am.[/QUOTE] You'd do something like this on both the client and server. [code] sv_css_damage_scale = CreateConVar("sv_css_damage_scale", "1", FCVAR_REPLICATED + FCVAR_ARCHIVE , "This is the value that all damage from CSS weapons is multiplied. Default is 1." ) print( sv_css_damage_scale:GetFloat() ) [/code]
Where did you guys lean SQLite or MySQL to incorporate it into gmod?
[url]https://www.sqlite.org/docs.html[/url] [url]http://dev.mysql.com/doc/refman/5.6/en/[/url]
I've been remaking the pokeball addon of mine (from scratch) that originally was just a 'fix up' from an old one from garrysmod.org and I'm having some issues with spawning the SEnt. It supposedly has a 'client prediction issue' and that's because when I have the SWEP 'throw' it, the SENT will stop for a moment, then move accordingly on the server. When the physgun grabs the SEnt, it grabs where the pokeball is on the Client not the Server. I don't know how to fix this, as it doesn't make sense why it would have this issue. SEnt: [url]http://pastebin.com/YsLndUgU[/url] SWep: [url]http://pastebin.com/4n6GRziu[/url]
Any way to make a textbox resize depending on the text inside it? EDIT: Never mind.
Is there anyway i can shorten the length of the Distance number at the moment its, 10.125172508127124, i know it has something to do with string.format but i just can't get my head around it, anyone got any ideas?
[QUOTE=Invule;46561303]Is there anyway i can shorten the length of the Distance number at the moment its, 10.125172508127124, i know it has something to do with string.format but i just can't get my head around it, anyone got any ideas?[/QUOTE] Taken from [url]http://www.lua.org/pil/20.html:[/url] [lua] print(string.format("pi = %.4f", PI)) --> pi = 3.1416 [/lua] "the %.4f means a floating-point number with four digits after the decimal point."
[QUOTE=Sereni;46561342]Taken from [url]http://www.lua.org/pil/20.html:[/url] [lua] print(string.format("pi = %.4f", PI)) --> pi = 3.1416 [/lua] "the %.4f means a floating-point number with four digits after the decimal point."[/QUOTE] Thank you.
Quick question, when using the Remove( ) command on a Derma element does it also remove any memory associated with the Derma element? I am pretty sure it does but I just want to be sure.
[QUOTE=residualgrub;46563274]Quick question, when using the Remove( ) command on a Derma element does it also remove any memory associated with the Derma element? I am pretty sure it does but I just want to be sure.[/QUOTE] Yep, it does. Generally you don't reeaally have to worry about Memory Leaks.
[QUOTE=freakyy;46563703]Yep, it does. Generally you don't reeaally have to worry about Memory Leaks.[/QUOTE] I forgot to run Remove() on a DHTML, every time someone would open the MOTD it created another awesomium process which never ended.
[QUOTE=freakyy;46563703]Yep, it does. Generally you don't reeaally have to worry about Memory Leaks.[/QUOTE] Ok thanks. I just wanted to make sure I wasn't leaving useless memory around when running that command.
How can make it so it automatically scales text smaller if its bigger than a rounded box
I'm trying to animate a scripted entity, and so far no luck. Right now I'm just calling self:FrameAdvance( FrameTime() ) inside ENT.Draw, but it's not playing the animation - can't find anything showing how to use it outside of DModelPanel. Background info, if it's needed, the base for the entity is just base_entity - and it's just a normal prop. Displaying it with a DModelPanel animates it properly. Can anyone tell me what I'm doing wrong?
Are rotated hull traces a thing?
[QUOTE=TheMrFailz;46554829]*Just started getting the thing together and forgot to set the pos to the ent1pos. Realized that immediately after posting. Also, I fixed the global ent pos bit. Will report back with how fixing it all up went. edit: And god I wish entities auto updated when their lua code was changed like with sweps and what not. It gets annoying when you have to wait 30 seconds to a minute for an entity reload because you need to make a tiny change. Edit: Woo it works. Thanks Ace.[/QUOTE] You don't need to wait for it to reload. If you update weapons, ents, etc... delete the entity that is on the server and spawn a new one after you make the change. The new one will be using the most recent code.
What's the most reliable way to detect if a prop overlaps with another prop, even if they don't collide with each other?
Sorry, you need to Log In to post a reply to this thread.