bartje01 Posted February 19, 2013 Share Posted February 19, 2013 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 comment
Sparrow Posted February 19, 2013 Share Posted February 19, 2013 you forgot: local screenHeight, screenWidth = guiGetScreenSize() Link to comment
Castillo Posted February 19, 2013 Share Posted February 19, 2013 That's obviously a server side script, and dxDrawText is a client side only function. Link to comment
bartje01 Posted February 19, 2013 Author Share Posted February 19, 2013 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 ? Link to comment
Castillo Posted February 19, 2013 Share Posted February 19, 2013 All dx drawing functions require onClientRender event in order to work. Link to comment
bartje01 Posted February 19, 2013 Author Share Posted February 19, 2013 Hmm. I don't really know what to do with that. Could you show me how to? Link to comment
Castillo Posted February 20, 2013 Share Posted February 20, 2013 -- 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 comment
bartje01 Posted February 20, 2013 Author Share Posted February 20, 2013 It still has no effect :l No errors and also no draw in my screen Link to comment
Castillo Posted February 20, 2013 Share Posted February 20, 2013 Should work, ur sure that there's no errors? Link to comment
Castillo Posted February 20, 2013 Share Posted February 20, 2013 The position of the text must be wrong, because I just tested it and the function is working, it's drawing it, but not where you can see it. Link to comment
bartje01 Posted February 20, 2013 Author Share Posted February 20, 2013 I put this below the draw line in the client sided file: outputConsole ( "Public console message" ) Even that doesnt show up in the console Link to comment
Castillo Posted February 21, 2013 Share Posted February 21, 2013 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 comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now