Arsilex Posted March 6, 2012 Posted March 6, 2012 Hola amigos me preguntava si alguen me puede decir como añadir el color del name de un player en el toptimes -- -- toptimes_client.lua -- CToptimes = {} CToptimes.__index = CToptimes CToptimes.instances = {} g_Settings = {} --------------------------------------------------------------------------- -- Client -- Handle events from Race -- -- This is the 'interface' from Race -- --------------------------------------------------------------------------- addEventHandler('onClientResourceStart', g_ResRoot, function() triggerServerEvent('onLoadedAtClient_tt', g_Me) end ) addEvent('onClientMapStarting', true) addEventHandler('onClientMapStarting', getRootElement(), function(mapinfo) outputDebug( 'TOPTIMES', 'onClientMapStarting' ) if g_CToptimes then g_CToptimes:onMapStarting(mapinfo) 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 g_CToptimes:doAutoShow() end end ) addEvent('onClientSetMapName', true) addEventHandler('onClientSetMapName', getRootElement(), function(manName) if g_CToptimes then g_CToptimes:setWindowTitle(manName) end end ) function updateSettings(settings, playeradmin) outputDebug( 'TOPTIMES', 'updateSettings' ) if g_CToptimes then if settings and settings.gui_x and settings.gui_y then g_CToptimes:setWindowPosition( settings.gui_x, settings.gui_y ) g_CToptimes.startshow = settings.startshow end -- If admin changed this setting manually, then show the table to him if playeradmin == getLocalPlayer() then g_CToptimes:doToggleToptimes(true) end end end --------------------------------------------------------------------------- -- -- CToptimes:create() -- -- -- --------------------------------------------------------------------------- function CToptimes:create() outputDebug ( 'TOPTIMES', 'CToptimes:create' ) local id = #CToptimes.instances + 1 CToptimes.instances[id] = setmetatable( { id = id, bManualShow = false, -- via key press bAutoShow = false, -- when player finished bGettingUpdates = false, -- server should send us updates to the toptimes listStatus = 'Empty', -- 'Empty', 'Loading' or 'Full' gui = {}, -- all gui items lastSeconds = 0, targetFade = 0, currentFade = 0, autoOffTimer = Timer:create(), hasTimes = false }, self ) CToptimes.instances[id]:postCreate() return CToptimes.instances[id] end --------------------------------------------------------------------------- -- -- CToptimes:destroy() -- -- -- --------------------------------------------------------------------------- function CToptimes:destroy() self:setHotKey(nil) self:closeWindow() self.autoOffTimer:destroy() CToptimes.instances[self.id] = nil self.id = 0 end --------------------------------------------------------------------------- -- -- CToptimes:postCreate() -- -- -- --------------------------------------------------------------------------- function CToptimes:postCreate() self:openWindow() self:setWindowPosition( 0.7, 0.02 ) self:setHotKey('F5') end --------------------------------------------------------------------------- -- -- CToptimes:openWindow() -- -- -- --------------------------------------------------------------------------- function CToptimes:openWindow () if self.gui['container'] then return end self.size = {} self.size.x = 400-120 self.size.y = 46 + 15 * 10 local sizeX = self.size.x local sizeY = self.size.y -- windowbg is the root gui element. -- windowbg holds the backround image, to which the required alpha is applied self.gui['windowbg'] = guiCreateStaticImage(100, 100, sizeX, sizeY, 'img/timepassedbg.png', false, nil) guiSetAlpha(self.gui['windowbg'], 0.4) guiSetVisible( self.gui['windowbg'], false ) -- windowbg as parent: self.gui['container'] = guiCreateStaticImage(0,0.1,1,1, 'img/blank.png', true, self.gui['windowbg']) guiSetProperty ( self.gui['container'], 'InheritsAlpha', 'false' ) -- container as parent: self.gui['bar'] = guiCreateStaticImage(0, 0, sizeX, 18, 'img/timepassedbg.png', false, self.gui['container']) guiSetAlpha(self.gui['bar'], 0.4) self.gui['title0'] = guiCreateLabel(0, 0, sizeX, 30, '-tbb- Hunter Times', false, self.gui['windowbg'] ) guiLabelSetHorizontalAlign ( self.gui['title0'], 'center' ) guiSetFont(self.gui['title0'], 'default-bold-small') guiLabelSetColor ( self.gui['title0'],128,255,0) self.gui['title'] = guiCreateLabel(0, 1, sizeX, 30, '', false, self.gui['container'] ) guiLabelSetHorizontalAlign ( self.gui['title'], 'center' ) guiSetFont(self.gui['title'], 'default-bold-small') guiLabelSetColor ( self.gui['title'], 255, 255, 255, 255 ) self.gui['header'] = guiCreateLabel(19, 21, sizeX-30, 15, 'Pos Time Name', false, self.gui['container'] ) guiSetFont(self.gui['header'], 'default-small') guiLabelSetColor ( self.gui['header'], 128,255,0 ) self.gui['headerul'] = guiCreateLabel(0, 21, sizeX, 15, string.rep('_', 38), false, self.gui['container'] ) guiLabelSetHorizontalAlign ( self.gui['headerul'], 'center' ) guiLabelSetColor ( self.gui['headerul'], 128,255,0 ) self.gui['paneLoading'] = guiCreateStaticImage(0,0,1,1, 'img/blank.png', true, self.gui['container']) -- paneLoading as parent: self.gui['busy'] = guiCreateLabel(sizeX/4, 38, sizeX/2, 15, 'Waiting ..', false, self.gui['paneLoading'] ) self.gui['busy2'] = guiCreateLabel(sizeX/4, 53, sizeX/2, 15, 'until next map', false, self.gui['paneLoading'] ) guiLabelSetHorizontalAlign ( self.gui['busy'], 'center' ) guiLabelSetHorizontalAlign ( self.gui['busy2'], 'center' ) guiSetFont(self.gui['busy'], 'default-bold-small') guiSetFont(self.gui['busy2'], 'default-bold-small') self.gui['paneTimes'] = guiCreateStaticImage(0,0,1,1, 'img/blank.png', true, self.gui['container']) -- paneTimes as parent: -- All the labels in the time list self.gui['listTimes'] = {} self:updateLabelCount(12) end --------------------------------------------------------------------------- -- -- CToptimes:closeWindow() -- -- -- --------------------------------------------------------------------------- function CToptimes:closeWindow () destroyElement( self.gui['windowbg'] ) self.gui = {} end --------------------------------------------------------------------------- -- -- CToptimes:setWindowPosition() -- -- -- --------------------------------------------------------------------------- function CToptimes:setWindowPosition ( gui_x, gui_y ) if self.gui['windowbg'] then local screenWidth, screenHeight = guiGetScreenSize() local posX = screenWidth/2 + 63 + ( screenWidth * (gui_x - 0.56) ) local posY = 14 + ( screenHeight * (gui_y - 0.02) ) local posXCurve = { {0, 0}, {0.7, screenWidth/2 + 63}, {1, screenWidth - self.size.x} } local posYCurve = { {0, 0}, {0.02, 14}, {1, screenHeight - self.size.y} } -- 1280 0-1000 -- 0.0 = 1280/2 - 140 = 0 -- 0.5 = 1280/2 - 140 = 500 -- 0.7 = 1280/2 - 140 = 500 = 703
Recommended Posts