Jump to content

Help!


gokalpfirat

Recommended Posts

Posted

Now i dont get error but i cant see my online time at scoreboard

  
function joinTime ( ) 
    setElementData ( source, "joinTime", getTickCount() ) 
    setElementData (source, "joinS", 0 ) 
    setElementData (source, "joinM", 0 ) 
    setElementData (source, "joinH", 0 ) 
    setElementData (source, "joinD", 0 ) 
    setElementData (source, "Online Time", nil ) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), joinTime ) 
function onResourceStart(res) 
call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Online Time") 
end 
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),onResourceStart) 
  
  
function control(source) 
endTime = getElementData(source,"joinTime") - getTickCount() 
if (endTime == 1000) then 
    setElementData (source, "joinS", tonumber(getElementData(source,"joinS"))+1 ) 
    setElementData ( source, "joinTime", getTickCount()-1000 ) 
    end 
    if (getElementData(source,"joinS") == 60) then 
        setElementData (source, "joinM", tonumber(getElementData(source,"joinM"))+1 ) 
        setElementData ( source, "joinS", tonumber(getElementData(source,"joinS"))-60 ) 
        end 
        if (getElementData(source,"joinM") == 60) then 
        setElementData (source, "joinH", tonumber(getElementData(source,"joinH"))+1 ) 
        setElementData ( source, "joinM", tonumber(getElementData(source,"joinM"))-60 ) 
        end 
                if (getElementData(source,"joinH") == 24) then 
        setElementData (source, "joinD", tonumber(getElementData(source,"joinD"))+1 ) 
        setElementData ( source, "joinH", tonumber(getElementData(source,"joinH"))-24 ) 
        end 
            end 
     
        function check(source) 
        Second = getElementData(source,"joinS") 
        Minute = getElementData(source,"joinM") 
        Hour = getElementData(source,"joinH") 
        Day = getElementData(source,"joinD") 
        if (Second >= 1) then  
        setElementData(source,"Online Time",Second.."second") 
        elseif (Minute >= 1) then 
        setElementData(source,"Online Time",Minute.."minute"..Second.."second") 
        elseif (Hour >= 1) then 
        setElementData(source,"Online Time",Hour.."Hour"..Minute.."minute"..Second.."second") 
        elseif (Day >= 1) then 
        setElementData(source,"Online Time",Day.."Day"..Hour.."Hour"..Minute.."minute"..Second.."second") 
        end 
        end 
         
        function all() 
for index , player in ipairs ( getElementsByType ( "player" ) ) do 
control(player) 
check(player) 
end 
end 
        setTimer(all,1000,0) 
         
         

mtaubluascripter.png
Posted

Why are you making it that hard, you can calculate it much easier (not tested)

function onResourceStart() 
    call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Online Time") 
end 
addEventHandler("onResourceStart",resourceRoot,onResourceStart) 
  
function joinTime() 
    setElementData (source, "joinTime", getTickCount() ) 
    setElementData (source, "Online Time", "0 hours, 0 minutes, 0 seconds" ) 
end 
addEventHandler ( "onPlayerJoin", root, joinTime ) 
  
function all() 
    for index , player in ipairs ( getElementsByType ( "player" ) ) do 
        local s = getElementData(player,"joinTime") or getTickCount() 
        s = (s  - getTickCount())  / 1000 
        local string = string.format("%02d hours, %02 minutes, %02d seconds", s/3600, (s%3600)/60, s%60) 
        setElementData(player,"Online Time",string) 
    end 
end 
setTimer(all,1000,0) 

Learn Lua - Learn to script - GUI scripting

Scripter tools - Find/fix errors yourself(!)

Don't pm me for scripting help, keep it for the Scripting subforum!

Posted

What does that mean? because what I get is that we're your "slaves" and we have to fix it for you, I think you're WRONG, why don't you try to fix it yourself?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes, but the way you ask for help is not right, you are like telling us to FIX it

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Try this:

function onResourceStart() 
    call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Online Time") 
    for index, player in pairs (getElementsByType("player")) do 
        setElementData (player, "joinTime", getTickCount() ) 
        setElementData (player, "Online Time", "0 hours, 0 minutes, 0 seconds" )         
    end 
end 
addEventHandler("onResourceStart",resourceRoot,onResourceStart) 
  
function joinTime() 
    setElementData (source, "joinTime", getTickCount() ) 
    setElementData (source, "Online Time", "0 hours, 0 minutes, 0 seconds" ) 
end 
addEventHandler ( "onPlayerJoin", root, joinTime ) 
  
function all() 
    for index , player in ipairs ( getElementsByType ( "player" ) ) do 
        local s = getElementData(player,"joinTime") or getTickCount() 
        s = (s  - getTickCount()) / 1000 
        local string = string.format("%02d hours, %02d minutes, %02d seconds", s/3600, s%3600/60, s%60) 
        setElementData(player,"Online Time",string) 
    end 
end 
setTimer(all,1000,0) 

I think SDK missed a "d" in " %02d minutes"

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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