Jump to content

Help :) [Resolved]


MrXz

Recommended Posts

I have this script that have the spectators, FPS ,map and nextmap but I get error ..

where the error? ... help me :)

--FPS 
local root = getRootElement() 
local player = getLocalPlayer() 
local counter = 0 
local starttick 
local currenttick 
addEventHandler("onClientRender",root, 
    function() 
        if not starttick then 
            starttick = getTickCount() 
        end 
        counter = counter + 1 
        currenttick = getTickCount() 
        if currenttick - starttick >= 1000 then 
            setElementData(player,"fps",counter) 
            counter = 0 
            starttick = false 
        end 
    end 
) 
-----------------Spectators 
local player = getLocalPlayer() 
local root = getRootElement () 
local Spectators = {} 
setElementData ( player, "Spectator", "" ) 
local scrX, scrY = guiGetScreenSize() 
------------------ 
function start () 
    setTimer ( checkTarget, 1000, 0 ) 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(), start ) 
------------------ 
function checkTarget ( ) 
local target = getCameraTarget () 
local car = getPedOccupiedVehicle ( player ) 
    if not ( car ) then 
        car = "noCar" 
    end 
    if ( target ) then 
        setElementData ( player, "Spectator", target ) 
    else 
        setElementData ( player, "Spectator", "" ) 
    end 
    Spectators = {} 
    for i,v in ipairs( getElementsByType ( "player" ) ) do 
        if ( v ~= player ) then 
            local vTarget = getElementData ( v, "Spectator" ) 
            if ( vTarget == car ) then 
                table.insert(Spectators,v) 
            end 
        end 
    end 
end 
------------------ 
  
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font) 
  local pat = "(.-)#(%x%x%x%x%x%x)" 
  local s, e, cap, col = str:find(pat, 1) 
  local last = 1 
  while s do 
    if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end 
    if s ~= 1 or cap ~= "" then 
      local w = dxGetTextWidth(cap, scale, font) 
      dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) 
      ax = ax + w 
      color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) 
    end 
    last = e + 1 
    s, e, cap, col = str:find(pat, last) 
  end 
  if last <= #str then 
    cap = str:sub(last) 
    local w = dxGetTextWidth(cap, scale, font) 
    dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) 
  end 
end 
  
function math.round(number, decimals, method) 
    decimals = decimals or 0 
    local factor = 10 ^ decimals 
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor 
    else return tonumber(("%."..decimals.."f"):format(number)) end 
end 
g_Root = getRootElement() 
g_ResRoot = getResourceRootElement(getThisResource()) 
g_Me = getLocalPlayer() 
g_ArmedVehicleIDs = table.create({ 425, 447, 520, 430, 464, 432 }, true) 
g_WaterCraftIDs = table.create({ 539, 460, 417, 447, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454 }, true) 
g_ModelForPickupType = { nitro = 2221, repair = 2222, vehiclechange = 2223 } 
g_HunterID = 425 
g_NextMap = "Random" 
g_Checkpoints = {} 
g_Pickups = {} 
g_VisiblePickups = {} 
g_Objects = {} 
function setNextMap ( mapname ) 
g_NextMap = mapname 
end 
addEvent ( "setNextMap", true ) 
addEventHandler ( "setNextMap", getRootElement(), setNextMap ) 
function math.round(number, decimals, method) 
    decimals = decimals or 0 
    local factor = 10 ^ decimals 
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor 
    else return tonumber(("%."..decimals.."f"):format(number)) end 
end 
  
function setNextNil ( dis ) 
g_NextMap = "Random" 
end 
addEvent ( "setNextNil", true ) 
addEventHandler ( "setNextNil", getRootElement(), setNextNil ) 
function hudSet () 
local screenWidth, screenHeight = guiGetScreenSize() 
dxDrawColorText ('Next: ' .. g_NextMap, 2+1, screenHeight - dxGetFontHeight(0.7, 'bankgothic')/2+1, 100+1, 100+1, tocolor ( 0, 0, 0, 255 ), 0.3, 'bankgothic', 0.3, 'left') 
dxDrawColorText ('#FF7300Next: #FFFFFF' .. g_NextMap, 2, screenHeight - dxGetFontHeight(0.7, 'bankgothic')/2, 100, 100, tocolor ( 255, 255, 255, 255 ), 0.3, 'bankgothic', 0.6, 'left') 
if (g_MapInfo) then 
dxDrawColorText ('Map: ' .. g_MapInfo.name, 2+1, screenHeight - dxGetFontHeight(1.2, 'bankgothic')/2+1, 100+1, 100+1, tocolor ( 0, 0, 0, 255 ), 0.3, 'bankgothic', 0.6, 'left') 
dxDrawColorText ('#FF7300Map: #FFFFFF' .. g_MapInfo.name, 2, screenHeight - dxGetFontHeight(1.1, 'bankgothic')/2, 100, 100, tocolor ( 255, 255, 255, 255 ), 0.3, 'bankgothic', 0.6, 'left') 
else 
dxDrawColorText ('Map: N/A', 1.8, screenHeight - dxGetFontHeight(1.2, 'bankgothic')/2.1, 100, 100, tocolor ( 0, 0, 0, 255 ), 0.6, 'bankgothic', 0.3, 'left') 
dxDrawColorText ('#FF7300Map: #FFFFFFRandom', 2+1, screenHeight - dxGetFontHeight(1.2, 'bankgothic')/2+1, 100+1, 100+1, tocolor ( 255, 255, 255, 255 ), 0.3, 'bankgothic', 0.6, 'left') 
end 
dxDrawColorText ('#FF7300Spectators: (#FFFFFF' .. #Spectators .. '#FF7300)', 1.6, screenHeight - dxGetFontHeight(1.6, 'bankgothic')/2+1, 100+1, 100+1, tocolor ( 255, 255, 255, 255 ), 0.3, 'bankgothic', 0.3, 'left') 
end 
if getElementData(getLocalPlayer(),"fps") then 
dxDrawColorText ('#7FFF00FPS: #FFFFFF' .. getElementData(getLocalPlayer(),"fps"), 2, screenHeight - dxGetFontHeight(3.00, 'bankgothic')/2, 100, 100, tocolor ( 255, 255, 255, 255 ), 0.55, 'bankgothic', 0.55, 'left') 
else 
dxDrawColorText ('#7FFF00FPS: #FFFFFF??', 2, screenHeight - dxGetFontHeight(3.00, 'bankgothic')/2, 100, 100, tocolor ( 255, 255, 255, 255 ), 0.55, 'bankgothic', 0.55, 'left') 
end 
end 

Edited by Guest
Link to comment
--FPS 
local player = getLocalPlayer() 
local counter = 0 
local starttick 
local currenttick 
addEventHandler("onClientRender",root, 
    function() 
        if not starttick then 
            starttick = getTickCount() 
        end 
        counter = counter + 1 
        currenttick = getTickCount() 
        if currenttick - starttick >= 1000 then 
            setElementData(player,"fps",counter) 
            counter = 0 
            starttick = false 
        end 
    end 
) 
-----------------Spectators 
local player = getLocalPlayer() 
local root = getRootElement () 
local Spectators = {} 
setElementData ( player, "Spectator", "" ) 
local scrX, scrY = guiGetScreenSize() 
------------------ 
function start () 
    setTimer ( checkTarget, 1000, 0 ) 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(), start ) 
------------------ 
function checkTarget ( ) 
local target = getCameraTarget () 
local car = getPedOccupiedVehicle ( player ) 
    if not ( car ) then 
        car = "noCar" 
    end 
    if ( target ) then 
        setElementData ( player, "Spectator", target ) 
    else 
        setElementData ( player, "Spectator", "" ) 
    end 
    Spectators = {} 
    for i,v in ipairs( getElementsByType ( "player" ) ) do 
        if ( v ~= player ) then 
            local vTarget = getElementData ( v, "Spectator" ) 
            if ( vTarget == car ) then 
                table.insert(Spectators,v) 
            end 
        end 
    end 
end 
------------------ 
  
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font) 
  local pat = "(.-)#(%x%x%x%x%x%x)" 
  local s, e, cap, col = str:find(pat, 1) 
  local last = 1 
  while s do 
    if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end 
    if s ~= 1 or cap ~= "" then 
      local w = dxGetTextWidth(cap, scale, font) 
      dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) 
      ax = ax + w 
      color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) 
    end 
    last = e + 1 
    s, e, cap, col = str:find(pat, last) 
  end 
  if last <= #str then 
    cap = str:sub(last) 
    local w = dxGetTextWidth(cap, scale, font) 
    dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) 
  end 
end 
  
function math.round(number, decimals, method) 
    decimals = decimals or 0 
    local factor = 10 ^ decimals 
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor 
    else return tonumber(("%."..decimals.."f"):format(number)) end 
end 
g_Root = getRootElement() 
g_ResRoot = getResourceRootElement(getThisResource()) 
g_Me = getLocalPlayer() 
g_ArmedVehicleIDs = table.create({ 425, 447, 520, 430, 464, 432 }, true) 
g_WaterCraftIDs = table.create({ 539, 460, 417, 447, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454 }, true) 
g_ModelForPickupType = { nitro = 2221, repair = 2222, vehiclechange = 2223 } 
g_HunterID = 425 
g_NextMap = "Random" 
g_Checkpoints = {} 
g_Pickups = {} 
g_VisiblePickups = {} 
g_Objects = {} 
function setNextMap ( mapname ) 
g_NextMap = mapname 
end 
addEvent ( "setNextMap", true ) 
addEventHandler ( "setNextMap", getRootElement(), setNextMap ) 
function math.round(number, decimals, method) 
    decimals = decimals or 0 
    local factor = 10 ^ decimals 
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor 
    else return tonumber(("%."..decimals.."f"):format(number)) end 
end 
  
function setNextNil ( dis ) 
    g_NextMap = "Random" 
end 
addEvent ( "setNextNil", true ) 
addEventHandler ( "setNextNil", getRootElement(), setNextNil ) 
  
function hudSet () 
local screenWidth, screenHeight = guiGetScreenSize() 
dxDrawColorText ('Next: ' .. g_NextMap, 2+1, screenHeight - dxGetFontHeight(0.7, 'bankgothic')/2+1, 100+1, 100+1, tocolor ( 0, 0, 0, 255 ), 0.3, 'bankgothic', 0.3, 'left') 
dxDrawColorText ('#FF7300Next: #FFFFFF' .. g_NextMap, 2, screenHeight - dxGetFontHeight(0.7, 'bankgothic')/2, 100, 100, tocolor ( 255, 255, 255, 255 ), 0.3, 'bankgothic', 0.6, 'left') 
if (g_MapInfo) then 
    dxDrawColorText ('Map: ' .. g_MapInfo.name, 2+1, screenHeight - dxGetFontHeight(1.2, 'bankgothic')/2+1, 100+1, 100+1, tocolor ( 0, 0, 0, 255 ), 0.3, 'bankgothic', 0.6, 'left') 
    dxDrawColorText ('#FF7300Map: #FFFFFF' .. g_MapInfo.name, 2, screenHeight - dxGetFontHeight(1.1, 'bankgothic')/2, 100, 100, tocolor ( 255, 255, 255, 255 ), 0.3, 'bankgothic', 0.6, 'left') 
else 
    dxDrawColorText ('Map: N/A', 1.8, screenHeight - dxGetFontHeight(1.2, 'bankgothic')/2.1, 100, 100, tocolor ( 0, 0, 0, 255 ), 0.6, 'bankgothic', 0.3, 'left') 
    dxDrawColorText ('#FF7300Map: #FFFFFFRandom', 2+1, screenHeight - dxGetFontHeight(1.2, 'bankgothic')/2+1, 100+1, 100+1, tocolor ( 255, 255, 255, 255 ), 0.3, 'bankgothic', 0.6, 'left') 
end 
dxDrawColorText ('#FF7300Spectators: (#FFFFFF' .. #Spectators .. '#FF7300)', 1.6, screenHeight - dxGetFontHeight(1.6, 'bankgothic')/2+1, 100+1, 100+1, tocolor ( 255, 255, 255, 255 ), 0.3, 'bankgothic', 0.3, 'left') 
if getElementData(getLocalPlayer(),"fps") then 
    dxDrawColorText ('#7FFF00FPS: #FFFFFF' .. getElementData(getLocalPlayer(),"fps"), 2, screenHeight - dxGetFontHeight(3.00, 'bankgothic')/2, 100, 100, tocolor ( 255, 255, 255, 255 ), 0.55, 'bankgothic', 0.55, 'left') 
else 
    dxDrawColorText ('#7FFF00FPS: #FFFFFF??', 2, screenHeight - dxGetFontHeight(3.00, 'bankgothic')/2, 100, 100, tocolor ( 255, 255, 255, 255 ), 0.55, 'bankgothic', 0.55, 'left') 
    end 
end 

To remove scoreboard columns, go to "race/race_server.lua" and search for "addScoreboardColumn", you can either remove the lines or comment them out by putting "--" in front of them.

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