Jump to content

Annoying message in debugscript


Mossy

Recommended Posts

  
spfont = dxCreateFont("fonts/font.ttf", 21) 
  
function speed ( ) 
    addEventHandler ( "onClientRender", root, getspeed ) 
end 
addEventHandler ("onClientVehicleEnter", root, speed) 
  
function wylacz ( ) 
  
    removeEventHandler ( "onClientRender", root, getspeed ) 
end 
addEventHandler("onClientVehicleExit", root, wylacz) 
  
function getspeed ( ) 
    if isPedInVehicle (localPlayer) == false then return end 
    sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) 
    kmhs = math.floor(((sx^2 + sy^2 + sz^2)^(0.5))*180) 
    mphs = math.floor((((sx^2 + sy^2 + sz^2)^(0.5))*180)/1.6) 
    health = getElementHealth (getPedOccupiedVehicle(localPlayer)) 
    name = getVehicleName (getPedOccupiedVehicle(localPlayer)) 
    currenthealth = math.floor(health/10) 
    screenWidth, screenHeight = guiGetScreenSize() 
    windowWidth, windowHeight = 300,170 
    left = screenWidth/1.15 - windowWidth/9.8 
    top = screenHeight/1.15 - windowHeight/20 
    dxDrawText ( " "..tostring(name).." ", left ,  top -93, screenWidth +2, screenHeight , tocolor ( 0, 0, 0, 255 ), 1, spfont ) 
    dxDrawText ( " "..tostring(name).." ", left -2,  top -95, screenWidth, screenHeight -2, tocolor ( 0, 255, 0, 255 ), 1, spfont ) 
    dxDrawText ( " "..tostring(currenthealth).."%", left ,  top -63, screenWidth +2, screenHeight , tocolor ( 0, 0, 0, 255 ), 1, spfont ) 
    dxDrawText ( " "..tostring(currenthealth).."#00FF00%", left -2,  top -65, screenWidth, screenHeight -2, tocolor ( 255, 12, 0, 255 ), 1, spfont, "left", "top", false, false, false, true  ) 
    dxDrawText ( " ___________________", left -2,  top -62, screenWidth, screenHeight -2, tocolor ( 255, 0, 0, 255 ), 1, spfont ) 
    dxDrawText ( " ___________________", left -2,  top -60, screenWidth, screenHeight -2, tocolor ( 0, 0, 0, 255 ), 1, spfont ) 
    dxDrawText ( " "..tostring(mphs).."mph", left ,  top +2, screenWidth +2, screenHeight , tocolor ( 0, 0, 0, 255 ), 1, spfont ) 
    dxDrawText ( " "..tostring(mphs).."#00FF00mph", left -2,  top, screenWidth, screenHeight -2, tocolor ( 0, 255, 255, 255 ), 1, spfont, "left", "top", false, false, false, true ) 
    dxDrawText ( " "..tostring(kmhs).."km/h", left ,  top -23, screenWidth +2, screenHeight , tocolor ( 0, 0, 0, 255 ), 1, spfont ) 
    dxDrawText ( " "..tostring(kmhs).."#00FF00km/h", left -2,  top -25, screenWidth, screenHeight -2, tocolor ( 0, 255, 255, 255 ), 1, spfont, "left", "top", false, false, false, true ) 
end 
  
  

Message I get: bspeedometer\speedo.lua:5: addEventHandler" 'onClientRender' with this function is already handled

Link to comment

Try This:

spfont = dxCreateFont("fonts/font.ttf", 21) 
clientRendering = false 
  
function speed ( ) 
    clientRendering = true 
end 
addEventHandler ("onClientVehicleEnter", root, speed) 
  
function wylacz ( ) 
    clientRendering = false 
end 
addEventHandler("onClientVehicleExit", root, wylacz) 
  
function getspeed ( ) 
    if (clientRendering == true) then 
        if isPedInVehicle (localPlayer) == false then return end 
        sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) 
        kmhs = math.floor(((sx^2 + sy^2 + sz^2)^(0.5))*180) 
        mphs = math.floor((((sx^2 + sy^2 + sz^2)^(0.5))*180)/1.6) 
        health = getElementHealth (getPedOccupiedVehicle(localPlayer)) 
        name = getVehicleName (getPedOccupiedVehicle(localPlayer)) 
        currenthealth = math.floor(health/10) 
        screenWidth, screenHeight = guiGetScreenSize() 
        windowWidth, windowHeight = 300,170 
        left = screenWidth/1.15 - windowWidth/9.8 
        top = screenHeight/1.15 - windowHeight/20 
        dxDrawText ( " "..tostring(name).." ", left ,  top -93, screenWidth +2, screenHeight , tocolor ( 0, 0, 0, 255 ), 1, spfont ) 
        dxDrawText ( " "..tostring(name).." ", left -2,  top -95, screenWidth, screenHeight -2, tocolor ( 0, 255, 0, 255 ), 1, spfont ) 
        dxDrawText ( " "..tostring(currenthealth).."%", left ,  top -63, screenWidth +2, screenHeight , tocolor ( 0, 0, 0, 255 ), 1, spfont ) 
        dxDrawText ( " "..tostring(currenthealth).."#00FF00%", left -2,  top -65, screenWidth, screenHeight -2, tocolor ( 255, 12, 0, 255 ), 1, spfont, "left", "top", false, false, false, true  ) 
        dxDrawText ( " ___________________", left -2,  top -62, screenWidth, screenHeight -2, tocolor ( 255, 0, 0, 255 ), 1, spfont ) 
        dxDrawText ( " ___________________", left -2,  top -60, screenWidth, screenHeight -2, tocolor ( 0, 0, 0, 255 ), 1, spfont ) 
        dxDrawText ( " "..tostring(mphs).."mph", left ,  top +2, screenWidth +2, screenHeight , tocolor ( 0, 0, 0, 255 ), 1, spfont ) 
        dxDrawText ( " "..tostring(mphs).."#00FF00mph", left -2,  top, screenWidth, screenHeight -2, tocolor ( 0, 255, 255, 255 ), 1, spfont, "left", "top", false, false, false, true ) 
        dxDrawText ( " "..tostring(kmhs).."km/h", left ,  top -23, screenWidth +2, screenHeight , tocolor ( 0, 0, 0, 255 ), 1, spfont ) 
        dxDrawText ( " "..tostring(kmhs).."#00FF00km/h", left -2,  top -25, screenWidth, screenHeight -2, tocolor ( 0, 255, 255, 255 ), 1, spfont, "left", "top", false, false, false, true ) 
    end 
end 
addEventHandler ( "onClientRender", root, getspeed ) 

Link to comment
Try This:

Worked, thanks!

And if you mind, can you do the same thing for one more script that has the same problem?

local SCREEN_WIDTH, SCREEN_HEIGHT = guiGetScreenSize() 
  
local name, author, lastTimePlayed, spawnPointCount, playedCount, modename 
local startTick 
  
local enabled = false 
  
local month = {"January","February","March","April","May","June","July","August","September","October","November","December"} 
  
function timestampToDate(stamp) 
    local time = getRealTime(stamp) 
    return string.format("%d %s %02d:%02d",time.monthday,month[time.month+1],time.hour,time.minute) 
end 
  
function handleMapInfo(mapInfo) 
    name            = mapInfo.name or "Unknown" 
      author          = mapInfo.author or "N/A" 
    playedCount     = tostring(mapInfo.playedCount or "N/A") 
  
outputChatBox("#FFFFFF[iNFO] #00FF00Map Name: #FFFFFF"..name,255,255,255,true) 
outputChatBox("#FFFFFF[iNFO] #00FF00Map Author: #FFFFFF"..author,255,255,255,true) 
  
    startTick = getTickCount() 
     
    if not enabled then 
        addEventHandler("onClientRender",getRootElement(),handleOnRender) 
        enabled = true 
    end 
end 
addEvent("onClientMapStarting",true) 
addEventHandler("onClientMapStarting",getRootElement(),handleMapInfo) 
  
  
local g_Root = getRootElement() 
local g_ResRoot = getResourceRootElement(getThisResource()) 
local screenWidth, screenHeight = guiGetScreenSize() -- Get the screen resolution 
  
local c_Font = "pricedown" 
local c_FontScale =0.90 
local yo 
  
local mapName 
  
addEvent("onSendMapName", true) 
addEventHandler("onSendMapName", g_ResRoot, 
    function(name) 
        mapName = name 
    end 
) 
  
addEventHandler("onClientResourceStart", g_ResRoot,  
    function() 
        yo = dxGetFontHeight(c_FontScale, c_Font) 
        triggerServerEvent("onRequestMapName", g_ResRoot) 
    end 
) 
  
addEventHandler("onClientRender", g_Root,  
    function() 
        if mapName then 
            dxDrawText("Current Map: '" .. mapName .."'", 5, screenHeight-yo-2, screenWidth, screenHeight, tocolor(0, 255, 0, 255), c_FontScale, c_Font) 
        end 
    end 
) 
  

Line 26.

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