Jump to content

I want to Know how To


Recommended Posts

Watch this Castillo, the image is scripted but when you go in you dont see it wats the problem?

  
local SCOREBOARD_WIDTH              = 420               -- The scoreboard window width
local SCOREBOARD_HEIGHT             = 360               -- The scoreboard window height
local SCOREBOARD_HEADER_HEIGHT      = 25                -- Height for the header in what you can see the server info
local SCOREBOARD_TOGGLE_CONTROL     = "tab"             -- Control/Key to toggle the scoreboard visibility
local SCOREBOARD_PGUP_CONTROL       = "mouse_wheel_up"  -- Control/Key to move one page up
local SCOREBOARD_PGDN_CONTROL       = "mouse_wheel_down"-- Control/Key to move one page down
local SCOREBOARD_DISABLED_CONTROLS  = { "next_weapon",  -- Controls that are disabled when the scoreboard is showing
                                        "previous_weapon",
                                        "aim_weapon",
                                        "radio_next",
                                        "radio_previous" }
local SCOREBOARD_TOGGLE_TIME        = 50                -- Time in miliseconds to make the scoreboard (dis)appear
local SCOREBOARD_POSTGUI        = true              -- Set to true if it must be drawn over the GUI
local SCOREBOARD_INFO_BACKGROUND    = { 255,0,0, 200 }          -- RGBA color for the info header background
local SCOREBOARD_SERVER_NAME_COLOR  = { 0, 255,50, 160 }        -- RGBA color for the server name text
local SCOREBOARD_PLAYERCOUNT_COLOR  = { 255, 255,50, 160 }  -- RGBA color for the server player count text
local SCOREBOARD_BACKGROUND     = { 0,0,0, 200}         -- RGBA color for the background
local SCOREBOARD_BACKGROUND_IMAGE   = { 255, 255, 255, 0 }      -- RGBA color for the background image
local SCOREBOARD_HEADERS_COLOR  =   { 0, 0, 0, 255 }          -- RGBA color for the headers
local SCOREBOARD_SEPARATOR_COLOR    = { 82, 82, 82, 140 }       -- RGBA color for the separator line between headers and body content
local SCOREBOARD_SCROLL_BACKGROUND  = { 0, 10, 20, 0 }      -- RGBA color for the scroll background
local SCOREBOARD_SCROLL_FOREGROUND  = { 15, 177, 253, 0 }       -- RGBA color for the scroll foreground
local SCOREBOARD_SCROLL_HEIGHT  = 40                        -- Size for the scroll marker
local SCOREBOARD_COLUMNS_WIDTH  = { 0.08, 0.74, 0.14, 0.04 }    -- Relative width for each column: id, player name, ping and scroll position
local SCOREBOARD_ROW_GAP        = 0                         -- Gap between rows     = 0                         -- Gap between rows
 
 
 
 
--[[ Global variables to this context ]]--
local g_isShowing = false       -- Marks if the scoreboard is showing
local g_currentWidth = 0        -- Current window width. Used for the fade in/out effect.
local g_currentHeight = 0       -- Current window height. Used for the fade in/out effect.
local g_scoreboardDummy         -- Will contain the scoreboard dummy element to gather info from.
local g_windowSize = { guiGetScreenSize () }    -- The window size
local g_localPlayer = getLocalPlayer ()         -- The local player...
local g_currentPage = 0         -- The current scroll page
local g_players                 -- We will keep a cache of the conected player list
local g_oldControlStates        -- To save the old control states before disabling them for scrolling
 
--[[ Pre-calculate some stuff ]]--
-- Scoreboard position
local SCOREBOARD_X = math.floor ( ( g_windowSize[1] - SCOREBOARD_WIDTH ) / 2 )
local SCOREBOARD_Y = math.floor ( ( g_windowSize[2] - SCOREBOARD_HEIGHT ) / 2 )
-- Scoreboard colors
SCOREBOARD_INFO_BACKGROUND = tocolor ( unpack ( SCOREBOARD_INFO_BACKGROUND ) )
SCOREBOARD_SERVER_NAME_COLOR = tocolor ( unpack ( SCOREBOARD_SERVER_NAME_COLOR ) )
SCOREBOARD_PLAYERCOUNT_COLOR = tocolor ( unpack ( SCOREBOARD_PLAYERCOUNT_COLOR ) )
SCOREBOARD_BACKGROUND = tocolor ( unpack ( SCOREBOARD_BACKGROUND ) )
SCOREBOARD_BACKGROUND_IMAGE = tocolor ( unpack ( SCOREBOARD_BACKGROUND_IMAGE ) )
SCOREBOARD_HEADERS_COLOR = tocolor ( unpack ( SCOREBOARD_HEADERS_COLOR ) )
SCOREBOARD_SCROLL_BACKGROUND = tocolor ( unpack ( SCOREBOARD_SCROLL_BACKGROUND ) )
SCOREBOARD_SCROLL_FOREGROUND = tocolor ( unpack ( SCOREBOARD_SCROLL_FOREGROUND ) )
SCOREBOARD_SEPARATOR_COLOR = tocolor ( unpack ( SCOREBOARD_SEPARATOR_COLOR ) )
-- Columns width in absolute units
for k=1,#SCOREBOARD_COLUMNS_WIDTH do
    SCOREBOARD_COLUMNS_WIDTH[k] = math.floor ( SCOREBOARD_COLUMNS_WIDTH[k] * SCOREBOARD_WIDTH )
end
-- Pre-calculate each row horizontal bounding box.
local rowsBoundingBox = { { SCOREBOARD_X, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 } }
-- ID
rowsBoundingBox[1][2] = SCOREBOARD_X + SCOREBOARD_COLUMNS_WIDTH[1]
-- Name
rowsBoundingBox[2][1] = rowsBoundingBox[1][2]
rowsBoundingBox[2][2] = rowsBoundingBox[2][1] + SCOREBOARD_COLUMNS_WIDTH[2]
-- Ping
rowsBoundingBox[3][1] = rowsBoundingBox[2][2]
rowsBoundingBox[3][2] = rowsBoundingBox[3][1] + SCOREBOARD_COLUMNS_WIDTH[3]
-- Scrollbar
rowsBoundingBox[4][1] = rowsBoundingBox[3][2]
rowsBoundingBox[4][2] = SCOREBOARD_X + SCOREBOARD_WIDTH
 
 
--[[ Pre-declare some functions ]]--
local onRender
local fadeScoreboard
local drawBackground
local drawScoreboard
 
 
--[[
* clamp
Clamps a value into a range.
--]]
local function clamp ( valueMin, current, valueMax )
    if current < valueMin then
        return valueMin
    elseif current > valueMax then
        return valueMax
    else
        return current
    end
end
 
--[[
* createPlayerCache
Generates a new player cache.
--]]
local function createPlayerCache ( ignorePlayer )
    -- Optimize the function in case of not having to ignore a player
    if ignorePlayer then
        -- Clear the gloal table
        g_players = {}
       
        -- Get the list of connected players
        local players = getElementsByType ( "player" )
   
        -- Dump them to the global table
        for k, player in ipairs(players) do
            if ignorePlayer ~= player then
                table.insert ( g_players, player )
            end
        end
    else
        g_players = getElementsByType ( "player" )
    end
   
    --[[ Uncomment to test with dummies ]]--
    --[[
    for k,v in ipairs(getElementsByType("playerDummy")) do
        table.insert(g_players, v)
    end
    --]]
   
    -- Sort the player list by their ID, giving priority to the local player
    table.sort ( g_players, function ( a, b )
        local idA = getElementData ( a, "playerid" ) or 0
        local idB = getElementData ( b, "playerid" ) or 0
 
        -- Perform the checks to always set the local player at the beggining
        if a == g_localPlayer then
            idA = -1
        elseif b == g_localPlayer then
            idB = -1
        end
       
        return tonumber(idA) < tonumber(idB)
    end )
end
 
--[[
* onClientResourceStart
Handles the resource start event to create the initial player cache
--]]
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), function ()
    createPlayerCache ()
end, false )
 
--[[
* onClientElementDataChange
Handles the element data changes event to update the player cache
if the playerid was changed.
--]]
addEventHandler ( "onClientElementDataChange", root, function ( dataName, dataValue )
    if dataName == "playerid" then
        createPlayerCache ()
    end
end )
 
--[[
* onClientPlayerQuit
Handles the player quit event to update the player cache.
--]]
addEventHandler ( "onClientPlayerQuit", root, function ()
    createPlayerCache ( source )
end )
 
--[[
* toggleScoreboard
Toggles the visibility of the scoreboard.
--]]
local function toggleScoreboard ( show )
    -- Force the parameter to be a boolean
    local show = show == true
   
    -- Check if the status has changed
    if show ~= g_isShowing then
        g_isShowing = show
       
        if g_isShowing and g_currentWidth == 0 and g_currentHeight == 0 then
            -- Handle the onClientRender event to start drawing the scoreboard.
            addEventHandler ( "onClientPreRender", root, onRender, false )
        end
       
        -- Little hack to avoid switching weapons while moving through the scoreboard pages.
        if g_isShowing then
            g_oldControlStates = {}
            for k, control in ipairs ( SCOREBOARD_DISABLED_CONTROLS ) do
                g_oldControlStates[k] = isControlEnabled ( control )
                toggleControl ( control, false )
            end
        else
            for k, control in ipairs ( SCOREBOARD_DISABLED_CONTROLS ) do
                toggleControl ( control, g_oldControlStates[k] )
            end
            g_oldControlStates = nil
        end
    end
end
 
--[[
* onToggleKey
Function to bind to the appropiate key the function to toggle the scoreboard visibility.
--]]
local function onToggleKey ( key, keyState )
    -- Check if the scoreboard element has been created
    if not g_scoreboardDummy then
        local elementTable = getElementsByType ( "scoreboard" )
        if #elementTable > 0 then
            g_scoreboardDummy = elementTable[1]
        else
            return
        end
    end
   
    -- Toggle the scoreboard, and check that it's allowed.
    toggleScoreboard ( keyState == "down" and getElementData ( g_scoreboardDummy, "allow" ) )
end
bindKey ( SCOREBOARD_TOGGLE_CONTROL, "both", onToggleKey )
 
--[[
* onScrollKey
Function to bind to the appropiate key the function to change the current page.
--]]
local function onScrollKey ( direction )
    if g_isShowing then
        if direction then
            g_currentPage = g_currentPage + 1
        else
            g_currentPage = g_currentPage - 1
            if g_currentPage < 0 then
                g_currentPage = 0
            end
        end
    end
end
bindKey ( SCOREBOARD_PGUP_CONTROL, "down", function () onScrollKey ( false ) end )
bindKey ( SCOREBOARD_PGDN_CONTROL, "down", function () onScrollKey ( true ) end )
 
--[[
* onRender
Event handler for onClientPreRender. It will forward the flow to the most appropiate
function: fading-in, fading-out or drawScoreboard.
--]]
onRender = function ( timeshift )
    -- Boolean to check if we must draw the scoreboard.
    local drawIt = false
   
    if g_isShowing then
        -- Check if the scoreboard has been disallowed
        if not getElementData ( g_scoreboardDummy, "allow" ) then
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...