• What do you need help with? V3
    6,419 replies, posted
Thanks for the help, Luni. That's how I will do it. :D
[QUOTE=RoopeFI;38712052]How do I hide the message it says when I change server cvar? Example: sbox_godmode 1 Server cvar value changed: sbox_godmode -> 1[/QUOTE] Little help please? :)
[QUOTE=itkuitkzhji;38722740]Thanks for the help, Luni. That's how I will do it. :D[/QUOTE] I don't think you should do it that way unless you plan on storing alot more information linked to the player, and you're using mysql on such a minor scale that optimization is the least of your worries, just do what is easiest.
[QUOTE=RoopeFI;38722797]Little help please? :)[/QUOTE] Just don't change the cvar. Use code to make the players invincible.
[QUOTE=Crazy Quebec;38722877]Just don't change the cvar. Use code to make the players invincible.[/QUOTE] This is in init.lua, it didn't give godmode so I used RunConsoleCommand("sbox_godmode", "1") [lua] function StopRound() timer.Remove("livechecktimer") timer.Remove("roundtime") print("ROUND STOPPED") timer.Create("startover", 15, 1, StartAgain) timer.Create("spawnplayers", 5, 1, SpawnPlayers) roundstarted = 0 for k,v in pairs(player.GetAll()) do v:PrintMessage( HUD_PRINTTALK, "New round starting in 15 seconds! Be prepared!") v:GodEnable() end end [/lua]
[QUOTE=zzaacckk;38722851]I don't think you should do it that way unless you plan on storing alot more information linked to the player, and you're using mysql on such a minor scale that optimization is the least of your worries, just do what is easiest.[/QUOTE] It's better than using strings as keys, depending on the scale. And if you're updating items constantly as they're added to or removed from players' inventories, it's not going to perform as well.
[QUOTE=itkuitkzhji;38722313]Hi. I'm working on an inventory system for DarkRp. It's almost done. The only thing missing is a way to save the inventory data and I want to use the Gmod sql database to do this. Here's my question: [IMG]https://photos-1.dropbox.com/t/0/AACpi-YXxRWfEwLMRiClM3IZ74t8w0mNpD6Nu6TLY9_hCQ/10/122278602/png/320x320/1/_/0/4/ScreenShot009.png/qul5ng4s0wtoih5/AzWYYT92OC/ScreenShot009.png[/IMG] This table structure doesn't feel right to me, but I can't come up with a better one. How would you do it, or is this ok?[/QUOTE] serialize the item table and save it as a string. ie: (sql table layout) Steamid -> ItemString STEAM_0:0:0 -> "item,amount;item,amount" or use JSON on the lua table of items and store that.
GetNWVector doesn't seem to be sending things to client? [lua] if SERVER then local sol = ents.Create( "barriertest" ) sol:SetPos( Ent1:GetPos() ) --sol.VERTICES = self:GetSolidMesh() local PairPos = Ent2:GetPos() local VERTICES = { Ent1:GetPos() + Vector( -1.5, -3.5, 150 ), Ent1:GetPos() + Vector(-1.5, -3.5, -30 ), PairPos + Vector( 1.5, -3.5, -30 ), PairPos + Vector( 1.5, -3.5, 150 ), Ent1:GetForward() } sol:SetNWVector("VERTICES1", Ent1:GetPos() + Vector( -1.5, -3.5, 150 )) sol:SetNWVector("VERTICES2", Ent1:GetPos() + Vector(-1.5, -3.5, -30 )) sol:SetNWVector("VERTICES3", PairPos + Vector( 1.5, -3.5, -30 )) sol:SetNWVector("VERTICES4", PairPos + Vector( 1.5, -3.5, 150 )) sol:SetNWVector("VERTICES5", Ent1:GetForward()) sol:SetParent(self) sol:Spawn() end [/lua] and the receiving code [lua] self.VERTICES = {} self.VERTICES[1] = self:GetNWVector("VERTICES1", nil) self.VERTICES[2] = self:GetNWVector("VERTICES2", nil) self.VERTICES[3] = self:GetNWVector("VERTICES3", nil) self.VERTICES[4] = self:GetNWVector("VERTICES4", nil) self.VERTICES[5] = self:GetNWVector("VERTICES5", nil) if !self.VERTICES or !next(self.VERTICES) then print("No vertices!") SafeRemoveEntity(self) return end PrintTable(self.VERTICES) [/lua] prints: (server)[code] 1 = 568.308289 609.790039 -12096.752930 2 = 568.308289 609.790039 -12276.752930 3 = 452.841248 770.396423 -12277.758789 4 = 452.841248 770.396423 -12097.758789 5 = -0.804755 -0.593606 -0.000000 [/code] (client)[code] 1 = 0.000000 0.000000 0.000000 2 = 0.000000 0.000000 0.000000 3 = 0.000000 0.000000 0.000000 4 = 0.000000 0.000000 0.000000 5 = 0.000000 0.000000 0.000000 [/code]
This might not be the answer you want but why aren't you just sending Ent1 and Ent2 to the client side (Which might not even be necessary depending on the rest of your code)?
Does this function no longer work client-side? [lua] function TabAdd() spawnmenu.AddToolTab("Name of the tab", "Unique Name") end -- Hook the Tab to the Menu hook.Add( "AddToolMenuTabs", "Unique Name", TabAdd) [/lua] I can not for the life of me getting a tab to show in q-menu...
Yeah, like someone earlier requested, I am also looking for a motion blur script when you are sprinting just to add immersion. Could anybody provide this?
[QUOTE=amkoc;38723218]GetNWVector doesn't seem to be sending things to client? [lua].[/lua][/QUOTE] Networked vars are sent to players if the player knows about the entity iirc, meaning in the same visleaf.
Cant seem to get a 3D2D html window to render. Code as follows: [lua] if (CLIENT) then function ENT:Draw() self:DrawModel() if self.browser then local Pos = self:GetPos() local Ang = self:GetAngles() surface.SetFont("HUDNumber5") Ang:RotateAroundAxis(Ang:Forward(), 90) local TextAng = Ang TextAng:RotateAroundAxis(TextAng:Right(), -180) cam.Start3D2D(Pos + Ang:Right() * -5.3 + Ang:Up()*1.18, TextAng, 0.08) surface.SetMaterial(self.browser:GetHTMLMaterial()) surface.DrawTexturedRect( 0, 0, 500, 500) cam.End3D2D() end end function htm() local self = net.ReadEntity() if not self.browser then local browser = vgui.Create("HTML") browser:SetSize(500, 500) browser:SetMouseInputEnabled(false) browser:SetVisible( false ) browser:OpenURL("http://www.google.com/") self.browser = browser end end net.Receive("htm", htm) end [/lua] Any idea as to why?
[QUOTE=Crazy Quebec;38723297]This might not be the answer you want but why aren't you just sending Ent1 and Ent2 to the client side (Which might not even be necessary depending on the rest of your code)?[/QUOTE] Realized that about five minutes after, but it's still odd
[QUOTE=KatNotDinner;38712401]I'm having a problem. I set some models' render origin and angles via the SetRenderOrigin|Angles. It works great. The models are drawing at a specified player's head pos and angles. The problem is that when this player turns at a specified angle, the model stops drawing until he turns at some other specified angle. Ideas?[/QUOTE] Sorry for reposting but I'm completely lost when it comes to such issues.
Hey guys. I want to code an addon extension - adding extra functionality to an existing addon, from a separate package. Doing this is easy for functions, data etc - just load the extension scripts after the addon has loaded. Doing this for entities and tools seems difficult. I can't guarantee that my addon will load after the target addon. If I edit an entity or tool, how can I guarantee that it will overwrite the original entity/tool?
Bump, could I get some help with drawing motion-blur around the screen when sprinting?
[QUOTE=Splambob;38726664]Hey guys. I want to code an addon extension - adding extra functionality to an existing addon, from a separate package. Doing this is easy for functions, data etc - just load the extension scripts after the addon has loaded. Doing this for entities and tools seems difficult. I can't guarantee that my addon will load after the target addon. If I edit an entity or tool, how can I guarantee that it will overwrite the original entity/tool?[/QUOTE] There was a lot of debate about this pre-13 but garry never accepted it. You can't easily.
Hoping for the right load order isn't the way to go about it. You should be storing and setting stuff up on loadtime - then do the actual act of interacting with the other addons in a hook - after EVERYTHING has loaded.
I want to make an extension to ACF which modifies the tool and adds a few new entities. I don't want to have to merge ACF code into my addon every time they update their git. I could get the behaviour I want with two invariants; my addon loads its tools/ents after ACF, and tools/entities can be overwritten after loaded. edit: whoa garry ninja. I'm looking for a way to replace an existing tool/entity class with another one. (e.g. original "ent_acf_gun" with my edited "ent_acf_gun") If there's a way to do this after all addons have loaded, I'm completely happy with using that method. edit2: i'm done editing now :v:
Hi everybody! I got this script from another thread, and edited it to work with my usergroups and colors. But now for some reason the people who are in the "Regular" group is able to display their chat messages while dead. Credits go to [B]brandonj4[/B] for the script. [lua] local ranks = { ["superadmin"] = Color(220,20,60), ["admin"] = Color(255,20,60), ["moderator"] = Color(238,0,238), ["regular"] = Color(255,255,255), ["friend"] = Color(150,255,150), } if (SERVER) then AddCSLuaFile("chat.lua") function CustomChat_ChatMessage(ply, msg, rank, r, g, b) umsg.Start("CustomChat_ChatMsg") umsg.Entity(ply) umsg.String(msg) umsg.String(rank) umsg.Short(r) umsg.Short(g) umsg.Short(b) umsg.End() end function CustomChat_Checker(ply, text, teamonly) local group = ply:GetUserGroup() local color = ranks[group] local txtcheck = string.sub(text,1,1) if txtcheck == "/" then return text else return "", CustomChat_ChatMessage(ply, text, "["..string.upper(string.sub(group,1,1))..string.sub(group,2).."]", color.r, color.g, color.b) end end hook.Add("PlayerSay", "WordCheck", CustomChat_Checker) else usermessage.Hook("CustomChat_ChatMsg", function(um) local ply = um:ReadEntity() local msg = um:ReadString() local rank = um:ReadString() local r = um:ReadShort() local g = um:ReadShort() local b = um:ReadShort() chat.AddText(Color(r, g, b), rank, team.GetColor(ply:Team()), " "..ply:Nick(), Color(255,255,255), ": "..msg) end) end [/lua] I think maybe this fuction is not working properly since its not really team only. [lua] function CustomChat_Checker(ply, text, teamonly) [/lua]
[QUOTE=Splambob;38727998]I want to make an extension to ACF which modifies the tool and adds a few new entities. I don't want to have to merge ACF code into my addon every time they update their git. I could get the behaviour I want with two invariants; my addon loads its tools/ents after ACF, and tools/entities can be overwritten after loaded. edit: whoa garry ninja. I'm looking for a way to replace an existing tool/entity class with another one. (e.g. original "ent_acf_gun" with my edited "ent_acf_gun") If there's a way to do this after all addons have loaded, I'm completely happy with using that method. edit2: i'm done editing now :v:[/QUOTE] Could try [url]http://wiki.garrysmod.com/page/Libraries/scripted_ents/Register[/url]
[QUOTE=Drakehawke;38728097]Could try [url]http://wiki.garrysmod.com/page/Libraries/scripted_ents/Register[/url][/QUOTE] That looks like it'll do the trick, thank you very much :) Is there an equivalent for scripted tools? (replacing a tool named "#ACFMenu" in gmod_tool\stools\acfmenu.lua)
The scripted tools system is purely created in Lua, have a poke around the [url=http://glua.me/bin/?path=/gamemodes/sandbox/entities/weapons/gmod_tool/stool.lua]source[/url] and you might find a way.
Anyone know how to manipulate the values of the edit_sky entity? I've tried the properties function on the item but it doesn't change the color of the sky. Is there source code anywhere for it? I've tried the glua.me bin but no luck.
[QUOTE=brandonj4;38728904]Is there source code anywhere for it? I've tried the glua.me bin but no luck.[/QUOTE] yeah sorry it takes a bit to upload the stuff, check back in like 20 minutes
"attempt to call field 'WriteLong' (a nil value)" init.lua [CODE] roundNumber = 1 util.AddNetworkString("RoundSet") function GM:PlayerAuthed( ply, stid, unid ) self.BaseClass:PlayerAuthed( ply, stid, unid ) net.Start("RoundSet") -- if person joinde late then sync current round number. net.WriteLong(roundNumber) net.Send( ply ) print("Synced round number with "..ply:Name()) end [/CODE] Trying to send clients (if they joined late) current round number.
[url]http://wiki.garrysmod.com/page/Libraries/net[/url] WriteLong doesn't exist
*facepalm* this always happens when i start using some other networking library. thanks :P
Hello, I'm trying to make my SWEP kill any NPC, but only if I'm looking at the NPC. However, my code seems to not work as I intend. [CODE]function SWEP:Think() local tr = self.Owner:GetEyeTrace(); if tr.Entity:IsPlayer() or tr.Entity:IsNPC() then timer.Simple(3, function () if tr.Entity:IsValid() then tr.Entity:TakeDamage(tr.Entity:Health(), self, self.Owner) end end) else end print(tr.Entity:GetClass()) end[/CODE]
Sorry, you need to Log In to post a reply to this thread.