Jump to content

[HELP] FadeCamera problem


BolonZX

Recommended Posts

Posted

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-|

Posted

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.

Posted

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) 

Posted

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
Posted

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 

  Tutorials  4x 

 

  • 4 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...