Lucario Posted May 21, 2013 Share Posted May 21, 2013 Hi, i really dont know how to put a dx timer in the jail of the police job by stolka when the timer end unjail the guy, im trying to script it more than 1 hour, but dont know what i must use, i use dxdrawtext, and then what? what functions i must use? code of the job by stolka modified but conserve his rights: afText = {} myTextItem = {} function warnText ( aWText, player ) if ( myTextItem[player] ) then textDestroyTextItem ( myTextItem[player]) end afText[player] = textCreateDisplay () textDisplayAddObserver( afText[player], player ) myTextItem[player] = textCreateTextItem ( aWText, 0.22, 0.8,0.5 , 0, 255, 0, 255, 3 ) textDisplayAddText ( afText[player], myTextItem[player] ) -- outputChatBox ( textA, player ) setTimer ( textDestroyTextItem, 5000, 1, myTextItem[player], player ) end createBlip ( 1552.4996337891, -1677.3264160156, 15.1953125, 30 ) createBlip ( -1604.5458984375, 712.25848388672, 12.8671875, 30 ) createBlip ( 2340.9245605469, 2456.0463867188, 13.96875, 30 ) function createSAPDTeam () SAPDteam = createTeam ("Policia", 100, 149, 237) end addEventHandler ("onResourceStart", resourceRoot, createSAPDTeam) function joinSAPD(id) setPlayerTeam(source,SAPDteam) setPlayerNametagColor ( source, 100, 149, 237 ) setElementModel(source, id) giveWeapon ( source, 3 ) playeraccount = getPlayerAccount( source ) setAccountData( playeraccount, "team", "Policia", true ) warnText("Ahora Eres un Policia.",source,0,255,0) end addEvent("getJob", true) addEventHandler("getJob",root,joinSAPD) function removeSAPD() setPlayerTeam(source, Civiles) takeWeapon(source, 3) playeraccount = getPlayerAccount(source) if not getAccountData(playeraccount, "standardskin") then setElementModel(source, 0) else setElementModel(source,getAccountData(playeraccount,"standardskin")) end warnText("Ahora Eres un Civil.",source,0,0,255) end addEvent("removeSAPD", true) addEventHandler("removeSAPD",root,removeSAPD) 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" or getTeamName( theTeam ) == "SWAT" or getTeamName( theTeam ) == "FBI" or getTeamName( theTeam ) == "Ejercito" then setElementPosition (source, 3306.1, 1195.7, 945, true) toggleAllControlls (source, true) theName = getPlayerName ( source ) theCop = getPlayerName ( attacker ) warnText( "Has Sido Encarcelado Por "..theCop.. ".", source ) warnText( "Has Encarcelado a "..theName, attacker ) local playeraccount = getPlayerAccount ( attacker ) local oldArrest = getAccountData(playeraccount, "arrest") local newArrest if oldArrest then newArrest = setAccountData(playeraccount, "arrest", tonumber(oldArrest) + 1 ) else newArrest = setAccountData(playeraccount, "arrest", 1 ) end if theWL == 1 then setTimer ( setElementPosition, 20000, 1, source, 1544.4332275391, -1674.7698974609, 13.688399200439) toggleControl (fire, false) toggleControl (enter_exit, false) toggleControl (jump, false) toggleControl (next_weapon, false) givePlayerMoney (attacker, 3000 * theWL ) setPlayerWantedLevel (source, 0) elseif theWL == 2 then setTimer ( setElementPosition, 40000, 1, source, 1544.4332275391, -1674.7698974609, 13.688399200439) toggleControl (fire, false) toggleControl (enter_exit, false) toggleControl (jump, false) toggleControl (next_weapon, false) givePlayerMoney (attacker, 6000 * theWL ) setPlayerWantedLevel (source, 0) elseif theWL == 3 then setTimer ( setElementPosition, 60000, 1, source, 1544.4332275391, -1674.7698974609, 13.688399200439) toggleControl (fire, false) toggleControl (enter_exit, false) toggleControl (jump, false) toggleControl (next_weapon, false) givePlayerMoney (attacker, 9000 * theWL ) setPlayerWantedLevel (source, 0) elseif theWL == 4 then setTimer ( setElementPosition, 80000, 1, source, 1544.4332275391, -1674.7698974609, 13.688399200439) toggleControl (fire, false) toggleControl (enter_exit, false) toggleControl (jump, false) toggleControl (next_weapon, false) givePlayerMoney (attacker, 12000 * theWL ) setPlayerWantedLevel (source, 0) elseif theWL == 5 then setTimer ( setElementPosition, 100000, 1, source, 1544.4332275391, -1674.7698974609, 13.688399200439) toggleControl (fire, false) toggleControl (enter_exit, false) toggleControl (jump, false) toggleControl (next_weapon, false) givePlayerMoney (attacker, 15000 * theWL ) setPlayerWantedLevel (source, 0) elseif theWL == 6 then -- max level is 6........ setTimer ( setElementPosition, 120000, 1, source, 1544.4332275391, -1674.7698974609, 13.688399200439) toggleControl (fire, false) toggleControl (enter_exit, false) toggleControl (jump, false) toggleControl (next_weapon, false) givePlayerMoney (attacker, 18000 * theWL ) setPlayerWantedLevel (source, 0) end end end end end addEventHandler ("onPlayerDamage", getRootElement(), policeJob) function freezeWeapon (attacker, attackerweapon, bodypart, loss) theTeam = getPlayerTeam ( attacker ) theWL = getPlayerWantedLevel ( source ) if attacker and attacker ~= source and theTeam and getElementType(attacker) == "player" then if (attackerweapon == 23) and (loss > 1) and (theWL > 0) then if getTeamName( theTeam ) == "Policia" or getTeamName( theTeam ) == "SWAT" or getTeamName( theTeam ) == "FBI" or getTeamName( theTeam ) == "Ejercito" then local camera = fadeCamera ( source, true, 2.0, 191, 191, 191 ) local state = setControlState (source, "walk", true) local timer = setTimer ( freezeWeapon, 3000, 1) end end end end end addEventHandler ("onPlayerDamage", getRootElement(), freezeWeapon) function consoleCreateMarker ( source ) local playerAccount = getPlayerAccount(source) local arrest = getAccountData(playeraccount, "arrest") if not arrest then outputChatBox("No Tienes Ningun Arresto",source, 255, 0, 0) else outputChatBox("Numero de Arrestos "..arrest,source, 0, 255, 0) end end addCommandHandler ( "arrestos", consoleCreateMarker ) function stopJailTimer(Player) textDestroyDisplay(TimerDisplay) if TimerText then textDestroyTextItem(TimerText) end if isTimer(timerShitTimer) then killTimer(timerShitTimer) end end --\\\\\\\\\\\\\\\\\\\\\\\\\\ --// Setting local g_screenX, g_screenY = guiGetScreenSize(); local gScale = 0.3; local gAlphaDistance = 25; local gMaxDistance = 50; -- Max Distance local gTextAlpha = 120; local gTextSize = 1; local gAlphaDiff = gMaxDistance - gAlphaDistance; gScale = 1 / gScale * 800 / g_screenY; local gMaxScaleCurve = { { 0, 0 }, { 3, 3 }, { 13, 5 } }; local gTextScaleCurve = { { 0, 0.8 }, { 0.8, 1.2 }, { 99, 99 } }; local gTextAlphaCurve = { { 0, 0 }, { 25, 100 }, { 120, 190 }, { 255, 190 } }; local markerp = createMarker( 1552.4996337891, -1677.3264160156, 15.1953125, 'Cylinder', 1.5, 0, 0, 255, 150 ); local marker1p = createMarker( -1604.5458984375, 712.25848388672, 12.8671875, 'Cylinder', 1.5, 0, 0, 255, 150 ); local marker2p = createMarker( 2340.9245605469, 2456.0463867188, 13.96875, 'Cylinder', 1.5, 0, 0, 255, 150 ); addEventHandler ( 'onClientRender', root, function ( ) -- local x, y, z = getCameraMatrix(); local x1, y1, z1 = getElementPosition ( markerp ); local x2, y2, z2 = getElementPosition ( marker1p ); local x3, y3, z3 = getElementPosition ( marker2p ); local distance_1 = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); local distance_2 = getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ); local distance_3 = getDistanceBetweenPoints3D( x, y, z, x3, y3, z3 ); -- -- Marker #1 if distance_1 <= gMaxDistance then local x1_, y1_ = getScreenFromWorldPosition( x1, y1, z1 + 0.95, 0.06 ); if x1_ and y1_ then -- local scale = 1 / ( gScale * ( distance_1 / gMaxDistance ) ); local alpha = ( ( distance_1 - gAlphaDistance ) / gAlphaDiff ); alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); scale = math.evalCurve( gMaxScaleCurve, scale ); local textscale = math.evalCurve( gTextScaleCurve, scale ); local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); -- dxDrawText( "Trabajo de Policia", x1_, y1_, x1_, y1_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); end -- Marker #2 elseif distance_2 <= gMaxDistance then local x2_, y2_ = getScreenFromWorldPosition( x2, y2, z2 + 0.95, 0.06 ); if x2_ and y2_ then -- local scale = 1 / ( gScale * ( distance_2 / gMaxDistance ) ); local alpha = ( ( distance_2 - gAlphaDistance ) / gAlphaDiff ); alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); scale = math.evalCurve( gMaxScaleCurve, scale ); local textscale = math.evalCurve( gTextScaleCurve, scale ); local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); -- dxDrawText( "Trabajo de Policia", x2_, y2_, x2_, y2_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); end -- Marker #3 elseif distance_3 <= gMaxDistance then local x3_, y3_ = getScreenFromWorldPosition( x3, y3, z3 + 0.95, 0.06 ); if x3_ and y3_ then -- local scale = 1 / ( gScale * ( distance_3 / gMaxDistance ) ); local alpha = ( ( distance_3 - gAlphaDistance ) / gAlphaDiff ); alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); scale = math.evalCurve( gMaxScaleCurve, scale ); local textscale = math.evalCurve( gTextScaleCurve, scale ); local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); -- dxDrawText( "police job", x3_, y3_, x3_, y3_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); end end end ); -- ////////////////////////////////// -- // MATH FUNCTIONS // -- ////////////////////////////////// function math.evalCurve( curve, input ) if input < curve[ 1 ][ 1 ] then return curve[ 1 ][ 2 ]; end for idx = 2, #curve do if input < curve[ idx ][ 1 ] then local x1 = curve[ idx - 1 ][ 1 ]; local y1 = curve[ idx - 1 ][ 2 ]; local x2 = curve[ idx ][ 1 ]; local y2 = curve[ idx ][ 2 ]; local alpha = ( input - x1 ) / ( x2 - x1 ); return math.lerp( y1, y2, alpha ); end end return curve[ #curve ][ 2 ]; end function math.lerp( from, to, alpha ) return from + ( to-from ) * alpha; end Wnd = guiCreateWindow ( 0.2, 0.2, 0.50, 0.60, "Trabajo de Policia Version Beta 2.0", true ) guiSetAlpha( Wnd, 1 ) button = guiCreateButton ( 0.5, 0.8, 0.45, 0.15, "Cerrar", true, Wnd ) button1 = guiCreateButton ( 0.01, 0.8, 0.45, 0.15, "Escoger Trabajo", true, Wnd ) label = guiCreateLabel ( 0.05, 0.1, 0.9, 0.2, "Puedes Arrestar Criminales Dandoles Con la Porra\nSi No la Tienes Se te Dara Una.", true, Wnd ) showCursor(false) guiSetVisible( Wnd, false ) guiWindowSetSizable( Wnd, false ) guiWindowSetMovable( Wnd, false ) skins = { {"Officer 1", 280}, {"Officer 2", 281}, {"Ranger 1", 283}, {"Ranger 2", 288}, {"Traffic officer", 284}, } skinG = guiCreateGridList(0.01, 0.3, 0.99, 0.5, true, Wnd) guiGridListAddColumn(skinG, "Skins", 0.85) for i,skins in ipairs(skins) do row = guiGridListAddRow(skinG) -- guiGridListSetItemText(skinG, row, 1, tostring(skins[1]), false, false) guiGridListSetItemData(skinG, row, 1, tostring(skins[2])) end function SAPDjob(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(Wnd) then guiSetVisible(Wnd, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", markerp, SAPDjob) addEventHandler("onClientMarkerHit", marker1p, SAPDjob) addEventHandler("onClientMarkerHit", marker2p, SAPDjob) function takeJob() local row, col = guiGridListGetSelectedItem(skinG) if (row and col and row ~= -1 and col ~= -1) then local models = tonumber(guiGridListGetItemData(skinG, row, 1)) if model ~= "" then triggerServerEvent("getJob", localPlayer, models) guiSetVisible(Wnd,false) showCursor(false) end end end addEventHandler("onClientGUIClick", button1, takeJob, false) function close() if (source == button) then guiSetVisible(Wnd,false) showCursor(false) end end addEventHandler("onClientGUIClick", button, close) Link to comment
Jacob Lenn Posted May 21, 2013 Share Posted May 21, 2013 What about missiontimer? Start timer, when player leaves save into account data time or into sql player's serial. https://wiki.multitheftauto.com/wiki/Re ... ssiontimer Link to comment
Lucario Posted May 23, 2013 Author Share Posted May 23, 2013 Can i put the timer where i want using the missiontimer? I think it so basic, but still work. Link to comment
Lucario Posted May 23, 2013 Author Share Posted May 23, 2013 can i put the timer in the position of the screen i want? Link to comment
iPrestege Posted May 23, 2013 Share Posted May 23, 2013 What you mean by position on screen with a timer ? We can't understand you please explain more clearly . Link to comment
Lucario Posted May 23, 2013 Author Share Posted May 23, 2013 When a crim got jailed, make a timer with the time in the jail in the screen, when the time end, release the crim, this what i mean Link to comment
iPrestege Posted May 23, 2013 Share Posted May 23, 2013 setTimer dxDrawText onClientRender Link to comment
Lucario Posted May 24, 2013 Author Share Posted May 24, 2013 Can you give me a example of a timer and the drawed text? Link to comment
Castillo Posted May 24, 2013 Share Posted May 24, 2013 setTimer dxDrawText onClientRender You forgot about: getTimerDetails to get the timer time left. Link to comment
Lucario Posted May 24, 2013 Author Share Posted May 24, 2013 I need to make any math function? 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