rusztamas Posted March 29, 2017 Share Posted March 29, 2017 function spawn_player_on_join() spawnPlayer (source, 0, 0, 0) end addEventHandler ("onPlayerJoin", spawn_player_on_join) I'd like to spawn player on join, instead of play resource spawning, but it shows a black screen. What could be the problem? Arguments? Link to comment
NeXuS™ Posted March 29, 2017 Share Posted March 29, 2017 function spawn_player_on_join() spawnPlayer (source, 0, 0, 0) fadeCamera(source, true) end addEventHandler ("onPlayerJoin", spawn_player_on_join) 1 Link to comment
rusztamas Posted March 29, 2017 Author Share Posted March 29, 2017 Now i can see the skies... It is still not good, and btw i left the argument out from the eventhandler. Link to comment
NeXuS™ Posted March 29, 2017 Share Posted March 29, 2017 Add this line to it. setCameraTarget(source) 1 Link to comment
itHyperoX Posted March 29, 2017 Share Posted March 29, 2017 addEventHandler("onPlayerJoin", root,function() spawn(source) end) function spawn(source) x, y, z = 2028.4606933594, 1342.2176513672, 10.8203125 repeat until spawnPlayer(source,x+1,y+1,z, 0,303) setCameraTarget(source, player) fadeCamera(source, true) setElementRotation(source, 0, 0, -90) end 1 Link to comment
_DrXenon Posted March 30, 2017 Share Posted March 30, 2017 don't use onPlayerJoin event I guess. Try onClientResourceStart so this thing work whenever the resource starts instead whenever the player join. when the player joins this resource would not be loaded and therefore won't work I guess. Link to comment
Administrators Lpsd Posted March 30, 2017 Administrators Share Posted March 30, 2017 (edited) local x,y,z = 0,0,0 function spawnHandler(player) spawnPlayer(player, x, y, z) fadeCamera(player, true) setCameraTarget(player, player) end function start() local players = getElementsByType ( "player" ) for i, v in ipairs(players) do spawnHandler(v) end end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), start ) function join() spawnHandler(source) end addEventHandler("onPlayerJoin", getRootElement(), join) This will handle player spawning on join, and in the event that you restart the resource whilst people are in the server it will handle respawning too. Works fine as I use this for many resources of my own. 2 hours ago, SuperCroz said: don't use onPlayerJoin event I guess. Try onClientResourceStart so this thing work whenever the resource starts instead whenever the player join. when the player joins this resource would not be loaded and therefore won't work I guess. Also this doesn't make any sense. "onPlayerJoin" is only being triggered because the resource IS loaded. Edited March 30, 2017 by LopSided_ Link to comment
NeXuS™ Posted March 30, 2017 Share Posted March 30, 2017 @LopSided_, this post is already fixed btw. You can see my posts above. Link to comment
Administrators Lpsd Posted March 30, 2017 Administrators Share Posted March 30, 2017 @NeXuS™ that's great. However I wanted to provide a slightly more advanced solution and also clear up any confusion with the information posted by SuperCroz. Link to comment
_DrXenon Posted April 1, 2017 Share Posted April 1, 2017 @LopSided_ It doesn't make any sense but I believe I was right. Because the event onPlayerJoin is triggered whenever a player joins, at this point he has no resources started therefore this won't be working for him and when the resource starts it would be too late to trigger the event onPlayerJoin because the player did not just join. To sum up, and I'm not quite sure as I mentioned above, onPlayerJoin can be only triggered when the resource was already started, so for instance to use onPlayerJoin we trigger this event to affect an already exisiting player by the joining of another player while we can't affect the joining player. 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