Jump to content

طلب كود


MA[S]RIY

Recommended Posts

Server
  1. addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),
  2. call ( getResourceFromName ( "scoreboard" ), "scoreboardAddColumn", "Online" )
  3.  
  4. addEventHandler ( "onResourceStart" , resourceRoot ,
  5.     function ( )
  6.         for index , player in ipairs ( getElementsByType ( "player" ) ) do
  7.             local pAccount = getPlayerAccount ( player )
  8.             if not isGuestAccount ( pAccount ) then
  9.                 local minutes = getAccountData ( pAccount , "Online.minutes" )
  10.                 if minutes then
  11.                     local hours = getAccountData ( pAccount , "Online.hours" )
  12.                     if # tostring ( minutes ) == 1 then
  13.                         minutes = "0" .. minutes
  14.                     end
  15.                     if # tostring ( hours ) == 1 then
  16.                         hours = "0" .. hours
  17.                     end
  18.                     setElementData ( player , "Online" , hours .. " H " .. minutes .. " M" )
  19.                     local timer = setTimer ( updatePlayerOnline , 60000 , 1 , player )
  20.                     setElementData ( player , "Online.timer" , timer )
  21.                 else
  22.                     setAccountData ( pAccount , "Online.minutes" , 0 )
  23.      
  24.               setAccountData ( pAccount , "Online.hours" , 0 )
  25.                     setElementData ( player , "Online" , "00 H 00 M" )
  26.                     local timer = setTimer ( updatePlayerOnline , 60000 , 1 , player )
  27.                     setElementData ( player , "Online.timer" , timer )
  28.                 end
  29.             else
  30.                 setElementData ( player , "Online" , "N/A" )
  31.             end
  32.         end
  33.     end
  34. )
  35.  
  36. addEventHandler ( "onResourceStop" , resourceRoot ,
  37.     function ( )
  38.         for index , player in ipairs ( getElementsByType ( "player" ) ) do
  39.             local pAccount = getPlayerAccount ( player )
  40.             if not isGuestAccount ( pAccount ) then
  41.                 local timer = getElementData ( player , "Online.timer" )
  42.                 if isTimer ( timer ) then
  43.                     killTimer ( timer )
  44.                 end
  45.             end
  46.         end
  47.     end
  48. )
  49.  
  50. addEventHandler ( "onPlayerLogin" , root ,
  51.     function ( _ , pAccount )
  52.         local minutes = getAccountData ( pAccount , "Online.minutes" )
  53.         if minutes then
  54.             local hours = getAccountData ( pAccount , "Online.hours" )
  55.             if # tostring ( minutes ) == 1 then
  56.                 minutes = "0" .. minutes
  57.             end
  58.             if # tostring ( hours ) == 1 then
  59.                 hours = "0" .. hours
  60.             end
  61.             setElementData ( source , "Online" , hours .. " H " .. minutes .. " M" )
  62.             local timer = setTimer ( updatePlayerOnline , 60000 , 1 , source )
  63.             setElementData ( source , "Online.timer" , timer )
  64.         else
  65.             setAccountData ( pAccount , "Online.minutes" , 0 )
  66.             setAccountData ( pAccount , "Online.hours" , 0 )
  67.             setElementData ( source , "Online" , "00 H 00 M" )
  68.             local timer = setTimer ( updatePlayerOnline , 60000 , 1 , source )
  69.             setElementData ( source , "Online.timer" , timer )
  70.         end
  71.     end
  72. )
  73.  
  74. addEventHandler ( "onPlayerLogout" , root ,
  75.     function ( pAccount )
  76.         local timer = getElementData ( source , "Online.timer" )
  77.         if isTimer ( timer ) then
  78.             killTimer ( timer )
  79.         end
  80.     end
  81. )
  82.  
  83. addEventHandler ( "onPlayerJoin" , root ,
  84.     function ( )
  85.         setElementData ( source , "Online" , "N/A" )
  86.     end
  87. )
  88.  
  89. addEventHandler ( "onPlayerQuit" , root ,
  90.     function ( )
  91.         local pAccount = getPlayerAccount ( source )
  92.         if not isGuestAccount ( pAccount ) then
  93.             local timer = getElementData ( source , "Online.timer" )
  94.             if isTimer ( timer ) then
  95.                 killTimer ( timer )
  96.             end
  97.         end
  98.     end
  99. )
  100.  
  101. function updatePlayerOnline ( player )
  102.     local pAccount = getPlayerAccount ( player )
  103.     local minutes = getAccountData ( pAccount , "Online.minutes" )
  104.     local hours = getAccountData ( pAccount , "Online.hours" )
  105.     minutes = tostring ( tonumber ( minutes ) + 1 )
  106.     if minutes == "60" then
  107.         hours = tostring ( tonumber ( hours ) + 1 )
  108.         minutes = "00"
  109.     end
  110.     setAccountData ( pAccount , "Online.minutes" , tonumber ( minutes ) )
  111.     setAccountData ( pAccount , "Online.hours" , tonumber ( hours ) )
  112.     if # tostring ( minutes ) == 1 then minutes = "0" .. minutes end
  113.     if # tostring ( hours ) == 1 then hours = "0" .. hours end
  114.     setElementData ( player , "Online" , hours .. " H " .. minutes .. " M" )
  115.     local timer = setTimer ( updatePlayerOnline , 60000 , 1 , player )
  116.     setElementData ( player , "Online.timer" , timer )
  117. end
 

 

i have no idea if it's working or not ,but you should try 

 
Edited by Moha|M|
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...