Estevam2d Posted October 7, 2014 Posted October 7, 2014 how can I make a DrawText for a certain time to pass on the screen as a villain is trapped? the time left to get out of jail ?
Anubhav Posted October 7, 2014 Posted October 7, 2014 dxDrawText with a variable which contains ..seconds.." seconds left!"
Estevam2d Posted October 7, 2014 Author Posted October 7, 2014 exact. would send me something or tell me how to do?
Arnold-1 Posted October 7, 2014 Posted October 7, 2014 seconds = 70 setTimer(function () seconds = seconds - 1 if seconds = 0 then removeEventHandler("onClientRender",root, drawing) end end ,1 ,seconds) addEventHandler("onClientRender",root, drawing) function drawing() dxDrawText(seconds.." Seconds left", x,y,h,w,--[[put your own dimensions]] ,1) end
Estevam2d Posted October 7, 2014 Author Posted October 7, 2014 I'm trying to call the server side of the draw but is not going addEvent("horariodesaida",true) addEventHandler("horariodesaida",root, function() seconds = 70 setTimer(function () seconds = seconds - 1 if seconds = 0 then removeEventHandler("onClientRender",root, drawing) end end end ,1 ,seconds) addEventHandler("onClientRender",root, drawing) ) function drawing() dxDrawText(seconds.." Seconds left", 198, 158 ,1003, 90, 3,1) end
Arnold-1 Posted October 7, 2014 Posted October 7, 2014 move onClientRender event to the function above it.\ Also you didn't end the function edit: just make it like this: addEvent("horariodesaida",true) addEventHandler("horariodesaida",root, function() seconds = 70 setTimer(function () seconds = seconds - 1 if seconds = 0 then removeEventHandler("onClientRender",root, drawing) end end end ,1 ,seconds) addEventHandler("onClientRender",root, drawing) end ) function drawing() dxDrawText(seconds.." Seconds left", 198, 158 ,1003, 90, 3,1) end
Estevam2d Posted October 7, 2014 Author Posted October 7, 2014 I know not to use dxDrawText can someone help me put a count in jail? I wanted to put a time on the screen when the source is stuck on the side of the server only for a player function policeJob ( attacker, attackerweapon, bodypart, loss ) if attacker and getElementType(attacker) == "player" then theTeam = getPlayerTeam ( attacker ) theWL = getPlayerWantedLevel ( source ) theSkin = getElementModel ( attacker ) if (attackerweapon == 3) and (loss > 2 ) and (theWL > 0) then if getTeamName( theTeam ) == "Policia Militar" or getTeamName( theTeam ) == "R.O.T.A" or getTeamName( theTeam ) == "FBI" or getTeamName( theTeam ) == "Exercito" then if (getPlayerWantedLevel(source) == 1) then if ( attacker ) and ( attacker ~= source ) then local aScore = getElementData(attacker, 'Players Presos') or 0 setElementData(attacker, 'Players Presos', aScore +1) givePlayerMoney(attacker, 1500) setElementPosition (source, 197.73651123047,162.57513427734,1003.0299682617, true) setElementInterior ( source, 3) theName = getPlayerName ( source ) theCop = getPlayerName ( attacker ) triggerClientEvent("horariodesaida", source) outputChatBox ( "Voce foi preso pelo policial "..theCop.. " por 1 minuto, nao tente escapar ou voce ficara bugado.", source ) exports.killmessages:outputMessage("*"..theCop.. " Prendeu o Criminoso " ..theName.." (Com 1 Estrela)", root, 10, 118, 240, true) exports.killmessages:outputMessage("*"..theName.." Voce ficara preso por 1 minuto aguarde sua saida.", source, 255, 15, 15, true) local playeraccount = getPlayerAccount ( attacker ) setPlayerWantedLevel (attacker, 0) setPlayerWantedLevel (source, 0) setTimer ( setElementPosition, 60000, 1, source, 198.60311889648,158.21235656738,1003.0234375) setElementInterior ( source, 3) end end end end end addEventHandler ("onPlayerDamage", getRootElement(), policeJob)
Anubhav Posted October 7, 2014 Posted October 7, 2014 Worked? Where ? Not possible, setTimer with 1? This is not seconds foolishness! addEvent("horariodesaida",true) addEventHandler("horariodesaida",root, function() seconds = 70 setTimer(function () seconds = seconds - 1 if seconds == 0 then removeEventHandler("onClientRender",root, drawing) end end end ,1000 ,seconds) addEventHandler("onClientRender",root, drawing) end ) function drawing() dxDrawText(seconds.." seconds left!", 198, 158 ,1003, 90, 3,1) end
Estevam2d Posted October 7, 2014 Author Posted October 7, 2014 how to create a time on the screen at the server side ?
Anubhav Posted October 7, 2014 Posted October 7, 2014 Not possible.. use text functions, but I don't think I can help you in because I don't know how to use them!
Estevam2d Posted October 8, 2014 Author Posted October 8, 2014 're not decreasing screen time function createText ( ) local seconds = 60 setTimer(function () seconds = seconds - 1 end ,1000 , seconds) local sWidth,sHeight = guiGetScreenSize() local sw,sh = 1280,960 dxDrawText("Saira em:", 500/sw*sWidth, 844/sh*sHeight, 1215/sw*sWidth, 905/sh*sHeight, tocolor(195, 195, 195, 255), 2.30, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("."..seconds.." Segundos", 800/sw*sWidth, 844/sh*sHeight, 1215/sw*sWidth, 905/sh*sHeight, tocolor(195, 195, 195, 255), 2.30, "pricedown", "left", "top", false, false, true, false, false) end function HandleTheRendering ( ) addEventHandler ( "onClientRender", root, createText ) end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", localPlayer, HandleTheRendering )r", root, createText ) end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", localPlayer, HandleTheRendering )
Anubhav Posted October 8, 2014 Posted October 8, 2014 seconds = 60 function createText ( ) setTimer(function () seconds = seconds - 1 end, 1000, seconds) local sWidth,sHeight = guiGetScreenSize() local sw,sh = 1280,960 function createText() dxDrawText("Saira em:", 500/sw*sWidth, 844/sh*sHeight, 1215/sw*sWidth, 905/sh*sHeight, tocolor(195, 195, 195, 255), 2.30, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("."..seconds.." Segundos", 800/sw*sWidth, 844/sh*sHeight, 1215/sw*sWidth, 905/sh*sHeight, tocolor(195, 195, 195, 255), 2.30, "pricedown", "left", "top", false, false, true, false, false) end function HandleTheRendering ( ) addEventHandler ( "onClientRender", root, createText ) end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", localPlayer, HandleTheRendering )
Estevam2d Posted October 8, 2014 Author Posted October 8, 2014 Because the time is negative? time goes very fast.
Anubhav Posted October 8, 2014 Posted October 8, 2014 seconds = 60 function createText ( ) seconds = 60 setTimer(function () seconds = seconds - 1 end, 1000, seconds) local sWidth,sHeight = guiGetScreenSize() local sw,sh = 1280,960 function createText() dxDrawText("Saira em:", 500/sw*sWidth, 844/sh*sHeight, 1215/sw*sWidth, 905/sh*sHeight, tocolor(195, 195, 195, 255), 2.30, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("."..seconds.." Segundos", 800/sw*sWidth, 844/sh*sHeight, 1215/sw*sWidth, 905/sh*sHeight, tocolor(195, 195, 195, 255), 2.30, "pricedown", "left", "top", false, false, true, false, false) end function HandleTheRendering ( ) addEventHandler ( "onClientRender", root, createText ) end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", localPlayer, HandleTheRendering )
</Mr.Tn6eL> Posted October 8, 2014 Posted October 8, 2014 local Count = 0 local Start = getTickCount( ) local sx, sy = guiGetScreenSize( ) function Render( ) local Now = getTickCount( ) if Now >= Start+1000 then if Count == 10 then -- Finish Time removeEventHandler("onClientRender", root, Render) else Count = Count + 1 Start = getTickCount( ) end end dxDrawText(Count, sx/2, sy/2, 0, 0) end addEventHandler("onClientRender", root, Render)
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