Amine#TN Posted May 21, 2017 Share Posted May 21, 2017 hi guys i made this script for players who join the server for the FIRST time but i have a problem i want the players who didnt spawn yet be frozen any idea local randomSpawnTable = { { 152.24,-2090,702 }, { 152.24,-2090,702 }, { 152.24,-2090,702 } } function randomSpawn( thePlayer, randomSpawnTable ) local random = math.random( 1, #randomSpawnTable ) spawnPlayer( thePlayer, randomSpawnTable[random][1], randomSpawnTable[random][2], randomSpawnTable[random][3], randomSpawnTable[random][4] ) setElementModel ( thePlayer, 312 ) giveWeapon ( thePlayer, 46 ) giveWeapon ( thePlayer, 9 ) giveWeapon ( thePlayer, 25, 5000 ,true ) giveWeapon ( thePlayer, 28, 5000 ,true ) giveWeapon ( thePlayer, 31, 5000 ,true ) giveWeapon ( thePlayer, 22, 5000 ,true ) end function onPlayerJoin() fadeCamera( source, true ) setCameraTarget( source, source ) randomSpawn( source, randomSpawnTable ) end addEventHandler( "onPlayerJoin",root, onPlayerJoin ) Link to comment
pa3ck Posted May 22, 2017 Share Posted May 22, 2017 (edited) I don't get it, onPlayerJoin gets called as soon as the player joins and you spawn them right away, there should be no window between joining and spawning? Edited May 22, 2017 by pa3ck Link to comment
Hale Posted May 22, 2017 Share Posted May 22, 2017 (edited) Hi, first off you're trying to get the 4th value of randomSpawnTable which doesn't exist (randomSpawnTable[random][4])? Second, to actually know if a player is joining for the first time or not, I'd suggest you store every player's serial key once they join in XML file or SQL table (your choice). That way you can loop through the XML file or SQL table in the onPlayerJoin function and if no serial matches his own then use setElementFrozen. Edited May 22, 2017 by Hale Link to comment
Amine#TN Posted May 22, 2017 Author Share Posted May 22, 2017 no i want all the players who join the server be frozen and when they login they can move local randomSpawnTable = { { 152.24,-2090,702 }, { 152.24,-2090,702 }, { 152.24,-2090,702 } } function randomSpawn( thePlayer, randomSpawnTable ) local random = math.random( 1, #randomSpawnTable ) spawnPlayer( thePlayer, randomSpawnTable[random][1], randomSpawnTable[random][2], randomSpawnTable[random][3], randomSpawnTable[random][4] ) setElementModel ( thePlayer, 312 ) giveWeapon ( thePlayer, 46 ) giveWeapon ( thePlayer, 9 ) giveWeapon ( thePlayer, 25, 5000 ,true ) giveWeapon ( thePlayer, 28, 5000 ,true ) giveWeapon ( thePlayer, 31, 5000 ,true ) giveWeapon ( thePlayer, 22, 5000 ,true ) end function onPlayerJoin() fadeCamera( source, true ) setElementFrozen ( source, true ) setCameraTarget( source, source ) randomSpawn( source, randomSpawnTable ) end addEventHandler( "onPlayerJoin",root, onPlayerJoin ) function onPlayerLogin() setElementFrozen ( source, false ) end addEventHandler( "onPlayerLogin",root, onPlayerLogin ) Link to comment
WorthlessCynomys Posted May 22, 2017 Share Posted May 22, 2017 Hello. I think that your problem is that the player is not existing when you freeze it. So the code runs from the top to the bottom and your freeze happens way before the spawn. What's more, you use randomSpawnTable[random][4] which is not an existing thing. Link to comment
Amine#TN Posted May 22, 2017 Author Share Posted May 22, 2017 local randomSpawnTable = { { 152.24,-2090,702 }, { 152.24,-2090,702 }, { 152.24,-2090,702 } } function randomSpawn( thePlayer, randomSpawnTable ) local random = math.random( 1, #randomSpawnTable ) spawnPlayer( thePlayer, randomSpawnTable[random][1], randomSpawnTable[random][2], randomSpawnTable[random][3] ) setElementModel ( thePlayer, 312 ) giveWeapon ( thePlayer, 46 ) giveWeapon ( thePlayer, 9 ) giveWeapon ( thePlayer, 25, 5000 ,true ) giveWeapon ( thePlayer, 28, 5000 ,true ) giveWeapon ( thePlayer, 31, 5000 ,true ) giveWeapon ( thePlayer, 22, 5000 ,true ) end function onPlayerJoin() fadeCamera( source, true ) setElementFrozen ( source, true ) setCameraTarget( source, source ) randomSpawn( source, randomSpawnTable ) end addEventHandler( "onPlayerJoin",root, onPlayerJoin ) function onPlayerLogin() setElementFrozen ( source, false ) end addEventHandler( "onPlayerLogin",root, onPlayerLogin ) not working yet Link to comment
koragg Posted May 22, 2017 Share Posted May 22, 2017 (edited) Try this, maybe @StormFighter is right about the player not being created so early. function onPlayerJoin() setTimer(function(source) fadeCamera(source, true) setElementFrozen(source, true) setCameraTarget(source, source) randomSpawn(source, randomSpawnTable) end, 1000, 1, source) end addEventHandler("onPlayerJoin", root, onPlayerJoin) function onPlayerLogin() setElementFrozen(source, false) end addEventHandler("onPlayerLogin", root, onPlayerLogin) Experiment with the timer's duration a bit, if this^ does nothing, try setting it from 1000ms to 10000ms (from 1second to 10 seconds) just to see if it will do anything when the player has for sure been created. Edited May 22, 2017 by koragg Link to comment
Amine#TN Posted May 23, 2017 Author Share Posted May 23, 2017 didnt work any other help please i fixed it thanx all Link to comment
DNL291 Posted May 23, 2017 Share Posted May 23, 2017 What's the point of freezing a not spawned player? He'll become unfreezed when spawned. 1 Link to comment
Amine#TN Posted May 23, 2017 Author Share Posted May 23, 2017 YES that is why i added the freez command to spawn player fonction 1 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