OrbTanT Posted July 21, 2014 Share Posted July 21, 2014 Good I am using a system of respawn player, and I'm trying to set the time to respawn after dying,more the setTimer is not working. local spawnLocations = { {2171.90625, 1392.59765625, 10.8203125}, {2265.3674316406, 2398.3068847656, 10.8203125}, {2361.689453125, 2070.2077636719, 10.671875} } local spawnPlayer = function() local chosenSpawnLocation = math.random(1,#spawnLocations) spawnPlayer(source,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3]) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("onPlayerJoin",root,spawnPlayer) local spawnLocations = { {2171.90625, 1392.59765625, 10.8203125}, {2265.3674316406, 2398.3068847656, 10.8203125}, {2361.689453125, 2070.2077636719, 10.671875} } local respawnPlayer = function() local chosenSpawnLocation = math.random(1,#spawnLocations) spawnPlayer(source,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3]) fadeCamera(source, true) setCameraTarget(source, source) setTimer ( source, 5000 ) end addEventHandler("onPlayerWasted",root,respawnPlayer) Link to comment
xeon17 Posted July 21, 2014 Share Posted July 21, 2014 local spawnLocations = { {2171.90625, 1392.59765625, 10.8203125}, {2265.3674316406, 2398.3068847656, 10.8203125}, {2361.689453125, 2070.2077636719, 10.671875} } local spawnPlayer = function() local chosenSpawnLocation = math.random(1,#spawnLocations) spawnPlayer(source,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3]) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("onPlayerJoin",root,spawnPlayer) local spawnLocations = { {2171.90625, 1392.59765625, 10.8203125}, {2265.3674316406, 2398.3068847656, 10.8203125}, {2361.689453125, 2070.2077636719, 10.671875} } local respawnPlayer = function() local chosenSpawnLocation = math.random(1,#spawnLocations) spawnPlayer(source,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3]) fadeCamera(source, true) setCameraTarget(source, source) setTimer ( respawnPlayer, 5000, 5000, source) end addEventHandler("onPlayerWasted",root,respawnPlayer) Link to comment
OrbTanT Posted July 21, 2014 Author Share Posted July 21, 2014 Still is not working, Still same problem the previous script. WARNING: [gamemodes]\[teamwar]\TeamWar\script.lua:26: Bad argument @ 'setTimer' [Expected function at argument 1, got nil] Link to comment
ViRuZGamiing Posted July 21, 2014 Share Posted July 21, 2014 How about this? addEventHandler("onPlayerWasted",root, setTimer(function() local chosenSpawnLocation = math.random(1,#spawnLocations) spawnPlayer(source,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3]) fadeCamera(source, true) setCameraTarget(source, source) end, 5000, 1) end) Link to comment
Et-win Posted July 21, 2014 Share Posted July 21, 2014 addEventHandler("onPlayerWasted",root, setTimer(function(tPlayer) local chosenSpawnLocation = math.random(1,#spawnLocations) spawnPlayer(tPlayer,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3]) fadeCamera(tPlayer, true) setCameraTarget(tPlayer, tPlayer) end, 5000, 1, source) end) You forgot to send the 'source' withing the setTimer, because setTimer has no source you have to send it with it. Link to comment
OrbTanT Posted July 21, 2014 Author Share Posted July 21, 2014 Now appeared bad argument in: SpawnPlayer, FadeCamera, SetCameraTarget. setTimer(function() local chosenSpawnLocation = math.random(1,#spawnLocations) spawnPlayer(source,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3]) fadeCamera(source, true) setCameraTarget(source, source) end, 5000, 1) addEventHandler("onPlayerWasted", root, setTimer) Link to comment
Et-win Posted July 21, 2014 Share Posted July 21, 2014 setTimer is a code and you can't use it like that. Also, like I said, send 'source' with the timer. Like this: function spawnThePlayer() setTimer(function(tPlayer) local chosenSpawnLocation = math.random(1,#spawnLocations) spawnPlayer(tPlayer,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3]) fadeCamera(tPlayer, true) setCameraTarget(tPlayer, tPlayer) end, 5000, 1, source) end addEventHandler("onPlayerWasted", getRootElement(), spawnThePlayer) (Tested) EDIT: Forgot to add it, it's working now x3 Link to comment
OrbTanT Posted July 21, 2014 Author Share Posted July 21, 2014 I was using "source" more was not working, not this more with the errors, the only problem that is not giving respawn after dying Link to comment
OrbTanT Posted July 21, 2014 Author Share Posted July 21, 2014 Continues giving bad argument in: SpawnPlayer, FadeCamera, SetCameraTarget. Link to comment
Et-win Posted July 21, 2014 Share Posted July 21, 2014 Weird, because mine is working. Link to comment
OrbTanT Posted July 21, 2014 Author Share Posted July 21, 2014 This is the complete script that I am using. local spawnLocations = { {2171.90625, 1392.59765625, 10.8203125}, {2265.3674316406, 2398.3068847656, 10.8203125}, {2361.689453125, 2070.2077636719, 10.671875} } local spawnPlayer = function() local chosenSpawnLocation = math.random(1,#spawnLocations) spawnPlayer(source,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3]) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("onPlayerJoin",root,spawnPlayer) local spawnLocations = { {2171.90625, 1392.59765625, 10.8203125}, {2265.3674316406, 2398.3068847656, 10.8203125}, {2361.689453125, 2070.2077636719, 10.671875} } function spawnThePlayer() setTimer(function(tPlayer) local chosenSpawnLocation = math.random(1,#spawnLocations) spawnPlayer(tPlayer,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3]) fadeCamera(tPlayer, true) setCameraTarget(tPlayer, tPlayer) end, 5000, 1, source) end addEventHandler("onPlayerWasted", getRootElement(), spawnThePlayer) Link to comment
Et-win Posted July 21, 2014 Share Posted July 21, 2014 local spawnLocations = { {2171.90625, 1392.59765625, 10.8203125}, {2265.3674316406, 2398.3068847656, 10.8203125}, {2361.689453125, 2070.2077636719, 10.671875} } function spawnThePlayerDirectly() local chosenSpawnLocation = math.random(1,#spawnLocations) spawnPlayer(source,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3]) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("onPlayerJoin",root,spawnThePlayerDirectly) local spawnLocations = { {2171.90625, 1392.59765625, 10.8203125}, {2265.3674316406, 2398.3068847656, 10.8203125}, {2361.689453125, 2070.2077636719, 10.671875} } function spawnThePlayer() setTimer(function(tPlayer) local chosenSpawnLocation = math.random(1,#spawnLocations) spawnPlayer(tPlayer,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3]) fadeCamera(tPlayer, true) setCameraTarget(tPlayer, tPlayer) end, 5000, 1, source) end addEventHandler("onPlayerWasted", getRootElement(), spawnThePlayer) Not sure or you can throw a function into a variable. Link to comment
OrbTanT Posted July 21, 2014 Author Share Posted July 21, 2014 Is now working, was going on a conflict between the events, thank you for your assistance 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