• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=mijyuoon;47545964]They are gonna be actual entities and each will take its own entity index and that means if you make too many this way you won't be able to spawn anything. So this isn't really good way to do complex geometry via simple primitives, you can try combining everything into one big mesh though but I'm not sure how physics engine is gonna react to it.[/QUOTE] Why would he do complex geometry via simple primitives when he can make use of meshes.
[QUOTE=James xX;47546095]Why would he do complex geometry via simple primitives when he can make use of meshes.[/QUOTE] [QUOTE=mijyuoon;47545964]you can try combining everything into one big mesh though but I'm not sure how physics engine is gonna react to it.[/QUOTE] I doubt you can merge everything into single collision mesh with arbitrarily complex shape without experiencing performance problems.
How do I get the player's team's color for a scoreboard? I'm currently trying to use this [code] if ( self.Player:Team() == TEAM_CONNECTING ) then draw.RoundedBox( 0, 0, 0, w, h, Color( team.GetColor (self.Player:Team())) ) return end if ( !self.Player:Alive() ) then draw.RoundedBox( 0, 0, 0, w, h, Color( team.GetColor (self.Player:Team())) ) return end [/code] It gives errors like [code] [ERROR] lua/includes/util/color.lua:16: bad argument #1 to 'min' (number expected, got nil) 1. min - [C]:-1 2. Color - lua/includes/util/color.lua:16 3. unknown - gamemodes/darkrp/gamemode/fadmin/cl_interface/cl_scoreboard.lua:155 [/code]
[lua]Color( team.GetColor (self.Player:Team()))[/lua] team.GetColor already returns a color type, try to replace that with : [lua]team.GetColor (self.Player:Team())[/lua] If that doesn't change anything, then : [quote](number expected, got nil)[/quote] A number is missing. Garrys'mod uses numbers to set up teams. I think your 'self.Player' variable doesn't exists or refers to a player. Try to print the player name to see what happens.
[QUOTE=SwikCoder;47547045]How do I get the player's team's color for a scoreboard? I'm currently trying to use this [code] if ( self.Player:Team() == TEAM_CONNECTING ) then draw.RoundedBox( 0, 0, 0, w, h, Color( team.GetColor (self.Player:Team())) ) return end if ( !self.Player:Alive() ) then draw.RoundedBox( 0, 0, 0, w, h, Color( team.GetColor (self.Player:Team())) ) return end [/code] It gives errors like [code] [ERROR] lua/includes/util/color.lua:16: bad argument #1 to 'min' (number expected, got nil) 1. min - [C]:-1 2. Color - lua/includes/util/color.lua:16 3. unknown - gamemodes/darkrp/gamemode/fadmin/cl_interface/cl_scoreboard.lua:155 [/code][/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/team/GetColor]team.GetColor[/url] returns a color, not the individual values to make a color. Remove the Color function in your code. Edit: Ninja :(
[QUOTE=Sm63;47543297]missing an ) on the end of the net.Receive function[/QUOTE] I fixed that but I still get this error cl_menu is called by cl_init so thats not the problem [CODE][ERROR] gamemodes/warfare/gamemode/cl_menu.lua:49: Calling net.Start with unpooled message name [http://goo.gl/qcx0y] 1. Start - [C]:-1 2. DoClick - gamemodes/warfare/gamemode/cl_menu.lua:49 3. unknown - lua/vgui/dlabel.lua:218 [/CODE]
Write an print(os.time()) after util.AddNetworkString( "SpawnRequest" ) and one after net.Start("SpawnRequest") then tell me the output of it. It seems that you are running the net.start before the util is running.
Open the link in the error ( [url]http://goo.gl/qcx0y[/url] ) and you shall learn the mysterious reason why it doesn't work.
[QUOTE=Robotboy655;47547762]Open the link in the error ( [url]http://goo.gl/qcx0y[/url] ) and you shall learn the mysterious reason why it doesn't work.[/QUOTE] He's already calling util.AddNetworkString( ).
[QUOTE=James xX;47547811]He's already calling util.AddNetworkString( ).[/QUOTE] What's happening is one of these: 1) He tries to send the net message too early ( Add a delay ) 2) util.AddNetworkString is never actually called ( Add print("da") after or before util.AddNetworkString call to make sure it is called, and it is called on server ) [editline]18th April 2015[/editline] [quote=wiki] you need to do it at least a couple of seconds before calling the message to be sure that it'll work.[/quote]
[QUOTE=Tomelyr;47547748]Write an print(os.time()) after util.AddNetworkString( "SpawnRequest" ) and one after net.Start("SpawnRequest") then tell me the output of it. It seems that you are running the net.start before the util is running.[/QUOTE] net.Start is called when a derma button is pressed I waited about 5 mins after the server booted up then pressed the button but still got the same error. I think it has time to load up SpawnRequest
[QUOTE=LosttSpacee;47547983]net.Start is called when a derma button is pressed I waited about 5 mins after the server booted up then pressed the button but still got the same error. I think it has time to load up SpawnRequest[/QUOTE] It would help to see if the util.AddNetworkString is actually being called, not just when, but also the realm.
[QUOTE=James xX;47548001]It would help to see if the util.AddNetworkString is actually being called, not just when, but also the realm.[/QUOTE] I use GM:Initialize to call all my strings heres the code [CODE] function GM:Initialize() print( "String loaded" ) util.AddNetworkString("SpawnRequest") end local function init() print( "Called, Test String" ) end hook.Add( "Initialize", "Strings", init )[/CODE]
[QUOTE=LosttSpacee;47548061]I use GM:Initialize to call all my strings heres the code [CODE] function GM:Initialize() print( "String loaded" ) util.AddNetworkString("SpawnRequest") end local function init() print( "Called, Test String" ) end hook.Add( "Initialize", "Strings", init )[/CODE][/QUOTE] The point was, does it print, and what colour is it. You don't need it in the Initialize hook anyway, just put it at the top of your script.
[QUOTE=James xX;47548074]The point was, does it print, and what colour is it. You don't need it in the Initialize hook anyway, just put it at the top of your script.[/QUOTE] I found out the string wasn't loading because my init file has an error somewhere but I don't understand where. I backed up my gamemode then I I made new files with just the code I need but I still get an error. [B] Server Side[/B] [CODE]AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include( "shared.lua" ) util.AddNetworkString("SpawnRequest") print( "Called, Test String" ) net.Receive( "SpawnRequest", function( length, client )) local data = net.ReadString() if data == "Soldier" then SpawnCombineS(client:GetEyeTraceNoCursor() HitPos+Vector(0,0,30)) end end function SpawnCombineS( pos ) NPC = ents.Create( "npc_combine_s" ) NPC:SetKeyValue("NumGrenades", "2") NPC:SetPos( pos ) NPC:SetKeyValue( "ignoreunseenenemies", 0 ) NPC:SetKeyValue( "spawnflags", 512 ) NPC:Spawn() end [/CODE] Client [CODE]include( 'shared.lua' ) function makecombine() net.Start("SpawnRequest") net.WriteString("Soldier") net.SendToServer() print(os.time()) end function checkostime() print(os.time()) end concommand.Add("makecombine", makecombine) --make the console command to make this menu popup concommand.Add("checkingostime", checkostime) --make the console command to make this menu popup [/CODE] [B]The error[/B] Sorry about the image didn't want to type that out [IMG]http://i.imgur.com/oMT9kht.png[/IMG]
Move the ) on line 9 to the end of the function. [lua] net.Receive( "SpawnRequest", function( length, client ) local data = net.ReadString() if data == "Soldier" then SpawnCombineS(client:GetEyeTraceNoCursor().HitPos+Vector(0,0,30)) end end) [/lua] I also placed a "." you forgot to add after client:GetEyeTraceNoCursor()
[QUOTE=LosttSpacee;47548197]I found out the string wasn't loading because my init file has an error somewhere but I don't understand where. I backed up my gamemode then I I made new files with just the code I need but I still get an error. [B] Server Side[/B] Client [CODE]include( 'shared.lua' ) function makecombine() net.Start("SpawnRequest") net.WriteString("Soldier") net.SendToServer() print(os.time()) end function checkostime() print(os.time()) end concommand.Add("makecombine", makecombine) --make the console command to make this menu popup concommand.Add("checkingostime", checkostime) --make the console command to make this menu popup [/CODE] [B]The error[/B] Sorry about the image didn't want to type that out [IMG]http://i.imgur.com/oMT9kht.png[/IMG][/QUOTE] The net.Receive in your serverside code should look like this: [CODE]net.Receive( "SpawnRequest", function( length, client ) local data = net.ReadString() if data == "Soldier" then SpawnCombineS(client:GetEyeTraceNoCursor() HitPos+Vector(0,0,30)) end end)[/CODE] Remember that the entire function starting with function(length,client) is an [I]argument[/I] of net.Receive(), so the ) closing net.Receive() should be [I]after[/I] the function's end. edit: use james' version, he caught another problem that I didn't
Thank you so much for you guys help. I have no idea what I would have done without it
Looks like my question got buried, so I'll post it again. [QUOTE=swadicalrag;47543721]I'm at a loss here. I've been experimenting with NWVars and I can't get the NWVarProxies to work. After a quick search on the gmod github, I was introduced to the EntityNetworkedVarChanged hook. Through the gmod wiki, I copypasted and tested, on clientside, the example for the EntityNetworkedVarChanged hook: [CODE]hook.Add("EntityNetworkedVarChanged","print out everything",print)[/CODE] However, it doesn't work. Suspecting that it would be only accessible serverside (despite the hook being shared) I tried the same code serverside, but to no avail. Has anyone had this problem before with the EntityNetworkedVarChanged hook not being called at all, or are there any easy, non-hacky replacements I can use?[/QUOTE] This feature should have already been made available in the last update. Yet, it isn't getting called on my client nor server. I've checked/verified that my server is up to date.
[QUOTE=swadicalrag;47548583]Looks like my question got buried, so I'll post it again. This feature should have already been made available in the last update. Yet, it isn't getting called on my client nor server. I've checked/verified that my server is up to date.[/QUOTE] I'm probably wrong but I think that hook was made to work with the new network vars, since they were reverted it may no longer work at the moment. Try it on the dev branch, I believe they're testing the new network vars on there again.
[QUOTE=Jeezy;47548616]I'm probably wrong but I think that hook was made to work with the new network vars, since they were reverted it may no longer work at the moment. Try it on the dev branch, I believe they're testing the new network vars on there again.[/QUOTE] Ah, shame. I'll skip testing it on the dev branch for now. I don't want to use a hook that still isn't in the main branch, especially when I have no clue when the next update is coming. Thanks!
Can anyone give me a hand in meshes, a bit of an explanation? I know that a mesh is a series of connected vertices with a face, and that they're used in polygonal modeling. So far, I've only been able to recreate the example given on the global/mesh page of the gmod wiki, which uses a triangle mesh function or something. Looking at all the other functions seemslike there are other ways to create meshes, ex: mesh.begin, etc. Im not sure how I'd create a mesh from these other methods. Can a face use more than 3 vertices? Also, my triangle mesh wasnt showing a face when I switched the material from wireframe to something else. Well, I saw the face, it just had a missing texture. Im also curious to learn about tangents and bisectors, and how they will change the mesh Sorry for long post, there may be some typos, typed this out on a phone. Any and all help would be appreciated!
How can I make a parented prop collide with other props? It seems when I parent a prop_physics to another prop, it becomes completely no-collided. I've tried messing with collision groups, setting its solid, and haven't had anything work. This is my work so far, without any effort of allowing collision. [lua]local lab = ents.Create('prop_physics') lab:SetModel('models/props_lab/reciever_cart.mdl') lab:SetParent(self) lab:SetAngles(ang + Angle(0,90,0)) lab:SetPos(self:GetPos() + self:GetUp()*15 + self:GetRight()*-45 + self:GetForward()*5)[/lua] I'm really at a loss right now. Any help is greatly appreciated.
I have some entities that I want to spawn ones a weapons pack another a turret pack that's in the entities tab. I will leave the workshop links down below in case that matters, I am using network strings and a derma menu to spawn stuff Any and all help would be appreciated! Weapon Pack [url]http://steamcommunity.com/sharedfiles/filedetails/?id=180507408&searchtext=FAS[/url] Turrets and stuff [url]http://steamcommunity.com/sharedfiles/filedetails/?id=295680095&searchtext=J.I[/url]
[QUOTE=Karp;47549541]How can I make a parented prop collide with other props? It seems when I parent a prop_physics to another prop, it becomes completely no-collided. I've tried messing with collision groups, setting its solid, and haven't had anything work. This is my work so far, without any effort of allowing collision. I'm really at a loss right now. Any help is greatly appreciated.[/QUOTE] The point of a parented entity is specifically to disable physics on it and follow the motion of something else. It should only be used to attach detail props to something if you don't want the engine to have to calculate physics for it (except moving with the parent). AFAIK, there is no way to accomplish what you want using parents. [QUOTE=LosttSpacee;47549558]I have some entities that I want to spawn ones a weapons pack another a turret pack that's in the entities tab. I will leave the workshop links down below in case that matters, I am using network strings and a derma menu to spawn stuff Any and all help would be appreciated! [/QUOTE] If you would like the player to spawn it rather than it being magically created, you can do [code]scripted_ents.Get("super_cool_turret_entity_name"):SpawnFunction(client, client:GetEyeTraceNoCursor())[/code] where client is obviously the player doing the spawning
[QUOTE=Z0mb1n3;47549981]The point of a parented entity is specifically to disable physics on it and follow the motion of something else. It should only be used to attach detail props to something if you don't want the engine to have to calculate physics for it (except moving with the parent). AFAIK, there is no way to accomplish what you want using parents. If you would like the player to spawn it rather than it being magically created, you can do [code]scripted_ents.Get("super_cool_turret_entity_name"):SpawnFunction(client, client:GetEyeTraceNoCursor())[/code] where client is obviously the player doing the spawning[/QUOTE] I get an error with that code, Im trying to spawn an entity out of an addon [CODE][ERROR] gamemodes/warfare/gamemode/cl_init.lua:16: attempt to index global 'client' (a nil value) 1. unknown - gamemodes/warfare/gamemode/cl_init.lua:16 2. unknown - lua/includes/modules/concommand.lua:54[/CODE]
[QUOTE=LosttSpacee;47550030]I get an error with that code, Im trying to spawn an entity out of an addon [CODE][ERROR] gamemodes/warfare/gamemode/cl_init.lua:16: attempt to index global 'client' (a nil value) 1. unknown - gamemodes/warfare/gamemode/cl_init.lua:16 2. unknown - lua/includes/modules/concommand.lua:54[/CODE][/QUOTE] ...because you need to replace "client" with the player who is spawning the object. In this case, you would probably make it LocalPlayer() (I think? Not sure if you can call this from the client) EDIT: no you can't do that from the client so you'll have to send a net message to tell the server you want to create it.
I'm trying to make an entity fly upwards and out when spawned, this is working however upon using SetModelScale to modify the size, velocity no longer affects the entity when spawned? [code] local vel = VectorRand() * 50 vel.z = 500 phys:SetVelocity( vel ) [/code] Is what I've done to make it move.
You should use SetLocalVelocity.
How would I add a custom check to an entity like a money printer in DarkRP. I tried this: [lua] customCheck = function(ply) return ply:CheckGroup("vip") or ply:IsAdmin() end, CustomCheckFailMsg = "This is VIP only!" [/lua] but all it did was spew errors at me whenever I tried to use the entity.
Sorry, you need to Log In to post a reply to this thread.