BolonZX Posted March 25, 2014 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) In-game name: |-FMJ-|
TheGamingMann Posted March 25, 2014 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.
cheez3d Posted March 25, 2014 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)
BolonZX Posted March 25, 2014 Author Posted March 25, 2014 both scripts work thanks guys. Cheez3D what do you mean when you say "use client instead of source for security" In-game name: |-FMJ-|
Moderators IIYAMA Posted March 25, 2014 Moderators 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. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
BolonZX Posted April 19, 2014 Author Posted April 19, 2014 Your welcome for the help. I know is a late reply but thank you In-game name: |-FMJ-|
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