Jump to content

donde Poner la Función para Dar vida??


Felipe Viedma

Recommended Posts

el Problema que tengo es que al hacerme de medico Luego no puedo curar

--Client--

    
    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( 2035.1999511719, -1406.5, 16.200000762939, 'Cylinder', 1.5, 6, 183, 248, 150 ); 
    local marker1p = createMarker( -2660.6008300781,635.90728759766,13.646651268005, 'Cylinder', 1.5, 6, 183, 248, 150 ); 
    local marker2p = createMarker( 1607.7686767578,1816.7622070313,10.000954627991, 'Cylinder', 1.5, 6, 183, 248, 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 medicos LS", 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 Medicos SF", 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( "Trabajo de Medicos LV", 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.3, 0.2, 0.20, 0.60, "Trabajo de Medicos", true ) 
guiSetAlpha( Wnd, 1 ) 
 button = guiCreateButton ( 0.5, 0.8, 0.40, 0.10, "Cerrar", true, Wnd ) 
 button1 = guiCreateButton ( 0.02, 0.8, 0.40, 0.10, "Obtener Trabajo", true, Wnd ) 
label = guiCreateLabel ( 0.05, 0.1, 0.9, 0.2, "Este trabajo consiste en curar Jugadores\nque padezcan de poca ~Salud o heal~.\nPara esto debes darle con la  flor al player\nla que se te da en el trabajo.al curar a los \nplayers generaras dinero tomando el \ndinero de ellos y ganaras algo extra.", true, Wnd ) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
guiWindowSetSizable( Wnd, false ) 
guiWindowSetMovable( Wnd, false ) 
  
    skins = 
            { 
            {"Profesional", 274}, 
            {"Cirujano", 275}, 
            {"Aprendiz", 276}, 
            {"white Medic", 177}, 
            {"Nigga Medic", 176}, 
            {"Old Medic", 156},             
            } 
      
    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("setMedic", localPlayer, models) 
                exports["drawData"]:outputDraw ( "You join the Medic job¡", 6, 183, 248, true ) 
                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) 
     
     
     
  
     

--Server--

function createSAPDTeam () 
    SAPDteam = createTeam ("Paramedicos", 6, 183, 248) 
end 
addEventHandler ("onResourceStart", resourceRoot, createSAPDTeam) 
  
function joinSAPDs(id) 
     setPlayerTeam(source,SAPDteam) 
    setPlayerNametagColor ( source, 6, 183, 248 ) 
     setElementModel(source, id) 
      giveWeapon ( source,14,9999) 
      playeraccount = getPlayerAccount( source ) 
     setAccountData( playeraccount, "team", "police", true ) 
     
  
end 
addEvent("setMedic", true) 
addEventHandler("setMedic",root,joinSAPDs) 
  
 function removeSAPD() 
    setPlayerTeam(source, 0) 
    takeWeapon(source, 3) 
    playeraccount = getPlayerAccount(source) 
    if not getAccountData(playeraccount, "standardskin") then 
    setElementModel(source, 0) 
    else 
    setElementModel(source,getAccountData(playeraccount,"standardskin")) 
     end 
     warnText("Ahora estas desempleado.",source,255,0,0) 
    end 
    addEvent("removeSAPD", true) 
    addEventHandler("removeSAPD",root,removeSAPD) 
addEvent("setMedic", true) 
addEventHandler("setMedic",root,joinMedic) 
addEvent("medic:healing", true) 
addEventHandler("medic:healing", root, 
function (medic) 
    if (getElementHealth(source) < 100) then 
        local Heal = getElementHealth(source) + 5 -- New health 
        setElementHealth(source, Heal)  
        if (Heal > 100) then 
             setElementHealth(source, 100) 
        end 
        givePlayerMoney(medic, 100)  
  
        takePlayerMoney(source, 25) -- Takes 100$ from the source when he get healed 
    end 
end) 

Link to comment

esta es la funcion pero claro si la coloco en client desaparece el marker y arruina todo si me ayudas donde ponerla por favor :D

function(attacker, weapon, bodypart, loss) 
team = getPlayerTeam(attacker) 
    if (attacker and getElementType(attacker) == "player" and weapon == 14 and team and getTeamName(team) == "Paramedicos") then  
        cancelEvent()  
        if (not isTimer(pause)) then  
            local health = getElementHealth(localPlayer) 
            if (health < 99) then 
            triggerServerEvent("medic:healing", localPlayer, attacker) -- Calls the Server Event 
            pause = setTimer(function() end, 1000, 1)  
            end 
        end 
    end 
end) 

Link to comment
addEventHandler ( "onClientPlayerDamage", root, 
    function ( attacker, weapon, bodypart, loss ) 
        if ( attacker and getElementType ( attacker ) == "player" and weapon == 14 and team ) then 
            local team = getPlayerTeam ( attacker ) 
            if ( team and getTeamName ( team ) == "Paramedicos" ) then 
                cancelEvent ( ) 
                if ( not isTimer ( pause ) ) then 
                    local health = getElementHealth ( localPlayer ) 
                    if ( health < 99 ) then 
                        triggerServerEvent ( "medic:healing", localPlayer, attacker ) -- Calls the Server Event 
                        pause = setTimer ( function ( ) end, 1000, 1 ) 
                    end 
                end 
            end 
        end 
    end 
) 

Link to comment

si mira asi quedo

  
      
    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( 2035.1999511719, -1406.5, 16.200000762939, 'Cylinder', 1.5, 6, 183, 248, 150 ); 
    local marker1p = createMarker( -2655.6284179688,636.09729003906,13.633478164673, 'Cylinder', 1.5, 6, 183, 248, 150 ); 
    local marker2p = createMarker( 1614.9406738281,1816.9710693359,10.0009765625, 'Cylinder', 1.5, 6, 183, 248, 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 medicos LS", 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 Medicos SF", 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( "Trabajo de Medicos LV", 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.3, 0.2, 0.20, 0.60, "Trabajo de Medicos", true ) 
guiSetAlpha( Wnd, 1 ) 
 button = guiCreateButton ( 0.5, 0.8, 0.40, 0.10, "Cerrar", true, Wnd ) 
 button1 = guiCreateButton ( 0.02, 0.8, 0.40, 0.10, "Obtener Trabajo", true, Wnd ) 
label = guiCreateLabel ( 0.05, 0.1, 0.9, 0.2, "Este trabajo consiste en curar Jugadores\nque padezcan de poca ~Salud o heal~.\nPara esto debes darle con la  flor al player\nla que se te da en el trabajo.al curar a los \nplayers generaras dinero tomando el \ndinero de ellos y ganaras algo extra.", true, Wnd ) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
guiWindowSetSizable( Wnd, false ) 
guiWindowSetMovable( Wnd, false ) 
  
    skins = 
            { 
            {"Profesional", 274}, 
            {"Cirujano", 275}, 
            {"Aprendiz", 276}, 
            {"white Medic", 177}, 
            {"Nigga Medic", 176}, 
            {"Old Medic", 156},             
            } 
      
    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("setMedic", localPlayer, models) 
                exports["drawData"]:outputDraw ( "You join the Medic job¡", 6, 183, 248, true ) 
                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) 
     
    addEventHandler ( "onClientPlayerDamage", root, 
    function ( attacker, weapon, bodypart, loss ) 
        if ( attacker and getElementType ( attacker ) == "player" and weapon == 14 and team ) then 
            local team = getPlayerTeam ( attacker ) 
            if ( team and getTeamName ( team ) == "Paramedicos" ) then 
                cancelEvent ( ) 
                if ( not isTimer ( pause ) ) then 
                    local health = getElementHealth ( localPlayer ) 
                    if ( health < 99 ) then 
                        triggerServerEvent ( "medic:healing", localPlayer, attacker ) -- Calls the Server Event 
                        pause = setTimer ( function ( ) end, 1000, 1 ) 
                    end 
                end 
            end 
        end 
    end 
) 

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...