BolonZX Posted March 25, 2014 Share Posted March 25, 2014 I am to trying to make a script that when a player joins my server it shows a black background and it doesn't spawn the user until he/she downloads all the resources. So the problem is that when the user is done downloading all the resources it does not spawn the user instead it shows the sky and nothing happens. here is the code: client: addEventHandler("onClientResourceStart",resourceRoot,function() fadeCamera(true) triggerServerEvent("onPlayerFilesDownloaded",localPlayer) end) server: addEventHandler("onPlayerJoin",root,function() fadeCamera(source,false,0) end) addEvent("onPlayerFilesDownloaded",true) addEventHandler("onPlayerFilesDownloaded",root,function() spawnPlayer(source,2125.7995605469,-1545.5288085938,302.15188598633) end) Link to comment
TheGamingMann Posted March 25, 2014 Share Posted March 25, 2014 I am new at scripting but I see what you are missing. Try this: Client: addEventHandler("onClientResourceStart",resourceRoot,function() fadeCamera(true) triggerServerEvent("onPlayerFilesDownloaded",localPlayer) end) Server: addEventHandler("onPlayerJoin",root,function() fadeCamera(source,false,0) end) addEvent("onPlayerFilesDownloaded",true) addEventHandler("onPlayerFilesDownloaded",root,function() spawnPlayer(source,2125.7995605469,-1545.5288085938,302.15188598633) fadeCamera(source, true) setCameraTarget(source) end) Note: Tested and seems to work fine. Link to comment
cheez3d Posted March 25, 2014 Share Posted March 25, 2014 Client: addEventHandler("onClientResourceStart",resourceRoot,function() triggerServerEvent("onPlayerFilesDownloaded",localPlayer) end) Server: addEventHandler("onPlayerJoin",root,function() fadeCamera(source,false,0) end) addEvent("onPlayerFilesDownloaded",true) addEventHandler("onPlayerFilesDownloaded",root,function() spawnPlayer(client,2125.7995605469,-1545.5288085938,302.15188598633) fadeCamera(client,true) setCameraTarget(client,client) -- use client instead of source for security end) Link to comment
BolonZX Posted March 25, 2014 Author Share Posted March 25, 2014 both scripts work thanks guys. Cheez3D what do you mean when you say "use client instead of source for security" Link to comment
Moderators IIYAMA Posted March 25, 2014 Moderators Share Posted March 25, 2014 client = always the playerElement who sends the data. source = the element that is sending with the event. >triggerServerEvent("onPlayerFilesDownloaded",localPlayer)< But afaik there aren't much people in mta who are able to send events without using a script. Maybe the development team can. I am using source as player too, unless I am sending another element as source. Link to comment
TheGamingMann Posted March 25, 2014 Share Posted March 25, 2014 Your welcome for the help. Link to comment
BolonZX Posted April 19, 2014 Author Share Posted April 19, 2014 Your welcome for the help. I know is a late reply but thank you 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