Jump to content

Smoke script [HELP]


Sande

Recommended Posts

Hey, i downloaded smoke script in mta commity, i edited it little now i have one problem.

When i type /smokeoff it doesnt destroy this sigarette.

function sigarette ( thePlayer, commandName ) 
    local x, y, z = getElementPosition ( thePlayer )  
    sig = createObject ( 1485, 0, 0, 0 ) 
    exports [ "bone_attach" ]:attachElementToBone ( sig, thePlayer,1,-0.01,-0.01,-0.02,90,90,0) 
    toggleControl ( thePlayer, "jump", false ) 
    toggleControl ( thePlayer, "sprint", false ) 
    toggleControl ( thePlayer, "crouch", false ) 
end 
addCommandHandler ( "smoke", sigarette ) 
  
function sigarette ( thePlayer, commandName ) 
    toggleControl ( thePlayer, "jump", true ) 
    toggleControl ( thePlayer, "sprint", true ) 
    toggleControl ( thePlayer, "crouch", true ) 
    destroyElement(sig) 
end 
addCommandHandler ( "smokeoff", sigarette ) 
  

Link to comment

function sigarette ( thePlayer, commandName ) 
     x, y, z = getElementPosition ( thePlayer )  
         exports [ "bone_attach" ]:attachElementToBone ( sig, thePlayer,1,-0.01,-0.01,-0.02,90,90,0) 
    sig = createObject ( 1485,x,y,z) 
    toggleControl ( thePlayer, "jump", false ) 
    toggleControl ( thePlayer, "sprint", false ) 
    toggleControl ( thePlayer, "crouch", false ) 
end 
addCommandHandler ( "smoke", sigarette ) 
  
function sigarette ( thePlayer, commandName ) 
     destroyElement(sig) 
    toggleControl ( thePlayer, "jump", true ) 
    toggleControl ( thePlayer, "sprint", true ) 
    toggleControl ( thePlayer, "crouch", true ) 
end 
addCommandHandler ( "smokeoff", sigarette ) 
  
Link to comment

Well, you should have stored the objects on a table, since if you use it, then another player does it too, it'll bug the script.

local cigarettes = { } 
  
function cigarette ( thePlayer ) 
    if ( not isElement ( cigarettes [ thePlayer ] ) ) then 
        local x, y, z = getElementPosition ( thePlayer ) 
        cigarettes [ thePlayer ] = createObject ( 1485, 0, 0, 0 ) 
        exports [ "bone_attach" ]:attachElementToBone ( cigarettes [ thePlayer ], thePlayer, 1, -0.01, -0.01, -0.02, 90, 90, 0 ) 
        toggleControl ( thePlayer, "jump", false ) 
        toggleControl ( thePlayer, "sprint", false ) 
        toggleControl ( thePlayer, "crouch", false ) 
    else 
        toggleControl ( thePlayer, "jump", true ) 
        toggleControl ( thePlayer, "sprint", true ) 
        toggleControl ( thePlayer, "crouch", true ) 
        destroyElement ( cigarettes [ thePlayer ] ) 
    end 
end 
addCommandHandler ( "smoke", cigarette ) 

Now you just need to use "/smoke".

Edit:

@Mr.Pres[T]ege: Your script has the same problem.

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