Jump to content

Please help :(


-.Paradox.-

Recommended Posts

Posted

Hello guys, i made this script, it suppose to add a sigarette into player mouth and fade camera and set animation to smoking and toggle control state to false, and after 9 seconds the sigarette must disappear and the player must stop animation and all control state back normal but it don't work help please and thanks.

function sigarette ( thePlayer, commandName ) 
    local x, y, z = getElementPosition ( thePlayer )  
    local sigarette = createObject ( 1485, 0, 0, 0 ) 
    attachElements ( sigarette, thePlayer, 0.05, 0, 0.7, 0, 45, 118 ) 
local faded = false 
    if faded then 
        fadeCamera ( player, true )     
    else 
        fadeCamera ( player, false, 1, 250, 0, 0 ) 
    end 
    faded = not faded  
    toggleControl ( thePlayer, "jump", false ) 
    toggleControl ( thePlayer, "sprint", false ) 
    toggleControl ( thePlayer, "walk", false ) 
    toggleControl ( thePlayer, "forwads", false ) 
    toggleControl ( thePlayer, "backwards", false ) 
    toggleControl ( thePlayer, "left", false ) 
    toggleControl ( thePlayer, "right", false ) 
    toggleControl ( thePlayer, "aim_weapon", false ) 
    toggleControl ( thePlayer, "fire", false ) 
    toggleControl ( thePlayer, "enter_exit", false ) 
    setPedAnimation ( source, "SMOKING", "M_smkstnd_loop") 
end 
addCommandHandler ( "smoke", sigarette ) 
  
setTimer( 
function () 
    stopObject ( sigarette ) 
    detachElements ( sigarette ) 
    toggleControl ( thePlayer, "jump", true ) 
    toggleControl ( thePlayer, "sprint", true ) 
    toggleControl ( thePlayer, "walk", true ) 
    toggleControl ( thePlayer, "forwads", true ) 
    toggleControl ( thePlayer, "backwards", true ) 
    toggleControl ( thePlayer, "left", true ) 
    toggleControl ( thePlayer, "right", true ) 
    toggleControl ( thePlayer, "aim_weapon", true ) 
    toggleControl ( thePlayer, "fire", true ) 
    toggleControl ( thePlayer, "enter_exit", true ) 
end 
, 9000, 1) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Change

setPedAnimation ( source, "SMOKING", "M_smkstnd_loop") 

To

setPedAnimation ( thePlayer, "SMOKING", "M_smkstnd_loop") 

Do the same with the fadeCamera.

Posted

"thePlayer" is not defined on the function executed by your timer.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

So the script is okay? because it only attach the sigarette to the mouth of cj

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Move the timer inside the function. I've corrected your code:

function sigarette ( thePlayer, commandName ) 
    local x, y, z = getElementPosition ( thePlayer ) 
    local sigarette = createObject ( 1485, 0, 0, 0 ) 
    attachElements ( sigarette, thePlayer, 0.05, 0, 0.7, 0, 45, 118 ) 
local faded = false 
    if faded then 
        fadeCamera ( thePlayer, true )     
    else 
        fadeCamera ( thePlayer, false, 1, 250, 0, 0 ) 
    end 
    faded = not faded 
    toggleControl ( thePlayer, "jump", false ) 
    toggleControl ( thePlayer, "sprint", false ) 
    toggleControl ( thePlayer, "walk", false ) 
    toggleControl ( thePlayer, "forwads", false ) 
    toggleControl ( thePlayer, "backwards", false ) 
    toggleControl ( thePlayer, "left", false ) 
    toggleControl ( thePlayer, "right", false ) 
    toggleControl ( thePlayer, "aim_weapon", false ) 
    toggleControl ( thePlayer, "fire", false ) 
    toggleControl ( thePlayer, "enter_exit", false ) 
    setPedAnimation ( thePlayer, "SMOKING", "M_smkstnd_loop") 
     
setTimer( 
function () 
     
    destroyElement ( sigarette ) -- The is no 'stopObject' - well actually there is, but it cancels the movement of the object, its not used for deleting an object 
    fadeCamera(thePlayer, true) -- I've added this. 
    toggleControl ( thePlayer, "jump", true ) 
    toggleControl ( thePlayer, "sprint", true ) 
    toggleControl ( thePlayer, "walk", true ) 
    toggleControl ( thePlayer, "forwads", true ) 
    toggleControl ( thePlayer, "backwards", true ) 
    toggleControl ( thePlayer, "left", true ) 
    toggleControl ( thePlayer, "right", true ) 
    toggleControl ( thePlayer, "aim_weapon", true ) 
    toggleControl ( thePlayer, "fire", true ) 
    toggleControl ( thePlayer, "enter_exit", true ) 
    setPedAnimation(thePlayer,false) 
end 
, 9000, 1)   
  
end 
addCommandHandler ( "smoke", sigarette ) 
  

Also, I recommend you to use bone attach ( https://community.multitheftauto.com/index.php?p= ... ls&id=2540 ), instead of attaching it to the ped itself.

Posted

It's working thanks, but i want to make that fade screen flash

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

this suppose to flash it

local faded = false 
    if faded then 
        fadeCamera ( thePlayer, true )     
    else 
        fadeCamera ( thePlayer, false, 1, 250, 0, 0 ) 
    end 
    faded = not faded 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
function sigarette ( thePlayer, commandName ) 
    local x, y, z = getElementPosition ( thePlayer ) 
    local sigarette = createObject ( 1485, 0, 0, 0 ) 
     
    attachElements ( sigarette, thePlayer, 0.05, 0, 0.7, 0, 45, 118 ) 
    toggleControl ( thePlayer, "jump", false ) 
    toggleControl ( thePlayer, "sprint", false ) 
    toggleControl ( thePlayer, "walk", false ) 
    toggleControl ( thePlayer, "forwads", false ) 
    toggleControl ( thePlayer, "backwards", false ) 
    toggleControl ( thePlayer, "left", false ) 
    toggleControl ( thePlayer, "right", false ) 
    toggleControl ( thePlayer, "aim_weapon", false ) 
    toggleControl ( thePlayer, "fire", false ) 
    toggleControl ( thePlayer, "enter_exit", false ) 
    setPedAnimation ( thePlayer, "SMOKING", "M_smkstnd_loop") 
     
    faded = false 
    setTimer(function() 
        faded = not faded 
        fadeCamera(thePlayer, faded, 1, 255, 0, 0) 
    end, 1000, 9) 
         
    
    setTimer( 
    function () 
        
        destroyElement ( sigarette )  
        toggleControl ( thePlayer, "jump", true ) 
        toggleControl ( thePlayer, "sprint", true ) 
        toggleControl ( thePlayer, "walk", true ) 
        toggleControl ( thePlayer, "forwads", true ) 
        toggleControl ( thePlayer, "backwards", true ) 
        toggleControl ( thePlayer, "left", true ) 
        toggleControl ( thePlayer, "right", true ) 
        toggleControl ( thePlayer, "aim_weapon", true ) 
        toggleControl ( thePlayer, "fire", true ) 
        toggleControl ( thePlayer, "enter_exit", true ) 
        setPedAnimation(thePlayer,false) 
    end, 9000, 1)  
  
end 
addCommandHandler ( "smoke", sigarette ) 
  

Posted

Thank you

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

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