OrbTanT Posted July 18, 2014 Share Posted July 18, 2014 alguém poderia me dizer qual jeito correto de ligar o DxDrawRectangle que estou criando com um território, gostaria de deixa para abrir o DxDrawRectangle quando iniciar o ataque a o território, quando a área fica em Flashing. e se possivel também fechar o DxDrawRectangle quando o tempo acabar. client: addEventHandler("onClientRender", root, function() dxDrawRectangle(60, 320, 250, 175, tocolor(0, 0, 0, 175), true) dxDrawText("Score", 225, 325, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) dxDrawText("Mortes:", 70, 365, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) dxDrawText("Mortes:", 70, 405, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) dxDrawText("TEMPO:", 70, 450, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) end ) function justForTest() end function msToTimeStr( ms ) if not ms then return '' end local s = math.floor( ms / 1000 ) local seconds = tostring( math.fmod( s, 60 ) ) if #seconds == 1 then seconds = '0' .. seconds end local minutes = tostring( math.floor( s / 60 ) ) if #minutes == 1 then minutes = '0' .. minutes end return minutes .. ':' .. seconds end myTimer = setTimer( justForTest, 180*1000, 1 ) addEventHandler( "onClientRender", root, function( ) if isTimer( myTimer ) then remaining, _, _ = getTimerDetails(myTimer) remaining = msToTimeStr( remaining ) if remaining then dxDrawText( remaining, 120, 442, 350, 300, tocolor(255, 255, 255, 255), 1.0, "pricedown", "left", "top", false, false, true, false, false) end end end ) local Bscore = 0 local Wscore = 0 addEventHandler("onClientPlayerWasted", function ( killer ) local kteam = getPlayerTeam(killer) if(getTeamName(kteam) == "Team1") then Wscore = Wscore + 1 elseif(getTeamName(kteam) == "Team2") then Bscore = Bscore + 1 end end ) function onRender() local team = getPlayerTeam(localPlayer) if(getTeamName(team) == "Team1" or getTeamName(team) == "Team2") then dxDrawText("Team1:"..tostring(Bscore), 70, 340, 319, 426, tocolor(255, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("Team2:"..tostring(Wscore), 70, 380, 319, 426, tocolor(0, 255, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) end end addEventHandler("onClientRender", root, onRender) server: local pArea = createRadarArea(1296.236572,2099.944335 ,100,100, 255, 255, 255,255) local pCuboid = createColCuboid(1296.236572,2099.944335 , 10, 197.5, 92, 30 ) addEventHandler("onResourceStart", resourceRoot, function() outputDebugString("Basaball", 3, 0, 255, 0) end ) addEventHandler( 'onColShapeHit', pCuboid, function( player ) if (getPlayerTeam( player )) then local pTeam = getPlayerTeam( player ) local iR, iG, iB = getTeamColor( pTeam ) local rR, gG, bB = getRadarAreaColor( pArea ) if ( iR == rR ) and ( iG == gG ) and ( iB == bB ) then triggerClientEvent(player, 'friendly', player) else setRadarAreaFlashing( pArea, true ) outputChatBox( "#F08080[GANGZONES] #F8F8FFA gang ".. getTeamName(getPlayerTeam(player)).." esta atacando a gang / no GANGZONE #ff0000 Basaball!",getRootElement(),255,255,255,true); triggerClientEvent(player, 'time', player) triggerClientEvent(player, 'countdown', player) pArea1Timer = setTimer( function() setRadarAreaColor (pArea, iR, iG, iB, 999); givePlayerMoney( player, 4000 ); outputChatBox( "#F08080[TERRITORIO]#F8F8FFA gang ".. getTeamName(getPlayerTeam(player)).." dominou A GANGZONE Basaball Da gang / !",getRootElement(),255,255,255,true); setRadarAreaFlashing( pArea, false ) end, 5000, 1 ) end else triggerClientEvent(player, 'group', player) end end ) Link to comment
DNL291 Posted July 23, 2014 Share Posted July 23, 2014 Passei o código para o lado client, assim, as funções que estavam sendo chamadas com triggerClientEvent, precisam serem alteradas para que sejam chamadas diretamente. Client: local pArea = createRadarArea(2163.524169,2031.388061 , 150, 60, 255, 255, 255, 225 ) local pCuboid = createColCuboid (2163.524169,2031.388061 , 10, 197.5, 92, 30 ) local Bscore = 0 local Wscore = 0 function drawRectangleInfo() dxDrawRectangle(60, 320, 250, 175, tocolor(0, 0, 0, 175), true) dxDrawText("Score", 225, 325, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) dxDrawText("Mortes:", 70, 365, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) dxDrawText("Mortes:", 70, 405, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) dxDrawText("TEMPO:", 70, 450, 73, 340, tocolor(255, 255, 255, 255), 1.1, "default", "left", "top", false, false, true, false, false) end addEventHandler( "onClientRender", root, function( ) if pArea1Timer and isTimer( pArea1Timer ) then remaining, _, _ = getTimerDetails(pArea1Timer) remaining = msToTimeStr( remaining ) if remaining then dxDrawText( "Tempo: "..tostring(remaining), 120, 442, 350, 300, tocolor(255, 255, 255, 255), 1.0, "pricedown", "left", "top", false, false, true, false, false) end end end ) addEventHandler( "onClientPlayerWasted", function ( killer ) local kteam = getPlayerTeam(killer) if(getTeamName(kteam) == "Team1") then Wscore = Wscore + 1 elseif(getTeamName(kteam) == "Team2") then Bscore = Bscore + 1 end end ) function onRender() local team = getPlayerTeam(localPlayer) if(getTeamName(team) == "Team1" or getTeamName(team) == "Team2") then dxDrawText("Team1:"..tostring(Bscore), 70, 340, 319, 426, tocolor(255, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("Team2:"..tostring(Wscore), 70, 380, 319, 426, tocolor(0, 255, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) end end addEventHandler("onClientRender", root, onRender) addEventHandler( 'onClientColShapeHit', pCuboid, function( player ) local pTeam = getPlayerTeam(player) if (getElementType(player) == "player" and pTeam) then local iR, iG, iB = getTeamColor( pTeam ) local rR, gG, bB = getRadarAreaColor( pArea ) if ( iR == rR ) and ( iG == gG ) and ( iB == bB ) then --triggerClientEvent(player, 'friendly', player) else setRadarAreaFlashing( pArea, true ) addEventHandler("onClientRender", root, drawDXRectangle) triggerServerEvent( "sendChatBoxMessage", resourceRoot, "#F08080[GANGZONES] #F8F8FFA gang ".. getTeamName(getPlayerTeam(player)).." esta atacando a gang / no GANGZONE #ff0000 Basaball!") --triggerClientEvent(player, 'time', player) --triggerClientEvent(player, 'countdown', player) pArea1Timer = setTimer( function() setRadarAreaColor (pArea, iR, iG, iB, 999); triggerServerEvent( "giveMoney", player, 4000 ) triggerServerEvent( "sendChatBoxMessage", resourceRoot, "#F08080[TERRITORIO]#F8F8FFA gang ".. getTeamName(getPlayerTeam(player)).." dominou A GANGZONE Basaball Da gang / !") setRadarAreaFlashing( pArea, false ) removeEventHandler("onClientRender", root, drawDXRectangle) end, 5000, 1 ) end else --triggerClientEvent(player, 'group', player) end end ) function msToTimeStr( ms ) if not ms then return '' end local s = math.floor( ms / 1000 ) local seconds = tostring( math.fmod( s, 60 ) ) if #seconds == 1 then seconds = '0' .. seconds end local minutes = tostring( math.floor( s / 60 ) ) if #minutes == 1 then minutes = '0' .. minutes end return minutes .. ':' .. seconds end Server: addEvent("sendChatBoxMessage", true) addEvent("giveMoney", true) addEvent( "sendChatBoxMessage", root, function (message) outputChatBox( tostring( message ), root, 255, 255, 255, true ) end ) addEvent( "giveMoney", root, function (player, value) givePlayerMoney( player, tonumber( value ) ) 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