WASSIm. Posted December 8, 2014 Posted December 8, 2014 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
AJXB Posted December 8, 2014 Posted December 8, 2014 You can check if something behind a player using Matrices: https://wiki.multitheftauto.com/wiki/Matrix ~ This has to be the worst board post I have ever read. It simply makes no sense. You start off by talking about space or something, then you randomly start babbling about cupcakes, and you end off with random fish names. ~ Don't listen to this guy, any board with the categories 'dinosaurs, spaceships, fried foods, wild animals, alien abductions, business casual, robots, and fireworks' has true potential.
DiSaMe Posted December 8, 2014 Posted December 8, 2014 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 -
WASSIm. Posted December 8, 2014 Author Posted December 8, 2014 thanks, so what about problem anim stealth kill ?
AJXB Posted December 8, 2014 Posted December 8, 2014 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. ~ This has to be the worst board post I have ever read. It simply makes no sense. You start off by talking about space or something, then you randomly start babbling about cupcakes, and you end off with random fish names. ~ Don't listen to this guy, any board with the categories 'dinosaurs, spaceships, fried foods, wild animals, alien abductions, business casual, robots, and fireworks' has true potential.
WASSIm. Posted December 9, 2014 Author Posted December 9, 2014 MTA 1.4 cut this code short, please check the OOP. dude read: https://wiki.multitheftauto.com/wiki/Meta.xml OOP - Please refer to OOP for documentation. false: Disable OOP. true: Enable OOP.
AJXB Posted December 9, 2014 Posted December 9, 2014 MTA 1.4 cut this code short, please check the OOP. dude read: https://wiki.multitheftauto.com/wiki/Meta.xml OOP - Please refer to OOP for documentation. false: Disable OOP. true: Enable OOP. "dude" I'm sorry if you're too lazy to add this simple line to your meta.xml, lazy coders are not meant to succeed. ~ This has to be the worst board post I have ever read. It simply makes no sense. You start off by talking about space or something, then you randomly start babbling about cupcakes, and you end off with random fish names. ~ Don't listen to this guy, any board with the categories 'dinosaurs, spaceships, fried foods, wild animals, alien abductions, business casual, robots, and fireworks' has true potential.
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