Jump to content

[HELP]FadeCamera not working


pragu

Recommended Posts

Hi, Thanks for having a look at this.

I am new to scripting and I am trying to create a basic script which will give give you some features of being in a SWAT team.

Problem: Everything works fine except the fadecamera function. What I am trying to do is, If conditions are satisfied, The player's Camera will fadeout for 3 secs to black and player's Team, Skins and weapons will be added later the camera will fade back to normal in 2 secs. Since I am totally new to scripting I have made this as a fully Server-side Script.

Code:

function teamCreate (source, commandName, teamName) 
    SWATteam = createTeam( "SWAT", 65, 105, 255) 
end 
addEventHandler("onResourceStart", resourceRoot, teamCreate) 
  
function getSwatJob(source, teamName) 
  
    local name = getPlayerName(source) 
  
    if  getPlayerTeam(source) == SWATteam  then 
        outputChatBox("You are already in SWAT team", source, 255, 0, 0, false) 
  
    else 
        fadeCamera(source, false, 3.0, 0, 0, 0 ) 
        setPlayerTeam(source, SWATteam) 
        setElementModel(source, 285) 
        outputChatBox("Welcome to SWAT team " ..getPlayerName(source).. ", You may hit 'X' to open SWAT GUI", source, 65, 105, 255, false) 
        setPlayerNametagColor ( source, 65, 105, 255) 
        --Weapons are given to source here, Cut it out since it works and will make it tougher to study this code 
        fadeCamera(source, true, 2.0) 
    end 
  
end 
addCommandHandler("goswat", getSwatJob) 

P.S If there is some tutorial on making a client-side and server-side script, Please share it with me.

Link to comment

This is because you are triggering another fadeCamera, which doesn't work while another is triggered.

Your script basically fades the camera out to black and then back to the game. Do you want this to happen or stay in black?

addEventHandler("onResourceStart", resourceRoot, 
    function teamCreate(source, commandName, teamName) 
        SWATteam = createTeam("SWAT", 65, 105, 255) 
    end 
) 
  
addCommandHandler("goswat", 
    function getSwatJob(source, teamName) 
        local name = getPlayerName(source) 
         
        if getPlayerTeam(source) == SWATteam then 
            outputChatBox("You are already in SWAT team", source, 255, 0, 0, false) 
        else 
            fadeCamera(source, false, 3.0) 
            setPlayerTeam(source, SWATteam) 
            setElementModel(source, 285) 
            outputChatBox("Welcome to SWAT team " .. getPlayerName(source) .. ", You may hit 'X' to open SWAT GUI", source, 65, 105, 255, false) 
            setPlayerNametagColor(source, 65, 105, 255) 
            setTimer(fadeCamera, 3000, 1, source, true, 2.0) 
        end 
    end 
) 

Link to comment

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