function onresource2Start()
bindKey ("f5", "down", OpenTopwins)
enabled = false
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onresource2Start)
local Serkan_TopWins_Client_Data = { }
local Serkan_TopWins_Mapname = "N/A"
local x,y = guiGetScreenSize()
function Serkan_TopWins_Render()
if not getPlayerTeam(getLocalPlayer()) then
playerName = getPlayerName(getLocalPlayer())
elseif getPlayerTeam(getLocalPlayer()) then
playerName = ""..RGBToHex(getTeamColor(getPlayerTeam(getLocalPlayer())))..""..getPlayerName(getLocalPlayer())..""
end
dxDrawImage( x-300, y/2 - 100, 270, 280, "back.png", 0, 0, 0, tocolor ( 20, 20, 20, 100 ), true )
dxDrawImage( x-300, y/2 - 100, 270, 18, "bar.png" )
dxDrawText( tostring (Serkan_TopWins_Mapname ), x-300, y/2 - 96, 0, 0, tocolor( 255, 255, 255 ), 0.35, "bankgothic", "left", "top", false, false, true )
dxDrawText(" #. Nick Kazanma", x-300, y/2 - 83, 0, 0, tocolor( 255, 255, 255 ), 0.45, "bankgothic", "left", "top", false, false, true )
for i=1,10 do
if Serkan_TopWins_Client_Data then
dxDrawText ( tostring ( i ) ..".#ffffff".. Serkan_TopWins_Client_Data.name, x-300 + 10, 20 * i + y/2 - 80, 0, 0, tocolor ( 255, 255, 255 ), 0.45, "bankgothic", "left", "top", false, false, true, true )
dxDrawText ("#FFFFFF".. tostring ( Serkan_TopWins_Client_Data.data ), x-100 + 10, 20 * i + y/2 - 80, 0, 0, tocolor ( 255, 255, 255 ), 0.45, "bankgothic", "left", "top", false, false, true, true )
Flag = ":flags/flags/"..Serkan_TopWins_Client_Data.Country..".png"
if fExists(Flag) then
dxDrawImage ( x-70 + 10, 20 * i + y/2 - 80, 16,16,Flag, 0, 0, 0 )
else
dxDrawImage ( x-70 + 10, 20 * i + y/2 - 80, 16, 16,":flags/flags/zz.png", 0, 0, 0 )
end
for xi=1,#Serkan_TopWins_Client_Data do
if Serkan_TopWins_Client_Data[xi].name == playerName then
dxDrawText ( tostring ( xi ) ..".#ffffff".. Serkan_TopWins_Client_Data[xi].name, x-300 + 10, 20 * 11 + y/2 - 80, 0, 0, tocolor ( 255, 255, 255 ), 0.45, "bankgothic", "left", "top", false, false, true, true )
dxDrawText ("#FFFFFF".. tostring ( Serkan_TopWins_Client_Data[xi].data ), x-100 + 10, 20 * 11 + y/2 - 80, 0, 0, tocolor ( 255, 255, 255 ), 0.45, "bankgothic", "left", "top", false, false, true, true )
Flag2 = ":flags/flags/"..Serkan_TopWins_Client_Data[xi].Country..".png"
if fExists(Flag2) then
dxDrawImage ( x-70 + 10, 20 * 11 + y/2 - 80, 16, 16,Flag2, 0, 0, 0 )
else
dxDrawImage ( x-70 + 10, 20 * 11 + y/2 - 80, 16, 16,":flags/flags/zz.png", 0, 0, 0 )
end
end
end
end
end
end
function onUpdateTopTimesClient(data,Mapname)
Serkan_TopWins_Client_Data = data
Serkan_TopWins_Mapname = Mapname
removeEventHandler ( "onClientRender", getRootElement(), Serkan_TopWins_Render )
addEventHandler ( "onClientRender", getRootElement(), Serkan_TopWins_Render )
setTimer(RemoveEvent,7000,1,source)
enabled = true
end
addEvent("onUpdateTopTimes",true)
addEventHandler("onUpdateTopTimes",getRootElement(),onUpdateTopTimes)
function RGBToHex(red, green, blue, alpha)
if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then
return nil
end
if(alpha) then
return string.format("#%.2X%.2X%.2X%.2X", red, green, blue, alpha)
else
return string.format("#%.2X%.2X%.2X", red, green, blue)
end
end
function OpenTopwins()
enabled = not enabled
if (enabled) then
addEventHandler ( "onClientRender", getRootElement(), Serkan_TopWins_Render )
else
removeEventHandler ( "onClientRender", getRootElement(), Serkan_TopWins_Render )
end
end
function RemoveEvent()
removeEventHandler ( "onClientRender", getRootElement(), Serkan_TopWins_Render )
end
flExists = {}
flChecked = {}
function fExists( filename )
if flChecked[filename] then return flExists[filename] end
flChecked[filename] = true
flExists[filename] = fileExists(filename)
return flExists[filename]
end