Jump to content

Help: Function to Get Remaining Times?


Hadif

Recommended Posts

Hello guys! I need to modify my script, I want to get times remaining. Example: If player get out from Tierra Robada and Bone County for 10 seconds, that player will be kill or vehicle will be explode. Any help will be appreciate!

Script:

addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource ( ) ), 
    function ( ) 
        startLocator ( ) 
    end 
) 
  
function theLocator ( ) 
    local allLocations = { 
    "Las Venturas", 
    "San Fierro", 
    "Whetstone", 
    "Flint County", 
    "Red County", 
    "Los Santos" 
    } 
    local allPlayers = getElementsByType ( "player" ) 
    local allVehicles = getElementsByType ( "vehicle" ) 
    for index, thePlayer in ipairs ( allPlayers ) do 
        local theLocation = getElementZoneName ( thePlayer, true ) 
        for index, allLocations in ipairs ( allLocations ) do 
            if ( theLocation == allLocations ) then 
                killPed ( thePlayer ) 
            end 
        end 
    end 
    for index, theVehicle in ipairs ( allVehicles ) do 
        local theLocation = getElementZoneName ( theVehicle, true ) 
        for index, allLocations in ipairs ( allLocations ) do 
            if ( theLocation == allLocations ) then 
                blowVehicle ( theVehicle ) 
            end 
        end 
    end 
end 
  
function startLocator ( ) 
    setTimer ( theLocator, 50, 0 ) 
end 

Link to comment
local deathTimer 
  
function theLocator ( ) 
    local allLocations = { 
    "Las Venturas", 
    "San Fierro", 
    "Whetstone", 
    "Flint County", 
    "Red County", 
    "Los Santos" 
    } 
    local allPlayers = getElementsByType ( "player" ) 
    local allVehicles = getElementsByType ( "vehicle" ) 
    for index, thePlayer in ipairs ( allPlayers ) do 
        local theLocation = getElementZoneName ( thePlayer, true ) 
        for index, allLocations in ipairs ( allLocations ) do 
            if ( theLocation == allLocations ) then 
                if not isTimer(deathTimer) then 
                    deathTimer = setTimer(killPed, 10000, 1, thePlayer ) 
                end 
            else 
                if isTimer(deathTimer) then 
                    killTimer(deathTimer) 
                end 
            end 
        end 
    end 
    for index, theVehicle in ipairs ( allVehicles ) do 
        local theLocation = getElementZoneName ( theVehicle, true ) 
        for index, allLocations in ipairs ( allLocations ) do 
            if ( theLocation == allLocations ) then 
                if not isTimer(deathTimer) then 
                    deathTimer = setTimer(blowVehicle, 10000, 1, theVehicle ) 
                end 
            else 
                if isTimer(deathTimer) then 
                    killTimer(deathTimer) 
                end 
            end 
        end 
    end 
end 

Link to comment
local deathTimer 
  
function theLocator ( ) 
    local allLocations = { 
    "Las Venturas", 
    "San Fierro", 
    "Whetstone", 
    "Flint County", 
    "Red County", 
    "Los Santos" 
    } 
    local allPlayers = getElementsByType ( "player" ) 
    local allVehicles = getElementsByType ( "vehicle" ) 
    for index, thePlayer in ipairs ( allPlayers ) do 
        local theLocation = getElementZoneName ( thePlayer, true ) 
        for index, allLocations in ipairs ( allLocations ) do 
            if ( theLocation == allLocations ) then 
                if not isTimer(deathTimer) then 
                    deathTimer = setTimer(killPed, 10000, 1, thePlayer ) 
                end 
            else 
                if isTimer(deathTimer) then 
                    killTimer(deathTimer) 
                end 
            end 
        end 
    end 
    for index, theVehicle in ipairs ( allVehicles ) do 
        local theLocation = getElementZoneName ( theVehicle, true ) 
        for index, allLocations in ipairs ( allLocations ) do 
            if ( theLocation == allLocations ) then 
                if not isTimer(deathTimer) then 
                    deathTimer = setTimer(blowVehicle, 10000, 1, theVehicle ) 
                end 
            else 
                if isTimer(deathTimer) then 
                    killTimer(deathTimer) 
                end 
            end 
        end 
    end 
end 

Not working... :(

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