Newbie Posted March 16, 2014 Share Posted March 16, 2014 Heu. I've edited toptimes and noticed one defect. It just shows one top time. other times does not show up.. 1. SomePlayerName (visible) 2. Does not show 3. Does not show 4. Does not show 5. Does not show 6. Does not show 7. Does not show 8. Does not show local topsFont = dxCreateFont( "font.ttf") -- -- toptimes_client.lua -- Created = {} CToptimes = {} CToptimes.__index = CToptimes CToptimes.instances = {} g_Settings = {} serverInfo = {} px = 0 sX,sY = guiGetScreenSize() toptimes = { anim = 360, size = {380,160}, mapname = "N/A", label = {"","","","","","","","","","",""}, time = {"","","","","","","","","","",""}, data = {"","","","","","","","","","",""}, country = {"","","","","","","","","","",""}, personal = {false,pos = 9,name="",time="",data="",country=""}, state = false, animState = "closed", tick = getTickCount() } function drawToptimesIntreface() if toptimes.animState == "closed" then local tick = getTickCount() - toptimes.tick local progress = tick/1000 toptimes.anim = interpolateBetween(0,0,0,390,0,0,progress,"InOutBack") else local tick = getTickCount() - toptimes.tick local progress = tick/1000 toptimes.anim = interpolateBetween(390,0,0,0,0,0,progress,"OutBounce") end local clanColor = {220,20,60} if toptimes.state then local sX = sX+toptimes.anim dxDrawRectangle(sX-toptimes.size[1]-10,(sY/2)-(toptimes.size[2]),toptimes.size[1],200/8,tocolor(232,31,31,200)) dxDrawText(toptimes.mapname,sX-toptimes.size[1]-10,(sY/2)-(toptimes.size[2]),sX-10,(sY/2)-(toptimes.size[2])+(200/8),tocolor(255,255,255,255),1,topsFont,"center","center",true) dxDrawRectangle(sX-toptimes.size[1]-10,(sY/2)-(toptimes.size[2])+(200/8),toptimes.size[1],toptimes.size[2],tocolor(15,15,15,150)) for i=1,8 do dxDrawText(i..") "..toptimes.label[i],sX-toptimes.size[1]+(toptimes.size[1]*0.03)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i-1)*20),sX-(toptimes.size[1]*0.1)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i)*20),tocolor(255,255,255,255),1,topsFont,"left","center",true,false,false,true) dxDrawText(toptimes.time[i],sX-toptimes.size[1]+(toptimes.size[1]*0.52)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i-1)*20),sX-(toptimes.size[1]*0.1)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i)*20),tocolor(255,255,255,255),1,topsFont,"left","center",true,false,false,true) dxDrawText(toptimes.data[i],sX-toptimes.size[1]+(toptimes.size[1]*0.75)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i-1)*20),sX-(toptimes.size[1]*0.1)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i)*20),tocolor(255,255,255,255),1,topsFont,"left","center",true,false,false,true) if toptimes.country[i] ~= "" then if fileExists(":admin/client/images/flags/"..toptimes.country[i]..".png") then dxDrawImage(sX-toptimes.size[1]+(toptimes.size[1]*0.93)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i-1)*20)+3,16,11,":admin/client/images/flags/"..toptimes.country[i]..".png",tocolor(255,255,255,255)) end end end if toptimes.personal[1] then dxDrawRectangle(sX-toptimes.size[1]-10,(sY/2)+(200/8),toptimes.size[1],30,tocolor(15,15,15,150)) dxDrawLine(sX-toptimes.size[1],(sY/2)+(200/8),sX-20,(sY/2)+(200/8),tocolor(141,182,205,255)) dxDrawText("#8DB6CD"..toptimes.personal.pos..") #FFFFFF "..toptimes.personal.name,sX-toptimes.size[1]+(toptimes.size[1]*0.03)-10,(sY/2)+(200/8),sX-(toptimes.size[1]*0.1)-10,(sY/2)+(200/8)+30,tocolor(255,255,255,255),1,topsFont,"left","center",true,false,false,true) dxDrawText(toptimes.personal.time,sX-toptimes.size[1]+(toptimes.size[1]*0.52)-10,(sY/2)+(200/8),sX-(toptimes.size[1]*0.1)-10,(sY/2)+(200/8)+30,tocolor(255,255,255,255),1,topsFont,"left","center",true,false,false,true) dxDrawText(toptimes.personal.data,sX-toptimes.size[1]+(toptimes.size[1]*0.75)-10,(sY/2)+(200/8),sX-(toptimes.size[1]*0.1)-10,(sY/2)+(200/8)+30,tocolor(255,255,255,255),1,topsFont,"left","center",true,false,false,true) if toptimes.personal.country ~= "" then if fileExists(":admin/client/images/flags/"..toptimes.personal.country..".png") then dxDrawImage(sX-toptimes.size[1]+(toptimes.size[1]*0.93)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i-1)*20)+3,16,11,":admin/client/images/flags/"..toptimes.personal.country..".png",tocolor(255,255,255,255)) end end end end end addEventHandler("onClientRender",getRootElement(),drawToptimesIntreface) function toggleToptimes() if toptimes.animState == "open" then closeToptimes() else openToptimes() end end bindKey("F5","down",toggleToptimes) function openToptimes() if toptimes.state and toptimes.animState == "closed" then toptimes.tick = getTickCount() toptimes.animState = "open" end end function closeToptimes() if toptimes.state and toptimes.animState == "open" then toptimes.tick = getTickCount() toptimes.animState = "closed" end end --------------------------------------------------------------------------- -- Client -- Handle events from Race -- -- This is the 'interface' from Race -- --------------------------------------------------------------------------- addEventHandler('onClientResourceStart', g_ResRoot, function() triggerServerEvent('onLoadedAtClient_tt', g_Me) topTimePersonalLabel = false chatBlock = false end ) addEvent('onClientMapStarting', true) addEventHandler('onClientMapStarting', getRootElement(), function(mapinfo) outputDebug( 'TOPTIMES', 'onClientMapStarting' ) if g_CToptimes then g_CToptimes:onMapStarting(mapinfo) chatBlock = false end end ) addEvent('onClientMapStopping', true) addEventHandler('onClientMapStopping', getRootElement(), function() outputDebug( 'TOPTIMES', 'onClientMapStopping' ) if g_CToptimes then g_CToptimes:onMapStopping() end end ) addEvent('onClientPlayerFinish', true) addEventHandler('onClientPlayerFinish', getRootElement(), function() outputDebug( 'TOPTIMES', 'onClientPlayerFinish' ) if g_CToptimes then openToptimes() setTimer(closeToptimes,5000,1) end end ) addEvent('onClientSetMapName', true) addEventHandler('onClientSetMapName', getRootElement(), function(manName) if g_CToptimes then g_CToptimes:setWindowTitle(manName) end end ) function updateSettings(settings, playeradmin) end --------------------------------------------------------------------------- -- -- CToptimes:create() -- -- -- --------------------------------------------------------------------------- function CToptimes:create() local id = #CToptimes.instances + 1 CToptimes.instances[id] = setmetatable( { id = id, hasTimes = false }, self ) return CToptimes.instances[id] end function CToptimes:setWindowTitle( mapName ) toptimes.mapname = mapName end function string.findIgnoreCase(haystack,needle) return string.find(string.lower(haystack),string.lower(needle),1,true) end function CToptimes:onMapStarting(mapinfo) self:setWindowTitle( mapinfo.name ) self.hasTimes = false -- table.dump(mapinfo) -- if self.startshow then --if mapinfo.name and string.findIgnoreCase(mapinfo.name,"[DM]") then for _,e in pairs(getElementsByType("racepickup") or {}) do local t = getElementData(e,"type") if t and t == "vehiclechange" then local v = getElementData(e,"vehicle") if v and tonumber(v) == 425 then self.hasTimes = true break end end end --end if self.hasTimes then self:doToggleToptimes( true ) openToptimes() setTimer(closeToptimes,5000,1) else self:doToggleToptimes( false ) closeToptimes() end end function CToptimes:onMapStopping() self:setWindowTitle( '' ) closeToptimes() end function CToptimes:doAutoShow() self.bAutoShow = true self:updateShow() end function CToptimes:updateShow(bOn) self:enableToptimeUpdatesFromServer(bOn) end function CToptimes:enableToptimeUpdatesFromServer( bOn ) triggerServerEvent('onClientRequestToptimesUpdates', g_Me, bOn, self.clientRevision ) end function CToptimes:doOnServerSentToptimes( data, serverRevision, playerPosition ) toptimes.personal[1] = false for i=1,8 do toptimes.label[i] = data[i].playerName local timeText = data[i].timeText if timeText:sub(1,1) == '0' then timeText = ' ' .. timeText:sub(2) end toptimes.time[i] = timeText toptimes.data[i] = string.sub(data[i].dateRecorded,1,10) toptimes.country[i] = data[i].country Link to comment
Newbie Posted March 16, 2014 Author Share Posted March 16, 2014 when i test with other toptimes it works and shows all taken toptimes of the map. Link to comment
zzx Posted March 16, 2014 Share Posted March 16, 2014 You have to change your nick after setting a toptime to set another one with the new nick, if not you only improve your toptime setted time in the list. Link to comment
Newbie Posted March 16, 2014 Author Share Posted March 16, 2014 I did it. I tested it on map while chanin my nick and reconnecting the server everytime i got top time. When i load other toptimes script they are showing all 1. 2. 3. .. Ect but this shows on only 1. Dont show others Link to comment
Newbie Posted March 16, 2014 Author Share Posted March 16, 2014 This how it looks. Like i said when i test same map with other toptimes they're showing. But in this case shows only 1... Maybe bug is in other file ? Link to comment
Castillo Posted March 16, 2014 Share Posted March 16, 2014 Do you get errors in the debugscript? because that may be the problem which is causing the rest not to draw. Link to comment
Castillo Posted March 16, 2014 Share Posted March 16, 2014 local topsFont = dxCreateFont( "font.ttf") -- -- toptimes_client.lua -- Created = {} CToptimes = {} CToptimes.__index = CToptimes CToptimes.instances = {} g_Settings = {} serverInfo = {} px = 0 sX,sY = guiGetScreenSize() toptimes = { anim = 360, size = {380,160}, mapname = "N/A", label = {"","","","","","","","","","",""}, time = {"","","","","","","","","","",""}, data = {"","","","","","","","","","",""}, country = {"","","","","","","","","","",""}, personal = {false,pos = 9,name="",time="",data="",country=""}, state = false, animState = "closed", tick = getTickCount() } function drawToptimesIntreface() if toptimes.animState == "closed" then local tick = getTickCount() - toptimes.tick local progress = tick/1000 toptimes.anim = interpolateBetween(0,0,0,390,0,0,progress,"InOutBack") else local tick = getTickCount() - toptimes.tick local progress = tick/1000 toptimes.anim = interpolateBetween(390,0,0,0,0,0,progress,"OutBounce") end local clanColor = {220,20,60} if toptimes.state then local sX = sX+toptimes.anim dxDrawRectangle(sX-toptimes.size[1]-10,(sY/2)-(toptimes.size[2]),toptimes.size[1],200/8,tocolor(232,31,31,200)) dxDrawText(toptimes.mapname,sX-toptimes.size[1]-10,(sY/2)-(toptimes.size[2]),sX-10,(sY/2)-(toptimes.size[2])+(200/8),tocolor(255,255,255,255),1,topsFont,"center","center",true) dxDrawRectangle(sX-toptimes.size[1]-10,(sY/2)-(toptimes.size[2])+(200/8),toptimes.size[1],toptimes.size[2],tocolor(15,15,15,150)) for i=1,8 do dxDrawText(i..") "..toptimes.label[i],sX-toptimes.size[1]+(toptimes.size[1]*0.03)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i-1)*20),sX-(toptimes.size[1]*0.1)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i)*20),tocolor(255,255,255,255),1,topsFont,"left","center",true,false,false,true) dxDrawText(toptimes.time[i],sX-toptimes.size[1]+(toptimes.size[1]*0.52)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i-1)*20),sX-(toptimes.size[1]*0.1)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i)*20),tocolor(255,255,255,255),1,topsFont,"left","center",true,false,false,true) dxDrawText(toptimes.data[i],sX-toptimes.size[1]+(toptimes.size[1]*0.75)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i-1)*20),sX-(toptimes.size[1]*0.1)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i)*20),tocolor(255,255,255,255),1,topsFont,"left","center",true,false,false,true) if toptimes.country[i] ~= "" then if fileExists(":admin/client/images/flags/"..toptimes.country[i]..".png") then dxDrawImage(sX-toptimes.size[1]+(toptimes.size[1]*0.93)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i-1)*20)+3,16,11,":admin/client/images/flags/"..toptimes.country[i]..".png",tocolor(255,255,255,255)) end end end if toptimes.personal[1] then dxDrawRectangle(sX-toptimes.size[1]-10,(sY/2)+(200/8),toptimes.size[1],30,tocolor(15,15,15,150)) dxDrawLine(sX-toptimes.size[1],(sY/2)+(200/8),sX-20,(sY/2)+(200/8),tocolor(141,182,205,255)) dxDrawText("#8DB6CD"..toptimes.personal.pos..") #FFFFFF "..toptimes.personal.name,sX-toptimes.size[1]+(toptimes.size[1]*0.03)-10,(sY/2)+(200/8),sX-(toptimes.size[1]*0.1)-10,(sY/2)+(200/8)+30,tocolor(255,255,255,255),1,topsFont,"left","center",true,false,false,true) dxDrawText(toptimes.personal.time,sX-toptimes.size[1]+(toptimes.size[1]*0.52)-10,(sY/2)+(200/8),sX-(toptimes.size[1]*0.1)-10,(sY/2)+(200/8)+30,tocolor(255,255,255,255),1,topsFont,"left","center",true,false,false,true) dxDrawText(toptimes.personal.data,sX-toptimes.size[1]+(toptimes.size[1]*0.75)-10,(sY/2)+(200/8),sX-(toptimes.size[1]*0.1)-10,(sY/2)+(200/8)+30,tocolor(255,255,255,255),1,topsFont,"left","center",true,false,false,true) if toptimes.personal.country ~= "" then if fileExists(":admin/client/images/flags/"..toptimes.personal.country..".png") then dxDrawImage(sX-toptimes.size[1]+(toptimes.size[1]*0.93)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i-1)*20)+3,16,11,":admin/client/images/flags/"..toptimes.personal.country..".png",tocolor(255,255,255,255)) end end end end end addEventHandler("onClientRender",getRootElement(),drawToptimesIntreface) function toggleToptimes() if toptimes.animState == "open" then closeToptimes() else openToptimes() end end bindKey("F5","down",toggleToptimes) function openToptimes() if toptimes.state and toptimes.animState == "closed" then toptimes.tick = getTickCount() toptimes.animState = "open" end end function closeToptimes() if toptimes.state and toptimes.animState == "open" then toptimes.tick = getTickCount() toptimes.animState = "closed" end end --------------------------------------------------------------------------- -- Client -- Handle events from Race -- -- This is the 'interface' from Race -- --------------------------------------------------------------------------- addEventHandler('onClientResourceStart', g_ResRoot, function() triggerServerEvent('onLoadedAtClient_tt', g_Me) topTimePersonalLabel = false chatBlock = false end ) addEvent('onClientMapStarting', true) addEventHandler('onClientMapStarting', getRootElement(), function(mapinfo) outputDebug( 'TOPTIMES', 'onClientMapStarting' ) if g_CToptimes then g_CToptimes:onMapStarting(mapinfo) chatBlock = false end end ) addEvent('onClientMapStopping', true) addEventHandler('onClientMapStopping', getRootElement(), function() outputDebug( 'TOPTIMES', 'onClientMapStopping' ) if g_CToptimes then g_CToptimes:onMapStopping() end end ) addEvent('onClientPlayerFinish', true) addEventHandler('onClientPlayerFinish', getRootElement(), function() outputDebug( 'TOPTIMES', 'onClientPlayerFinish' ) if g_CToptimes then openToptimes() setTimer(closeToptimes,5000,1) end end ) addEvent('onClientSetMapName', true) addEventHandler('onClientSetMapName', getRootElement(), function(manName) if g_CToptimes then g_CToptimes:setWindowTitle(manName) end end ) function updateSettings(settings, playeradmin) end --------------------------------------------------------------------------- -- -- CToptimes:create() -- -- -- --------------------------------------------------------------------------- function CToptimes:create() local id = #CToptimes.instances + 1 CToptimes.instances[id] = setmetatable( { id = id, hasTimes = false }, self ) return CToptimes.instances[id] end function CToptimes:setWindowTitle( mapName ) toptimes.mapname = mapName end function string.findIgnoreCase(haystack,needle) return string.find(string.lower(haystack),string.lower(needle),1,true) end function CToptimes:onMapStarting(mapinfo) self:setWindowTitle( mapinfo.name ) self.hasTimes = false -- table.dump(mapinfo) -- if self.startshow then --if mapinfo.name and string.findIgnoreCase(mapinfo.name,"[DM]") then for _,e in pairs(getElementsByType("racepickup") or {}) do local t = getElementData(e,"type") if t and t == "vehiclechange" then local v = getElementData(e,"vehicle") if v and tonumber(v) == 425 then self.hasTimes = true break end end end --end if self.hasTimes then self:doToggleToptimes( true ) openToptimes() setTimer(closeToptimes,5000,1) else self:doToggleToptimes( false ) closeToptimes() end end function CToptimes:onMapStopping() self:setWindowTitle( '' ) closeToptimes() end function CToptimes:doAutoShow() self.bAutoShow = true self:updateShow() end function CToptimes:updateShow(bOn) self:enableToptimeUpdatesFromServer(bOn) end function CToptimes:enableToptimeUpdatesFromServer( bOn ) triggerServerEvent('onClientRequestToptimesUpdates', g_Me, bOn, self.clientRevision ) end function CToptimes:doOnServerSentToptimes( data, serverRevision, playerPosition ) toptimes.personal[1] = false for i=1,8 do toptimes.label[i] = data[i].playerName local timeText = data[i].timeText if timeText:sub(1,1) == '0' then timeText = ' ' .. timeText:sub(2) end toptimes.time[i] = timeText toptimes.data[i] = string.sub(tostring(data[i].dateRecorded),1,10) toptimes.country[i] = data[i].country Link to comment
Castillo Posted March 16, 2014 Share Posted March 16, 2014 There are no other errors? Link to comment
Newbie Posted March 16, 2014 Author Share Posted March 16, 2014 There's, but not of toptimes. Link to comment
Newbie Posted March 16, 2014 Author Share Posted March 16, 2014 I have fixed it. I was missed some functions in other top files. Thanks for help Solid! Link to comment
Castillo Posted March 17, 2014 Share Posted March 17, 2014 Glad you got it working. You're welcome. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now