Backsage Posted April 16, 2016 Share Posted April 16, 2016 Hi all. I'm trying out the spawnmanager resource. And I'm trying to create a spawnpoint, but it's not working. However, when I tried mark2 command, it spawned me somewhere and made a sound. Edit: I found out that the optional requirements for createSpawnpoint are actually required. That's why it wasn't working. Old: Server: function createSP( source, command, skin) local x, y, z = getElementPosition( source ) --Get the players location local rot = getPlayerRotation( source ) --Get the players rotation local theSpawnpoint = call(getResourceFromName("spawnmanager"), "createSpawnpoint", x, y, z, rot, skin ) --Create the spawnpoint. if ( theSpawnpoint ) then outputConsole ( "Spawnpoint created.", source ) --notify the player if it was successful else outputChatBox("Was not created.") end end addCommandHandler( "mark", createSP ) function thing() -- Get a table of all the players players = getElementsByType ( "player" ) -- Get a table of all the spawnpoints spawnpoints = getElementsByType ( "spawnpoint" ) -- Go through every player for playerKey, playerValue in ipairs (players) do -- Spawn them at the first spawnpoint call(getResourceFromName("spawnmanager"), "spawnPlayerAtSpawnpoint", playerValue, spawnpoints[1] ) end end addCommandHandler( "mark2", thing ) function spawnUse ( player ) --when a player spawns playSoundFrontEnd ( player, 16 ) --play a sound for him end addEventHandler ( "onSpawnpointUse", getRootElement(), spawnUse ) Fixed server: local spawnpointsTable = { } function createSpawnpointCmd(player,cmd,arg1) local x, y, z = getElementPosition(player) local rot = getPlayerRotation(player) local int = getElementInterior(player) local dim = getElementDimension(player) local skin = arg1 or 0 local spawnpoint = exports.spawnmanager:createSpawnpoint(x, y, z, rot, skin, int, dim) if spawnpoint then table.insert(spawnpointsTable, spawnpoint) outputChatBox("Created Spawn Point", player) else outputChatBox("Failed to create Spawn Point", player) end end addCommandHandler("createspawn",createSpawnpointCmd) function spawnPlayersCmd(player,command) local randomSpawn = math.random(1, #spawnpointsTable) for _,p in pairs(getElementsByType("player")) do exports.spawnmanager:spawnPlayerAtSpawnpoint(p, spawnpointsTable[randomSpawn]) end end addCommandHandler("spawnplayers", spawnPlayersCmd) function OnSpawnpointUse(player) playSoundFrontEnd(player, 16) end addEventHandler("onSpawnpointUse", root, OnSpawnpointUse) Link to comment
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