Jump to content

Stealth kill


WASSIm.

Recommended Posts

hi guys, i make zombie/player can kill other player by stealth but for first trying this its working fine but after idk why its work but don't do sealthkill anim, and how check if someone back of player ?, any help ?

--CHECKS FOR ZOMBIE GRABBING FROM BEHIND 
function setZombieBitten (ped, target) 
    if (isElement(ped)) and (exports["ZA-export"]:isPedZombie(ped)) and not (isPedDead(ped)) then 
        if (isElement(target)) and not (exports["ZA-export"]:isPedZombie(target)) and not (isPedInVehicle(target)) then 
            local tx,ty,tz = getElementPosition(ped) 
            local vx,vy,vz = getElementPosition(target) 
            local zombdistance = getDistanceBetweenPoints3D(tx, ty, tz, vx, vy, vz) 
            if (zombdistance < 0.8 ) and (getElementType(target) == "player") and not (isPedDead(target)) then 
                triggerClientEvent("onZombieControl", ped, "moan", math.random(moanlimit)) 
                if (getElementType(ped) == "ped") then 
                    triggerClientEvent("onZombieControl", ped, "stop") 
                end 
                return killPed(target, ped, 0, 4, true)  
            end 
        end 
    end 
    return false 
end 

Link to comment
function isZombieBehindPlayer(zombie, player) 
    local px, py, pz = getElementPosition(player) 
    local zx, zy, zz = getElementPosition(zombie) 
    local zdx, zdy = zx-px, zy-py -- direction from player to zombie 
  
    local _, _, pr = getElementRotation(player) 
    pr = -math.rad(pr) 
    local fdx, fdy = math.sin(pr), math.cos(pr) -- player's front direction 
  
    return zdx*fdx+zdy*fdy < 0 -- dot product is less than 0 if vectors point to opposite directions 
end 

Link to comment
function isZombieBehindPlayer(zombie, player) 
    local px, py, pz = getElementPosition(player) 
    local zx, zy, zz = getElementPosition(zombie) 
    local zdx, zdy = zx-px, zy-py -- direction from player to zombie 
  
    local _, _, pr = getElementRotation(player) 
    pr = -math.rad(pr) 
    local fdx, fdy = math.sin(pr), math.cos(pr) -- player's front direction 
  
    return zdx*fdx+zdy*fdy < 0 -- dot product is less than 0 if vectors point to opposite directions 
end 

MTA 1.4 cut this code short, please check the OOP.

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...