Jump to content

الوقت الحقيقي


Recommended Posts

السلام عليكم ورحمة الله وبركاته

سويت مود بسيط وهو الوقت الحقيقي بالسيرفر

يوجد مشكلتان

الاولى هي ان الساعة 7 تيجي 19

والمشكلة الثانية بأن الساعة مثال 7:16

ما تتغير وتبقى كما هي

local time = getRealTime() 
local hours = time.hour 
local minutes = time.minute 
     
GUIEditor = { 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.label[1] = guiCreateLabel(711, 141, 79, 33, ""..hours..":"..minutes.."", false) 
        guiSetFont(GUIEditor.label[1], "sa-header")     
    end 
) 
  
  
addEventHandler("onClientRender",root,function() 
    guiSetText(GUIEditor.label[1],""..hours..":"..minutes.."") 
end) 

Link to comment

GUIEditor = { 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.label[1] = guiCreateLabel(711, 141, 79, 33, ""..hours..":"..minutes.."", false) 
        guiSetFont(GUIEditor.label[1], "sa-header")     
    end 
) 
  
  
addEventHandler("onClientRender",root,function() 
  local time = getRealTime() 
  local hours = time.hour 
  local minutes = time.minute 
    guiSetText(GUIEditor.label[1],""..hours..":"..minutes.."") 
end) 

:/ 'onClientRender' الخطأ عندكـ هو أنك جبت الوقت في بدايـة تشغـيل السكربت 'الكـلنت' والمـفروض تجيـبه دآخل الحـدث

Link to comment

حل مشكلتك الاولى هو

وظيفة تقوم بارجاع الوقت الحقيقي وتحويله من 24 ساعة الى 12 ساعة

The function returns real time with convert 24h to 12h

Shared function


function getTime( )
    local time = getRealTime( )
    local h, m = time.hour, time.minute
    return (h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m).." "..(h >= 12 and "PM" or "AM")
end

Link to comment

شكرأً لكم

ممكن تصحيح

ERROR: Time\C.lua:9: attempt to conactenate gloal 'm' (a nill value)

function getTime( ) 
    local time = getRealTime( ) 
    local h = time.hour 
    local m = time.minute 
    return (h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m).." "..(h >= 12 and "PM" or "AM") 
end 
  
  
        TIME = guiCreateLabel(711, 141, 79, 33, ""..h..":"..m.."", false) 
        guiSetFont(TIME, "sa-header")     
  
  
addEventHandler("onClientRender",root,function() 
    guiSetText(TIME,""..h..":"..m.."") 
end) 

Link to comment

function getTime( ) 
    local time = getRealTime( ) 
    local h = time.hour 
    local m = time.minute 
    return (h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m).." "..(h >= 12 and "PM" or "AM") 
end 
  
TIME = guiCreateLabel(711, 141, 79, 33, "", false) 
guiSetFont(TIME, "sa-header")     
  
addEventHandler("onClientRender",root,function() 
  local h,m = getTime() 
    guiSetText(TIME,""..tostring(h)..":"..tostring(m).."") 
end) 
Link to comment
function getTime( ) 
    local time = getRealTime( ) 
    local h = time.hour 
    local m = time.minute 
    return (h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m).." "..(h >= 12 and "PM" or "AM") 
end 
  
TIME = guiCreateLabel(711, 141, 79, 33, "", false) 
guiSetFont(TIME, "sa-header")     
  
addEventHandler("onClientRender",root,function() 
  local h,m = getTime() 
    guiSetText(TIME,""..tostring(h)..":"..tostring(m).."") 
end) 

ERROR Time\C.lya:13: attempt to conactenate local 'm' (a nil value)

Link to comment
function getTime( ) 
    local time = getRealTime( ) 
    local h = time.hour 
    local m = time.minute 
    return (h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m).." "..(h >= 12 and "PM" or "AM") 
end 
  
  
        TIME = guiCreateLabel(711, 141, 79, 33, tostring(getTime()), false) 
        guiSetFont(TIME, "sa-header")     
  
  
addEventHandler("onClientRender",root,function() 
    guiSetText(TIME,tostring(getTime())) 
end) 

Link to comment

ضفت الثواني

صار يجي

9:49 PM:nill:nill

function getTime( ) 
    local time = getRealTime( ) 
    local h = time.hour 
    local m = time.minute 
    local s = time.second 
    return (h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m).." "..(h >= 12 and "PM" or "AM") 
end 
  
TIME = guiCreateLabel(711, 141, 79, 33, "", false) 
    
  
addEventHandler("onClientRender",root,function() 
  local h,m,s = getTime() 
    guiSetText(TIME,""..tostring(h)..":"..tostring(m)..":"..tostring(s).."") 
end) 
  

ما هو الحل؟

Link to comment

!بـس 'PM' آمم غـريبة أنا يجيني

ع العمـوم جربـه كـذآ:

function getTime( ) 
    local time = getRealTime( ) 
    local h = time.hour 
    local m = time.minute 
    return (h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m).." "..(h >= 12 and "PM" or "AM") 
end 
  
TIME = guiCreateLabel(711, 141, 140, 40, "", false) 
guiSetFont(TIME, "sa-header")     
  
addEventHandler("onClientRender",root,function() 
  local time = getTime() 
    guiSetText(TIME,""..tostring(time).."") 
end) 

Link to comment
!بـس 'PM' آمم غـريبة أنا يجيني

ع العمـوم جربـه كـذآ:

function getTime( ) 
    local time = getRealTime( ) 
    local h = time.hour 
    local m = time.minute 
    return (h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m).." "..(h >= 12 and "PM" or "AM") 
end 
  
TIME = guiCreateLabel(711, 141, 140, 40, "", false) 
guiSetFont(TIME, "sa-header")     
  
addEventHandler("onClientRender",root,function() 
  local time = getTime() 
    guiSetText(TIME,""..tostring(time).."") 
end) 

شكراً لك اختفت ال nil

لكن ماذا عن الثواني ما تظهر

function getTime( ) 
    local time = getRealTime( ) 
    local h = time.hour 
    local m = time.minute 
    local s = time.second 
    return (h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m).." "..(h >= 12 and "PM" or "AM") 
end 
  
TIME = guiCreateLabel(711, 141, 140, 40, "", false) 
  
addEventHandler("onClientRender",root,function() 
  local time = getTime() 
    guiSetText(TIME,""..tostring(time).."") 
end) 

Link to comment

getTime قـم بتعديـل الوظيفة:

function getTime( ) 
    local time = getRealTime( ) 
    local h = time.hour 
    local m = time.minute 
    local s = time.second 
    return (h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m)..":"..s.." "..(h >= 12 and "PM" or "AM") 
end 

Link to comment
getTime قـم بتعديـل الوظيفة:
function getTime( ) 
    local time = getRealTime( ) 
    local h = time.hour 
    local m = time.minute 
    local s = time.second 
    return (h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m)..":"..s.." "..(h >= 12 and "PM" or "AM") 
end 

شكرأًً لك

ولكل شخص ساعدني

Link to comment

المود صار ما يشتغل

function getTime( ) 
    local time = getRealTime( ) 
    local h = time.hour 
    local m = time.minute 
    local s = time.second 
    local y = time.year 
    local m = time.month 
    local d = time.monthday 
    return y.."-"..m.."-"..d.." "(h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m)..":"..s.." "..(h >= 12 and "PM" or "AM") 
end 
  
TIME = guiCreateLabel(711, 141, 140, 40, "", false) 
  
addEventHandler("onClientRender",root,function() 
  local time = getTime() 
    guiSetText(TIME,"["..tostring(time).."]") 
end) 

الدي بق يقول سطر 9

end

Link to comment

function getTime( ) 
    local time = getRealTime( ) 
    local h = time.hour 
    local m = time.minute 
    local s = time.second 
    local y = time.year 
    local m = time.month 
    local d = time.monthday 
    return y.."-"..m.."-"..d.." "..(h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m)..":"..s.." "..(h >= 12 and "PM" or "AM") 
end 
  
TIME = guiCreateLabel(711, 141, 140, 40, "", false) 
  
addEventHandler("onClientRender",root,function() 
  local time = getTime() 
    guiSetText(TIME,"["..tostring(time).."]") 
end) 
Link to comment
function getTime( ) 
    local time = getRealTime( ) 
    local h = time.hour 
    local m = time.minute 
    local s = time.second 
    local y = time.year 
    local m = time.month 
    local d = time.monthday 
    return y.."-"..m.."-"..d.." "..(h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m)..":"..s.." "..(h >= 12 and "PM" or "AM") 
end 
  
TIME = guiCreateLabel(711, 141, 140, 40, "", false) 
  
addEventHandler("onClientRender",root,function() 
  local time = getTime() 
    guiSetText(TIME,"["..tostring(time).."]") 
end) 

شكراً لك يوجد مشكلة السنة تيجي 116

Link to comment

function getTime( ) 
    local time = getRealTime( ) 
    local h = time.hour 
    local m = time.minute 
    local s = time.second 
    local y = time.year+1900 
    local m = time.month 
    local d = time.monthday 
    return y.."-"..m.."-"..d.." "..(h % 12 and h % 12 or 12)..":"..(m < 10 and "0"..m or m)..":"..s.." "..(h >= 12 and "PM" or "AM") 
end 
  
TIME = guiCreateLabel(711, 141, 140, 40, "", false) 
  
addEventHandler("onClientRender",root,function() 
  local time = getTime() 
    guiSetText(TIME,"["..tostring(time).."]") 
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...