• Help spawning ent
    19 replies, posted
Hey. I have a problem. When i run falco_addmapent it works fine but when i run falco_restoremapent i get LUA error, here's the code. What's wrong? Note: Code not made by me. I am just trying to modify it in the right way [lua] sql.Query("CREATE TABLE IF NOT EXISTS falco_worldents('map' TEXT NOT NULL, 'class' TEXT NOT NULL, 'x' INTEGER NOT NULL, 'y' INTEGER NOT NULL, 'z' INTEGER NOT NULL, 'pitch' INTEGER NOT NULL, 'yaw' INTEGER NOT NULL, 'roll' INTEGER NOT NULL, PRIMARY KEY('map'));") function AddWorldEnt(ply) local ent = ply:GetEyeTrace().Entity if not ValidEntity(ent) or not ply:IsSuperAdmin() then ply:ChatPrint("Entity not vaild!") return end local pos = ent:GetPos() pos = Vector(math.Round(pos.x), math.Round(pos.y), math.Round(pos.z)) ent:SetPos(pos) local ang = ent:EyeAngles() ang = Angle(math.Round(ang.p), math.Round(ang.y), math.Round(ang.r)) ent:SetAngles(ang) local map = string.lower(game.GetMap()) local class = ent:GetClass() local data = sql.Query("SELECT * FROM falco_worldents;") or {} sql.Query("INSERT INTO falco_worldents VALUES("..sql.SQLStr(map..tostring(table.Count(data) + 1))..", "..sql.SQLStr(class)..", "..sql.SQLStr(pos.x)..", "..sql.SQLStr(pos.y)..", "..sql.SQLStr(pos.z)..", "..sql.SQLStr(ang.p)..", "..sql.SQLStr(ang.y)..", "..sql.SQLStr(ang.r)..");") ply:ChatPrint("Added: "..class) end concommand.Add("falco_addmapent", AddWorldEnt) function spawnent(ent, svector, sangle) local e = ents.Create(ent) e:SetPos(svector) ent:SetAngles(sangle) e:Spawn() e:Activate() local phys = e:GetPhysicsObject() if phys:IsValid() then phys:EnableMotion(false) end e:SetNWString("Owner", "World") --SPP e:SetNWBool("mapprop", true) return e end function RestoreMapItems(ply) if ply and not ply:IsSuperAdmin() then return end timer.Simple(1, function() local data = sql.Query("SELECT * FROM falco_worldents;") if not data then return end for k,v in pairs(data) do if string.find(v.map, string.lower(game.GetMap())) == 1 then spawnent(v.Class, Vector(tonumber(v.x), tonumber(v.y), tonumber(v.z)), Angle(v.pitch, v.yaw, v.roll)) end end end) end hook.Add( "InitPostEntity", "falco_RestoreMapItems", RestoreMapItems) concommand.Add("falco_restoremapents", RestoreMapItems) function ClearMapEnts(ply,cmd,args) if not ply:IsSuperAdmin() then return end local data = sql.Query("SELECT * FROM falco_worldents;") or {} for k,v in pairs(data) do if string.find(v.map, string.lower(game.GetMap())) == 1 then sql.Query("DELETE FROM falco_worldents WHERE map = "..sql.SQLStr(v.map)..";") end end end concommand.Add("falco_clearmapents", ClearMapEnts) [/lua] I get error: [lua] Timer Error: [@addons\a_stargate\lua\autorun\server\addworldent.lua:24] Tried to use a NULL entity! [/lua] Try to find a fix ASAP!
Your stargate aeronautics is conflicting.
What? What stargate aeronautics?
Sorry, stupid autocorrect, I meant addon. :v:
there's no conflicting stargate addon. addons\a_stargate\lua\autorun\server\addworldent.lua is the lua file i am trying to run (the code above) but i get this error. It's strange, when i run this code it's working fine (but for saving models ofc) [lua] sql.Query("CREATE TABLE IF NOT EXISTS falco_worldprops('map' TEXT NOT NULL, 'model' TEXT NOT NULL, 'x' INTEGER NOT NULL, 'y' INTEGER NOT NULL, 'z' INTEGER NOT NULL, 'pitch' INTEGER NOT NULL, 'yaw' INTEGER NOT NULL, 'roll' INTEGER NOT NULL, PRIMARY KEY('map'));") function AddWorldProp(ply) local ent = ply:GetEyeTrace().Entity if not ValidEntity(ent) or not ply:IsSuperAdmin() then return end local pos = ent:GetPos() pos = Vector(math.Round(pos.x), math.Round(pos.y), math.Round(pos.z)) ent:SetPos(pos) local ang = ent:EyeAngles() ang = Angle(math.Round(ang.p), math.Round(ang.y), math.Round(ang.r)) ent:SetAngles(ang) local map = string.lower(game.GetMap()) local model = ent:GetModel() local data = sql.Query("SELECT * FROM falco_worldprops;") or {} sql.Query("INSERT INTO falco_worldprops VALUES("..sql.SQLStr(map..tostring(table.Count(data) + 1))..", "..sql.SQLStr(model)..", "..sql.SQLStr(pos.x)..", "..sql.SQLStr(pos.y)..", "..sql.SQLStr(pos.z)..", "..sql.SQLStr(ang.p)..", "..sql.SQLStr(ang.y)..", "..sql.SQLStr(ang.r)..");") ply:ChatPrint("added "..model) end concommand.Add("falco_addmapprop", AddWorldProp) function RestoreMapItems(ply) if ply and not ply:IsSuperAdmin() then return end timer.Simple(1, function() local data = sql.Query("SELECT * FROM falco_worldprops;") if not data then return end for k,v in pairs(data) do if string.find(v.map, string.lower(game.GetMap())) == 1 then local ent = ents.Create("prop_physics") ent:SetPos(Vector(tonumber(v.x), tonumber(v.y), tonumber(v.z))) ent:SetAngles(Angle(v.pitch, v.yaw, v.roll)) ent:SetModel(v.model) ent:SetSolid(SOLID_VPHYSICS) ent:SetMoveType(MOVETYPE_NONE) end end end) end hook.Add( "InitPostEntity", "falco_RestoreMapItems", RestoreMapItems) concommand.Add("falco_restoremapprops", RestoreMapItems) function ClearMapEnts(ply,cmd,args) if not ply:IsSuperAdmin() then return end local data = sql.Query("SELECT * FROM falco_worldprops;") or {} for k,v in pairs(data) do if string.find(v.map, string.lower(game.GetMap())) == 1 then sql.Query("DELETE FROM falco_worldprops WHERE map = "..sql.SQLStr(v.map)..";") end end end concommand.Add("falco_clearmapprops", ClearMapEnts) [/lua]
Can you use lua tags please, it makes it considerably easier for everyone else.
Oh, okay. Let me just change it.
The error shows there's an error on line 24, but it's impossible for that error to occur on that line in both the snippets you've posted. You've pasted the wrong version of the script or something.
No i did not. Try it ingame.
*bump* Anyway, i did check if i posted something wrong, and i did not. Everything's fine. Except it's not working, and i see you guys aren't helping me...
[QUOTE=cartman300;35887235]*bump* Anyway, i did check if i posted something wrong, and i did not. Everything's fine. Except it's not working, and i see you guys aren't helping me...[/QUOTE] Falco the creator of the gamemode just told you to update your script since it's out of date. Wrong version = Update DarkRP SVN
[QUOTE=brandonj4;35888259]Falco the creator of the gamemode just told you to update your script since it's out of date. Wrong version = Update DarkRP SVN[/QUOTE] Are you on crack or something. This has nothing to do with DarkRP or SVNs. It's an LUA bug i am trying to fix.
If you don't follow the creators directions why are you still asking for help?
[QUOTE=TylerB;35888777]If you don't follow the creators directions why are you still asking for help?[/QUOTE] Please post me this "creators directions", it seems i can't find them, maybe because there are none?
Update your version of Stargate, it's very annoying when you keep posting for help while not reading other peoples entire posts.
[QUOTE=brandonj4;35890839]Update your version of Stargate, it's very annoying when you keep posting for help while not reading other peoples entire posts.[/QUOTE] This has nothing to do with stargate. btw. My stargate addon is always up to date. I will now write it so less clever people can understand it: 1. This lua code's location is "addons\a_stargate\lua\autorun\server\addworldent.lua" 2. I get this error when i run it in game: "Timer Error: [@addons\a_stargate\lua\autorun\server\addworldent.lua:24] Tried to use a NULL entity!" 3. This has nothing to do with stargate nor with darkRP or any other addon. 4. The proplem is an error is occurring for no reason... 5. The creator of the original script is "FPtje" Get it??
Which line is line 24? It is impossible to error with the snippet you have.
[QUOTE=Chessnut;35897441]Which line is line 24? It is impossible to error with the snippet you have.[/QUOTE] I know, that IS the problem damn it!
[QUOTE=cartman300;35900173]I know, that IS the problem damn it![/QUOTE] He told you to try and update. If you're not going to update the script why are you still crying for help? If you have updated the script you should say something instead of keep screaming and rating everyone dumb and disagree.
[QUOTE=TylerB;35929135]He told you to try and update. If you're not going to update the script why are you still crying for help? If you have updated the script you should say something instead of keep screaming and rating everyone dumb and disagree.[/QUOTE] Please explain how do i update the script? Here's something on croatian for you. "Kakav jebeni update? Kako da kvragu updateam objasni ti meni. Ovaj skript neradi i trebam drugi i događa se error koji se nebi smijo događat i ti si retardiran. Jebi se."
Sorry, you need to Log In to post a reply to this thread.