-Blaze- Posted November 19, 2014 Share Posted November 19, 2014 hello, today i was making a script related to zombies. here it is. well, when the person , who created it , is far away from the zombie , the zombie gets killed. Zombies = createTeam("Zombies") function makeazombie(source) local x, y, z = getElementPosition( source ) zombie = exports [ "slothBot" ]:spawnBot ( x+7, y, z, 90, 285, 0, 0, Zombies, 0,"hunting", true ) setElementData( zombie, "loler", true) gay = setTimer( function () local xL,yL,zL = getElementPosition( zombie ) local xx, yx, zx = getElementPosition( source ) if getDistanceBetweenPoints3D (xx,yx,zx,xL,yL,zL) > 50 then if (zombie) then killPed( zombie ) if (gay) then killTimer(gay) outputChatBox( " the zombie was killed ", source) end end end end, 5000, 0) end addCommandHandler("zombie", makeazombie) But if there are any other players around ( in his range of 50) , when the person gone farther than 50 , then he shoudn't die, so that he can attack the others in his range. But if there is no one in the range of 50 , then he should be killed. Any idea how i can do this? Link to comment
Gallardo9944 Posted November 19, 2014 Share Posted November 19, 2014 You can create collisions 50x50x50 for every zombie and use that for checks Link to comment
-Blaze- Posted November 20, 2014 Author Share Posted November 20, 2014 well , i tried this. col = {} Zombies = createTeam("Zombies") function getElementsWithinMarker(marker) if (not isElement(marker) or getElementType(marker) ~= "marker") then return false end local markerColShape = getElementColShape(marker) local elements = getElementsWithinColShape(markerColShape) return elements end function makeazombie(source) local x, y, z = getElementPosition( source ) zombie = exports [ "slothBot" ]:spawnBot ( x+7, y, z, 90, 285, 0, 0, Zombies, 0,"hunting", true ) setElementData( zombie, "loler", true) col[1] = createMarker( 0, 0, 0, "cylinder", 10, 0, 255, 0, 100) attachElements(col[1], zombie, 0, 0, -1) setElementParent(col[1],zombie) killTimer = setTimer( function() local howmany = getElementsWithinMarker ( col[1] , "player") if (#howmany == 0) then if (zombie) then killPed( zombie ) end end end, 5000, 0) end addCommandHandler("zombie", makeazombie) function test(hitElement, mD) if (source == col[1]) then outputChatBox("you entered", hitElement) end end addEventHandler ( "onMarkerHit", getRootElement(), test ) but it doesn't work. any help? Link to comment
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