Jump to content

HELP-ME !!


Dinossauro

Recommended Posts

Hello

I have one script. In the script there is a place on the map where they sell drugs.

script:

s_drug.lua

--[[ 
    Para se drogar, diriga-se à respetiva loja,  
    marcada no mapa, compre a quantidade que  
    quiser por um determinado dinheiro, irá  
    ter vários efeitos visuais, esp. que goste! 
]]-- 
  
function restoreWeather() 
    local ww,bb = getWeather() 
    triggerClientEvent(source, "restoreWeather", source, ww) 
end 
  
addEvent("restoreWeather", true) 
addEventHandler("restoreWeather", getRootElement(), restoreWeather) 
  
function takeMoney(howmuch) 
    takePlayerMoney(source,tonumber(howmuch)) 
end 
  
  
addEvent("takeMoney", true) 
addEventHandler("takeMoney", getRootElement(), takeMoney) 

c_drug.lua

function timeCheck() 
    local hh, mm = getTime()
    if (hh<7) then
        local ww, bb = getWeather()
        if (ww ~= -52123) then
            setWeather(-52123)
        end    
    else
        local ww, bb = getWeather()
        if (ww ~= 190) then
            setWeather(190)
        end
    end
end
 
function fall()
    if (isDrugActive) then
        setPedAnimation(getLocalPlayer(), "ped", "getup_front",1000, false, false)
        setTimer(function() fall() end, math.random(10000, 30000), 1)
        setTimer(function() setControlState ('jump',true) end, 1500, 1)
        setTimer(function() setControlState ('jump',false) end, 2000, 1)
    end
end
 
function fades()
    local rnd = math.random(2,4)
    fadeCamera(false, rnd, math.random(1,255), math.random(1,255), math.random(1,255))
    local xx, yy, zz = getElementPosition(getLocalPlayer())
    setTimer(function() fadeCamera(true, 1) end, rnd*1000/2, 1)
end
 
 
function drugSteer()
    left=false
    right=false
    up=false
    down=false
   
    local keys = getBoundKeys ('vehicle_left')
    if keys then
        tmpLeft = false
        for keyName, state in pairs(keys) do
            if (getKeyState(keyName)) then
                tmpLeft=true
            end
        end
        if tmpLeft then
            left=true
            right=false
        end
    end
 
    local keys = getBoundKeys ('vehicle_right')
    if keys then
        tmpRight = false
        for keyName, state in pairs(keys) do
            if (getKeyState(keyName)) then
                tmpRight=true
            end
        end
        if tmpRight then
            left=false
            right=true
        end
    end
 
    if (left) then
        setControlState('vehicle_left', false)
        setControlState('vehicle_right', true)
    elseif (right) then
        setControlState('vehicle_right', false)
        setControlState('vehicle_left', true)
    else
        setControlState('vehicle_right', false)
        setControlState('vehicle_left', false)
    end
   
   
    local keys = getBoundKeys ('accelerate')
    if keys then
        tmpUp = false
        for keyName, state in pairs(keys) do
            if (getKeyState(keyName)) then
                tmpUp=true
            end
        end
        if tmpUp then
            down=false
            up=true
        end
    end
   
    local keys = getBoundKeys ('brake_reverse')
    if keys then
        tmpDown = false
        for keyName, state in pairs(keys) do
            if (getKeyState(keyName)) then
                tmpDown=true
            end
        end
        if tmpDown then
            down=true
            up=false
        end
    end
   
    if (up) then
        setControlState('accelerate', false)
        setControlState('brake_reverse', true)
    elseif (down) then
        setControlState('brake_reverse', false)
        setControlState('accelerate', true)
    else
        setControlState('brake_reverse', false)
        setControlState('accelerate', false)
    end
end
 
roll = 0
rollGrow = false
function drugCam()
    if (rollGrow) then
        if (roll > 15) then rollGrow = false end
        roll = roll + 1
    else
        if (roll < -15) then rollGrow = true end
        roll = roll -1
    end
    local xx, yy, zz = getElementPosition(getLocalPlayer())
    local rot = getPedRotation(getLocalPlayer())
    local lx = xx + math.sin (math.rad(-rot)) * -10
    local ly = yy + math.cos (math.rad(-rot)) * -10
    setCameraMatrix(lx, ly, zz + 4, xx, yy, zz, roll)
    fxAddBlood(xx, yy, zz, 0, 0, 0, 6)
end
 
function startDrug(time)
    fadeCamera(false)
    setTimer(function(time)
        if (time == nil) then
            time = 10*1000
        else
            if (tonumber(time) < 5000) then
            tiaaame = 10*1000
            end
        end
       
        timerWeather = setTimer(function() timeCheck() end, 1000)
        timerFades = setTimer(function() fades() end, 4000)
        isDrugActive = true
        setTimer(function() fall() end, 1000, 1)
        addEventHandler("onClientRender", getRootElement(), drugSteer)
        addEventHandler("onClientPreRender", getRootElement(), drugCam)
       
        setTimer(function() stopDrug() end, time, 1)
    end, 1500, 1, time)
end
 
function stopDrug()
    fadeCamera(false)
    killTimer(timerFades)
    killTimer(timerWeather)
    isDrugActive = false
    fadeCamera(false)
    removeEventHandler("onClientRender", getRootElement(), drugSteer)
    removeEventHandler("onClientPreRender", getRootElement(), drugCam)
    fadeCamera(false)
    triggerServerEvent("restoreWeather", getLocalPlayer())
    setTimer(function()
        setCameraTarget(getLocalPlayer())
        fadeCamera(true)
    end, 2500, 1)
end
 
function startDrug2()
    startDrug(4)
end
function stopDrug2()
    stopDrug()
end
 
--addCommandHandler("sd", startDrug2)
--addCommandHandler("sds", stopDrug2)
 
function restoreWeather(ww)
    setWeather(ww)
end
 
addEvent("restoreWeather", true)
addEventHandler("restoreWeather", getRootElement(), restoreWeather)
 
 
 
 
 
function missionStart(whichMouse, state, absoluteX, absoluteY)
    local number = getElementData(source,"number") -- this is the button "id"
   
    local money=getPlayerMoney(getLocalPlayer())
    if (number=='a') then
        if (money>=1000) then
            startDrug(1*60*1000)
            triggerServerEvent("takeMoney", getLocalPlayer(),5000)
        else
            outputChatBox("Não tens dinheiro suficiente!", 255, 0, 0)
        end
    elseif (number=='b') then
        if (money>=3000) then
            startDrug(3*60*1000)
            triggerServerEvent("takeMoney", getLocalPlayer(),10000)
        else
            outputChatBox("Não tens dinheiro suficiente!", 255, 0, 0)
        end
    elseif (number=='c') then
        if (money>=5000) then
            startDrug(6*60*1000)
            triggerServerEvent("takeMoney", getLocalPlayer(),15000)
        else
            outputChatBox("Não tens dinheiro suficiente!", 255, 0, 0)
        end
    else
        if (money>=8000) then
            startDrug(10*60*1000)
            triggerServerEvent("takeMoney", getLocalPlayer(),20000)
        else
            outputChatBox("Não tens dinheiro suficiente!", 255, 0, 0)
        end
    end
 
    --outputChatBox("#00ff00\"dfdf\" #ffffff started!",255,255,255,true)
    guiSetVisible (missionSelectWindow1, false)
    showCursor (false)
end
 
 
-- this fires when player hits the marker
function missionSelect(hitPlayer, matchingDimension)
    if (hitPlayer == getLocalPlayer()) and (isPedOnGround (getLocalPlayer()) and not isPedInVehicle(hitPlayer)) then
        if isDrugActive then
            outputChatBox("Tu já estas drogado. Queres morrer?", 255, 0, 0)
        else
            guiSetVisible (missionSelectWindow1, true)
            guiBringToFront (missionSelectWindow1)
            showCursor (true)   
        end
    end
end
 
function guiCancel ()
    guiSetVisible (missionSelectWindow1, false)
   
Link to comment

so u want that while theyre using the drug they cant die?

try this:

function stopDamage ( attacker, weapon, bodypart ) 
    if isDrugActive then 
        cancelEvent() 
    end 
end 
addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), stopDamage ) 

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