Jump to content

toptime deleting error


bartje01

Recommended Posts

Hey guys. I 'm trying to show my deleting toptimes script showing up in a dxdrawtext instead of a simple output.

I have this:

  
addCommandHandler( "deletetime", 
    function( player, cmd, place ) 
          
          
        if deleteTimeOnline == false then return outputChatBox("#33ccffDeleting toptimes disabled by default",player,255,255,255,true) end 
        if not _TESTING and not isPlayerInACLGroup(player, g_Settings.admingroup) then 
            return 
        end 
        if g_SToptimesManager and g_SToptimesManager.mapTimes then 
            local row = g_SToptimesManager.mapTimes:deletetime(place) 
            if row then 
                g_SToptimesManager:updateTopText() 
                local mapName = tostring(g_SToptimesManager.mapTimes.mapName) 
                local placeText = place and " #" .. tostring(place) or "" 
                dxDrawText ( mapName, 44, screenHeight - 43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "deleting" ) 
                outputServerLog( "INFO: Top time"..placeText.." from '" ..tostring(row.playerName).. "' (" ..tostring(row.timeText).. " in " ..mapName.. ") deleted by " .. getAdminNameForLog(player) ) 
            end 
        end 
    end 
  
) 
  

And this errors:

  
[2013-02-19 13:55:49] ERROR: unzipped\race_toptimes\toptimes_server.lua:398: attempt to perform arithmetic on global 'screenHeight' (a nil value) 
[2013-02-19 13:55:59] ERROR: unzipped\race_toptimes\toptimes_server.lua:398: attempt to perform arithmetic on global 'screenHeight' (a nil value) 
  

Could anyone please help me?

Link to post

Okay, I've got this now:

server side:

  
addCommandHandler( "deletetime", 
    function( player, cmd, place ) 
          
         
        if deleteTimeOnline == false then return outputChatBox("#33ccffDeleting toptimes disabled by default",player,255,255,255,true) end 
        if not _TESTING and not isPlayerInACLGroup(player, g_Settings.admingroup) then 
            return 
        end 
        if g_SToptimesManager and g_SToptimesManager.mapTimes then 
            local row = g_SToptimesManager.mapTimes:deletetime(place) 
            if row then 
                g_SToptimesManager:updateTopText() 
                local mapName = tostring(g_SToptimesManager.mapTimes.mapName) 
                local placeText = place and " #" .. tostring(place) or "" 
                triggerClientEvent ( "onDeleting", getRootElement(), "Hello World!" ) 
                outputServerLog( "INFO: Top time"..placeText.." from '" ..tostring(row.playerName).. "' (" ..tostring(row.timeText).. " in " ..mapName.. ") deleted by " .. getAdminNameForLog(player) ) 
            end 
        end 
    end 
  
) 
  

client side:

  
function deleteTimeHandler (mapName,placeText) 
local screenHeight, screenWidth = guiGetScreenSize() 
local mapName = tostring(g_SToptimesManager.mapTimes.mapName) 
local placeText = place and " #" .. tostring(place) or "" 
dxDrawText ( mapName, 44, screenHeight - 43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "deleting" ) 
  
end 
  
addEvent( "onDeleting", true ) 
addEventHandler( "onDeleting", getRootElement(), deleteTimeHandler ) 
  

How much did I fuck up here :P ?

Link to post

-- client side:

local mapName, placeText 
local screenHeight, screenWidth = guiGetScreenSize ( ) 
  
function deleteTimeHandler ( map, place ) 
    removeEventHandler ( "onClientRender", root, renderText ) 
    mapName, placeText = map, place 
    addEventHandler ( "onClientRender", root, renderText ) 
end 
addEvent ( "onDeleting", true ) 
addEventHandler ( "onDeleting", getRootElement(), deleteTimeHandler ) 
  
function renderText ( ) 
    dxDrawText ( mapName, 44, screenHeight - 43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "default" ) 
end 

-- server side:

addCommandHandler( "deletetime", 
    function( player, cmd, place )  
        if deleteTimeOnline == false then return outputChatBox("#33ccffDeleting toptimes disabled by default",player,255,255,255,true) end 
        if not _TESTING and not isPlayerInACLGroup(player, g_Settings.admingroup) then 
            return 
        end 
  
        if g_SToptimesManager and g_SToptimesManager.mapTimes then 
            local row = g_SToptimesManager.mapTimes:deletetime(place) 
            if row then 
                g_SToptimesManager:updateTopText() 
                local mapName = tostring(g_SToptimesManager.mapTimes.mapName) 
                local placeText = place and " #" .. tostring(place) or "" 
                triggerClientEvent ( "onDeleting", getRootElement(), mapName, placeText ) 
                outputServerLog( "INFO: Top time"..placeText.." from '" ..tostring(row.playerName).. "' (" ..tostring(row.timeText).. " in " ..mapName.. ") deleted by " .. getAdminNameForLog(player) ) 
            end 
        end 
    end 
) 

Try it.

Link to post

I did this and it started spamming the chat box:

local mapName, placeText 
local screenHeight, screenWidth = guiGetScreenSize ( ) 
  
function deleteTimeHandler ( map, place ) 
    removeEventHandler ( "onClientRender", root, renderText ) 
    mapName, placeText = map, place 
    addEventHandler ( "onClientRender", root, renderText ) 
end 
addEvent ( "onDeleting", true ) 
addEventHandler ( "onDeleting", getRootElement(), deleteTimeHandler ) 
  
function renderText ( ) 
outputChatBox ( "RENDERING" ) 
    dxDrawText ( mapName, 44, screenHeight - 43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "default" ) 
end 

Link to post

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