Jump to content

Bean666

Members
  • Posts

    732
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Bean666

  1. there are no bugs atm @slothmans slothbot script, as i have known and i'm using it as well, make sure to reinstall slothbot resource, clean. just to be sure. anyway the damage script, try this, try putting this on a brand-new resource name it "pedDamages" or "botDamages" or something like "botUtilities" or something anyway, just give it a test first and see how it goes. Client-Side: function pedDamageTest ( attacker, weapon, bodypart , loss ) if attacker and attacker == localPlayer then local remainingHealth = getElementHealth(source) outputChatBox("DEBUG: Remaining health "..remainingHealth) triggerServerEvent("damageThePed",source,attacker,weapon,bodypart,loss) end end addEventHandler ( "onClientPedDamage", root, pedDamageTest ) Server-Side: function damageThePed(attacker,weapon,bodypart,loss) if (source.health - loss) <= 0 then killPed(source,attacker,weapon,bodypart) else source.health = source.health - loss end end addEvent("damageThePed", true) addEventHandler("damageThePed", root, damageThePed)
  2. Bean666

    Sync peds?

    Animations is an option for me, i'll take a look on that after i fix the sync. and the zombie script i'm using isn't slothmans thats why the walking anims kinda aren't suited on it, but i'll try. anyway, about: Send a message to server-side. Serverside sends a message to all other clients (excluding yourself). By this how do I do this? The send message kinda thingy. is it like a trigger Client/Server Event or some sort? Can i have a short example, I'm kind of new to sync stuff. I might have an idea once I see how it's done.
  3. where is that setElementHealth function?
  4. yes if u spawn the bots without a team they will fight each other and kill each other thus them disappearing before u get to that area. and the "no damage thing", make sure to check turned on scripts that has onClientPedDamage or something that is related to ped damage there might be a function that is cancelling the event.
  5. Bean666

    Sync peds?

    i might do the same way as the streamer works, but first thing, wdym by animations/interactions? if u mean by walking anims i can't set it since it does not update, peds wont rotate and just keep going the same direction, even tho updatePosition bool is set to true, thats why i only have the state "forward" set to true instead.
  6. Bean666

    Sync peds?

    tried 100 ped sync interval, works better than before but other's peds still kinda looking stuttery. local function trackMe() local zombies = getElementsByType("ped",resourceRoot,true) for index,zombie in ipairs(zombies) do if math.random(1,60) == 15 and isPedDead(zombie) == false then local sound = playSound3D("sounds/mgroan"..tostring(math.random(1,10))..".ogg",zombie.position) setSoundMaxDistance(sound, 50) end local zombieTarget = zombieData[zombie].target if zombieTarget and isElement(zombieTarget) and isPedDead(zombieTarget) == false then local lx,ly,lz = getElementPosition(zombieTarget) local lVector = Vector3(lx,ly,lz) local hVector = Vector3(getPedBonePosition(zombie,6)) local zVector = Vector3(getElementPosition(zombie)) local doesZombieSeePlayer = isLineOfSightClear(hVector,lVector,true,false,false,true,false,true,true,zombie) local distanceToPlayer = getDistanceBetweenPoints2D(zVector.x,zVector.y,lVector.x,lVector.y) if timesExecuted%5 == 0 and zombieData[zombie].target == localPlayer then local newTarget,doesSee,distance = getNewTarget(zombie) if newTarget and doesSee and distance < distanceToPlayer and newTarget ~= zombieData[zombie].target then triggerServerEvent("Zday:setZombieNewTarget",zombie,newTarget) end end if getDistanceBetweenPoints3D(zVector,lVector) > 100 then triggerServerEvent("Zday:destroyZombie",zombie) end if zombieData[zombie].hunting then if not zombieData[zombie].positions then zombieData[zombie].positions = 0 end if not zombieData[zombie].paths then zombieData[zombie].paths = {} end local dist = false if #zombieData[zombie].paths > 1 then local llx,lly,llz = unpack(zombieData[zombie].paths[#zombieData[zombie].paths-1]) dist = getDistanceBetweenPoints3D(llx,lly,llz,lx,ly,lz) end if dist and dist > 0.7 then table.insert(zombieData[zombie].paths,{lx,ly,lz,getPedControlState(zombieTarget,"jump"),getPedControlState(zombieTarget,"sprint")}) elseif not dist then table.insert(zombieData[zombie].paths,{lx,ly,lz,getPedControlState(zombieTarget,"jump"),getPedControlState(zombieTarget,"sprint")}) end if zombieData[zombie].paths[zombieData[zombie].positions+1] and not zombieData[zombie].eating then local nx,ny,nz,jump,sprint = unpack(zombieData[zombie].paths[zombieData[zombie].positions+1]) local nVector = Vector3(nx,ny,nz) local isClear = isLineOfSightClear(zVector,nVector,true,true,false,true,false,true,true,zombie) local notMoving = false if zombieData[zombie].lastPosition then local dist = getDistanceBetweenPoints3D(zombieData[zombie].lastPosition,zVector) if dist < 0.01 then local action = math.random(1,2) if action == 1 then setPedControlState(zombie,"fire",true) elseif action == 2 then notMoving = true end else setPedControlState(zombie,"fire",false) end end local needToJump = (jump or getPedSimplestTask(zombie) == "TASK_SIMPLE_CLIMB" or arePedLegsBlocked(zombie) or notMoving) if needToJump then if (getPedMoveState(zombie) ~= "jump" or getPedMoveState(zombie) ~= "climb") then setPedControlState(zombie,"forwards",false) end if sprint then setPedControlState(zombie,"sprint",true) end setPedControlState(zombie,"jump",true) else setPedControlState(zombie,"sprint",false) setPedControlState(zombie,"jump",false) end local dist = getDistanceBetweenPoints2D(zVector.x,zVector.y,nVector.x,nVector.y) local pathDistance = getZombieCalculatedPathDistance(zombie) local diff = pathDistance/distanceToPlayer if pathDistance > distanceToPlayer and diff > 1.1 and doesZombieSeePlayer then zombieData[zombie].paths = {} zombieData[zombie].positions = 0 zombieData[zombie].changingPath = true zombieData[zombie].changePathTick = getTickCount() end if zombieData[zombie].changingPath then if (getTickCount() - zombieData[zombie].changePathTick) > 500 then zombieData[zombie].changingPath = nil zombieData[zombie].changePathTick = nil end end local angle = rot(zVector.x,zVector.y,nVector.x,nVector.y) local mutatedZombie = getElementData(zombie, "mutatedZombie") setPedCameraRotation(zombie,-angle) setPedControlState(zombie,"forwards",true) if mutatedZombie == "Runner" then setPedControlState(zombie,"sprint",true) end if zombie.inWater then setElementRotation(zombie,0,0,angle) setPedControlState(zombie,"sprint",true) elseif not sprint then if mutatedZombie == "Runner" then setPedControlState(zombie,"sprint",true) else setPedControlState(zombie,"sprint",false) end end zombieData[zombie].lastPosition = Vector3(getElementPosition(zombie)) if isClear and dist < 1 then zombieData[zombie].positions = zombieData[zombie].positions + 1 end if getDistanceBetweenPoints3D(zVector,lVector) < 4 then if getPedControlState(zombie, "sprint") == true then setPedControlState(zombie, "sprint", false) end end else if getDistanceBetweenPoints3D(zVector,lVector) > 100 then triggerServerEvent("Zday:destroyZombie",zombie) elseif isPedDead(zombie) == false and getDistanceBetweenPoints3D(zVector,lVector) < 2 and not playersDoomed[zombieTarget] then murderPlayerByZombie(zombieTarget,zombie) if isPedDead(zombieTarget) then playersDoomed[zombieTarget] = true end elseif getDistanceBetweenPoints3D(zVector,lVector) < 1 and ((isPedDead(zombieTarget) or zombieTarget.health<1) and playersEatable[zombieTarget] and not playerEated[zombieTarget]) then playerEated[zombieTarget] = true zombieData[zombie].eating = true setPedAnimation(zombie,"MEDIC","cpr",-1,false,true,false) setTimer(resetZombieAnimation,10000,1,zombie) end if getDistanceBetweenPoints3D(zVector,lVector) < 4 then if getPedControlState(zombie, "sprint") == true then setPedControlState(zombie, "sprint", false) end end setPedControlState(zombie,"forwards",false) end else if doesZombieSeePlayer and not zombieData[zombie].hunting then zombieData[zombie].hunting = true zombieData[zombie].positions = 0 elseif not zombieData[zombie].hunting then local newTarget = getNewTarget(zombie,localPlayer),doesSee if newTarget and doesSee and not zombieData[zombie].changingTarget then triggerServerEvent("Zday:setZombieNewTarget",zombie,newTarget) zombieData[zombie].changingTarget = true end end if not zombieData[zombie].changingPath then setPedControlState(zombie,"forwards",false) end end else setPedControlState(zombie,"forwards",false) triggerServerEvent("Zday:delayDestroyZombie", zombie) end end timesExecuted=timesExecuted+1 end setTimer(trackMe,100,0) client follow func. syncer(Server): local function setZombieTarget(zombie,target) if target and isElement(target) then triggerClientEvent(root,"Zday:setZombieTarget",zombie,zombie,target) zombieTargets[zombie] = target if getElementSyncer(zombie) ~= target then setElementSyncer(zombie,target) end end end overall nothings wrong, it's just the sync.
  7. Bean666

    Sync peds?

    it says valid 50-4000 so yeah maybe 100 is valid though idk ill try.
  8. Bean666

    Sync peds?

    will 100 hurt the server? as when i start the script an info is saying it needs to set ped sync interval to a 100.
  9. might be related to that.
  10. Bean666

    Sync peds?

    Hi, this script works fine if you're seeing it on your own perspective, you could see the zombies walking smoothly and fine, but when you see others being chased by their own zombies, the zombies is kinda laggy and kinda slow, is there anyway to sync with other players on what you're seeing as well? this is a clientside script so. yeah that might be the problem but im sure there might be something? the peds are created serverside, but the chase function is on client. Chase function: local function trackMe() local zombies = getElementsByType("ped",resourceRoot,true) for index,zombie in ipairs(zombies) do if math.random(1,60) == 15 and isPedDead(zombie) == false then local sound = playSound3D("sounds/mgroan"..tostring(math.random(1,10))..".ogg",zombie.position) setSoundMaxDistance(sound, 30) end local zombieTarget = zombieData[zombie].target if zombieTarget and isElement(zombieTarget) then local lx,ly,lz = getElementPosition(zombieTarget) local lVector = Vector3(lx,ly,lz) local hVector = Vector3(getPedBonePosition(zombie,6)) local zVector = Vector3(getElementPosition(zombie)) local doesZombieSeePlayer = isLineOfSightClear(hVector,lVector,true,false,false,true,false,true,true,zombie) local distanceToPlayer = getDistanceBetweenPoints2D(zVector.x,zVector.y,lVector.x,lVector.y) if timesExecuted%5 == 0 and zombieData[zombie].target == localPlayer then local newTarget,doesSee,distance = getNewTarget(zombie) if newTarget and doesSee and distance < distanceToPlayer and newTarget ~= zombieData[zombie].target then triggerServerEvent("Zday:setZombieNewTarget",zombie,newTarget) end end if zombieData[zombie].target == localPlayer and doesZombieSeePlayer == false and isPedDead(zombieTarget)==false then local newTarget,doesSee = getNewTarget(zombie,localPlayer) if newTarget and doesSee and newTarget ~= zombieData[zombie].target then triggerServerEvent("Zday:setZombieNewTarget",zombie,newTarget) end end if zombieData[zombie].hunting then if not zombieData[zombie].positions then zombieData[zombie].positions = 0 end if not zombieData[zombie].paths then zombieData[zombie].paths = {} end local dist = false if #zombieData[zombie].paths > 1 then local llx,lly,llz = unpack(zombieData[zombie].paths[#zombieData[zombie].paths-1]) dist = getDistanceBetweenPoints3D(llx,lly,llz,lx,ly,lz) end if dist and dist > 0.7 then table.insert(zombieData[zombie].paths,{lx,ly,lz,getPedControlState(zombieTarget,"jump"),getPedControlState(zombieTarget,"sprint")}) elseif not dist then table.insert(zombieData[zombie].paths,{lx,ly,lz,getPedControlState(zombieTarget,"jump"),getPedControlState(zombieTarget,"sprint")}) end if zombieData[zombie].paths[zombieData[zombie].positions+1] and not zombieData[zombie].eating then local nx,ny,nz,jump,sprint = unpack(zombieData[zombie].paths[zombieData[zombie].positions+1]) local nVector = Vector3(nx,ny,nz) local isClear = isLineOfSightClear(zVector,nVector,true,true,false,true,false,true,true,zombie) local notMoving = false if zombieData[zombie].lastPosition then local dist = getDistanceBetweenPoints3D(zombieData[zombie].lastPosition,zVector) if dist < 0.01 then local action = math.random(1,2) if action == 1 then setPedControlState(zombie,"fire",true) elseif action == 2 then notMoving = true end else setPedControlState(zombie,"fire",false) end end local needToJump = (jump or getPedSimplestTask(zombie) == "TASK_SIMPLE_CLIMB" or arePedLegsBlocked(zombie) or notMoving) if needToJump then if (getPedMoveState(zombie) ~= "jump" or getPedMoveState(zombie) ~= "climb") then setPedControlState(zombie,"forwards",false) end if sprint then setPedControlState(zombie,"sprint",true) end setPedControlState(zombie,"jump",true) else setPedControlState(zombie,"sprint",false) setPedControlState(zombie,"jump",false) end local dist = getDistanceBetweenPoints2D(zVector.x,zVector.y,nVector.x,nVector.y) local pathDistance = getZombieCalculatedPathDistance(zombie) local diff = pathDistance/distanceToPlayer if pathDistance > distanceToPlayer and diff > 1.1 and doesZombieSeePlayer then zombieData[zombie].paths = {} zombieData[zombie].positions = 0 zombieData[zombie].changingPath = true zombieData[zombie].changePathTick = getTickCount() end if zombieData[zombie].changingPath then if (getTickCount() - zombieData[zombie].changePathTick) > 500 then zombieData[zombie].changingPath = nil zombieData[zombie].changePathTick = nil end end local angle = rot(zVector.x,zVector.y,nVector.x,nVector.y) setPedCameraRotation(zombie,-angle) setPedControlState(zombie,"forwards",true) if zombie.inWater then setElementRotation(zombie,0,0,angle) setPedControlState(zombie,"sprint",true) elseif not sprint then setPedControlState(zombie,"sprint",false) end zombieData[zombie].lastPosition = Vector3(getElementPosition(zombie)) if isClear and dist < 1 then zombieData[zombie].positions = zombieData[zombie].positions + 1 end else if isPedDead(zombie) == false and getDistanceBetweenPoints3D(zVector,lVector) < 1 and not playersDoomed[zombieTarget] then murderPlayerByZombie(zombieTarget,zombie) if isPedDead(zombieTarget) then playersDoomed[zombieTarget] = true end elseif getDistanceBetweenPoints3D(zVector,lVector) < 1 and ((isPedDead(zombieTarget) or zombieTarget.health<1) and playersEatable[zombieTarget] and not playerEated[zombieTarget]) then playerEated[zombieTarget] = true zombieData[zombie].eating = true setPedAnimation(zombie,"MEDIC","cpr",-1,false,true,false) setTimer(resetZombieAnimation,10000,1,zombie) end setPedControlState(zombie,"forwards",false) end else if doesZombieSeePlayer and not zombieData[zombie].hunting then zombieData[zombie].hunting = true zombieData[zombie].positions = 0 elseif not zombieData[zombie].hunting then local newTarget = getNewTarget(zombie,localPlayer),doesSee if newTarget and doesSee and not zombieData[zombie].changingTarget then triggerServerEvent("Zday:setZombieNewTarget",zombie,newTarget) zombieData[zombie].changingTarget = true end end if not zombieData[zombie].changingPath then setPedControlState(zombie,"forwards",false) end end else setPedControlState(zombie,"forwards",false) end end timesExecuted=timesExecuted+1 end setTimer(trackMe,100,0)
  11. Hi i got this zombie script from the community by dutchman, even though the max zombies is set to 5 and the spawnZombie function has a check as well if #zombiesChasingMe >= maxZombies it still exceeds the limit, more zombies are still spawning than the maxZombies value. local maxZombies = 5 --Max zombies to chase local player local minDistance = 10 --Minium distance from player to keep zombies spawning local maxDistance = 30 --Maximum distance to spawn zombies local minInterval = 2000 --Minium time between spawning zombies local maxInterval = 5000 --Maximum time between spawning zombies local zombieData = {skins={10, 11, 12, 13, 14, 15}} local zombiesChasingMe = {} local playersDoomed = {} local timesExecuted = 0 local playersEatable = {} local playerEated = {} local colshapes = {} local mySteps = {} local function rot( x1, y1, x2, y2 ) local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) return t < 0 and t + 360 or t end local function getZombieCalculatedPathDistance(zombie) local currentIndex = zombieData[zombie].positions local distance = 0 if currentIndex < #zombieData[zombie].paths then for index = currentIndex,#zombieData[zombie].paths do if zombieData[zombie].paths[index] and zombieData[zombie].paths[index+1] then local ox,oy = unpack(zombieData[zombie].paths[index]) local nx,ny = unpack(zombieData[zombie].paths[index+1]) distance = distance + getDistanceBetweenPoints2D(ox,oy,nx,ny) end end else local zVector = zombie.position local npVector = zombieData[zombie].paths[currentIndex]+1 distance = getDistanceBetweenPoints2D(zVector.x,zVector.y,npVector.x,npVector.y) end return distance end local function isZombieChasingMe(zombieToCheck,removeIt) for index,zombie in ipairs(zombiesChasingMe) do if zombie == zombieToCheck then if removeIt then table.remove(zombiesChasingMe,index) end return zombie end end end local function onDamage(attacker,weapon,bodypart,loss) if attacker and isElement(attacker) and attacker == localPlayer then triggerServerEvent("Zday:damageZombie",source,attacker,weapon,bodypart,loss) end end local function onWasted(killer) if zombieData[source].doomed then return end zombieData[source].doomed = true triggerServerEvent("Zday:delayDestroyZombie",source) end local function onDestroy() isZombieChasingMe(source,true) if zombieData[source].syncCol and isElement(zombieData[source].syncCol) then destroyElement(zombieData[source].syncCol) end zombieData[source] = nil end local function resetPlayer() playersDoomed[source] = nil playersEatable[source] = nil playerEated[source] = nil end local function setPlayerEatable(player) playersEatable[player] = true end local function murderPlayerByZombie(player,zombie) if not getElementData(zombie, "groaning") == true then playSound3D("sounds/mgroan"..tostring(math.random(1,10))..".ogg",zombie.position) setElementData(zombie, "groaning", true) setTimer(setElementData, 3000, 1, zombie, "groaning", false) end if player == localPlayer then triggerServerEvent("Zday:murderPlayer",localPlayer,zombie) end end local function arePedLegsBlocked(zombie) local upperTorsoVec = Vector3(getPedBonePosition(zombie,4)) local legVec = Vector3(getPedBonePosition(zombie,54)) local forwardVec = zombie.matrix.position + (zombie.matrix.forward/2) local x,y = upperTorsoVec.x,upperTorsoVec.y local x2,y2 = forwardVec.x,forwardVec.y local notClear = false for z=legVec.z,upperTorsoVec.z,0.05 do if not isLineOfSightClear(x,y,z,x2,y2,z,true,true,false,true,false,true,true,zombie) then notClear=true break end end return notClear end local function checkPlayer(player,col) if not isElement(player) then return false end if not isElement(col) then return end if not colshapes[col] then return false end if player.type ~= "player" then return false end if player.dimension ~= col.dimension then return false end if player.interior ~= col.interior then return false end return true,colshapes[col] end local function comp(w1,w2) if w1[2] < w2[2] then return true end return false end local function getNewTarget(zombie,excludedTarget) local col = zombieData[zombie].syncCol local players = getElementsWithinColShape(col,"player") local possibleTargets = {} local alternativeReturn = false local isClear = false for index,player in ipairs(players) do if checkPlayer(player,col) and player ~= excludedTarget and player ~= zombieData[zombie].target then local distance = getDistanceBetweenPoints2D(zombie.position,player.position) if distance < 80 then table.insert(possibleTargets,{player,distance}) isClear = isLineOfSightClear(zombie.position,player.position,true,false,false,true,false,true,true,zombie) alternativeReturn=true end end end if not alternativeReturn then return false end table.sort(possibleTargets,comp) local target,distance2 = unpack(possibleTargets[1]) return target,isClear,distance2 end local function resetZombieAnimation(zombie) if zombie and isElement(zombie) then setPedAnimation(zombie) zombieData[zombie].eating = nil end end local function findNewTarget(player) local valid,zombie = checkPlayer(player,source) if not valid then return end if player ~= zombieData[zombie].target then return end if player ~= localPlayer then return end local newTarget = getNewTarget(zombie) if newTarget and newTarget ~= localPlayer and newTarget ~= zombieData[zombie].target then triggerServerEvent("Zday:setZombieNewTarget",zombie,newTarget) elseif not zombieData[zombie].doomed then zombieData[zombie].doomed = true triggerLatentServerEvent("Zday:destroyZombie",5000,true,zombie) end end local function trackMe() local zombies = getElementsByType("ped",resourceRoot,true) for index,zombie in ipairs(zombies) do if math.random(1,40) == 5 and isPedDead(zombie) == false then playSound3D("sounds/mgroan"..tostring(math.random(1,10))..".ogg",zombie.position) end local zombieTarget = zombieData[zombie].target if zombieTarget and isElement(zombieTarget) then local lx,ly,lz = getElementPosition(zombieTarget) local lVector = Vector3(lx,ly,lz) local hVector = Vector3(getPedBonePosition(zombie,6)) local zVector = Vector3(getElementPosition(zombie)) local doesZombieSeePlayer = isLineOfSightClear(hVector,lVector,true,false,false,true,false,true,true,zombie) local distanceToPlayer = getDistanceBetweenPoints2D(zVector.x,zVector.y,lVector.x,lVector.y) if timesExecuted%5 == 0 and zombieData[zombie].target == localPlayer then local newTarget,doesSee,distance = getNewTarget(zombie) if newTarget and doesSee and distance < distanceToPlayer and newTarget ~= zombieData[zombie].target then triggerServerEvent("Zday:setZombieNewTarget",zombie,newTarget) end end if zombieData[zombie].target == localPlayer and doesZombieSeePlayer == false and isPedDead(zombieTarget)==false then local newTarget,doesSee = getNewTarget(zombie,localPlayer) if newTarget and doesSee and newTarget ~= zombieData[zombie].target then triggerServerEvent("Zday:setZombieNewTarget",zombie,newTarget) end end if zombieData[zombie].hunting then if not zombieData[zombie].positions then zombieData[zombie].positions = 0 end if not zombieData[zombie].paths then zombieData[zombie].paths = {} end local dist = false if #zombieData[zombie].paths > 1 then local llx,lly,llz = unpack(zombieData[zombie].paths[#zombieData[zombie].paths-1]) dist = getDistanceBetweenPoints3D(llx,lly,llz,lx,ly,lz) end if dist and dist > 0.7 then table.insert(zombieData[zombie].paths,{lx,ly,lz,getPedControlState(zombieTarget,"jump"),getPedControlState(zombieTarget,"sprint")}) elseif not dist then table.insert(zombieData[zombie].paths,{lx,ly,lz,getPedControlState(zombieTarget,"jump"),getPedControlState(zombieTarget,"sprint")}) end if zombieData[zombie].paths[zombieData[zombie].positions+1] and not zombieData[zombie].eating then local nx,ny,nz,jump,sprint = unpack(zombieData[zombie].paths[zombieData[zombie].positions+1]) local nVector = Vector3(nx,ny,nz) local isClear = isLineOfSightClear(zVector,nVector,true,true,false,true,false,true,true,zombie) local notMoving = false if zombieData[zombie].lastPosition then local dist = getDistanceBetweenPoints3D(zombieData[zombie].lastPosition,zVector) if dist < 0.01 then local action = math.random(1,2) if action == 1 then setPedControlState(zombie,"fire",true) elseif action == 2 then notMoving = true end else setPedControlState(zombie,"fire",false) end end local needToJump = (jump or getPedSimplestTask(zombie) == "TASK_SIMPLE_CLIMB" or arePedLegsBlocked(zombie) or notMoving) if needToJump then if (getPedMoveState(zombie) ~= "jump" or getPedMoveState(zombie) ~= "climb") then setPedControlState(zombie,"forwards",false) end if sprint then setPedControlState(zombie,"sprint",true) end setPedControlState(zombie,"jump",true) else setPedControlState(zombie,"sprint",false) setPedControlState(zombie,"jump",false) end local dist = getDistanceBetweenPoints2D(zVector.x,zVector.y,nVector.x,nVector.y) local pathDistance = getZombieCalculatedPathDistance(zombie) local diff = pathDistance/distanceToPlayer if pathDistance > distanceToPlayer and diff > 1.1 and doesZombieSeePlayer then zombieData[zombie].paths = {} zombieData[zombie].positions = 0 zombieData[zombie].changingPath = true zombieData[zombie].changePathTick = getTickCount() end if zombieData[zombie].changingPath then if (getTickCount() - zombieData[zombie].changePathTick) > 500 then zombieData[zombie].changingPath = nil zombieData[zombie].changePathTick = nil end end local angle = rot(zVector.x,zVector.y,nVector.x,nVector.y) setPedCameraRotation(zombie,-angle) setPedControlState(zombie,"forwards",true) if zombie.inWater then setElementRotation(zombie,0,0,angle) setPedControlState(zombie,"sprint",true) elseif not sprint then setPedControlState(zombie,"sprint",false) end zombieData[zombie].lastPosition = Vector3(getElementPosition(zombie)) if isClear and dist < 1 then zombieData[zombie].positions = zombieData[zombie].positions + 1 end else if isPedDead(zombie) == false and getDistanceBetweenPoints3D(zVector,lVector) < 1 and not playersDoomed[zombieTarget] then murderPlayerByZombie(zombieTarget,zombie) if isPedDead(zombieTarget) then playersDoomed[zombieTarget] = true end elseif getDistanceBetweenPoints3D(zVector,lVector) < 1 and ((isPedDead(zombieTarget) or zombieTarget.health<1) and playersEatable[zombieTarget] and not playerEated[zombieTarget]) then playerEated[zombieTarget] = true zombieData[zombie].eating = true setPedAnimation(zombie,"MEDIC","cpr",-1,false,true,false) setTimer(resetZombieAnimation,10000,1,zombie) end setPedControlState(zombie,"forwards",false) end else if doesZombieSeePlayer and not zombieData[zombie].hunting then zombieData[zombie].hunting = true zombieData[zombie].positions = 0 elseif not zombieData[zombie].hunting then local newTarget = getNewTarget(zombie,localPlayer),doesSee if newTarget and doesSee and not zombieData[zombie].changingTarget then triggerServerEvent("Zday:setZombieNewTarget",zombie,newTarget) zombieData[zombie].changingTarget = true end end if not zombieData[zombie].changingPath then setPedControlState(zombie,"forwards",false) end end else setPedControlState(zombie,"forwards",false) end end timesExecuted=timesExecuted+1 end local function getPointFromDistanceRotation(x, y, dist, angle) local a = math.rad(90 - angle); local dx = math.cos(a) * dist; local dy = math.sin(a) * dist; return x+dx, y+dy; end local function spawnZombie() if #zombiesChasingMe >= maxZombies then setTimer(spawnZombie,math.random(minInterval,maxInterval),1) return end local x,y,z = getElementPosition(localPlayer) local dist = math.random(minDistance,maxDistance) local _,_,_,_,_,_,_,fov = getCameraMatrix() local cr = getPedCameraRotation(localPlayer)+(getPedControlState(localPlayer,"look_behind") and 0 or 180) if cr > 360 then cr = cr-360 end local r = math.random(cr-fov,cr+fov) local zx,zy = getPointFromDistanceRotation(x,y,dist,r) local zz = false for tz = z,550 do local newZ = getGroundPosition(zx,zy,tz) if newZ and newZ ~= 0 then zz = newZ+1 break end end if not zz then zz = z+3 end if not isLineOfSightClear(x,y,z,zx,zy,zz,true,false,false,true,false,true,true,localPlayer) then return setTimer(spawnZombie,500,1) end local zr = rot(x,y,zx,zy) local s = zombieData.skins[math.random(1,#zombieData.skins)] triggerServerEvent("Zday:spawnZombie",localPlayer,s,zx,zy,zz,zr) setTimer(spawnZombie,math.random(minInterval,maxInterval),1) end local function lookForNewTarget(excludedTarget) local newTarget = getNewTarget(source,excludedTarget,true) if isElement(newTarget) and not zombieData[source].target ~= newTarget then triggerServerEvent("Zday:setZombieNewTarget",zombie,newTarget) elseif not zombieData[source].doomed then zombieData[source].doomed = true triggerLatentServerEvent("Zday:destroyZombie",5000,true,source) end end local function setZombieTarget(zombie,targett) if not zombieData[zombie] then zombieData[zombie] = {} end if not zombieData[zombie].handled then addEventHandler("onClientPedDamage",zombie,onDamage) addEventHandler("onClientPedWasted",zombie,onWasted) addEventHandler("onClientElementDestroy",zombie,onDestroy) addEventHandler("Zday:askForNewTarget",zombie,lookForNewTarget) zombieData[zombie].handled = true end if not zombieData[zombie].syncCol then zombieData[zombie].syncCol = createColSphere(zombie.position,80) colshapes[zombieData[zombie].syncCol] = zombie attachElements(zombieData[zombie].syncCol,zombie) addEventHandler("onClientColShapeLeave",zombieData[zombie].syncCol,findNewTarget) end zombieData[zombie].target = targett isZombieChasingMe(zombie,true) if target == localPlayer then table.insert(zombiesChasingMe,zombie) end end local function getZombiesInfo(zombiesReceived) for zombie,target in pairs(zombiesReceived) do setZombieTarget(zombie,target) end end local function initScript() for _,id in ipairs(zombieData.skins) do local txd = engineLoadTXD("skins/"..tostring(id)..".txd") engineImportTXD(txd,id) local dff = engineLoadDFF("skins/"..tostring(id)..".dff") engineReplaceModel(dff,id) end for _,zombie in ipairs(getElementsByType("ped",resourceRoot)) do zombieData[zombie] = {} addEventHandler("onClientPedDamage",zombie,onDamage) addEventHandler("onClientPedWasted",zombie,onWasted) addEventHandler("onClientElementDestroy",zombie,onDestroy) addEventHandler("Zday:askForNewTarget",zombie,lookForNewTarget) zombieData[zombie].handled = true zombieData[zombie].syncCol = createColSphere(zombie.position,80) colshapes[zombieData[zombie].syncCol] = zombie attachElements(zombieData[zombie].syncCol,zombie) addEventHandler("onClientColShapeLeave",zombieData[zombie].syncCol,findNewTarget) end addEvent("Zday:askForNewTarget",true) addEvent("Zday:setZombieTarget",true) addEvent("Zday:sendZombiesInfo",true) addEventHandler("Zday:sendZombiesInfo",localPlayer,getZombiesInfo) addEventHandler("Zday:setZombieTarget",resourceRoot,setZombieTarget) addEventHandler("onClientPlayerSpawn",root,resetPlayer) setTimer(trackMe,100,0) setTimer(spawnZombie,math.random(minInterval,maxInterval),1) triggerServerEvent("Zday:getZombiesInfo",localPlayer) end addEventHandler("onClientResourceStart",resourceRoot,initScript) --MAKES A ZOMBIE PUNCH addEvent( "ZOMB_PUNCH", true ) function Zpunch ( zombie ) if (isElement(zombie)) then setPedControlState( zombie, "fire", true ) setTimer ( function (zombie) if ( isElement ( zombie ) ) then setPedControlState ( zombie, "fire", false) end end, 500, 1, zombie ) end end addEventHandler( "ZOMB_PUNCH", root, Zpunch ) --STFU ZOMBIE addEvent( "Zomb_STFU", true ) function Zstfu ( zombie ) if (isElement(zombie)) then setPedVoice(zombie, "PED_TYPE_DISABLED") end end addEventHandler( "Zomb_STFU", root, Zstfu ) -- More damage ZOMBIE function zombieattack ( attacker, weapon, bodypart ) if (attacker) then if getElementType ( attacker ) == "ped" then if (getElementData (attacker, "zombie") == true) then if getElementData(source, "threat") == "high" then local timehour, timeminute = getTime() if timehour == 21 or timehour == 22 or timehour == 23 or timehour == 0 or timehour == 1 or timehour == 2 or timehour == 3 or timehour == 4 then if not getElementData(attacker, "zombieSpecial") then setElementHealth(source, getElementHealth(getLocalPlayer())-10) end end end local playerHealth = getElementHealth ( getLocalPlayer() ) local mutatedZombie = getElementData(attacker, "mutatedZombie") local zombieSpecial = getElementData(attacker, "zombieSpecial") local model = getElementModel(attacker) if playerHealth > 15 then if mutatedZombie == "Armored" or mutatedZombie == "Brute" or mutatedZombie == "Mutated" then setElementHealth ( source, playerHealth - 40 ) elseif mutatedZombie == "Abomination" then setElementHealth ( source, playerHealth - 80 ) elseif model == 49 then setElementHealth ( source, playerHealth - 40 ) elseif zombieSpecial then setElementHealth ( source, playerHealth - 30 ) elseif getElementData(attacker, "zombie") then setElementHealth ( source, playerHealth - 10 ) end end end end end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), zombieattack )
  12. so basically i just replace the if attacker == localPlayer to this? says element at arg 1 nil.
  13. as long as it does not affect player damages it would be fine for me. But the player damages wont duplicate now right? only for the peds, since there's no really local ped thingy
  14. function botdamaged ( attacker, weapon, bodypart ) if getElementType ( source ) == "ped" then local bot = getElementData(source, "bot") local settlementguard = getElementData(source, "settlementguard") local boss = getElementData(source, "boss") local zombie = getElementData(source, "zombie") local zombieSpecial = getElementData(source, "zombieSpecial") if attacker == localPlayer then if boss then triggerServerEvent ("bossdamages", source, source, attacker, weapon, bodypart ) cancelEvent() elseif settlementguard then local playerTeam = getPlayerTeam(attacker) local teamName = getTeamName(playerTeam) local teamData = getElementData(source, "settlementguard") if teamName == teamData then exports.amhelp:helpmessage("You cannot kill friendlies!", 255, 0, 0) cancelEvent() else triggerServerEvent ("botdamages", source, source, attacker, weapon, bodypart ) cancelEvent() end elseif bot or zombieSpecial then triggerServerEvent ("botdamages", source, source, attacker, weapon, bodypart ) cancelEvent() end if boss == "Mutant" then if attacker and attacker == localPlayer then if isTimer(participatetimer) then killTimer(participatetimer) setElementData(attacker, "bossparticipated", true) end participatetimer = setTimer(function() setElementData(attacker, "bossparticipated", false) end, 240000, 1) end end elseif attacker and getElementType(attacker) == "ped" then if zombie then --- source triggerServerEvent ("botdamages", source, source, attacker, weapon, bodypart ) elseif bot then triggerServerEvent ("botdamages", source, source, attacker, weapon, bodypart ) end end end end addEventHandler ( "onClientPedDamage", root, botdamaged) I added it now, i also added an elseif if the attacker is a ped, would that be fine?
  15. Hi why is the damage being duplicated whenever there are more than one players in the server? if i'm testing by myself it works fine, but whenever there are like 3-4 players, this goes glitched and the elementdatas/ damage counts are duplicating. it only happens if there are more than 1 player in the server and it's weird. Client: function botdamaged ( attacker, weapon, bodypart ) if getElementType ( source ) == "ped" then local bot = getElementData(source, "bot") local settlementguard = getElementData(source, "settlementguard") local boss = getElementData(source, "boss") local zombie = getElementData(source, "zombie") local zombieSpecial = getElementData(source, "zombieSpecial") if boss then triggerServerEvent ("bossdamages", source, source, attacker, weapon, bodypart ) cancelEvent() elseif settlementguard then if attacker then if getElementType(attacker) == "player" then local playerTeam = getPlayerTeam(attacker) local teamName = getTeamName(playerTeam) local teamData = getElementData(source, "settlementguard") if teamName == teamData then exports.amhelp:helpmessage("You cannot kill friendlies!", 255, 0, 0) cancelEvent() else triggerServerEvent ("botdamages", source, source, attacker, weapon, bodypart ) cancelEvent() end else triggerServerEvent ("botdamages", source, source, attacker, weapon, bodypart ) cancelEvent() end end elseif bot or zombieSpecial then triggerServerEvent ("botdamages", source, source, attacker, weapon, bodypart ) cancelEvent() elseif zombie then if attacker and getElementType(attacker) == "ped" then triggerServerEvent ("botdamages", source, source, attacker, weapon, bodypart ) end end if boss == "Mutant" then if attacker and attacker == localPlayer then if isTimer(participatetimer) then killTimer(participatetimer) setElementData(attacker, "bossparticipated", true) end participatetimer = setTimer(function() setElementData(attacker, "bossparticipated", false) end, 240000, 1) end end end end addEventHandler ( "onClientPedDamage", root, botdamaged) Server: local shotguns = { [27] = true, [25] = true, [26] = true } local assaultrifles = { [31] = true, [30] = true } local lightweapons = { [29] = true, [32] = true, [28] = true, [23] = true, [22] = true } local snipers = { [33] = true, [34] = true } local heavybullets = { [24] = true, [38] = true } addEvent( "botdamages", true ) function botdamages( ped,attacker, weapon, bodypart) local bot = getElementData(ped, "bot") local zombie = getElementData(ped, "zombie") local zombieSpecial = getElementData(ped, "zombieSpecial") local health = getElementData(ped, "elementHealth") if bot or zombieSpecial then if attacker and getElementType(attacker) == "ped" then if getElementData(attacker, "zombie") == true then setElementData(ped, "elementHealth", tonumber(health) - math.random(50,60)) else setElementData(ped, "elementHealth", tonumber(health) - math.random(30,45)) end if getElementData(ped, "elementHealth") < 20 then killPed(ped, attacker, weapon, bodypart ) end else if shotguns[weapon] then setElementData(ped, "elementHealth", tonumber(health) - math.random(50,60)) else if assaultrifles[weapon] then setElementData(ped, "elementHealth", tonumber(health) - math.random(30,45)) elseif lightweapons[weapon] then setElementData(ped, "elementHealth", tonumber(health) - math.random(20,25)) elseif snipers[weapon] then setElementData(ped, "elementHealth", tonumber(health) - math.random(250,300)) elseif heavybullets[weapon] then setElementData(ped, "elementHealth", tonumber(health) - math.random(70,100)) end end if getElementData(ped, "elementHealth") < 20 then killPed(ped, attacker, weapon, bodypart ) end end elseif zombie then if attacker and getElementType(attacker) == "ped" then local health = getElementHealth(ped) setElementHealth(ped, health-20) if health < 30 then killPed(ped, attacker, weapon, bodypart ) end end end end addEventHandler( "botdamages", root, botdamages )
  16. Bean666

    Rotation?

    How do I make a ped facing towards me? ex: ik getElementPosition wont work with rotations but how do I get a ped to know my position and face towards it? local pedTest = createPed(34, -454.654296875, 2716.099609375, 63.490333557129) function testRotate() local x, y, z = getElementPosition(localPlayer) setElementRotation( pedTest, x, y, z ) end
  17. Hi i'm trying to do a knockback effect, but instead idk how to calculate player's position, all i can do is to set him flying upwards which I want backwards, i want him to be thrown backwards wherever he's facing, like if he's facing north he will be knocked south, if im facing west i will be knocked east, how do I do that? addEventHandler( "onClientRender",root, function( ) local flying = getElementData(localPlayer, "knockback") local x, y, z = getElementPosition(localPlayer) if knockback then setElementPosition(localPlayer, x, y, z+0.5) end end )
  18. NOTE: READ BELOW FOR THE NEW UPDATES
  19. function stopmusic() if isElement(bossmusic) then fadeout = setTimer(function() if isElement(bossmusic) then volume = getSoundVolume(bossmusic) setSoundVolume(bossmusic, volume-0.1) end end, 1000, 0) removefade = setTimer(function() killTimer(fadeout) stopSound(bossmusic) end, 15000, 1) end end addEvent("stopmusic", true) addEventHandler("stopmusic", root, stopmusic) basically like this? i add another revalidation. i got what u meant but is this right?
  20. Hi i tried to do a fade out effect when stopping music, but I did it poorly, it works fine no errors, but sometimes it gives an error, it says bad sound pointer? especially when we're more than 3 players that have the music played. at the volume variable and the setSoundVolume(bossmusic, volume-0.1) function bossmusic() if isTimer(fadeout) then stopSound(bossmusic) killTimer(fadeout) end if isTimer(removefade) then killTimer(removefade) end bossmusic = playSound("sounds/theme.mp3", true) setSoundVolume(bossmusic, 0.7) end addEvent("playmusic", true) addEventHandler("playmusic", root, bossmusic) function stopmusic() if isElement(bossmusic) then fadeout = setTimer(function() volume = getSoundVolume(bossmusic) setSoundVolume(bossmusic, volume-0.1) end, 1000, 0) removefade = setTimer(function() killTimer(fadeout) stopSound(bossmusic) end, 15000, 1) end end addEvent("stopmusic", true) addEventHandler("stopmusic", root, stopmusic)
  21. Bean666

    ACL rights

    Hi, i have the ACL functions false on this ACL, but has resources functions, but why this ACL can still add / remove objects from ACL / Group? <group name="L4 Staff"> <acl name="L1 Staff"></acl> <acl name="L2 Staff"></acl> <acl name="L3 Staff"></acl> <acl name="L4 Staff"></acl> <object name="user.testacl"></object> </group> <acl name="L4 Staff"> <right name="function.addBan" access="true"></right> <right name="function.setUnbanTime" access="true"></right> <right name="function.setBanAdmin" access="true"></right> <right name="function.setBanReason" access="true"></right> <right name="function.setBanNick" access="true"></right> <right name="function.removeBan" access="true"></right> <right name="function.reloadBans" access="true"></right> <right name="function.refreshResources" access="true"></right> <right name="function.setPlayerScriptDebugLevel" access="true"></right> <right name="general.adminpanel" access="true"></right> <right name="general.tab_players" access="true"></right> <right name="general.tab_resources" access="true"></right> <right name="general.tab_maps" access="true"></right> <right name="general.tab_server" access="true"></right> <right name="general.tab_bans" access="true"></right> <right name="general.tab_adminchat" access="true"></right> <right name="command.kick" access="true"></right> <right name="command.freeze" access="true"></right> <right name="command.mute" access="true"></right> <right name="command.setnick" access="true"></right> <right name="command.shout" access="true"></right> <right name="command.spectate" access="true"></right> <right name="command.slap" access="true"></right> <right name="command.sethealth" access="true"></right> <right name="command.setarmour" access="true"></right> <right name="command.setmoney" access="true"></right> <right name="command.setskin" access="true"></right> <right name="command.setteam" access="true"></right> <right name="command.giveweapon" access="true"></right> <right name="command.setstat" access="true"></right> <right name="command.jetpack" access="true"></right> <right name="command.warp" access="true"></right> <right name="command.setdimension" access="true"></right> <right name="command.setinterior" access="true"></right> <right name="command.givevehicle" access="true"></right> <right name="command.repair" access="true"></right> <right name="command.blowvehicle" access="true"></right> <right name="command.destroyvehicle" access="true"></right> <right name="command.customize" access="true"></right> <right name="command.setcolor" access="true"></right> <right name="command.setpaintjob" access="true"></right> <right name="command.listmessages" access="true"></right> <right name="command.readmessage" access="true"></right> <right name="command.listresources" access="true"></right> <right name="command.start" access="true"></right> <right name="command.stop" access="true"></right> <right name="command.restart" access="true"></right> <right name="command.setweather" access="true"></right> <right name="command.setwaveheight" access="true"></right> <right name="command.settime" access="true"></right> <right name="command.clearchat" access="true"></right> <right name="command.ban" access="true"></right> <right name="command.unban" access="true"></right> <right name="command.banip" access="true"></right> <right name="command.unbanip" access="true"></right> <right name="command.banserial" access="true"></right> <right name="command.unbanserial" access="true"></right> <right name="command.listbans" access="true"></right> <right name="command.setgroup" access="false"></right> <right name="command.createteam" access="false"></right> <right name="command.destroyteam" access="false"></right> <right name="command.stopall" access="false"></right> <right name="command.delete" access="false"></right> <right name="command.execute" access="false"></right> <right name="command.setpassword" access="false"></right> <right name="command.setwelcome" access="true"></right> <right name="command.setgame" access="false"></right> <right name="command.setmap" access="false"></right> <right name="command.blendweather" access="false"></right> <right name="command.setblurlevel" access="false"></right> <right name="command.setskygradient" access="false"></right> <right name="command.setgamespeed" access="false"></right> <right name="command.setgravity" access="false"></right> <right name="command.setfpslimit" access="false"></right> <right name="function.shutdown" access="false"></right> <right name="function.aclReload" access="false"></right> <right name="function.aclSave" access="false"></right> <right name="function.aclCreate" access="false"></right> <right name="function.aclDestroy" access="false"></right> <right name="function.aclSetRight" access="false"></right> <right name="function.aclRemoveRight" access="false"></right> <right name="function.aclCreateGroup" access="false"></right> <right name="function.aclDestroyGroup" access="false"></right> <right name="function.aclGroupAddACL" access="false"></right> <right name="function.aclGroupAddObject" access="false"></right> <right name="function.aclGroupRemoveObject" access="false"></right> </acl>
  22. Hello i'm tryna make a shop with a gridlist + editbox and a button smth like this: So how do i get to get this work: Ik i'll probably use guiGetText on the editbox but how do I make if in the editbox: 10, the event will trigger 10 times as well or the money needed on a single purchase would be multiplied by 10x and he will get 10x the amount of the single purchase.
  23. Bean666

    Hud problem

    thanks! the only big flaw now of this script is whenever i restart it, we all crash hahahah idk the reason, but yeah it's all good.
×
×
  • Create New...