Jump to content

[Help] NPC Damage


Recommended Posts

i cant make ped imortal in this script

--[[
 __                      __      __                                     __         
/\ \                    /\ \    /\ \__                                 /\ \        
\ \ \        ___     ___\ \ \/'\\ \ ,_\   ___   __  __     __      ____\ \ \/'\    
 \ \ \  __  / __`\  / __`\ \ , < \ \ \/  / __`\/\ \/\ \  /'__`\   /',__\\ \ , <    
  \ \ \L\ \/\ \L\ \/\ \L\ \ \ \\`\\ \ \_/\ \L\ \ \ \_/ |/\ \L\.\_/\__, `\\ \ \\`\  
   \ \____/\ \____/\ \____/\ \_\ \_\ \__\ \____/\ \___/ \ \__/.\_\/\____/ \ \_\ \_\
    \/___/  \/___/  \/___/  \/_/\/_/\/__/\/___/  \/__/   \/__/\/_/\/___/   \/_/\/_/
                                                                                   
--]]

local AmmuEntrada = createMarker( 1367.837, -1279.836, 12 ,"cylinder", 1.5, 255, 0, 0, 170 )
local AmmuSaida = createMarker( 315.8203125,-143.3, 1000 -1.6 ,"cylinder", 1.2, 255, 0, 0, 170 )
local Vendedor = createPed( 179, 308.36, -143.3 , 999.602 , 0 )
local Vendedor1 = createPed( 179, 316.48, -133.333, 999.602 , 90 )
local MenuComprar = createMarker( 308.36, -141.14, 998.4 ,"cylinder", 1, 0, 56, 255, 170 )
local MenuComprar1 = createMarker( 313.734, -133.333, 998.4 ,"cylinder", 1, 0, 56, 255, 170 )

    setPedAnimation(Vendedor, "dealer", "dealer_idle")
    setPedAnimation(Vendedor1, "ped", "idle_armed")
    givePedWeapon( Vendedor1, 33, 30, true )
    createBlipAttachedTo( AmmuEntrada, 6 )
    setElementInterior( AmmuSaida , 7 )
    setElementInterior( Vendedor, 7 )
    setElementInterior( Vendedor1, 7 )
    setElementInterior( MenuComprar, 7 )
    setElementInterior( MenuComprar1, 7 )

local menuAmmu = false
local menuAmmu1 = false

--cancelar danos NPC
addEventHandler( "onClientPlayerStealthKill", root, 
function (targetPlayer) 
    if targetPlayer == vendedor then
        cancelEvent()
    elseif targetPlayer == vendedor1 then
        cancelEvent()
    end
end)

addEventHandler( "onClientPedDamage", root, 
function (attacker, weapon, bodypart, loss) 
    if source == vendedor then
        cancelEvent()
    elseif source == vendedor1 then
        cancelEvent()
    end
end)

addEventHandler( "onClientPedWasted", root, 
function (killer, weapon, bodypart, loss, stealth) 
    if source == vendedor then
        cancelEvent()
    elseif source == vendedor1 then
        cancelEvent()
    end
end)

--Funções dos markers
addEventHandler( "onClientMarkerHit", root, 
function (hitPlayer, matchingDimension) 
    local x,y,z = getElementPosition( localPlayer )

    if (matchingDimension) then -- checa dimensão
        if source == AmmuEntrada then 
            setElementInterior(hitPlayer, 7)
            setElementPosition (hitPlayer, 313.6630859375,-142.9970703125,999.6015625)
            setElementRotation( hitPlayer, -0, 0, 25.519 )
            setPedCameraRotation( hitPlayer, 21 )
        end
        if source == AmmuSaida then 
            setElementInterior(hitPlayer, 0)
            setElementDimension( hitPlayer, 0 )
            setElementPosition(hitPlayer, 1365.741, -1279.792, 13.547 )
            setElementRotation( hitPlayer, -0, 0, 90 )
            setPedCameraRotation( hitPlayer, 90 )
        end
        if source == MenuComprar and z < 1000 then
            addEventHandler( "onClientRender", root, MenuCompra1)
            showCursor( true )
            menuAmmu = true
        end
        if source == MenuComprar1 and z < 1000 then 
            addEventHandler( "onClientRender", root, MenuCompra2)
            showCursor( true )
            menuAmmu1 = true
        end
    end
end)

-- Se sair do marker remove o menu
addEventHandler( "onClientMarkerLeave", root, 
function (leftPlayer, matchingDimension) 
    if source == MenuComprar then 
        removeEventHandler( "onClientRender", root, MenuCompra1 )
        showCursor( false )
        menuAmmu = false
    end
    if source == MenuComprar1 then 
        removeEventHandler( "onClientRender", root, MenuCompra2 )
        showCursor( false )
        menuAmmu1 = false
    end
end)

local screenW, screenH = guiGetScreenSize()

local CorIMG = tocolor(255, 255, 255, 255)
local CorTXT = tocolor(0, 0, 0, 255)

local CorIMG1 = tocolor(255, 255, 255, 255)
local CorTXT1 = tocolor(0, 0, 0, 255)

local CorIMG2 = tocolor(255, 255, 255, 255)
local CorTXT2 = tocolor(0, 0, 0, 255)

local CorIMG3 = tocolor(255, 255, 255, 255)
local CorTXT3 = tocolor(0, 0, 0, 255)


-- Menu DX
function MenuCompra1()
    dxDrawLine((screenW * 0.2260) - 1, (screenH * 0.2815) - 1, (screenW * 0.2260) - 1, screenH * 0.7259, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine(screenW * 0.3812, (screenH * 0.2815) - 1, (screenW * 0.2260) - 1, (screenH * 0.2815) - 1, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine((screenW * 0.2260) - 1, screenH * 0.7259, screenW * 0.3812, screenH * 0.7259, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine(screenW * 0.3812, screenH * 0.7259, screenW * 0.3812, (screenH * 0.2815) - 1, tocolor(0, 0, 0, 255), 1, false)
    dxDrawRectangle(screenW * 0.2260, screenH * 0.2815, screenW * 0.1552, screenH * 0.4444, tocolor(1, 0, 0, 193), false)
    faquinha = dxDrawImage(screenW * 0.2313, screenH * 0.3833, screenW * 0.0469, screenH * 0.0833, "imgs/KABAR.png", 0, 0, 0, CorIMG, false)
    dxDrawLine((screenW * 0.2260) - 1, (screenH * 0.2815) - 1, (screenW * 0.2260) - 1, screenH * 0.3741, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine(screenW * 0.3812, (screenH * 0.2815) - 1, (screenW * 0.2260) - 1, (screenH * 0.2815) - 1, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine((screenW * 0.2260) - 1, screenH * 0.3741, screenW * 0.3812, screenH * 0.3741, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine(screenW * 0.3812, screenH * 0.3741, screenW * 0.3812, (screenH * 0.2815) - 1, tocolor(0, 0, 0, 255), 1, false)
    dxDrawRectangle(screenW * 0.2260, screenH * 0.2815, screenW * 0.1552, screenH * 0.0926, tocolor(201, 0, 0, 100), false)
    dxDrawText("Loja De Armas", (screenW * 0.2323) - 1, (screenH * 0.2907) - 1, (screenW * 0.3760) - 1, (screenH * 0.3648) - 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
    dxDrawText("Loja De Armas", (screenW * 0.2323) + 1, (screenH * 0.2907) - 1, (screenW * 0.3760) + 1, (screenH * 0.3648) - 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
    dxDrawText("Loja De Armas", (screenW * 0.2323) - 1, (screenH * 0.2907) + 1, (screenW * 0.3760) - 1, (screenH * 0.3648) + 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
    dxDrawText("Loja De Armas", (screenW * 0.2323) + 1, (screenH * 0.2907) + 1, (screenW * 0.3760) + 1, (screenH * 0.3648) + 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
    dxDrawText("Loja De Armas", screenW * 0.2323, screenH * 0.2907, screenW * 0.3760, screenH * 0.3648, tocolor(254, 254, 254, 254), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
    dxDrawImage(screenW * 0.2313, screenH * 0.4667, screenW * 0.0469, screenH * 0.0833, "imgs/ColtM1911.png", 0, 0, 0, CorIMG1, false)
    dxDrawImage(screenW * 0.2313, screenH * 0.5500, screenW * 0.0469, screenH * 0.0833, "imgs/M29.png", 0, 0, 0, CorIMG2, false)
    dxDrawImage(screenW * 0.2313, screenH * 0.6333, screenW * 0.0469, screenH * 0.0833, "imgs/Glock-17.png", 0, 0, 0, CorIMG3, false)
    dxDrawText("Faca R$250", (screenW * 0.2781) - 1, (screenH * 0.3833) - 1, (screenW * 0.3771) - 1, (screenH * 0.4667) - 1, CorTXT, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Faca R$250", (screenW * 0.2781) + 1, (screenH * 0.3833) - 1, (screenW * 0.3771) + 1, (screenH * 0.4667) - 1, CorTXT, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Faca R$250", (screenW * 0.2781) - 1, (screenH * 0.3833) + 1, (screenW * 0.3771) - 1, (screenH * 0.4667) + 1, CorTXT, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Faca R$250", (screenW * 0.2781) + 1, (screenH * 0.3833) + 1, (screenW * 0.3771) + 1, (screenH * 0.4667) + 1, CorTXT, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Faca R$250", screenW * 0.2781, screenH * 0.3833, screenW * 0.3771, screenH * 0.4667, tocolor(254, 254, 254, 255), 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Colt .45 R$1500", (screenW * 0.2781) - 1, (screenH * 0.4667) - 1, (screenW * 0.3771) - 1, (screenH * 0.5500) - 1, CorTXT1, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Colt .45 R$1500", (screenW * 0.2781) + 1, (screenH * 0.4667) - 1, (screenW * 0.3771) + 1, (screenH * 0.5500) - 1, CorTXT1, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Colt .45 R$1500", (screenW * 0.2781) - 1, (screenH * 0.4667) + 1, (screenW * 0.3771) - 1, (screenH * 0.5500) + 1, CorTXT1, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Colt .45 R$1500", (screenW * 0.2781) + 1, (screenH * 0.4667) + 1, (screenW * 0.3771) + 1, (screenH * 0.5500) + 1, CorTXT1, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Colt .45 R$1500", screenW * 0.2781, screenH * 0.4667, screenW * 0.3771, screenH * 0.5500, tocolor(254, 254, 254, 255), 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Revolver .357 R$2500", (screenW * 0.2781) - 1, (screenH * 0.5500) - 1, (screenW * 0.3771) - 1, (screenH * 0.6333) - 1, CorTXT2, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Revolver .357 R$2500", (screenW * 0.2781) + 1, (screenH * 0.5500) - 1, (screenW * 0.3771) + 1, (screenH * 0.6333) - 1, CorTXT2, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Revolver .357 R$2500", (screenW * 0.2781) - 1, (screenH * 0.5500) + 1, (screenW * 0.3771) - 1, (screenH * 0.6333) + 1, CorTXT2, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Revolver .357 R$2500", (screenW * 0.2781) + 1, (screenH * 0.5500) + 1, (screenW * 0.3771) + 1, (screenH * 0.6333) + 1, CorTXT2, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Revolver .357 R$2500", screenW * 0.2781, screenH * 0.5500, screenW * 0.3771, screenH * 0.6333, tocolor(254, 255, 254, 255), 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Glock 9mm Automatica R$4000", (screenW * 0.2781) - 1, (screenH * 0.6333) - 1, (screenW * 0.3771) - 1, (screenH * 0.7167) - 1, CorTXT3, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Glock 9mm Automatica R$4000", (screenW * 0.2781) + 1, (screenH * 0.6333) - 1, (screenW * 0.3771) + 1, (screenH * 0.7167) - 1, CorTXT3, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Glock 9mm Automatica R$4000", (screenW * 0.2781) - 1, (screenH * 0.6333) + 1, (screenW * 0.3771) - 1, (screenH * 0.7167) + 1, CorTXT3, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Glock 9mm Automatica R$4000", (screenW * 0.2781) + 1, (screenH * 0.6333) + 1, (screenW * 0.3771) + 1, (screenH * 0.7167) + 1, CorTXT3, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("Glock 9mm Automatica R$4000", screenW * 0.2781, screenH * 0.6333, screenW * 0.3771, screenH * 0.7167, tocolor(254, 255, 254, 255), 1.00, "default", "center", "center", false, false, false, false, false)
end

function MenuCompra2()
    dxDrawLine((screenW * 0.2260) - 1, (screenH * 0.2815) - 1, (screenW * 0.2260) - 1, screenH * 0.7259, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine(screenW * 0.3812, (screenH * 0.2815) - 1, (screenW * 0.2260) - 1, (screenH * 0.2815) - 1, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine((screenW * 0.2260) - 1, screenH * 0.7259, screenW * 0.3812, screenH * 0.7259, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine(screenW * 0.3812, screenH * 0.7259, screenW * 0.3812, (screenH * 0.2815) - 1, tocolor(0, 0, 0, 255), 1, false)
    dxDrawRectangle(screenW * 0.2260, screenH * 0.2815, screenW * 0.1552, screenH * 0.4444, tocolor(1, 0, 0, 193), false)
    faquinha = dxDrawImage(screenW * 0.2313, screenH * 0.3833, screenW * 0.0469, screenH * 0.0833, "imgs/Sawn-offShotgun.png", 0, 0, 0, CorIMG, false)
    dxDrawLine((screenW * 0.2260) - 1, (screenH * 0.2815) - 1, (screenW * 0.2260) - 1, screenH * 0.3741, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine(screenW * 0.3812, (screenH * 0.2815) - 1, (screenW * 0.2260) - 1, (screenH * 0.2815) - 1, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine((screenW * 0.2260) - 1, screenH * 0.3741, screenW * 0.3812, screenH * 0.3741, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine(screenW * 0.3812, screenH * 0.3741, screenW * 0.3812, (screenH * 0.2815) - 1, tocolor(0, 0, 0, 255), 1, false)
    dxDrawRectangle(screenW * 0.2260, screenH * 0.2815, screenW * 0.1552, screenH * 0.0926, tocolor(201, 0, 0, 100), false)
    dxDrawText("Loja De Armas", (screenW * 0.2323) - 1, (screenH * 0.2907) - 1, (screenW * 0.3760) - 1, (screenH * 0.3648) - 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
    dxDrawText("Loja De Armas", (screenW * 0.2323) + 1, (screenH * 0.2907) - 1, (screenW * 0.3760) + 1, (screenH * 0.3648) - 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
    dxDrawText("Loja De Armas", (screenW * 0.2323) - 1, (screenH * 0.2907) + 1, (screenW * 0.3760) - 1, (screenH * 0.3648) + 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
    dxDrawText("Loja De Armas", (screenW * 0.2323) + 1, (screenH * 0.2907) + 1, (screenW * 0.3760) + 1, (screenH * 0.3648) + 1, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
    dxDrawText("Loja De Armas", screenW * 0.2323, screenH * 0.2907, screenW * 0.3760, screenH * 0.3648, tocolor(254, 254, 254, 254), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
    dxDrawImage(screenW * 0.2313, screenH * 0.4667, screenW * 0.0469, screenH * 0.0833, "imgs/Mossberg590.png", 0, 0, 0, CorIMG1, false)
    dxDrawImage(screenW * 0.2313, screenH * 0.5500, screenW * 0.0469, screenH * 0.0833, "imgs/MP5A3.png", 0, 0, 0, CorIMG2, false)
    dxDrawImage(screenW * 0.2313, screenH * 0.6333, screenW * 0.0469, screenH * 0.0833, "imgs/M14.png", 0, 0, 0, CorIMG3, false)
    dxDrawText("12 Cano Duplo R$3000", (screenW * 0.2781) - 1, (screenH * 0.3833) - 1, (screenW * 0.3771) - 1, (screenH * 0.4667) - 1, CorTXT, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("12 Cano Duplo R$3000", (screenW * 0.2781) + 1, (screenH * 0.3833) - 1, (screenW * 0.3771) + 1, (screenH * 0.4667) - 1, CorTXT, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("12 Cano Duplo R$3000", (screenW * 0.2781) - 1, (screenH * 0.3833) + 1, (screenW * 0.3771) - 1, (screenH * 0.4667) + 1, CorTXT, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("12 Cano Duplo R$3000", (screenW * 0.2781) + 1, (screenH * 0.3833) + 1, (screenW * 0.3771) + 1, (screenH * 0.4667) + 1, CorTXT, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("12 Cano Duplo R$3000", screenW * 0.2781, screenH * 0.3833, screenW * 0.3771, screenH * 0.4667, tocolor(254, 254, 254, 255), 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("12 Punheteira R$4000", (screenW * 0.2781) - 1, (screenH * 0.4667) - 1, (screenW * 0.3771) - 1, (screenH * 0.5500) - 1, CorTXT1, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("12 Punheteira R$4000", (screenW * 0.2781) + 1, (screenH * 0.4667) - 1, (screenW * 0.3771) + 1, (screenH * 0.5500) - 1, CorTXT1, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("12 Punheteira R$4000", (screenW * 0.2781) - 1, (screenH * 0.4667) + 1, (screenW * 0.3771) - 1, (screenH * 0.5500) + 1, CorTXT1, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("12 Punheteira R$4000", (screenW * 0.2781) + 1, (screenH * 0.4667) + 1, (screenW * 0.3771) + 1, (screenH * 0.5500) + 1, CorTXT1, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("12 Punheteira R$4000", screenW * 0.2781, screenH * 0.4667, screenW * 0.3771, screenH * 0.5500, tocolor(254, 254, 254, 255), 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("HK MP5 R$6000", (screenW * 0.2781) - 1, (screenH * 0.5500) - 1, (screenW * 0.3771) - 1, (screenH * 0.6333) - 1, CorTXT2, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("HK MP5 R$6000", (screenW * 0.2781) + 1, (screenH * 0.5500) - 1, (screenW * 0.3771) + 1, (screenH * 0.6333) - 1, CorTXT2, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("HK MP5 R$6000", (screenW * 0.2781) - 1, (screenH * 0.5500) + 1, (screenW * 0.3771) - 1, (screenH * 0.6333) + 1, CorTXT2, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("HK MP5 R$6000", (screenW * 0.2781) + 1, (screenH * 0.5500) + 1, (screenW * 0.3771) + 1, (screenH * 0.6333) + 1, CorTXT2, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("HK MP5 R$6000", screenW * 0.2781, screenH * 0.5500, screenW * 0.3771, screenH * 0.6333, tocolor(254, 255, 254, 255), 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("BAR M1918 R$10000", (screenW * 0.2781) - 1, (screenH * 0.6333) - 1, (screenW * 0.3771) - 1, (screenH * 0.7167) - 1, CorTXT3, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("BAR M1918 R$10000", (screenW * 0.2781) + 1, (screenH * 0.6333) - 1, (screenW * 0.3771) + 1, (screenH * 0.7167) - 1, CorTXT3, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("BAR M1918 R$10000", (screenW * 0.2781) - 1, (screenH * 0.6333) + 1, (screenW * 0.3771) - 1, (screenH * 0.7167) + 1, CorTXT3, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("BAR M1918 R$10000", (screenW * 0.2781) + 1, (screenH * 0.6333) + 1, (screenW * 0.3771) + 1, (screenH * 0.7167) + 1, CorTXT3, 1.00, "default", "center", "center", false, false, false, false, false)
    dxDrawText("BAR M1918 R$10000", screenW * 0.2781, screenH * 0.6333, screenW * 0.3771, screenH * 0.7167, tocolor(254, 255, 254, 255), 1.00, "default", "center", "center", false, false, false, false, false)
end

-- função clique
function Clicar (_,state)
    local money= getPlayerMoney( thePlayer )
    if state == "down" then
        if menuAmmu == true then
            local ArmaMeele =  getPedWeapon ( localPlayer, 1 ) -- checa slot de meele
            if isCursorOnElement ( screenW * 0.2292, screenH * 0.3806, screenW * 0.1479, screenH * 0.0880 ) and money >= 250 and tonumber(ArmaMeele) ~= 4 then -- se não tem faca
                playSound("sounds/cash.mp3")
                CorIMG = tocolor(0, 255, 0, 100)
                CorTXT = tocolor(0, 0, 0, 10)
                triggerServerEvent("ComproFaca", localPlayer)
                setTimer(function()
                    CorIMG = tocolor(255, 255, 255, 255)
                    CorTXT = tocolor(0, 0, 0, 255)
                end,500,1)
                    elseif isCursorOnElement ( screenW * 0.2292, screenH * 0.3806, screenW * 0.1479, screenH * 0.0880 ) and money < 250 and tonumber(ArmaMeele) ~= 4 then
                        playSound("sounds/dont.mp3")
                        CorIMG = tocolor(255, 0, 0, 100)
                        CorTXT = tocolor(0, 0, 0, 10)
                        setTimer(function()
                        CorIMG = tocolor(255, 255, 255, 255)
                        CorTXT = tocolor(0, 0, 0, 255)
                        end,500,1)
                    elseif isCursorOnElement ( screenW * 0.2292, screenH * 0.3806, screenW * 0.1479, screenH * 0.0880 ) and money >= 250 and tonumber(ArmaMeele) == 4 then -- se ja tem faca
                        playSound("sounds/dont.mp3")
                        CorIMG = tocolor(255, 255, 0, 100)
                        CorTXT = tocolor(0, 0, 0, 10)
                        setTimer(function()
                        CorIMG = tocolor(255, 255, 255, 255)
                        CorTXT = tocolor(0, 0, 0, 255)
                        end,500,1)
            end
            if isCursorOnElement (screenW * 0.2292, screenH * 0.4685, screenW * 0.1479, screenH * 0.0833 ) and money >= 1500 then
                playSound("sounds/cash.mp3")
                CorIMG1 = tocolor(0, 255, 0, 100)
                CorTXT1 = tocolor(0, 0, 0, 10)
                triggerServerEvent("ComproPistola", localPlayer)
                setTimer(function()
                    CorIMG1 = tocolor(255, 255, 255, 255)
                    CorTXT1 = tocolor(0, 0, 0, 255)
                end,500,1)
                    elseif isCursorOnElement (screenW * 0.2292, screenH * 0.4685, screenW * 0.1479, screenH * 0.0833 ) and money < 1500 then
                        playSound("sounds/dont.mp3")
                        CorIMG1 = tocolor(255, 0, 0, 100)
                        CorTXT1 = tocolor(0, 0, 0, 10)
                        setTimer(function()
                        CorIMG1 = tocolor(255, 255, 255, 255)
                        CorTXT1 = tocolor(0, 0, 0, 255)
                        end,500,1)
            end
            if isCursorOnElement (screenW * 0.2292, screenH * 0.5519, screenW * 0.1479, screenH * 0.0833 ) and money >= 2500 then
                playSound("sounds/cash.mp3")
                CorIMG2 = tocolor(0, 255, 0, 100)
                CorTXT2 = tocolor(0, 0, 0, 10)
                triggerServerEvent("ComproRevolver", localPlayer)
                setTimer(function()
                    CorIMG2 = tocolor(255, 255, 255, 255)
                    CorTXT2 = tocolor(0, 0, 0, 255)
                end,500,1)
                    elseif isCursorOnElement (screenW * 0.2292, screenH * 0.5519, screenW * 0.1479, screenH * 0.0833 ) and money < 2500 then
                        playSound("sounds/dont.mp3")
                        CorIMG2 = tocolor(255, 0, 0, 100)
                        CorTXT2 = tocolor(0, 0, 0, 10)
                        setTimer(function()
                        CorIMG2 = tocolor(255, 255, 255, 255)
                        CorTXT2 = tocolor(0, 0, 0, 255)
                        end,500,1)
                    end
            if isCursorOnElement (screenW * 0.2292, screenH * 0.6352, screenW * 0.1479, screenH * 0.0833 ) and money >= 4000 then
                playSound("sounds/cash.mp3")
                CorIMG3 = tocolor(0, 255, 0, 100)
                CorTXT3 = tocolor(0, 0, 0, 10)
                triggerServerEvent("ComproGlock", localPlayer)
                setTimer(function()
                    CorIMG3 = tocolor(255, 255, 255, 255)
                    CorTXT3 = tocolor(0, 0, 0, 255)
                end,500,1)
                    elseif isCursorOnElement (screenW * 0.2292, screenH * 0.6352, screenW * 0.1479, screenH * 0.0833 ) and money < 4000 then
                        playSound("sounds/dont.mp3")
                        CorIMG3 = tocolor(255, 0, 0, 100)
                        CorTXT3 = tocolor(0, 0, 0, 10)
                        setTimer(function()
                        CorIMG3 = tocolor(255, 255, 255, 255)
                        CorTXT3 = tocolor(0, 0, 0, 255)
                        end,500,1) 
                    end 
            end 
            if menuAmmu1 == true then
                if isCursorOnElement ( screenW * 0.2292, screenH * 0.3806, screenW * 0.1479, screenH * 0.0880 ) and money >= 3000 then
                playSound("sounds/cash.mp3")
                CorIMG = tocolor(0, 255, 0, 100)
                CorTXT = tocolor(0, 0, 0, 10)
                triggerServerEvent("Compro12Dupla", localPlayer)
                setTimer(function()
                    CorIMG = tocolor(255, 255, 255, 255)
                    CorTXT = tocolor(0, 0, 0, 255)
                end,500,1)
                    elseif isCursorOnElement ( screenW * 0.2292, screenH * 0.3806, screenW * 0.1479, screenH * 0.0880 ) and money < 3000 then
                        playSound("sounds/dont.mp3")
                        CorIMG = tocolor(255, 0, 0, 100)
                        CorTXT = tocolor(0, 0, 0, 10)
                        setTimer(function()
                        CorIMG = tocolor(255, 255, 255, 255)
                        CorTXT = tocolor(0, 0, 0, 255)
                        end,500,1)
            end
            if isCursorOnElement (screenW * 0.2292, screenH * 0.4685, screenW * 0.1479, screenH * 0.0833 ) and money >= 4000 then
                playSound("sounds/cash.mp3")
                CorIMG1 = tocolor(0, 255, 0, 100)
                CorTXT1 = tocolor(0, 0, 0, 10)
                triggerServerEvent("Compro12", localPlayer)
                setTimer(function()
                    CorIMG1 = tocolor(255, 255, 255, 255)
                    CorTXT1 = tocolor(0, 0, 0, 255)
                end,500,1)
                    elseif isCursorOnElement (screenW * 0.2292, screenH * 0.4685, screenW * 0.1479, screenH * 0.0833 ) and money < 4000 then
                        playSound("sounds/dont.mp3")
                        CorIMG1 = tocolor(255, 0, 0, 100)
                        CorTXT1 = tocolor(0, 0, 0, 10)
                        setTimer(function()
                        CorIMG1 = tocolor(255, 255, 255, 255)
                        CorTXT1 = tocolor(0, 0, 0, 255)
                        end,500,1)
            end
            if isCursorOnElement (screenW * 0.2292, screenH * 0.5519, screenW * 0.1479, screenH * 0.0833 ) and money >= 6000 then
                playSound("sounds/cash.mp3")
                CorIMG2 = tocolor(0, 255, 0, 100)
                CorTXT2 = tocolor(0, 0, 0, 10)
                triggerServerEvent("ComproMP5", localPlayer)
                setTimer(function()
                    CorIMG2 = tocolor(255, 255, 255, 255)
                    CorTXT2 = tocolor(0, 0, 0, 255)
                end,500,1)
                    elseif isCursorOnElement (screenW * 0.2292, screenH * 0.5519, screenW * 0.1479, screenH * 0.0833 ) and money < 6000 then
                        playSound("sounds/dont.mp3")
                        CorIMG2 = tocolor(255, 0, 0, 100)
                        CorTXT2 = tocolor(0, 0, 0, 10)
                        setTimer(function()
                        CorIMG2 = tocolor(255, 255, 255, 255)
                        CorTXT2 = tocolor(0, 0, 0, 255)
                        end,500,1)
                    end
            if isCursorOnElement (screenW * 0.2292, screenH * 0.6352, screenW * 0.1479, screenH * 0.0833 ) and money >= 10000 then
                playSound("sounds/cash.mp3")
                CorIMG3 = tocolor(0, 255, 0, 100)
                CorTXT3 = tocolor(0, 0, 0, 10)
                triggerServerEvent("ComproBAR", localPlayer)
                setTimer(function()
                    CorIMG3 = tocolor(255, 255, 255, 255)
                    CorTXT3 = tocolor(0, 0, 0, 255)
                end,500,1)
                    elseif isCursorOnElement (screenW * 0.2292, screenH * 0.6352, screenW * 0.1479, screenH * 0.0833 ) and money < 10000 then
                        playSound("sounds/dont.mp3")
                        CorIMG3 = tocolor(255, 0, 0, 100)
                        CorTXT3 = tocolor(0, 0, 0, 10)
                        setTimer(function()
                        CorIMG3 = tocolor(255, 255, 255, 255)
                        CorTXT3 = tocolor(0, 0, 0, 255)
                        end,500,1) 
                    end
                end
        end
end
addEventHandler ("onClientClick", root, Clicar ) 

-- importante função para pegar posição do mouse 
-- creditos da função da posição do mouse: Croack
function isCursorOnElement ( x, y, w, h )

local mx, my = getCursorPosition ()
local fullx, fully = guiGetScreenSize ()
    cursorx, cursory = mx*fullx, my*fully
        if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
            return true
        else
            return false
        end
end

npc damage part

addEventHandler( "onClientPlayerStealthKill", root, 
function (targetPlayer) 
    if targetPlayer == vendedor then
        cancelEvent()
    elseif targetPlayer == vendedor1 then
        cancelEvent()
    end
end)

addEventHandler( "onClientPedDamage", root, 
function (attacker, weapon, bodypart, loss) 
    if source == vendedor then
        cancelEvent()
    elseif source == vendedor1 then
        cancelEvent()
    end
end)

addEventHandler( "onClientPedWasted", root, 
function (killer, weapon, bodypart, loss, stealth) 
    if source == vendedor then
        cancelEvent()
    elseif source == vendedor1 then
        cancelEvent()
    end
end)

 

Edited by Looktovask
Link to comment

Hey,

Don't forget that variable names are case sensitive!

local Vendedor = createPed( 179, 308.36, -143.3 , 999.602 , 0 )
local Vendedor1 = createPed( 179, 316.48, -133.333, 999.602 , 90 )

And now check the names you used in the damage events.
Do you notice something wrong ? ?

  • Thanks 1
Link to comment

i got another ploblem, the markethit dont detect player in server

 

--[[
 __                      __      __                                     __         
/\ \                    /\ \    /\ \__                                 /\ \        
\ \ \        ___     ___\ \ \/'\\ \ ,_\   ___   __  __     __      ____\ \ \/'\    
 \ \ \  __  / __`\  / __`\ \ , < \ \ \/  / __`\/\ \/\ \  /'__`\   /',__\\ \ , <    
  \ \ \L\ \/\ \L\ \/\ \L\ \ \ \\`\\ \ \_/\ \L\ \ \ \_/ |/\ \L\.\_/\__, `\\ \ \\`\  
   \ \____/\ \____/\ \____/\ \_\ \_\ \__\ \____/\ \___/ \ \__/.\_\/\____/ \ \_\ \_\
    \/___/  \/___/  \/___/  \/_/\/_/\/__/\/___/  \/__/   \/__/\/_/\/___/   \/_/\/_/
                                                                                   
--]]

MarkerInicio = createMarker(238.088, 73.331, 1004 ,"cylinder", 1, 0, 56, 255, 100 )

setElementInterior( MarkerInicio , 6 )
setElementVisibleTo( MarkerInicio, root, false )

function CompraPorte()
    setPlayerMoney( client, getPlayerMoney(client)-30000 )
    setElementVisibleTo( MarkerInicio, client, true )
end
addEvent( "ComproPorte", true )
addEventHandler( "ComproPorte", root, CompraPorte )

function MarkerHIT(hitElement, matchingDimension)
        setElementVisibleTo( MarkerInicio, hitElement, false )
        setAccountData( hitElement, "Porte1", true )
        triggerClientEvent( "Conversar", player )
end
addEventHandler( "onMarkerHit", MarkerInicio, MarkerHIT )

 

Link to comment
  • 2 months later...
On 07/06/2021 at 00:43, Looktovask said:

i got another ploblem, the markethit dont detect player in server

 

--[[
 __                      __      __                                     __         
/\ \                    /\ \    /\ \__                                 /\ \        
\ \ \        ___     ___\ \ \/'\\ \ ,_\   ___   __  __     __      ____\ \ \/'\    
 \ \ \  __  / __`\  / __`\ \ , < \ \ \/  / __`\/\ \/\ \  /'__`\   /',__\\ \ , <    
  \ \ \L\ \/\ \L\ \/\ \L\ \ \ \\`\\ \ \_/\ \L\ \ \ \_/ |/\ \L\.\_/\__, `\\ \ \\`\  
   \ \____/\ \____/\ \____/\ \_\ \_\ \__\ \____/\ \___/ \ \__/.\_\/\____/ \ \_\ \_\
    \/___/  \/___/  \/___/  \/_/\/_/\/__/\/___/  \/__/   \/__/\/_/\/___/   \/_/\/_/
                                                                                   
--]]

MarkerInicio = createMarker(238.088, 73.331, 1004 ,"cylinder", 1, 0, 56, 255, 100 )

setElementInterior( MarkerInicio , 6 )
setElementVisibleTo( MarkerInicio, root, false )

function CompraPorte()
    setPlayerMoney( client, getPlayerMoney(client)-30000 )
    setElementVisibleTo( MarkerInicio, client, true )
end
addEvent( "ComproPorte", true )
addEventHandler( "ComproPorte", root, CompraPorte )

function MarkerHIT(hitElement, matchingDimension)
        setElementVisibleTo( MarkerInicio, hitElement, false )
        setAccountData( hitElement, "Porte1", true )
        triggerClientEvent( "Conversar", player )
end
addEventHandler( "onMarkerHit", MarkerInicio, MarkerHIT )

 

try to change "player" to "source"

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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