• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=Roag15;47312117]I understand how to create a font, this isn't the problem, but thanks anyway. I meant I need the font to stay fitting in the HUD regardless of the client's resolution, because I'm also scaling the background. The HUD looks fine on my resolution (1920,1080) and the background and HUD bars scale just fine when I change resolution, however the text does not.[/QUOTE] Use ScreenScale for the font size. Ex: surface.CreateFont( "goldhudname", { font = segoeui, size = ScreenScale(8), antialias = true, weight = 650 }) Hope I help :)
[code] for k, v in pairs(table) do net.WriteTable(v) end [/code] [quote] [ERROR] lua/includes/modules/net.lua:161: net.WriteType: Couldn't write function (type 6) [/quote] Does anyone know what I'm doing wrong here?
Is there a way to limit the amount of characters that can be inputted to a text field?
[QUOTE=NiandraLades;47312374][code] for k, v in pairs(table) do net.WriteTable(v) end [/code] Does anyone know what I'm doing wrong here?[/QUOTE] [url]http://wiki.garrysmod.com/page/Category:table[/url] You're iterating over the global table library. :v:
[QUOTE=NiandraLades;47312374][code] for k, v in pairs(table) do net.WriteTable(v) end [/code] Does anyone know what I'm doing wrong here?[/QUOTE] The table you are trying to send, does it contain functions?
[QUOTE=NiandraLades;47312374][code] for k, v in pairs(table) do net.WriteTable(v) end [/code] Does anyone know what I'm doing wrong here?[/QUOTE] Using net.WriteTable :v: But really, type 6 is a function so it seems you are trying to send a function.
Yeah, okay, I'm gonna go into more detail cuz I'm making a mess I'm basically creating a menu where you can preform serverside stuff on a player by pressing a button, i.e kill them. I've got a folder of plugin files, which have info and then a function that takes the current player who pressed the button and another as an argument. I can grab these locally from the menu and have sent them to the server via net.ReadEntity, this all prints fine. The menu loops through a table and displays each button via that but I honestly can't figure out how to actually, like, run the function serverside with both of these values, especially since it needs to work in the loop with each individual button So better question, how the fuck do I send a function through the net library or what's a good method to tackle this? i'm probably overcomplicating this fuck
Emitting a sound within a room but not out of the room, possible? I haven't been able to find a sound value that works for the range I'm looking for (I guess according to the wiki these are varies dbs that have been made for hl2 sounds) Anyways, just wondering! Thanks in advanced.
[QUOTE=NiandraLades;47312448] So better question, how the fuck do I send a function through the net library or what's a good method to tackle this?[/QUOTE] you don't unless you send the lua to the server via writestring and have the source code edit: best browser & os edit: a mod removed my os & browser :(
[QUOTE=NiandraLades;47312448]-things-[/QUOTE] You are going about it the complete wrong way. Why do you need to send a function to the client? That doesnt make any sense. Why dont you send a function [b]name[/b] instead and have the client call it?
How do I get a tool's client number without using Self? [CODE] local testvar = tobool( self:GetClientNumber( "test_variable" ) ) [/CODE] I had an idea-the part below-but I'm pretty sure the idea only gets the serverside var. [CODE] local testvar = tobool( GetConVarNumber( "test_variable" ) ) [/CODE]
[IMG]https://dl.dropboxusercontent.com/u/8081284/ShareX/2015/03/2015-03-12_23-48-23.png[/IMG] For some reason when you use [URL="http://wiki.garrysmod.com/page/Entity/GetClass"]Entity:GetClass()[/URL] on func_button entities it returns "class C_BaseEntity"? Edit: It's only clientside issue. [IMG]https://dl.dropboxusercontent.com/u/8081284/ShareX/2015/03/2015-03-12_23-55-53.png[/IMG]
[QUOTE=edgarasf123;47313814][IMG]https://dl.dropboxusercontent.com/u/8081284/ShareX/2015/03/2015-03-12_23-48-23.png[/IMG] For some reason when you use [URL="http://wiki.garrysmod.com/page/Entity/GetClass"]Entity:GetClass()[/URL] on func_button entities it returns "class C_BaseEntity"? Edit: It's only clientside issue. [IMG]https://dl.dropboxusercontent.com/u/8081284/ShareX/2015/03/2015-03-12_23-55-53.png[/IMG][/QUOTE] Because it is a serverside entity ( Like most brush and point entities are ), on client it only has properties of a base entity.
[QUOTE=NiandraLades;47312448]overcomplicating shit[/QUOTE] Make your plugin files shared.
Can I please have some help too?
[QUOTE=StonedPenguin;47314062]Make your plugin files shared.[/QUOTE] Mhm, this I already have, as it allows me to put plugin details onto the menu itself. I'm not on my desktop right now, but this is roughly how I have it set up. Plugin example: [code] Plugin.Name = "Kill" Plugin.Tooltip = "Kill the player" function Plugin:CallFunction(ply, target) target:Kill() end [/code] Menu example: [code] local loop = 0 for k, v in pairs(plugin_table) do local button = vgui.Create("DButton") button:SetText(k) button:SetToolTip(v.Tooltip) button.DoClick = function() local ply = LocalPlayer() local t = LocalPlayer():GetTargetUser() v:CallFunction(ply, t) end loop = loop + 1 end [/code] So if the CallFunction inside the plugin has client-side stuff, i.e [code] function Plugin:CallFunction(ply, target) chat.AddText(Color(255,255,255), ply:Nick(), Color(255,255,255), target:Nick()) end [/code] It works PERFECTLY fine (prints the two nicknames into chat), but obviously I get clientside errors about Kill() not existing if I try the first example. So, like, that's what I was trying to figure out - how to preform that button's function serverside. Like obviously I can send LocalPlayer() and their target serverside very easily via net.WriteEntity, but wasn't sure how to tackle the next bit. Apologies for the awful explaining and thanks for the help so far!
[QUOTE=NiandraLades;47315140]-sneep[/QUOTE] Firstly, when you're registering your plugins, are you looping through them in order? You can use a number of helper functions to loop through a table based on alphabetical order - have a look. Now you're probably storing them in a table, right? So why not give them an identification number based on their position in that table? so when you're storing the plugins, [LUA] plugin_table[#plugin_table + 1] = PLUGIN PLUGIN.id = #plugin_table [/LUA] you will give each plugin a lookup id that will be the same on client and server (assuming you're registering in the same order!). Excellent! So now that you have a single digit ID for each plugin, which is the same on both realms and can be used to retrieve the plugin, what would be a better way to communicate the selected plugin?
Aw, that's a good idea! Thank you very much, I'll try this method
[QUOTE=NiandraLades;47315140]Mhm, this I already have, as it allows me to put plugin details onto the menu itself. I'm not on my desktop right now, but this is roughly how I have it set up. Plugin example: [code] Plugin.Name = "Kill" Plugin.Tooltip = "Kill the player" function Plugin:CallFunction(ply, target) target:Kill() end [/code] Menu example: [code] local loop = 0 for k, v in pairs(plugin_table) do local button = vgui.Create("DButton") button:SetText(k) button:SetToolTip(v.Tooltip) button.DoClick = function() local ply = LocalPlayer() local t = LocalPlayer():GetTargetUser() v:CallFunction(ply, t) end loop = loop + 1 end [/code] So if the CallFunction inside the plugin has client-side stuff, i.e [code] function Plugin:CallFunction(ply, target) chat.AddText(Color(255,255,255), ply:Nick(), Color(255,255,255), target:Nick()) end [/code] It works PERFECTLY fine (prints the two nicknames into chat), but obviously I get clientside errors about Kill() not existing if I try the first example. So, like, that's what I was trying to figure out - how to preform that button's function serverside. Like obviously I can send LocalPlayer() and their target serverside very easily via net.WriteEntity, but wasn't sure how to tackle the next bit. Apologies for the awful explaining and thanks for the help so far![/QUOTE] What you need to do is send a net message to the server, containing: 1) An unique plugin identifier, that will be the same for server and client and that will be unique to each plugin 2) Target entity Then on server when you receive the message, check if the sender is authorized to execute the command/plugin and then call Plugin:CallFunction. In your Plugin:CallFunction add if ( SERVER ) then checks if you plan to keep them shared, which i do not recommend you to do.
I'm trying to get a sub material to load from the data folder so I don't have to add the to the pre-join downloads. I have tried this: [LUA]concommand.Add("Shirt", function() local p = LocalPlayer() local mat = Material("../data/shirt_cache/example2.txt\n.vtf", "nocull smooth") CreateMaterial("shirt_example", "VertexLitGeneric", { ["$basetexture"] = mat:GetString("$basetexture") }) p:SetSubMaterial(4, "shirt_example") end)[/LUA] Where data/shirt_cache/example2.txt is a VTF file and I have also tried it with it being a PNG file. Neither of them work, and with it being a VTF file I get this error in the console: [T]http://puu.sh/gyAQM.png[/T] Is doing this even possible? If so, how would you go about getting the VMT to load too?
I don't think this is possible for .vtfs.
Can anyone tell me how I'd set a tool's header information (the text at the top left when the tool is equipped) including the descriptions/etc...? I'm too retarded to find it myself apparently
[QUOTE=VIoxtar;47316517]Can anyone tell me how I'd set a tool's header information (the text at the top left when the tool is equipped) including the descriptions/etc...? I'm too retarded to find it myself apparently[/QUOTE] Add this to the tool's Lua file, where yourstool is the name of the file itself (minus the .lua at the end of course): [code]if ( CLIENT ) then language.Add( "tool.yourstool.name", "Your Scripted Tool" ) language.Add( "tool.yourstool.desc", "A brief description of what it does" ) language.Add( "tool.yourstool.0", "Left Click: Do something | Right Click: Do something else" ) end[/code] Using self:SetStage(#) on the tool also changes which string it uses for that last one - if you set the stage to 0 (what it is by default), it'll use tool.yourstool.0; if you set the stage to 1, it'll use tool.yourstool.1, and so on, so you can use it for multi-step things like the Rope or Weld tool: [code]if ( CLIENT ) then language.Add( "tool.yourstool.name", "Your Scripted Tool Again" ) language.Add( "tool.yourstool.desc", "This one is just a copy of the rope tool, I guess" ) language.Add( "tool.yourstool.0", "Click something to attach one end of the rope" ) language.Add( "tool.yourstool.1", "Click something else to attach the other end of the rope" ) end[/code]
Im running a DarkRP server, and with the gmod update they "[I]fixed[/I]" the ammocrate on the back of the HL2 jeep. Is there any way to disable this? Preferably without editing the vehicle itself. Thanks =)
[QUOTE=Deathbypwnage;47317405]Im running a DarkRP server, and with the gmod update they "[I]fixed[/I]" the ammocrate on the back of the HL2 jeep. Is there any way to disable this? Preferably without editing the vehicle itself. Thanks =)[/QUOTE] Example 2 [url=http://wiki.garrysmod.com/page/GM/PlayerUse]here[/url].
[QUOTE=thefreeman193;47317420]Example 2 [url=http://wiki.garrysmod.com/page/GM/PlayerUse]here[/url].[/QUOTE] Where would I put that? The files for the vehicle? Thanks for the quick reply! =)
How do I get a tool's client number without using Self? [CODE] local testvar = tobool( self:GetClientNumber( "test_variable" ) ) [/CODE] I had an idea- [CODE] local testvar = tobool( GetConVarNumber( "example_test_variable" ) ) [/CODE] but I'm pretty sure that only gets the serverside number. Someone said that if I wanted it clientside, I needed to use GetConVar without 'Number' at the end, but wouldn't that still be the same? It returned a table instead of a number for me, so do I need to do something like [CODE] local testvar = tobool( GetConVar( "example_test_variable" ):GetClientNumber( "example_test_variable" ) ) [/CODE] Seems a bit dodgy to me. Note the variable was created with [CODE] TOOL.ClientConVar[ "test_variable" ] = "0" [/CODE] and the tool name (example) might be needed
[QUOTE=Deathbypwnage;47317549]Where would I put that? The files for the vehicle? Thanks for the quick reply! =)[/QUOTE] Somewhere in the gamemode, serverside. [QUOTE=MPan1;47317591]How do I get a tool's client number without using Self? [CODE] local testvar = tobool( self:GetClientNumber( "test_variable" ) ) [/CODE] I had an idea- [CODE] local testvar = tobool( GetConVarNumber( "example_test_variable" ) ) [/CODE] but I'm pretty sure that only gets the serverside number. Someone said that if I wanted it clientside, I needed to use GetConVar without 'Number' at the end, but wouldn't that still be the same? It returned a table instead of a number for me, so do I need to do something like [CODE] local testvar = tobool( GetConVar( "example_test_variable" ):GetClientNumber( "example_test_variable" ) ) [/CODE] Seems a bit dodgy to me. Note the variable was created with [CODE] TOOL.ClientConVar[ "test_variable" ] = "0" [/CODE] and the tool name (example) might be needed[/QUOTE] What in the world are you trying to do? What's wrong with self:GetClientNumber?
I need to get it for a ConCommand- e.g. [CODE] concommand.Add( "testcommand", function( ply ) local getvar = tobool( GetConVarNumber( "example_test_variable" ) ) if getvar then --Do some stuff else --Alternative stuff end [/CODE] [editline]13th March 2015[/editline] Or, a bit more of the actual code.... [CODE] --The vars TOOL.ClientConVar[ "freeze_grav_remove" ] = "0" TOOL.ClientConVar[ "legacy" ] = "0" concommand.Add( "gravityeditor_allfloat", function( ply ) if ply:IsAdmin() or ply:IsSuperAdmin() or ply:IsUserGroup( "Moderator" ) then local legacy = tobool( GetConVarNumber( "gravityeditor_legacy" ) ) local freeze_remove = tobool( GetConVarNumber( "gravityeditor_freeze_grav_remove" ) ) if legacy then local props = ents.FindByClass("prop_*") physenv.SetGravity(Vector(0,0,0)) for k, v in pairs(props) do if(v:GetPhysicsObject():IsValid()) then for i=0,v:GetPhysicsObjectCount()-1 do v:GetPhysicsObjectNum(i):EnableGravity(true) if freeze_remove then v:GetPhysicsObjectNum(i):EnableMotion(false) else v:GetPhysicsObjectNum(i):Wake() end end end end else local props = ents.FindByClass("prop_*") physenv.SetGravity(Vector(0,0,-600)) for k, v in pairs(props) do if(v:GetPhysicsObject():IsValid()) then for i=0,v:GetPhysicsObjectCount()-1 do v:GetPhysicsObjectNum(i):EnableGravity(false) if freeze_remove then v:GetPhysicsObjectNum(i):EnableMotion(false) else v:GetPhysicsObjectNum(i):Wake() end end end end end else ply:SendLua( [[chat.AddText(Color(255,0,0,255),"Sorry, only admins can take gravity from all props!")]] ) end end) function TOOL.BuildCPanel( CPanel ) --The panel simplified CPanel:AddControl( "Button", { Label = "#tool.gravityeditor.allfloat", Command = "gravityeditor_allfloat" } ) CPanel:AddControl( "CheckBox", { Label = "#tool.gravityeditor.legacy", Command = "gravityeditor_legacy", Help = true } ) CPanel:AddControl( "CheckBox", { Label = "#tool.gravityeditor.freeze_grav_remove", Command = "gravityeditor_freeze_grav_remove" } ) [/CODE] [editline]13th March 2015[/editline] It's for [URL="http://steamcommunity.com/sharedfiles/filedetails/?id=405179557"]the gravity editor.[/URL]
[QUOTE=MPan1;47317633]-snip-[/QUOTE] I think I get it. Either way, I did some poking around for ya, and found [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetInfo]Player:GetInfo[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetInfoNum]Player:GetInfoNum[/url]. Hope this helps!
Sorry, you need to Log In to post a reply to this thread.