Jump to content

setElementData with timer?


Rat32

Recommended Posts

Hi. I want to set the timer setElementData , but debugscript think it is impossible. "Expected element at point 1 - got lua - timer" . It is very necessary to me , because without it I am not able to do the script. Dam code can invent something . Hi.

function takegangzone(hitElement) 
tim = getPlayerTeam(hitElement) 
if getRadarAreaColor(getElementData(source, "area")) ~= getTeamColor(tim) then 
setRadarAreaFlashing(getElementData(source, "area"), true) 
tt = setTimer(function(source)  
local r,g,b = getTeamColor(getPlayerTeam(hitElement)) 
setRadarAreaColor(getElementData(source, "area"), r,g,b,150) setRadarAreaFlashing(getElementData(source, "area"), false) end, 5000, 1, source, tim) 
setElementData(tt, "przejmujacy", getPlayerName(hitElement)) 
    end 
end 
addEventHandler("onColShapeHit", gz1col, takegangzone) 

Link to comment

try :

function takegangzone(hitElement) 
tim = getPlayerTeam(hitElement) 
    if getRadarAreaColor(getElementData(source, "area")) ~= getTeamColor(tim) then 
    setRadarAreaFlashing(getElementData(source, "area"), true) 
        tt = setTimer(function(source) 
        local r,g,b = getTeamColor(getPlayerTeam(hitElement)) 
        setRadarAreaColor(getElementData(source, "area"), r,g,b,150) 
        setRadarAreaFlashing(getElementData(source, "area"), false) 
        end,5000,1) 
    setElementData(tt, "przejmujacy", getPlayerName(hitElement)) 
    end 
end 
addEventHandler("onColShapeHit", gz1col, takegangzone) 

Link to comment

In order to KillTimer then he acted only on this one timer. If it is running 40 timers with variable tt and I want to keep only one timer is no problem arises : / . And so it would add "if" and getElementData (tt, " gangzone " zone) is stopowaloby only one timer which is equal to , for example, getElementData " gangzone1 " . How can I do this? If this array would ask for example in the code, because not too understand how to do it. I know how to do the kind of arrays in Lua , but I can not see how to replace the setElementData . Greetings.

Link to comment

I don't understand you. The point is, you can't setElementData to timer. Put it in table. It's same as element data.

  
-- Example of what you can do. 
local timers = {} 
timer = setTimer(function() end, 500, 1) 
timers[timer] = true 
-- Add another timer 
timers[setTimer(function() end, 500, 1)] = true 
for i, v in pairs(timers) do 
    if isTimer(i) and v == true then 
        killTimer(i) 
    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...