• LUA help!
    11 replies, posted
Hello! I get this error message in console --> [url]http://aijaa.com/3DUSwn[/url] This is how the file looks: [CODE] TOOL.Category = "Spawnables" TOOL.Name = "#NadioMod" TOOL.Command = nil TOOL.ConfigName = "" TOOL.Tab = "NadioMod" cleanup.Register( "Electronics" ) TOOL.ClientConVar = { model = "models/Items/car_battery01.mdl", select = "1", } if CLIENT then language.Add( "Tool_easyengineelectronics_name", "Electronics" ) language.Add( "Tool_easyengineelectronics_desc", "Spawn electronics" ) language.Add( "Tool_easyengineelectronics_0", "Primary fire: spawn" ) language.Add( "Undone_Electronics", "Undone Electronics" ) language.Add( "Cleanup_Electronics", "Engine Mod: Electronics" ) language.Add( "Cleaned_Electronics", "Electronics Removed" ) -- CreateConVar('EN_ElectronicModel', "blah") -- CreateConVar('electronicschoosen', 1) end function TOOL:LeftClick( trace ) if ( trace.Entity && trace.Entity:IsPlayer() ) then return false end // If there's no physics object then we can't constraint it! if ( SERVER && !util.IsValidPhysicsObject( trace.Entity, trace.PhysicsBone ) ) then return false end if (CLIENT) then return true end local ply = self:GetOwner() local electronicsNum = self:GetClientNumber( "select" ) local Ang = trace.HitNormal:Angle() Ang.pitch = Ang.pitch + 90 local electronicsProp = Makeelectronics( Ang, trace.HitPos, electronicsNum, ply ) local min = electronicsProp:OBBMins() electronicsProp:SetPos( trace.HitPos - trace.HitNormal * min.z ) undo.Create("Electronics") undo.AddEntity( electronicsProp ) undo.SetPlayer( ply ) undo.Finish() ply:AddCleanup( "Electronics", electronicsProp ) return true end if (SERVER) then function Makeelectronics( Ang, Pos, Num, ply ) local electronics = null if Num == 1 or Num == 2 or Num == 3 then if Num == 1 then electronics = ents.Create( "prop_physics" ) electronics:SetModel("models/Items/car_battery01.mdl") electronics:SetPos( Pos ) electronics:SetAngles( Ang ) electronics:Spawn() electronics:Activate() end if Num == 2 then electronics = ents.Create( "prop_physics" ) electronics:SetModel("models/props_junk/garbage_metalcan002a.mdl") electronics:SetPos( Pos ) electronics:SetAngles( Ang ) electronics:Spawn() electronics:Activate() end if Num == 3 then electronics = ents.Create( "prop_physics" ) electronics:SetModel("models/props_lab/reciever01b.mdl") electronics:SetPos( Pos ) electronics:SetAngles( Ang ) electronics:Spawn() electronics:Activate() end else if Num == 4 then electronics = ents.Create( "sent_FrontLight" ) end if Num == 5 then electronics = ents.Create( "sent_L_DirIndicator" ) electronics.Owner = ply end if Num == 6 then electronics = ents.Create( "sent_R_DirIndicator" ) electronics.Owner = ply end if Num == 7 then electronics = ents.Create( "sent_RearLight" ) electronics.Owner = ply end if Num == 8 then electronics = ents.Create( "sent_guage" ) end if Num == 9 then electronics = ents.Create( "sent_thermo" ) end if Num == 10 then electronics = ents.Create( "sent_Radio2" ) end if Num == 11 then electronics = ents.Create( "sent_Radio3" ) end electronics:SetAngles( Ang ) electronics:SetPos( Pos ) electronics:Spawn() end return electronics end end function TOOL:UpdateGhostElectronics( ent, player ) if ( !ent ) then return end if ( !ent:IsValid() ) then return end local tr = utilx.GetPlayerTrace( player, player:GetCursorAimVector() ) local trace = util.TraceLine( tr ) if (!trace.Hit) then return end local Ang = trace.HitNormal:Angle() Ang.pitch = Ang.pitch + 90 local min = ent:OBBMins() ent:SetPos( trace.HitPos - trace.HitNormal * min.z ) ent:SetAngles( Ang ) ent:SetNoDraw( false ) end function TOOL:Think() if (!self.GhostEntity || !self.GhostEntity:IsValid() || self.GhostEntity:GetModel() != self:GetClientInfo( "model" )) then self:MakeGhostEntity( self:GetClientInfo( "model" ), Vector(0,0,0), Angle(0,0,0) ) end self:UpdateGhostElectronics( self.GhostEntity, self:GetOwner() ) end function TOOL.BuildCPanel( CPanel ) // HEADER CPanel:AddControl( "Header", { Text = "#Tool_easyengineelectronics_name", Description = "Spawn electronics" } ) ThaMaterialBox = {} ThaMaterialBox.Label = "Fuel" ThaMaterialBox.MenuButton = 0 ThaMaterialBox.Height = 100 ThaMaterialBox.Width = 100 ThaMaterialBox.Rows = 2 ThaMaterialBox.Options = {} ThaMaterialBox.Options["Radio3"] = { Material = "vgui/entities/sent_Radio3", radiomodelectronics_select = 11, radiomodelectronics_model = "models/props_lab/citizenradio.mdl", Value = "Radio electro" } CPanel:AddControl("MaterialGallery", ThaMaterialBox) end[/CODE]
[CODE]local tr = utilx.GetPlayerTrace( player, player:GetCursorAimVector() )[/CODE] I believe that should be util.GetPlayerTrace ([url]http://wiki.garrysmod.com/page/util/GetPlayerTrace[/url])
Now im getting this: [url]http://aijaa.com/As0Y3z[/url]
This is developer discussion, asking for tips or help on stuff that people don't understand which is perfectly fine but you're coming here, opening 10 threads daily with either stupid questions which are easily solved by googling or just throw code at us and want us to fix it. Unless you're going to learn please head over to coderhire, people there are mostly friendly and will do/fix small things for a small amount of payment.
[QUOTE=arcaneex;42650214]This is developer discussion, asking for tips or help on stuff that people don't understand which is perfectly fine but you're coming here, opening 10 threads daily with either stupid questions which are easily solved by googling or just throw code at us and want us to fix it. Unless you're going to learn please head over to coderhire, people there are mostly friendly and will do/fix small things for a small amount of payment.[/QUOTE] Im not going to pay, lawl. Im opening thread only if i don't find any info about it from google, would you please google this for me please? :)
[QUOTE=Niskuo;42650233]Im not going to pay, lawl. Im opening thread only if i don't find any info about it from google, would you please google this for me please? :)[/QUOTE] [URL]http://www.lua.org/pil/contents.html[/URL] Read this it will teach you all about why that error is happening and then you will be able to apply that knowledge to fixing it
[URL="https://www.google.co.il/search?q=attempt+to+index+utilx&oq=attempt+to+index+utilx&aqs=chrome..69i57.10731j0j4&sourceid=chrome&espv=210&es_sm=93&ie=UTF-8"]First error[/URL] [URL="https://www.google.co.il/search?q=attempt+to+call+method+getcursoeraimvector&oq=attempt+to+call+method+getcursoeraimvector&aqs=chrome..69i57.15896j0j4&sourceid=chrome&espv=210&es_sm=93&ie=UTF-8#es_sm=93&espv=210&q=attempt+to+call+method+GetCursorAimVector&safe=off"]Second error[/URL] Atleast 10 results from each to answer your question.
[QUOTE=arcaneex;42650257][URL="https://www.google.co.il/search?q=attempt+to+index+utilx&oq=attempt+to+index+utilx&aqs=chrome..69i57.10731j0j4&sourceid=chrome&espv=210&es_sm=93&ie=UTF-8"]First error[/URL] [URL="https://www.google.co.il/search?q=attempt+to+call+method+getcursoeraimvector&oq=attempt+to+call+method+getcursoeraimvector&aqs=chrome..69i57.15896j0j4&sourceid=chrome&espv=210&es_sm=93&ie=UTF-8#es_sm=93&espv=210&q=attempt+to+call+method+GetCursorAimVector&safe=off"]Second error[/URL] Atleast 10 results from each to answer your question.[/QUOTE] How about this? attempt to call method 'stop' Didn't found anything that helps from google
It tells you all you need to know. The method 'stop' does not exist wherever you call it. Look at how to use the function/thing you're using and what methods it has.
[QUOTE=arcaneex;42650418]It tells you all you need to know. The method 'stop' does not exist wherever you call it. Look at how to use the function/thing you're using and what methods it has.[/QUOTE] I cannot find anything that would replace 'stop'... Can you tell me, because google didn't tell me :(
Fixed it, dunno how.
Sorry, you need to Log In to post a reply to this thread.