iPot Posted January 17, 2008 Posted January 17, 2008 I got this code here wich gives an error where I can't find the solution for. Anyone that can help is thankful. Here's the error btw: [19:26:43] SCRIPT ERROR: ...Program Files/MTA DM/server/mods/deathmatc s/Headcrab/spawn.lua:13: unexpected symbol near ')' [19:26:43] INFO: Loading script failed: ...Program Files/MTA DM/server hmatch/resources/Headcrab/spawn.lua:13: unexpected symbol near ')' And here's the code: function startMap(startedMap) local mapRoot = getResourceRootElement(startedMap) local players = getElementsByType("player") fadeCamera ( thePlayer, false, 1.0, 0, 0, 0 ) for key, player in pairs(players) do local spawn = spawns[math.random(1, #spawns)] local posX = getElementData(spawn, "posX") local posY = getElementData(spawn, "posY") local posZ = getElementData(spawn, "posZ") local angle = getElementData(spawn, "angle") spawnPlayer(player, posX, posY, posZ, angle)) end end addEventHandler("onGamemodeMapStart", getRootElement(), startMap Tom
CJGrove Posted January 17, 2008 Posted January 17, 2008 Try function startMap(startedMap) local mapRoot = getResourceRootElement(startedMap) local players = getElementsByType("player") fadeCamera ( thePlayer, false, 1.0, 0, 0, 0 ) for key, player in pairs(players) do local spawn = spawns[math.random(1, #spawns)] local posX = getElementData(spawn, "posX") local posY = getElementData(spawn, "posY") local posZ = getElementData(spawn, "posZ") local angle = getElementData(spawn, "angle") spawnPlayer(player, posX, posY, posZ, angle) end end addEventHandler ( "onGamemodeMapStart", getRootElement(), startMap )
iPot Posted January 17, 2008 Author Posted January 17, 2008 There's another 1 [20:24:07] SCRIPT ERROR: ...Program Files/MTA DM/server/mods/deathmatch/resource s/Headcrab/spawn.lua:8: ']' expected near 'local' [20:24:07] INFO: Loading script failed: ...Program Files/MTA DM/server/mods/deat hmatch/resources/Headcrab/spawn.lua:8: ']' expected near 'local' I used the exact code as you said. Tom
CJGrove Posted January 17, 2008 Posted January 17, 2008 There's another 1 [20:24:07] SCRIPT ERROR: ...Program Files/MTA DM/server/mods/deathmatch/resource s/Headcrab/spawn.lua:8: ']' expected near 'local' [20:24:07] INFO: Loading script failed: ...Program Files/MTA DM/server/mods/deat hmatch/resources/Headcrab/spawn.lua:8: ']' expected near 'local' I used the exact code as you said. Tom I eddited try the code standing there now... (Oh jeah i tested it and i get no errors.)
iPot Posted January 17, 2008 Author Posted January 17, 2008 Now I feel like an idiot [20:52:03] ERROR: .../server/mods/deathmatch/resources/Headcrab/spawn.lua:7: empt to get length of global 'spawns' (a nil value)
iPot Posted January 18, 2008 Author Posted January 18, 2008 Here are all my code's now : Meta for gamemode: <meta> <info author="Underworld" name="Bla" version="1" type="gamemode"/> <config src="help.xml" type="client" /> <script src="spawn.lua" /> </meta> Spawn script: function startMap(startedMap) local mapRoot = getResourceRootElement(startedMap) local players = getElementsByType("player") fadeCamera ( thePlayer, false, 1.0, 0, 0, 0 ) for key, player in pairs(players) do local spawn = spawns[math.random(1, #spawns)] local posX = getElementData(spawn, "posX") local posY = getElementData(spawn, "posY") local posZ = getElementData(spawn, "posZ") local angle = getElementData(spawn, "angle") spawnPlayer(player, posX, posY, posZ, angle) end end addEventHandler ( "onGamemodeMapStart", getRootElement(), startMap ) --------------------------------------------------------------------------------------------------------------- Meta for the map: <meta> <info author="Underworld" description="map" version="1" type="map" gamemodes="Bla"/> <map src="Bla.map"/> </meta> And here, the map: <map> <spawnpoint posX="2495.1257324219" posY="-1686.6124267578" posZ="13.513834953308" angle="3.4530944824219"/> <spawnpoint posX="2519.9204101563" posY="-1678.9359130859" posZ="14.879755020142" angle="91.500610351563"/> <spawnpoint posX="2509.6416015625" posY="-1654.0524902344" posZ="13.655654907227" angle="135.68103027344"/> <spawnpoint posX="2487.0036621094" posY="-1647.6352539063" posZ="14.0703125" angle="181.4281463623"/> <spawnpoint posX="2471.869140625" posY="-1686.2700195313" posZ="13.5078125" angle="325.85275268555"/> <spawnpoint posX="2469.6413574219" posY="-1650.4163818359" posZ="13.471806526184" angle="183.62147521973"/> <spawnpoint posX="2452.4020996094" posY="-1646.6909179688" posZ="13.468873977661" angle="178.92138671875"/> </map>
eAi Posted January 18, 2008 Posted January 18, 2008 Well it's basically saying 'wtf is spawns?' You haven't told it what it is yet you're trying to use it. You probably want: spawns = getElementsByType("spawnpoint')
szlend Posted January 18, 2008 Posted January 18, 2008 Try this function startMap(startedMap) local mapRoot = getResourceRootElement(startedMap) local players = getElementsByType("player") local spawns = getElementsByType("spawnpoint") for key, player in pairs(players) do local spawn = spawns[math.random(1, #spawns)] local posX = getElementData(spawn, "posX") local posY = getElementData(spawn, "posY") local posZ = getElementData(spawn, "posZ") local angle = getElementData(spawn, "angle") spawnPlayer(player, posX, posY, posZ, angle) fadeCamera (player, false, 1.0, 0, 0, 0 ) end end addEventHandler ( "onGamemodeMapStart", getRootElement(), startMap ) Edit: bah eAi was faster
iPot Posted January 18, 2008 Author Posted January 18, 2008 Well thank you I guess i deleted some wrong stuff Tom
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now