Jump to content

(HELPME)Checking with getElementData problem


Hero192

Recommended Posts

Hey guys, i made an hospital system with spawn protection also i made vehicle spawner ,so my problem is i want to check if the disableGhostMode function is still running and the timer isn't false i mean 0sec.

1st code part is the spawnprotection its in hospital resource.

2nd code part is the vehicle spawner system in other resource, and its what im looking for, i want to know how to do an getElementData and setElementData in this situation to check if the timer is still not 0 sec or false if it still working not false then when a player spawn a car from the spawner system the vehicle be with 140ALPHA too and if the timer is on the 0sec then the vehicle should back to 255 ALPHA.

--1st code part is the spawnprotection

function enableGhostMode(player) 
    setElementData( player, "spawnProtection", true ) 
    toggleControl ( player,"fire", false ) 
    toggleControl ( player,"next_weapon", false ) 
    toggleControl ( player,"previous_weapon", false ) 
    setElementAlpha( player, 170 ) 
end 
  
function disableGhostMode(player) 
        setElementData(player,"disableGhostMode",disableGhostMode) 
    setTimer( setElementData, 15000, 1, player, "spawnProtection", false ) 
    setTimer( toggleControl, 15000, 1, player,"fire", true ) 
    setTimer( toggleControl, 15000, 1, player,"next_weapon", true ) 
    setTimer( toggleControl, 15000, 1, player,"previous_weapon", true ) 
    setTimer( setElementAlpha, 15000, 1,player, 255 ) 
end 

--2nd code part is the vehicle spawner system

addEvent("spawner",true) 
addEventHandler("spawner",root, 
function (player, vehicleID, marker) 
    local x, y, z = getElementPosition(marker) 
    Vehicles[player] = createVehicle(vehicleID, x, y, z+2, 0, 0, markers[marker][3]) 
    warpPedIntoVehicle(player, Vehicles[player]) 
    local Vehicle = Vehicles[player] 
    local disableGhostMode= getElementData(player, "disableGhostMode") 
    if not disableGhostModethen return end 
    if (disableGhostMode== true) then 
     setElementAlpha ( Vehicle, 150 )  
    else 
     setElementAlpha ( Vehicle, 250 )  
    end 
end) 

I hope someone can help me because i stuck here.. thanks in advance

Link to comment

When the player spawn the vehicle i checked with the function isTimer like what you said if the timer still running or not but doesn't works

Also please can you look at the elemnt datas because im not sure of myself if they're correct i still have no experience with elementdatas.

addEvent("spawner",true) 
addEventHandler("spawner",root, 
function (player, vehicleID, marker) 
    local x, y, z = getElementPosition(marker) 
    Vehicles[player] = createVehicle(vehicleID, x, y, z+2, 0, 0, markers[marker][3]) 
    warpPedIntoVehicle(player, Vehicles[player]) 
    local Vehicle = Vehicles[player] 
    local disableGhostMode= getElementData(player, "disableGhostMode") 
    if not disableGhostMode then return end 
        if isTimer disableGhostMode[player] then --Here where is the problem... 
     setElementAlpha ( Vehicle, 150 ) 
    else 
     setElementAlpha ( Vehicle, 250 ) 
    end 
end) 

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