Jump to content

Help Script Drugs


Recommended Posts

I am trying to create a script for drugs someone could help me? eg typing / drugs will withdraw and life vest, $ 100 and set animation and stop control control car crazy

function bmoney(thePlayer) 
    if (getPlayerMoney(thePlayer) >= 100) then 
        takePlayerMoney(thePlayer, 100) 
        outputChatBox( "#FFFF00Você gastou 100$ em 1 pedra de CRACK!", thePlayer, 255, 255, 255, true ) 
    else 
        outputChatBox( "Você deve ter $100 ou mais para usar este comando.", thePlayer, 220, 0, 0, true ) 
    end 
end 
addCommandHandler( "drogas", bmoney ) 
  
function sdrogas ( player ) 
         setPedArmor ( player, 97 ) 
         setElementHealth ( player, 30 ) 
         outputChatBox ( "Você usou Drogas!",player, 255, 255, 255, true ) 
end 
addCommandHandler ( "drogas", sdrogas ) 
  
function sdrogas (source) 
    daBlockz = getElementData(root,"blockz") 
    daAnimz = getElementData(root,"animz") 
        if daBlockz == "crack" and daAnimz == "Bbalbat_Idle_02" then 
            setPedAnimation(source,false) 
        else 
            setPedAnimation ( source, "CRACK", "Bbalbat_Idle_02") 
        end 
    end 
addCommandHandler("drogas",sdrogas) 
  
function onClientPlayerEnterVehicle ( theVehicle, seat, jacked ) 
setTimer ( onClientPlayerEnterVehicle() 
    toggleControl ( "accelerate", false ) -- disable the accelerate key 
    toggleControl ( "brake_reverse", false ) -- disable the brake_reverse key 
    toggleControl ( "handbrake", false ) -- disable the handbrake key 
    setControlState ( "accelerate", true ) -- force the accelerate key on 
    outputChatBox ( "Efeito das Drogas Passou" ) 
end, 5000, 1 ) 
end 
addEventHandler ( "onClientPlayerVehicleEnter", getRootElement(), onClientPlayerEnterVehicle ) 

Link to comment

Try this:

  
function bmoney(thePlayer) 
    if (getPlayerMoney(thePlayer) >= 100) then 
        takePlayerMoney(thePlayer, 100) 
        outputChatBox( "#FFFF00Você gastou 100$ em 1 pedra de CRACK!", thePlayer, 255, 255, 255, true ) 
        sdrogas(thePlayer) 
    else 
        outputChatBox( "Você deve ter $100 ou mais para usar este comando.", thePlayer, 220, 0, 0, true ) 
    end 
end 
addCommandHandler( "drogas", bmoney ) 
  
function sdrogas ( player ) 
    setPedArmor ( player, 97 ) 
    setElementHealth ( player, 30 ) 
    outputChatBox ( "Você usou Drogas!",player, 255, 255, 255, true ) 
     
    daBlockz = getElementData(player,"blockz") 
    daAnimz = getElementData(player,"animz") 
    if daBlockz == "crack" and daAnimz == "Bbalbat_Idle_02" then 
        setPedAnimation(player,false) 
    else 
        setPedAnimation ( player, "CRACK", "Bbalbat_Idle_02") 
    end 
end 
  
function onEnterVehicle ( theVehicle, seat, jacked ) 
setTimer ( function() 
    toggleControl ( "accelerate", false ) -- disable the accelerate key 
    toggleControl ( "brake_reverse", false ) -- disable the brake_reverse key 
    toggleControl ( "handbrake", false ) -- disable the handbrake key 
    setControlState ( "accelerate", true ) -- force the accelerate key on 
    outputChatBox ( "Efeito das Drogas Passou" ) 
end, 5000, 1 ) 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), onEnterVehicle ) 

Link to comment

Not sure if this will work, but;

function drogas(thePlayer, theCommand) 
    if not (getPlayerMoney(thePlayer) >= 100) then 
        outputChatBox( "Você deve ter $100 ou mais para usar este comando.", thePlayer, 220, 0, 0) 
    else 
        takePlayerMoney(thePlayer, 100) 
        outputChatBox( "#FFFF00Você gastou 100$ em 1 pedra de CRACK!", thePlayer, 255, 255, 0) 
        setPedArmor(thePlayer, 97) 
        setElementHealth(thePlayer, 30) 
        outputChatBox("Você usou Drogas!", thePlayer, 255, 255, 255) 
         
        local daBlockz = getElementData(thePlayer, "blockz") 
        local daAnmiz = getElementData(thePlayer, "animz") 
        if not (daBlockz == "crack") and not (daAnimx == "Bbalbat_Idle_02") then 
            setPedAnimation(thePlayer, "CRACK", "Bbalbat_Idle_02") 
            setElementData(thePlayer, "blockz", "crack") 
            setElementData(thePlayer, "animz", "Bbalbat_Idle_02") 
        else 
            setPedAnimation(thePlayer, false) 
            setElementData(thePlayer, "blockz", false) 
            setElementData(thePlayer, "animz", false) 
        end 
    end 
end 
addCommandHandler( "drogas", drogas ) 
  
function onClientPlayerEnterVehicle ( theVehicle, seat, jacked ) 
    setTimer ( onClientPlayerEnterVehicle() 
    toggleControl ( "accelerate", false ) -- disable the accelerate key 
    toggleControl ( "brake_reverse", false ) -- disable the brake_reverse key 
    toggleControl ( "handbrake", false ) -- disable the handbrake key 
    setControlState ( "accelerate", true ) -- force the accelerate key on 
    outputChatBox ( "Efeito das Drogas Passou" ) 
        end, 5000, 1 ) 
end 
addEventHandler ( "onClientPlayerVehicleEnter", getRootElement(), onClientPlayerEnterVehicle ) 

Link to comment
Not sure if this will work, but;
function drogas(thePlayer, theCommand) 
    if not (getPlayerMoney(thePlayer) >= 100) then 
        outputChatBox( "Você deve ter $100 ou mais para usar este comando.", thePlayer, 220, 0, 0) 
    else 
        takePlayerMoney(thePlayer, 100) 
        outputChatBox( "#FFFF00Você gastou 100$ em 1 pedra de CRACK!", thePlayer, 255, 255, 0) 
        setPedArmor(thePlayer, 97) 
        setElementHealth(thePlayer, 30) 
        outputChatBox("Você usou Drogas!", thePlayer, 255, 255, 255) 
         
        local daBlockz = getElementData(thePlayer, "blockz") 
        local daAnmiz = getElementData(thePlayer, "animz") 
        if not (daBlockz == "crack") and not (daAnimx == "Bbalbat_Idle_02") then 
            setPedAnimation(thePlayer, "CRACK", "Bbalbat_Idle_02") 
            setElementData(thePlayer, "blockz", "crack") 
            setElementData(thePlayer, "animz", "Bbalbat_Idle_02") 
        else 
            setPedAnimation(thePlayer, false) 
            setElementData(thePlayer, "blockz", false) 
            setElementData(thePlayer, "animz", false) 
        end 
    end 
end 
addCommandHandler( "drogas", drogas ) 
  
function onClientPlayerEnterVehicle ( theVehicle, seat, jacked ) 
    setTimer ( onClientPlayerEnterVehicle() 
    toggleControl ( "accelerate", false ) -- disable the accelerate key 
    toggleControl ( "brake_reverse", false ) -- disable the brake_reverse key 
    toggleControl ( "handbrake", false ) -- disable the handbrake key 
    setControlState ( "accelerate", true ) -- force the accelerate key on 
    outputChatBox ( "Efeito das Drogas Passou" ) 
        end, 5000, 1 ) 
end 
addEventHandler ( "onClientPlayerVehicleEnter", getRootElement(), onClientPlayerEnterVehicle ) 

"onClientPlayerVehicleEnter" is client-side only.

Link to comment

So I would like to end the SetTimer when the player does not continue with the anim and setControlState is not picking

META:

<meta> 
    <info author="Miller" version="1.0" description="drogas" name="drogas" type="script" /> 
    <script src="main.lua" type="server"/> 
</meta> 

Bem eu sei que tu é Brasileiro então eu gostaria que quando o SetTimer acabasse o ( player ) parasse com o anim e o SetControl não ta funfando :P eu entro no carro e o o elemento não inverte os movimentos do carro

Link to comment
Not sure if this will work, but;
function drogas(thePlayer, theCommand) 
    if not (getPlayerMoney(thePlayer) >= 100) then 
        outputChatBox( "Você deve ter $100 ou mais para usar este comando.", thePlayer, 220, 0, 0) 
    else 
        takePlayerMoney(thePlayer, 100) 
        outputChatBox( "#FFFF00Você gastou 100$ em 1 pedra de CRACK!", thePlayer, 255, 255, 0) 
        setPedArmor(thePlayer, 97) 
        setElementHealth(thePlayer, 30) 
        outputChatBox("Você usou Drogas!", thePlayer, 255, 255, 255) 
         
        local daBlockz = getElementData(thePlayer, "blockz") 
        local daAnmiz = getElementData(thePlayer, "animz") 
        if not (daBlockz == "crack") and not (daAnimx == "Bbalbat_Idle_02") then 
            setPedAnimation(thePlayer, "CRACK", "Bbalbat_Idle_02") 
            setElementData(thePlayer, "blockz", "crack") 
            setElementData(thePlayer, "animz", "Bbalbat_Idle_02") 
        else 
            setPedAnimation(thePlayer, false) 
            setElementData(thePlayer, "blockz", false) 
            setElementData(thePlayer, "animz", false) 
        end 
    end 
end 
addCommandHandler( "drogas", drogas ) 
  
function onClientPlayerEnterVehicle ( theVehicle, seat, jacked ) 
    setTimer ( onClientPlayerEnterVehicle() 
    toggleControl ( "accelerate", false ) -- disable the accelerate key 
    toggleControl ( "brake_reverse", false ) -- disable the brake_reverse key 
    toggleControl ( "handbrake", false ) -- disable the handbrake key 
    setControlState ( "accelerate", true ) -- force the accelerate key on 
    outputChatBox ( "Efeito das Drogas Passou" ) 
        end, 5000, 1 ) 
end 
addEventHandler ( "onClientPlayerVehicleEnter", getRootElement(), onClientPlayerEnterVehicle ) 

The setTimer function is wrong.

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