Jump to content

مشكله وآجهتني


Recommended Posts

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

انا جديد بي المنتدى

بس اعرف افتح موضوع

انا مبرمج متوسط بس سويت مود اعلى تواجد كل شي تمام حتى الديبوق مايظهر فيه شي

كلنت

  
  
  
local rankTable = {} 
local oldTick = 0 
local timeToUpdate = 3000   
  
GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(215, 117, 460, 403, "اعلى 30 تواجد  في السـيـرفـر", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 1.00) 
        guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF01FAB6") 
  
        Gridilist = guiCreateGridList(10, 54, 436, 324, false, GUIEditor.window[1]) 
        guiGridListAddColumn(Gridilist, "playerName", 0.5) 
        guiGridListAddColumn(Gridilist, "PlayTime", 0.5) 
  
        GUIEditor.label[1] = guiCreateLabel(-7, -45, 453, 40, "", false, GUIEditor.gridlist[1])     
    end 
) 
function on() 
local currentTick = getTickCount() 
if(currentTick-oldTick>=timeToUpdate)then  
oldTick = currentTick 
triggerServerEvent("onTopPlayerListRequest",localPlayer,text) 
end 
end 
  
  
  
addEvent("onClientReceiveTopListTable",true) 
addEventHandler("onClientReceiveTopListTable",root, 
function(t) 
rankTable = t 
UpdateTopList() 
end) 
  
function UpdateTopList() 
guiGridListClear(Gridilist) 
for k,v in ipairs(rankTable) do  
local row = guiGridListAddRow(Gridilist) 
guiGridListSetItemText(Gridilist,row,1,v["playerName"],false,false) 
guiGridListSetItemText(Gridilist,row,2,v["PlayTime"],false,false) 
end 
end 
  
function TopGui() 
local guiS = guiGetVisible(GUIEditor.window[1]) 
guiSetVisible(GUIEditor.window[1],not guiS) 
showCursor(not guiS) 
guiSetInputEnabled(not guiS) 
end 
bindKey("F12","down",TopGui) 
  

سيرفر

  
  
local playTime = {} 
  
function onLogin(old,current) 
if(current and not isGuestAccount(current))then  
local timeHour    = tonumber(getAccountData(current,"hour"))or 0 
local timeMinute  = tonumber(getAccountData(current,"minute"))or 0 
local timeSecond  = tonumber(getAccountData(current,"second"))or 0 
if(not playTime[source])then  
playTime[source] = { 
["hour"] = 0, 
["min"]  = 0, 
["sec"] = 0 
}  
end 
playTime[source]["hour"] = timeHour 
playTime[source]["min"] = timeMinute 
playTime[source]["sec"] = timeSecond 
end 
end 
addEventHandler("onPlayerLogin",root,onLogin) 
  
function onQuit() 
local acc = getPlayerAccount(source) 
if(acc and not isGuestAccount(acc))then  
local timeHour = playTime[source]["hour"] or 0 
local timeMin  = playTime[source]["min"] or 0 
local timeSec  = playTime[source]["sec"] or 0 
local name = getPlayerName(source) 
local nickAcc = string.gsub(name,"#%x%x%x%x%x%x","") 
setAccountData(acc,"hour",timeHour) 
setAccountData(acc,"minute",timeMin) 
setAccountData(acc,"second",timeSec) 
setAccountData(acc,"PlayerName",nickAcc) 
playTime[source] = nil 
end 
end 
addEventHandler("onPlayerQuit",root,onQuit) 
  
  
  
  
  
  
  
addEvent("onTopPlayerListRequest",true) 
addEventHandler("onTopPlayerListRequest",root, 
function(text) 
local allAccounts = getAccounts() 
local sendTable = {} 
local data = 0 
for k,v in ipairs(allAccounts) do 
local name = getAccountName(v) 
local dataHour = tonumber(getAccountData(v,"hour")) or 0 
local dataMin = tonumber(getAccountData(v,"minute")) or 0 
local dataSec = tonumber(getAccountData(v,"second")) or 0 
if(text == "Play Time")then  
data = dataHour+DividiveIfMoreZero(dataMin,60)+DividiveIfMoreZero(dataSec,3600) 
else 
data = tonumber(getAccountData(v,text) or 0)or 0 
end 
if(data>0)then 
table.insert(sendTable,{["playerName"] = name,["PlayTime"] = data}) 
end 
end 
table.sort(sendTable,function(a,b) return tonumber(a["PlayTime"] or 0)>tonumber(b["PlayTime"] or 0) end) 
table.setMaxIndex(sendTable,10) 
if(text == "Play Time")then  
for i=1,#sendTable do 
local timeString = "" 
local nAcc = getAccount(sendTable[i]["playerName"]) 
local hourS = getAccountData(nAcc,"hour") or 0 
local minS = getAccountData(nAcc,"minute") or 0 
local secS = getAccountData(nAcc,"second") or 0 
hourS = tostring(hourS) 
minS = tostring(minS) 
secS = tostring(secS) 
timeString = hourS..":"..minS..":"..secS 
sendTable[i]["PlayTime"] = timeString 
end 
end 
for i=1,#sendTable do 
local acc = getAccount(sendTable[i]["playerName"]) 
local accRealName = getAccountData(acc,"PlayerName") 
if(accRealName and tostring(accRealName)~="false")then  
sendTable[i]["playerName"] = accRealName 
end 
end 
triggerClientEvent(client,"onClientReceiveTopListTable",client,sendTable) 
end) 
function table.setMaxIndex(t,n) 
if(#t>n)then  
while(#t>n)do 
table.remove(t) 
end 
end 
end 
  
function DividiveIfMoreZero(v,d) 
if(v>0)then return (v/d) end 
return 0 
end 
  
  
function SavePlayTime() 
local players = getElementsByType("player") 
for k,v in ipairs(players) do  
if(not playTime[v]) then 
playTime[v] = { 
["hour"] = 0, 
["min"]  = 0, 
["sec"] = 0 
}  
end 
playTime[v]["sec"] = tonumber(playTime[v]["sec"]+1) 
convertTime(v,playTime[v]["min"],playTime[v]["sec"]) 
local hour = playTime[v]["hour"] 
local min  = playTime[v]["min"] 
local sec  = playTime[v]["sec"] 
local acc = getPlayerAccount(v) 
if(acc and isGuestAccount(acc)==false)then  
setAccountData(acc,"hour",hour) 
setAccountData(acc,"minute",min) 
setAccountData(acc,"second",sec) 
end 
end 
setTimer(SavePlayTime,1000,1) 
end 
setTimer(SavePlayTime,1000,1) 
  
  
function ResetTopPlayers() 
local allAccounts = getAccounts() 
for k,v in ipairs(allAccounts) do 
setAccountData(v,"hour",0) 
setAccountData(v,"minute",0) 
setAccountData(v,"second",0) 
end 
outputChatBox("تم تحديث اعلى تواجد") 
end 
  
function resetConsoleTop(p) 
local accName = getAccountName(getPlayerAccount(p)) 
if(isObjectInACLGroup("user." .. accName, aclGetGroup("Console")))then  
ResetTopPlayers() 
else 
outputChatBox("هذا الخاصيه فقط لـ الكونسل",p) 
end 
end 
addCommandHandler("CL1",resetConsoleTop) 
  
function convertTime(source,m,s) 
if(s>=60)then  
playTime[source]["min"] = tonumber(playTime[source]["min"]+1) 
playTime[source]["sec"]  = 0 
end 
if(m>=60)then  
playTime[source]["hour"] = tonumber(playTime[source]["hour"]+1) 
playTime[source]["min"]  = 0 
end 
end 
  

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

انا جديد بي المنتدى

بس اعرف افتح موضوع

انا مبرمج متوسط بس سويت مود اعلى تواجد كل شي تمام حتى الديبوق مايظهر فيه شي

كلنت

  
  
  
local rankTable = {} 
local oldTick = 0 
local timeToUpdate = 3000   
  
GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(215, 117, 460, 403, "اعلى 30 تواجد  في السـيـرفـر", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 1.00) 
        guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF01FAB6") 
  
        Gridilist = guiCreateGridList(10, 54, 436, 324, false, GUIEditor.window[1]) 
        guiGridListAddColumn(Gridilist, "playerName", 0.5) 
        guiGridListAddColumn(Gridilist, "PlayTime", 0.5) 
  
        GUIEditor.label[1] = guiCreateLabel(-7, -45, 453, 40, "", false, GUIEditor.gridlist[1])     
    end 
) 
function on() 
local currentTick = getTickCount() 
if(currentTick-oldTick>=timeToUpdate)then  
oldTick = currentTick 
triggerServerEvent("onTopPlayerListRequest",localPlayer,text) 
end 
end 
  
  
  
addEvent("onClientReceiveTopListTable",true) 
addEventHandler("onClientReceiveTopListTable",root, 
function(t) 
rankTable = t 
UpdateTopList() 
end) 
  
function UpdateTopList() 
guiGridListClear(Gridilist) 
for k,v in ipairs(rankTable) do  
local row = guiGridListAddRow(Gridilist) 
guiGridListSetItemText(Gridilist,row,1,v["playerName"],false,false) 
guiGridListSetItemText(Gridilist,row,2,v["PlayTime"],false,false) 
end 
end 
  
function TopGui() 
local guiS = guiGetVisible(GUIEditor.window[1]) 
guiSetVisible(GUIEditor.window[1],not guiS) 
showCursor(not guiS) 
guiSetInputEnabled(not guiS) 
end 
bindKey("F12","down",TopGui) 
  

سيرفر

  
  
local playTime = {} 
  
function onLogin(old,current) 
if(current and not isGuestAccount(current))then  
local timeHour    = tonumber(getAccountData(current,"hour"))or 0 
local timeMinute  = tonumber(getAccountData(current,"minute"))or 0 
local timeSecond  = tonumber(getAccountData(current,"second"))or 0 
if(not playTime[source])then  
playTime[source] = { 
["hour"] = 0, 
["min"]  = 0, 
["sec"] = 0 
}  
end 
playTime[source]["hour"] = timeHour 
playTime[source]["min"] = timeMinute 
playTime[source]["sec"] = timeSecond 
end 
end 
addEventHandler("onPlayerLogin",root,onLogin) 
  
function onQuit() 
local acc = getPlayerAccount(source) 
if(acc and not isGuestAccount(acc))then  
local timeHour = playTime[source]["hour"] or 0 
local timeMin  = playTime[source]["min"] or 0 
local timeSec  = playTime[source]["sec"] or 0 
local name = getPlayerName(source) 
local nickAcc = string.gsub(name,"#%x%x%x%x%x%x","") 
setAccountData(acc,"hour",timeHour) 
setAccountData(acc,"minute",timeMin) 
setAccountData(acc,"second",timeSec) 
setAccountData(acc,"PlayerName",nickAcc) 
playTime[source] = nil 
end 
end 
addEventHandler("onPlayerQuit",root,onQuit) 
  
  
  
  
  
  
  
addEvent("onTopPlayerListRequest",true) 
addEventHandler("onTopPlayerListRequest",root, 
function(text) 
local allAccounts = getAccounts() 
local sendTable = {} 
local data = 0 
for k,v in ipairs(allAccounts) do 
local name = getAccountName(v) 
local dataHour = tonumber(getAccountData(v,"hour")) or 0 
local dataMin = tonumber(getAccountData(v,"minute")) or 0 
local dataSec = tonumber(getAccountData(v,"second")) or 0 
if(text == "Play Time")then  
data = dataHour+DividiveIfMoreZero(dataMin,60)+DividiveIfMoreZero(dataSec,3600) 
else 
data = tonumber(getAccountData(v,text) or 0)or 0 
end 
if(data>0)then 
table.insert(sendTable,{["playerName"] = name,["PlayTime"] = data}) 
end 
end 
table.sort(sendTable,function(a,b) return tonumber(a["PlayTime"] or 0)>tonumber(b["PlayTime"] or 0) end) 
table.setMaxIndex(sendTable,10) 
if(text == "Play Time")then  
for i=1,#sendTable do 
local timeString = "" 
local nAcc = getAccount(sendTable[i]["playerName"]) 
local hourS = getAccountData(nAcc,"hour") or 0 
local minS = getAccountData(nAcc,"minute") or 0 
local secS = getAccountData(nAcc,"second") or 0 
hourS = tostring(hourS) 
minS = tostring(minS) 
secS = tostring(secS) 
timeString = hourS..":"..minS..":"..secS 
sendTable[i]["PlayTime"] = timeString 
end 
end 
for i=1,#sendTable do 
local acc = getAccount(sendTable[i]["playerName"]) 
local accRealName = getAccountData(acc,"PlayerName") 
if(accRealName and tostring(accRealName)~="false")then  
sendTable[i]["playerName"] = accRealName 
end 
end 
triggerClientEvent(client,"onClientReceiveTopListTable",client,sendTable) 
end) 
function table.setMaxIndex(t,n) 
if(#t>n)then  
while(#t>n)do 
table.remove(t) 
end 
end 
end 
  
function DividiveIfMoreZero(v,d) 
if(v>0)then return (v/d) end 
return 0 
end 
  
  
function SavePlayTime() 
local players = getElementsByType("player") 
for k,v in ipairs(players) do  
if(not playTime[v]) then 
playTime[v] = { 
["hour"] = 0, 
["min"]  = 0, 
["sec"] = 0 
}  
end 
playTime[v]["sec"] = tonumber(playTime[v]["sec"]+1) 
convertTime(v,playTime[v]["min"],playTime[v]["sec"]) 
local hour = playTime[v]["hour"] 
local min  = playTime[v]["min"] 
local sec  = playTime[v]["sec"] 
local acc = getPlayerAccount(v) 
if(acc and isGuestAccount(acc)==false)then  
setAccountData(acc,"hour",hour) 
setAccountData(acc,"minute",min) 
setAccountData(acc,"second",sec) 
end 
end 
setTimer(SavePlayTime,1000,1) 
end 
setTimer(SavePlayTime,1000,1) 
  
  
function ResetTopPlayers() 
local allAccounts = getAccounts() 
for k,v in ipairs(allAccounts) do 
setAccountData(v,"hour",0) 
setAccountData(v,"minute",0) 
setAccountData(v,"second",0) 
end 
outputChatBox("تم تحديث اعلى تواجد") 
end 
  
function resetConsoleTop(p) 
local accName = getAccountName(getPlayerAccount(p)) 
if(isObjectInACLGroup("user." .. accName, aclGetGroup("Console")))then  
ResetTopPlayers() 
else 
outputChatBox("هذا الخاصيه فقط لـ الكونسل",p) 
end 
end 
addCommandHandler("CL1",resetConsoleTop) 
  
function convertTime(source,m,s) 
if(s>=60)then  
playTime[source]["min"] = tonumber(playTime[source]["min"]+1) 
playTime[source]["sec"]  = 0 
end 
if(m>=60)then  
playTime[source]["hour"] = tonumber(playTime[source]["hour"]+1) 
playTime[source]["min"]  = 0 
end 
end 
  

وش المشكلة؟

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

انا جديد بي المنتدى

بس اعرف افتح موضوع

انا مبرمج متوسط بس سويت مود اعلى تواجد كل شي تمام حتى الديبوق مايظهر فيه شي

كلنت

  
  
  
local rankTable = {} 
local oldTick = 0 
local timeToUpdate = 3000   
  
GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(215, 117, 460, 403, "اعلى 30 تواجد  في السـيـرفـر", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 1.00) 
        guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF01FAB6") 
  
        Gridilist = guiCreateGridList(10, 54, 436, 324, false, GUIEditor.window[1]) 
        guiGridListAddColumn(Gridilist, "playerName", 0.5) 
        guiGridListAddColumn(Gridilist, "PlayTime", 0.5) 
  
        GUIEditor.label[1] = guiCreateLabel(-7, -45, 453, 40, "", false, GUIEditor.gridlist[1])     
    end 
) 
function on() 
local currentTick = getTickCount() 
if(currentTick-oldTick>=timeToUpdate)then  
oldTick = currentTick 
triggerServerEvent("onTopPlayerListRequest",localPlayer,text) 
end 
end 
  
  
  
addEvent("onClientReceiveTopListTable",true) 
addEventHandler("onClientReceiveTopListTable",root, 
function(t) 
rankTable = t 
UpdateTopList() 
end) 
  
function UpdateTopList() 
guiGridListClear(Gridilist) 
for k,v in ipairs(rankTable) do  
local row = guiGridListAddRow(Gridilist) 
guiGridListSetItemText(Gridilist,row,1,v["playerName"],false,false) 
guiGridListSetItemText(Gridilist,row,2,v["PlayTime"],false,false) 
end 
end 
  
function TopGui() 
local guiS = guiGetVisible(GUIEditor.window[1]) 
guiSetVisible(GUIEditor.window[1],not guiS) 
showCursor(not guiS) 
guiSetInputEnabled(not guiS) 
end 
bindKey("F12","down",TopGui) 
  

سيرفر

  
  
local playTime = {} 
  
function onLogin(old,current) 
if(current and not isGuestAccount(current))then  
local timeHour    = tonumber(getAccountData(current,"hour"))or 0 
local timeMinute  = tonumber(getAccountData(current,"minute"))or 0 
local timeSecond  = tonumber(getAccountData(current,"second"))or 0 
if(not playTime[source])then  
playTime[source] = { 
["hour"] = 0, 
["min"]  = 0, 
["sec"] = 0 
}  
end 
playTime[source]["hour"] = timeHour 
playTime[source]["min"] = timeMinute 
playTime[source]["sec"] = timeSecond 
end 
end 
addEventHandler("onPlayerLogin",root,onLogin) 
  
function onQuit() 
local acc = getPlayerAccount(source) 
if(acc and not isGuestAccount(acc))then  
local timeHour = playTime[source]["hour"] or 0 
local timeMin  = playTime[source]["min"] or 0 
local timeSec  = playTime[source]["sec"] or 0 
local name = getPlayerName(source) 
local nickAcc = string.gsub(name,"#%x%x%x%x%x%x","") 
setAccountData(acc,"hour",timeHour) 
setAccountData(acc,"minute",timeMin) 
setAccountData(acc,"second",timeSec) 
setAccountData(acc,"PlayerName",nickAcc) 
playTime[source] = nil 
end 
end 
addEventHandler("onPlayerQuit",root,onQuit) 
  
  
  
  
  
  
  
addEvent("onTopPlayerListRequest",true) 
addEventHandler("onTopPlayerListRequest",root, 
function(text) 
local allAccounts = getAccounts() 
local sendTable = {} 
local data = 0 
for k,v in ipairs(allAccounts) do 
local name = getAccountName(v) 
local dataHour = tonumber(getAccountData(v,"hour")) or 0 
local dataMin = tonumber(getAccountData(v,"minute")) or 0 
local dataSec = tonumber(getAccountData(v,"second")) or 0 
if(text == "Play Time")then  
data = dataHour+DividiveIfMoreZero(dataMin,60)+DividiveIfMoreZero(dataSec,3600) 
else 
data = tonumber(getAccountData(v,text) or 0)or 0 
end 
if(data>0)then 
table.insert(sendTable,{["playerName"] = name,["PlayTime"] = data}) 
end 
end 
table.sort(sendTable,function(a,b) return tonumber(a["PlayTime"] or 0)>tonumber(b["PlayTime"] or 0) end) 
table.setMaxIndex(sendTable,10) 
if(text == "Play Time")then  
for i=1,#sendTable do 
local timeString = "" 
local nAcc = getAccount(sendTable[i]["playerName"]) 
local hourS = getAccountData(nAcc,"hour") or 0 
local minS = getAccountData(nAcc,"minute") or 0 
local secS = getAccountData(nAcc,"second") or 0 
hourS = tostring(hourS) 
minS = tostring(minS) 
secS = tostring(secS) 
timeString = hourS..":"..minS..":"..secS 
sendTable[i]["PlayTime"] = timeString 
end 
end 
for i=1,#sendTable do 
local acc = getAccount(sendTable[i]["playerName"]) 
local accRealName = getAccountData(acc,"PlayerName") 
if(accRealName and tostring(accRealName)~="false")then  
sendTable[i]["playerName"] = accRealName 
end 
end 
triggerClientEvent(client,"onClientReceiveTopListTable",client,sendTable) 
end) 
function table.setMaxIndex(t,n) 
if(#t>n)then  
while(#t>n)do 
table.remove(t) 
end 
end 
end 
  
function DividiveIfMoreZero(v,d) 
if(v>0)then return (v/d) end 
return 0 
end 
  
  
function SavePlayTime() 
local players = getElementsByType("player") 
for k,v in ipairs(players) do  
if(not playTime[v]) then 
playTime[v] = { 
["hour"] = 0, 
["min"]  = 0, 
["sec"] = 0 
}  
end 
playTime[v]["sec"] = tonumber(playTime[v]["sec"]+1) 
convertTime(v,playTime[v]["min"],playTime[v]["sec"]) 
local hour = playTime[v]["hour"] 
local min  = playTime[v]["min"] 
local sec  = playTime[v]["sec"] 
local acc = getPlayerAccount(v) 
if(acc and isGuestAccount(acc)==false)then  
setAccountData(acc,"hour",hour) 
setAccountData(acc,"minute",min) 
setAccountData(acc,"second",sec) 
end 
end 
setTimer(SavePlayTime,1000,1) 
end 
setTimer(SavePlayTime,1000,1) 
  
  
function ResetTopPlayers() 
local allAccounts = getAccounts() 
for k,v in ipairs(allAccounts) do 
setAccountData(v,"hour",0) 
setAccountData(v,"minute",0) 
setAccountData(v,"second",0) 
end 
outputChatBox("تم تحديث اعلى تواجد") 
end 
  
function resetConsoleTop(p) 
local accName = getAccountName(getPlayerAccount(p)) 
if(isObjectInACLGroup("user." .. accName, aclGetGroup("Console")))then  
ResetTopPlayers() 
else 
outputChatBox("هذا الخاصيه فقط لـ الكونسل",p) 
end 
end 
addCommandHandler("CL1",resetConsoleTop) 
  
function convertTime(source,m,s) 
if(s>=60)then  
playTime[source]["min"] = tonumber(playTime[source]["min"]+1) 
playTime[source]["sec"]  = 0 
end 
if(m>=60)then  
playTime[source]["hour"] = tonumber(playTime[source]["hour"]+1) 
playTime[source]["min"]  = 0 
end 
end 
  

وش المشكلة؟

المشكله مايظهر شيء بي القريد لست

Link to comment

اذا السكربت حقك يطلع الوقت بالتاب

استخدم الالمنت داتا

سوي لوب لجميع الاعبين بالكلنت وجيب الداتا , وحطهم في تيبل مع الوقت

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

وان كنت تبي ترتبهم استخدم

table.sort 
getElementsByType -- for i , v ... 
getElementData 
table.insert  
-- for - Table  -- لوب على التيبل 
Link to comment
اذا السكربت حقك يطلع الوقت بالتاب

استخدم الالمنت داتا

سوي لوب لجميع الاعبين بالكلنت وجيب الداتا , وحطهم في تيبل مع الوقت

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

وان كنت تبي ترتبهم استخدم

table.sort 
getElementsByType -- for i , v ... 
getElementData 
table.insert  
-- for - Table  -- لوب على التيبل 

لا انا ابي الترتيب حسبب الاكثر ساعات ^_^

موب يجي في التاب

في التاب يكفي مود الساعات

Link to comment
اذا السكربت حقك يطلع الوقت بالتاب

استخدم الالمنت داتا

سوي لوب لجميع الاعبين بالكلنت وجيب الداتا , وحطهم في تيبل مع الوقت

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

وان كنت تبي ترتبهم استخدم

table.sort 
getElementsByType -- for i , v ... 
getElementData 
table.insert  
-- for - Table  -- لوب على التيبل 

مافي غير ذا الرد سوي الي قالك اياه ,

واذا انت منت مبرمج متوسط بطل الفكرة وسويلك مود اسهل من كذا

Link to comment
اذا السكربت حقك يطلع الوقت بالتاب

استخدم الالمنت داتا

سوي لوب لجميع الاعبين بالكلنت وجيب الداتا , وحطهم في تيبل مع الوقت

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

وان كنت تبي ترتبهم استخدم

table.sort 
getElementsByType -- for i , v ... 
getElementData 
table.insert  
-- for - Table  -- لوب على التيبل 

مافي غير ذا الرد سوي الي قالك اياه ,

واذا انت منت مبرمج متوسط بطل الفكرة وسويلك مود اسهل من كذا

لا اعرف بس ي اخوي يعني لو اسوي ذي بتطلع كل شيء بي القريد لست

Link to comment
اذا السكربت حقك يطلع الوقت بالتاب

استخدم الالمنت داتا

سوي لوب لجميع الاعبين بالكلنت وجيب الداتا , وحطهم في تيبل مع الوقت

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

وان كنت تبي ترتبهم استخدم

table.sort 
getElementsByType -- for i , v ... 
getElementData 
table.insert  
-- for - Table  -- لوب على التيبل 

مافي غير ذا الرد سوي الي قالك اياه ,

واذا انت منت مبرمج متوسط بطل الفكرة وسويلك مود اسهل من كذا

لا اعرف بس ي اخوي يعني لو اسوي ذي بتطلع كل شيء بي القريد لست

  
function getPlayersSortByaTime( ) 
    local TopTimer = { } -- ضفنآه ل جدول 
    for _, playerw in next, getElementsByType 'player' do -- هذا  الوب حق لاعبين 
        Time = getElementData ( playerw, 'Time' ) or "0:0:0" -- هنا حطينا دآتآ 
        local h, m, s = unpack ( split ( Time, ":" ) )   
        table.insert ( 
            TopTimer, 
            { 
                player = playerw, 
                Time = Time, 
                Sorttime = ( tonumber ( h ) * 3600000 + tonumber ( m ) * 60000 + tonumber ( s ) * 1000 ) 
            } 
        ) 
    end 
    table.sort ( 
        TopTimer, 
        function ( a, b ) 
            return ( tonumber ( a.Sorttime ) or 0 ) > ( tonumber ( b.Sorttime ) or 0 ) 
        end 
    ) 
    return TopTimer 
end 
  

Link to comment
تقدر توقف القيمة لين 30

الكود

  
for i ,v in ipairs ( TableName ) do 
 for i == 30 do break end end 
  

غلط حبيبي, ليه اللوب الثاني؟ حط شرط بداله !

@ صاحب الموضوع انت مسوي فنكشن ومو مستخدمه اساساً, سوي كذا

addEvent("onClientReceiveTopListTable",true) 
addEventHandler("onClientReceiveTopListTable",root, 
function(t) 
UpdateTopList(t) 
end) 
  
function UpdateTopList(t) 
    guiGridListClear(Gridilist) 
        for k,v in ipairs(t) do 
            local row = guiGridListAddRow(Gridilist) 
                guiGridListSetItemText(Gridilist,row,1,v["playerName"],false,false) 
                    guiGridListSetItemText(Gridilist,row,2,v["PlayTime"],false,false) 
    end 
end 

وحط الحدث :

function on(state) 
    if state and not tonumber ( state ) and type (state) == 'boolean' then 
        if state == true then 
            triggerServerEvent("onTopPlayerListRequest",localPlayer,"Play Time") 
                else  
            return  
        end 
    end 
end 
addEventHandler( 'onClientResourceStart', resourceRoot,function() on(true) end) 

عشان تحدث الجريد بالتايمر او اي شي بهذي الطريقه on وتقدر تستخدم الفنكشن

on(true) 

..عشان ترتب الجدول table.sort واستخدم

Link to comment
تقدر توقف القيمة لين 30

الكود

  
for i ,v in ipairs ( TableName ) do 
 for i == 30 do break end end 
  

غلط حبيبي, ليه اللوب الثاني؟ حط شرط بداله !

@ صاحب الموضوع انت مسوي فنكشن ومو مستخدمه اساساً, سوي كذا

addEvent("onClientReceiveTopListTable",true) 
addEventHandler("onClientReceiveTopListTable",root, 
function(t) 
UpdateTopList(t) 
end) 
  
function UpdateTopList(t) 
    guiGridListClear(Gridilist) 
        for k,v in ipairs(t) do 
            local row = guiGridListAddRow(Gridilist) 
                guiGridListSetItemText(Gridilist,row,1,v["playerName"],false,false) 
                    guiGridListSetItemText(Gridilist,row,2,v["PlayTime"],false,false) 
    end 
end 

وحط الحدث :

function on(state) 
    if state and not tonumber ( state ) and type (state) == 'boolean' then 
        if state == true then 
            triggerServerEvent("onTopPlayerListRequest",localPlayer,"Play Time") 
                else  
            return  
        end 
    end 
end 
addEventHandler( 'onClientResourceStart', resourceRoot,function() on(true) end) 

عشان تحدث الجريد بالتايمر او اي شي بهذي الطريقه on وتقدر تستخدم الفنكشن

on(true) 

..عشان ترتب الجدول table.sort واستخدم

  
  
data = tonumber(getAccountData(v,text) or 0)or 0 
end 
if(data>0)then 
table.insert(sendTable,{["playerName"] = name,["PlayTime"] = data}) 
end 
end 
table.sort(sendTable,function(a,b) return tonumber(a["PlayTime"] or 0)>tonumber(b["PlayTime"] or 0) end) 
table.setMaxIndex(sendTable,10) 
  
  
مسوي كل شيء  وش الفانكشن  تقصد الفانكشن الثاني الي بي الكلنت يبي له حدث؟ 
  
  
هذا الي فوق مو ترتيب؟؟؟ 
  

Link to comment
اكواد الكلينت اللي حطيتها لك بدلها باللي عندك .

اوكك

  
  
-- سويت كل شي قلت عليه و ماظهرت لا الاسماء ولا الساعات   
  
- الخطا:  
[18:09:09] SCRIPT ERROR: SAE\s.lua:2: '=' expected near 'local' 
[18:09:09] ERROR: Loading script failed: SAE\s.lua:2: '=' expected near 'local' 
[18:09:09] ERROR: Client () triggered serverside event onTopPlayerListRequest, but event is not added serverside 
  
  
------------------------------------------ 
local playTime = {} 
function onLogin(old,current) 
if(current and not isGuestAccount(current))then  
local timeHour    = tonumber(getAccountData(current,"hour"))or 0 
local timeMinute  = tonumber(getAccountData(current,"minute"))or 0 
local timeSecond  = tonumber(getAccountData(current,"second"))or 0 
if(not playTime[source])then  
playTime[source] = { 
["hour"] = 0, 
["min"]  = 0, 
["sec"] = 0 
}  
end 
playTime[source]["hour"] = timeHour 
playTime[source]["min"] = timeMinute 
playTime[source]["sec"] = timeSecond 
end 
end 
addEventHandler("onPlayerLogin",root,onLogin) 
  
function onQuit() 
local acc = getPlayerAccount(source) 
if(acc and not isGuestAccount(acc))then  
local timeHour = playTime[source]["hour"] or 0 
local timeMin  = playTime[source]["min"] or 0 
local timeSec  = playTime[source]["sec"] or 0 
local name = getPlayerName(source) 
local nickAcc = string.gsub(name,"#%x%x%x%x%x%x","") 
setAccountData(acc,"hour",timeHour) 
setAccountData(acc,"minute",timeMin) 
setAccountData(acc,"second",timeSec) 
setAccountData(acc,"PlayerName",nickAcc) 
playTime[source] = nil 
end 
end 
addEventHandler("onPlayerQuit",root,onQuit) 
  
  
  
  
  
  
  
addEvent("onTopPlayerListRequest",true) 
addEventHandler("onTopPlayerListRequest",root, 
function(text) 
local allAccounts = getAccounts() 
local sendTable = {} 
local data = 0 
for k,v in ipairs(allAccounts) do 
local name = getAccountName(v) 
local dataHour = tonumber(getAccountData(v,"hour")) or 0 
local dataMin = tonumber(getAccountData(v,"minute")) or 0 
local dataSec = tonumber(getAccountData(v,"second")) or 0 
if(text == "Play Time")then  
data = dataHour+DividiveIfMoreZero(dataMin,60)+DividiveIfMoreZero(dataSec,3600) 
else 
data = tonumber(getAccountData(v,text) or 0)or 0 
end 
if(data>0)then 
table.insert(sendTable,{["playerName"] = name,["PlayTime"] = data}) 
end 
end 
table.sort(sendTable,function(a,b) return tonumber(a["PlayTime"] or 0)>tonumber(b["PlayTime"] or 0) end) 
table.setMaxIndex(sendTable,10) 
if(text == "Play Time")then  
for i=1,#sendTable do 
local timeString = "" 
local nAcc = getAccount(sendTable[i]["playerName"]) 
local hourS = getAccountData(nAcc,"hour") or 0 
local minS = getAccountData(nAcc,"minute") or 0 
local secS = getAccountData(nAcc,"second") or 0 
hourS = tostring(hourS) 
minS = tostring(minS) 
secS = tostring(secS) 
timeString = hourS..":"..minS..":"..secS 
sendTable[i]["PlayTime"] = timeString 
end 
end 
for i=1,#sendTable do 
local acc = getAccount(sendTable[i]["playerName"]) 
local accRealName = getAccountData(acc,"PlayerName") 
if(accRealName and tostring(accRealName)~="false")then  
sendTable[i]["playerName"] = accRealName 
end 
end 
triggerClientEvent(client,"onClientReceiveTopListTable",client,sendTable) 
end) 
function table.setMaxIndex(t,n) 
if(#t>n)then  
while(#t>n)do 
table.remove(t) 
end 
end 
end 
  
function DividiveIfMoreZero(v,d) 
if(v>0)then return (v/d) end 
return 0 
end 
  
  
function SavePlayTime() 
local players = getElementsByType("player") 
for k,v in ipairs(players) do  
if(not playTime[v]) then 
playTime[v] = { 
["hour"] = 0, 
["min"]  = 0, 
["sec"] = 0 
}  
end 
playTime[v]["sec"] = tonumber(playTime[v]["sec"]+1) 
convertTime(v,playTime[v]["min"],playTime[v]["sec"]) 
local hour = playTime[v]["hour"] 
local min  = playTime[v]["min"] 
local sec  = playTime[v]["sec"] 
local acc = getPlayerAccount(v) 
if(acc and isGuestAccount(acc)==false)then  
setAccountData(acc,"hour",hour) 
setAccountData(acc,"minute",min) 
setAccountData(acc,"second",sec) 
end 
end 
setTimer(SavePlayTime,1000,1) 
end 
setTimer(SavePlayTime,1000,1) 
  
  
function ResetTopPlayers() 
local allAccounts = getAccounts() 
for k,v in ipairs(allAccounts) do 
setAccountData(v,"hour",0) 
setAccountData(v,"minute",0) 
setAccountData(v,"second",0) 
end 
outputChatBox("[server]: Clear Top 10 list!") 
end 
  
function resetConsoleTop(p) 
local accName = getAccountName(getPlayerAccount(p)) 
if(isObjectInACLGroup("user." .. accName, aclGetGroup("Console")))then  
ResetTopPlayers() 
else 
outputChatBox("Only console can clear Top 10 list!",p) 
end 
end 
addCommandHandler("rplayer",resetConsoleTop) 
  
function convertTime(source,m,s) 
if(s>=60)then  
playTime[source]["min"] = tonumber(playTime[source]["min"]+1) 
playTime[source]["sec"]  = 0 
end 
if(m>=60)then  
playTime[source]["hour"] = tonumber(playTime[source]["hour"]+1) 
playTime[source]["min"]  = 0 
end 
end 
  

Link to comment

جرب كذا :

--Client side # 
GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(215, 117, 460, 403, "اعلى 30 تواجد  في السـيـرفـر", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 1.00) 
        guiSetVisible ( GUIEditor.window[1], false ) 
        guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF01FAB6") 
  
        Gridilist = guiCreateGridList(10, 54, 436, 324, false, GUIEditor.window[1]) 
        guiGridListAddColumn(Gridilist, "playerName", 0.5) 
        guiGridListAddColumn(Gridilist, "PlayTime", 0.5) 
  
        GUIEditor.label[1] = guiCreateLabel(-7, -45, 453, 40, "", false, GUIEditor.gridlist[1])     
    end 
) 
  
function on(state) 
    if state and not tonumber ( state ) and type (state) == 'boolean' then 
        if state == true then 
            triggerServerEvent("onTopPlayerListRequest",localPlayer,"Play Time") 
                else 
            return 
        end 
    end 
end 
addEventHandler( 'onClientResourceStart', resourceRoot,function() on(true) end) 
  
function UpdateTopList(t) 
    guiGridListClear(Gridilist) 
        for k,v in ipairs(t) do 
            local row = guiGridListAddRow(Gridilist) 
                guiGridListSetItemText(Gridilist,row,1,v["playerName"],false,false) 
                    guiGridListSetItemText(Gridilist,row,2,v["PlayTime"],false,false) 
    end 
end 
  
addEvent("onClientReceiveTopListTable",true) 
addEventHandler("onClientReceiveTopListTable",root, 
function(t) 
UpdateTopList(t) 
end) 
  
  
  
  
function TopGui() 
local guiS = guiGetVisible(GUIEditor.window[1]) 
guiSetVisible(GUIEditor.window[1],not guiS) 
showCursor(not guiS) 
guiSetInputEnabled(not guiS) 
on (guiS) 
end 
bindKey("F12","down",TopGui) 

-- Server side # 
local playTime = {} 
  
function onLogin(old,current) 
if(current and not isGuestAccount(current))then 
local timeHour    = tonumber(getAccountData(current,"hour"))or 0 
local timeMinute  = tonumber(getAccountData(current,"minute"))or 0 
local timeSecond  = tonumber(getAccountData(current,"second"))or 0 
if(not playTime[source])then 
playTime[source] = { 
["hour"] = 0, 
["min"]  = 0, 
["sec"] = 0 
} 
end 
playTime[source]["hour"] = timeHour 
playTime[source]["min"] = timeMinute 
playTime[source]["sec"] = timeSecond 
end 
end 
addEventHandler("onPlayerLogin",root,onLogin) 
  
addEventHandler ( 'onResourceStop', resourceRoot, function() 
    for k,v in ipairs ( getElementsByType ('player') ) do 
        local acc = getPlayerAccount(v) 
            if(acc and not isGuestAccount(acc))then 
local timeHour = playTime[v]["hour"] or 0 
local timeMin  = playTime[v]["min"] or 0 
local timeSec  = playTime[v]["sec"] or 0 
local name = getPlayerName(v) 
local nickAcc = string.gsub(name,"#%x%x%x%x%x%x","") 
setAccountData(acc,"hour",timeHour) 
setAccountData(acc,"minute",timeMin) 
setAccountData(acc,"second",timeSec) 
setAccountData(acc,"PlayerName",nickAcc) 
playTime[v] = nil 
        end 
    end 
end) 
  
  
addEventHandler ( 'onResourceStart', resourceRoot, function() 
    for k,v in ipairs ( getElementsByType ('player') ) do 
        local acc = getPlayerAccount ( v ) 
            if( acc and not isGuestAccount(acc))then 
            local timeHour    = tonumber(getAccountData(acc,"hour"))or 0 
            local timeMinute  = tonumber(getAccountData(acc,"minute"))or 0 
            local timeSecond  = tonumber(getAccountData(acc,"second"))or 0 
if(not playTime[v])then 
playTime[v] = { 
["hour"] = 0, 
["min"]  = 0, 
["sec"] = 0 
} 
end 
playTime[v]["hour"] = timeHour 
playTime[v]["min"] = timeMinute 
playTime[v]["sec"] = timeSecond 
        end 
    end 
end) 
  
function onQuit() 
local acc = getPlayerAccount(source) 
if(acc and not isGuestAccount(acc))then 
local timeHour = playTime[source]["hour"] or 0 
local timeMin  = playTime[source]["min"] or 0 
local timeSec  = playTime[source]["sec"] or 0 
local name = getPlayerName(source) 
local nickAcc = string.gsub(name,"#%x%x%x%x%x%x","") 
setAccountData(acc,"hour",timeHour) 
setAccountData(acc,"minute",timeMin) 
setAccountData(acc,"second",timeSec) 
setAccountData(acc,"PlayerName",nickAcc) 
playTime[source] = nil 
end 
end 
addEventHandler("onPlayerQuit",root,onQuit) 
  
  
  
  
  
  
  
addEvent("onTopPlayerListRequest",true) 
addEventHandler("onTopPlayerListRequest",root, 
function(text) 
local allAccounts = getAccounts() 
local sendTable = {} 
local data = 0 
for k,v in ipairs(allAccounts) do 
local name = getAccountName(v) 
local dataHour = tonumber(getAccountData(v,"hour")) or 0 
local dataMin = tonumber(getAccountData(v,"minute")) or 0 
local dataSec = tonumber(getAccountData(v,"second")) or 0 
if(text == "Play Time")then 
data = dataHour+DividiveIfMoreZero(dataMin,60)+DividiveIfMoreZero(dataSec,3600) 
else 
data = tonumber(getAccountData(v,text) or 0)or 0 
end 
if(data>0)then 
table.insert(sendTable,{["playerName"] = name,["PlayTime"] = data}) 
end 
end 
table.sort(sendTable,function(a,b) return tonumber(a["PlayTime"] or 0)>tonumber(b["PlayTime"] or 0) end) 
table.setMaxIndex(sendTable,10) 
if(text == "Play Time")then 
for i=1,#sendTable do 
local timeString = "" 
local nAcc = getAccount(sendTable[i]["playerName"]) 
local hourS = getAccountData(nAcc,"hour") or 0 
local minS = getAccountData(nAcc,"minute") or 0 
local secS = getAccountData(nAcc,"second") or 0 
hourS = tostring(hourS) 
minS = tostring(minS) 
secS = tostring(secS) 
timeString = hourS..":"..minS..":"..secS 
sendTable[i]["PlayTime"] = timeString 
end 
end 
for i=1,#sendTable do 
local acc = getAccount(sendTable[i]["playerName"]) 
local accRealName = getAccountData(acc,"PlayerName") 
if(accRealName and tostring(accRealName)~="false")then 
sendTable[i]["playerName"] = accRealName 
end 
end 
triggerClientEvent(client,"onClientReceiveTopListTable",client,sendTable) 
end) 
function table.setMaxIndex(t,n) 
if(#t>n)then 
while(#t>n)do 
table.remove(t) 
end 
end 
end 
  
function DividiveIfMoreZero(v,d) 
if(v>0)then return (v/d) end 
return 0 
end 
  
  
function SavePlayTime() 
local players = getElementsByType("player") 
for k,v in ipairs(players) do 
if(not playTime[v]) then 
playTime[v] = { 
["hour"] = 0, 
["min"]  = 0, 
["sec"] = 0 
} 
end 
playTime[v]["sec"] = tonumber(playTime[v]["sec"]+1) 
convertTime(v,playTime[v]["min"],playTime[v]["sec"]) 
local hour = playTime[v]["hour"] 
local min  = playTime[v]["min"] 
local sec  = playTime[v]["sec"] 
local acc = getPlayerAccount(v) 
if(acc and isGuestAccount(acc)==false)then 
setAccountData(acc,"hour",hour) 
setAccountData(acc,"minute",min) 
setAccountData(acc,"second",sec) 
end 
end 
setTimer(SavePlayTime,1000,1) 
end 
setTimer(SavePlayTime,1000,1) 
  
  
function ResetTopPlayers() 
local allAccounts = getAccounts() 
for k,v in ipairs(allAccounts) do 
setAccountData(v,"hour",0) 
setAccountData(v,"minute",0) 
setAccountData(v,"second",0) 
end 
outputChatBox("تم تحديث اعلى تواجد") 
end 
  
function resetConsoleTop(p) 
local accName = getAccountName(getPlayerAccount(p)) 
if(isObjectInACLGroup("user." .. accName, aclGetGroup("Console")))then 
ResetTopPlayers() 
else 
outputChatBox("هذا الخاصيه فقط لـ الكونسل",p) 
end 
end 
addCommandHandler("CL1",resetConsoleTop) 
  
function convertTime(source,m,s) 
if(s>=60)then 
playTime[source]["min"] = tonumber(playTime[source]["min"]+1) 
playTime[source]["sec"]  = 0 
end 
if(m>=60)then 
playTime[source]["hour"] = tonumber(playTime[source]["hour"]+1) 
playTime[source]["min"]  = 0 
end 
end 

وللمعلوميه ما بيتحدث الوقت الا كل ما تفتح اللوحه اف12, تقدر تسوي تايمر او اي شي اذا تبيه يحدث على طول ..

Link to comment
جرب كذا :

--Client side # 
GUIEditor = { 
    gridlist = {}, 
    window = {}, 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(215, 117, 460, 403, "اعلى 30 تواجد  في السـيـرفـر", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 1.00) 
        guiSetVisible ( GUIEditor.window[1], false ) 
        guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF01FAB6") 
  
        Gridilist = guiCreateGridList(10, 54, 436, 324, false, GUIEditor.window[1]) 
        guiGridListAddColumn(Gridilist, "playerName", 0.5) 
        guiGridListAddColumn(Gridilist, "PlayTime", 0.5) 
  
        GUIEditor.label[1] = guiCreateLabel(-7, -45, 453, 40, "", false, GUIEditor.gridlist[1])     
    end 
) 
  
function on(state) 
    if state and not tonumber ( state ) and type (state) == 'boolean' then 
        if state == true then 
            triggerServerEvent("onTopPlayerListRequest",localPlayer,"Play Time") 
                else 
            return 
        end 
    end 
end 
addEventHandler( 'onClientResourceStart', resourceRoot,function() on(true) end) 
  
function UpdateTopList(t) 
    guiGridListClear(Gridilist) 
        for k,v in ipairs(t) do 
            local row = guiGridListAddRow(Gridilist) 
                guiGridListSetItemText(Gridilist,row,1,v["playerName"],false,false) 
                    guiGridListSetItemText(Gridilist,row,2,v["PlayTime"],false,false) 
    end 
end 
  
addEvent("onClientReceiveTopListTable",true) 
addEventHandler("onClientReceiveTopListTable",root, 
function(t) 
UpdateTopList(t) 
end) 
  
  
  
  
function TopGui() 
local guiS = guiGetVisible(GUIEditor.window[1]) 
guiSetVisible(GUIEditor.window[1],not guiS) 
showCursor(not guiS) 
guiSetInputEnabled(not guiS) 
on (guiS) 
end 
bindKey("F12","down",TopGui) 

-- Server side # 
local playTime = {} 
  
function onLogin(old,current) 
if(current and not isGuestAccount(current))then 
local timeHour    = tonumber(getAccountData(current,"hour"))or 0 
local timeMinute  = tonumber(getAccountData(current,"minute"))or 0 
local timeSecond  = tonumber(getAccountData(current,"second"))or 0 
if(not playTime[source])then 
playTime[source] = { 
["hour"] = 0, 
["min"]  = 0, 
["sec"] = 0 
} 
end 
playTime[source]["hour"] = timeHour 
playTime[source]["min"] = timeMinute 
playTime[source]["sec"] = timeSecond 
end 
end 
addEventHandler("onPlayerLogin",root,onLogin) 
  
addEventHandler ( 'onResourceStop', resourceRoot, function() 
    for k,v in ipairs ( getElementsByType ('player') ) do 
        local acc = getPlayerAccount(v) 
            if(acc and not isGuestAccount(acc))then 
local timeHour = playTime[v]["hour"] or 0 
local timeMin  = playTime[v]["min"] or 0 
local timeSec  = playTime[v]["sec"] or 0 
local name = getPlayerName(v) 
local nickAcc = string.gsub(name,"#%x%x%x%x%x%x","") 
setAccountData(acc,"hour",timeHour) 
setAccountData(acc,"minute",timeMin) 
setAccountData(acc,"second",timeSec) 
setAccountData(acc,"PlayerName",nickAcc) 
playTime[v] = nil 
        end 
    end 
end) 
  
  
addEventHandler ( 'onResourceStart', resourceRoot, function() 
    for k,v in ipairs ( getElementsByType ('player') ) do 
        local acc = getPlayerAccount ( v ) 
            if( acc and not isGuestAccount(acc))then 
            local timeHour    = tonumber(getAccountData(acc,"hour"))or 0 
            local timeMinute  = tonumber(getAccountData(acc,"minute"))or 0 
            local timeSecond  = tonumber(getAccountData(acc,"second"))or 0 
if(not playTime[v])then 
playTime[v] = { 
["hour"] = 0, 
["min"]  = 0, 
["sec"] = 0 
} 
end 
playTime[v]["hour"] = timeHour 
playTime[v]["min"] = timeMinute 
playTime[v]["sec"] = timeSecond 
        end 
    end 
end) 
  
function onQuit() 
local acc = getPlayerAccount(source) 
if(acc and not isGuestAccount(acc))then 
local timeHour = playTime[source]["hour"] or 0 
local timeMin  = playTime[source]["min"] or 0 
local timeSec  = playTime[source]["sec"] or 0 
local name = getPlayerName(source) 
local nickAcc = string.gsub(name,"#%x%x%x%x%x%x","") 
setAccountData(acc,"hour",timeHour) 
setAccountData(acc,"minute",timeMin) 
setAccountData(acc,"second",timeSec) 
setAccountData(acc,"PlayerName",nickAcc) 
playTime[source] = nil 
end 
end 
addEventHandler("onPlayerQuit",root,onQuit) 
  
  
  
  
  
  
  
addEvent("onTopPlayerListRequest",true) 
addEventHandler("onTopPlayerListRequest",root, 
function(text) 
local allAccounts = getAccounts() 
local sendTable = {} 
local data = 0 
for k,v in ipairs(allAccounts) do 
local name = getAccountName(v) 
local dataHour = tonumber(getAccountData(v,"hour")) or 0 
local dataMin = tonumber(getAccountData(v,"minute")) or 0 
local dataSec = tonumber(getAccountData(v,"second")) or 0 
if(text == "Play Time")then 
data = dataHour+DividiveIfMoreZero(dataMin,60)+DividiveIfMoreZero(dataSec,3600) 
else 
data = tonumber(getAccountData(v,text) or 0)or 0 
end 
if(data>0)then 
table.insert(sendTable,{["playerName"] = name,["PlayTime"] = data}) 
end 
end 
table.sort(sendTable,function(a,b) return tonumber(a["PlayTime"] or 0)>tonumber(b["PlayTime"] or 0) end) 
table.setMaxIndex(sendTable,10) 
if(text == "Play Time")then 
for i=1,#sendTable do 
local timeString = "" 
local nAcc = getAccount(sendTable[i]["playerName"]) 
local hourS = getAccountData(nAcc,"hour") or 0 
local minS = getAccountData(nAcc,"minute") or 0 
local secS = getAccountData(nAcc,"second") or 0 
hourS = tostring(hourS) 
minS = tostring(minS) 
secS = tostring(secS) 
timeString = hourS..":"..minS..":"..secS 
sendTable[i]["PlayTime"] = timeString 
end 
end 
for i=1,#sendTable do 
local acc = getAccount(sendTable[i]["playerName"]) 
local accRealName = getAccountData(acc,"PlayerName") 
if(accRealName and tostring(accRealName)~="false")then 
sendTable[i]["playerName"] = accRealName 
end 
end 
triggerClientEvent(client,"onClientReceiveTopListTable",client,sendTable) 
end) 
function table.setMaxIndex(t,n) 
if(#t>n)then 
while(#t>n)do 
table.remove(t) 
end 
end 
end 
  
function DividiveIfMoreZero(v,d) 
if(v>0)then return (v/d) end 
return 0 
end 
  
  
function SavePlayTime() 
local players = getElementsByType("player") 
for k,v in ipairs(players) do 
if(not playTime[v]) then 
playTime[v] = { 
["hour"] = 0, 
["min"]  = 0, 
["sec"] = 0 
} 
end 
playTime[v]["sec"] = tonumber(playTime[v]["sec"]+1) 
convertTime(v,playTime[v]["min"],playTime[v]["sec"]) 
local hour = playTime[v]["hour"] 
local min  = playTime[v]["min"] 
local sec  = playTime[v]["sec"] 
local acc = getPlayerAccount(v) 
if(acc and isGuestAccount(acc)==false)then 
setAccountData(acc,"hour",hour) 
setAccountData(acc,"minute",min) 
setAccountData(acc,"second",sec) 
end 
end 
setTimer(SavePlayTime,1000,1) 
end 
setTimer(SavePlayTime,1000,1) 
  
  
function ResetTopPlayers() 
local allAccounts = getAccounts() 
for k,v in ipairs(allAccounts) do 
setAccountData(v,"hour",0) 
setAccountData(v,"minute",0) 
setAccountData(v,"second",0) 
end 
outputChatBox("تم تحديث اعلى تواجد") 
end 
  
function resetConsoleTop(p) 
local accName = getAccountName(getPlayerAccount(p)) 
if(isObjectInACLGroup("user." .. accName, aclGetGroup("Console")))then 
ResetTopPlayers() 
else 
outputChatBox("هذا الخاصيه فقط لـ الكونسل",p) 
end 
end 
addCommandHandler("CL1",resetConsoleTop) 
  
function convertTime(source,m,s) 
if(s>=60)then 
playTime[source]["min"] = tonumber(playTime[source]["min"]+1) 
playTime[source]["sec"]  = 0 
end 
if(m>=60)then 
playTime[source]["hour"] = tonumber(playTime[source]["hour"]+1) 
playTime[source]["min"]  = 0 
end 
end 

وللمعلوميه ما بيتحدث الوقت الا كل ما تفتح اللوحه اف12, تقدر تسوي تايمر او اي شي اذا تبيه يحدث على طول ..

  
مازبط 
الخطا 
  
[18:24:59] ERROR: Client () triggered serverside event onTopPlayerListRequest, but event is not added serverside  [DUP x7] 
  

Link to comment
اشوف الميتا؟
  
           
    

  
--- يمكن من اليبل لانه  انا عملت واحد في القريد لست بي الغلط 
  
        GUIEditor.label[1] = guiCreateLabel(-7, -45, 453, 40, "", false, GUIEditor.gridlist[1])  
  

-----------------------

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