Jump to content

Zombies resource (client) modif


synskidz

Recommended Posts

help, i want zombies not chasing local player with the skin id = 293

--THIS CHECKS ALL ZOMBIES EVERY SECOND TO SEE IF THEY ARE IN SIGHT
function zombie_check ()
	if (getElementData (getLocalPlayer (), "zombie") ~= true) and ( isPedDead ( getLocalPlayer () ) == false ) then
		local zombies = getElementsByType ( "ped",getRootElement(),true )
		local id = getElementModel (localPlayer)
		local Px,Py,Pz = getElementPosition( getLocalPlayer () )
		if isPedDucked ( getLocalPlayer ()) then
			local Pz = Pz-1
		end		
		for theKey,theZomb in ipairs(zombies) do
			if (isElement(theZomb)) then
				local Zx,Zy,Zz = getElementPosition( theZomb )
				if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < 45 ) then
					if (getElementData (theZomb, "zombie") == true) then
						if ( getElementData ( theZomb, "status" ) == "idle" ) then --CHECKS IF AN IDLE ZOMBIE IS IN SIGHT
							local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false) 
							if (isclear == true) then
								setElementData ( theZomb, "status", "chasing" )
								setElementData ( theZomb, "target", getLocalPlayer() )
								table.insert( myZombies, theZomb ) --ADDS ZOMBIE TO PLAYERS COLLECTION
								table.remove( zombies, theKey)
								zombieradiusalert (theZomb)
							end
						elseif (getElementData(theZomb,"status") == "chasing") and (getElementData(theZomb,"target") == nil) then --CHECKS IF AN AGGRESSIVE LOST ZOMBIE IS IN SIGHT
							local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false) 
							if (isclear == true) then
								setElementData ( theZomb, "target", getLocalPlayer() )
								isthere = "no"
								for k, ped in pairs( myZombies ) do
									if ped == theZomb then
										isthere = "yes"
									end
								end
								if isthere == "no" then
									table.insert( myZombies, theZomb ) --ADDS THE WAYWARD ZOMBIE TO THE PLAYERS COLLECTION
									if id = 293 then
									table.insert( myZombies, id )
									end
									table.remove( zombies, theKey)
								end
							end
						elseif ( getElementData ( theZomb, "target" ) == getLocalPlayer() ) then --CHECKS IF AN ALREADY AGGRESSIVE ZOMBIE IS IN SIGHT
							local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false) 
							if (isclear == false) then --IF YOUR ZOMBIE LOST YOU, MAKES IT REMEMBER YOUR LAST COORDS
								setElementData ( theZomb, "target", nil )
								triggerServerEvent ("onZombieLostPlayer", theZomb, oldPx, oldPy, oldPz)
							end
						end
					end
				end
			end
		end
	--this second half is for checking peds and zombies
	
		local nonzombies = getElementsByType ( "ped",getRootElement(),true )
		local id = getElementModel (localPlayer)
		for theKey,theZomb in ipairs(zombies) do
			if (isElement(theZomb)) then
				if (getElementData (theZomb, "zombie") == true) then
					local Zx,Zy,Zz = getElementPosition( theZomb )
					for theKey,theNonZomb in ipairs(nonzombies) do
						if (getElementData (theNonZomb, "zombie") ~= true) and (id ~= 293)  then -- if the ped isnt a zombie
							local Px,Py,Pz = getElementPosition( theNonZomb )
							if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < 45 ) then
								local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false ) 
								if (isclear == true) and ( getElementHealth ( theNonZomb ) > 0) then
									if ( getElementData ( theZomb, "status" ) == "idle" ) then --CHECKS IF AN IDLE ZOMBIE IS IN SIGHT
										triggerServerEvent ("onZombieLostPlayer", theZomb, Px, Py, Pz)									
										setElementData ( theZomb, "status", "chasing" )
										setElementData ( theZomb, "target", theNonZomb )
										zombieradiusalert (theZomb)
									elseif ( getElementData ( theZomb, "status" ) == "chasing" ) and ( getElementData ( theZomb, "target" ) == nil) then
										triggerServerEvent ("onZombieLostPlayer", theZomb, Px, Py, Pz)
										setElementData ( theZomb, "target", theNonZomb )									
									end
								end					
							end		
							if ( getElementData ( theZomb, "target" ) == theNonZomb ) then --CHECKS IF AN ALREADY AGGRESSIVE ZOMBIE IS IN SIGHT OF THE PED
								local Px,Py,Pz = getElementPosition( theNonZomb )
								if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < 45 ) then
									local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz+1, true, false, false, true, false, false, false) 
									if (isclear == false) then --IF YOUR ZOMBIE LOST THE PED, MAKES IT REMEMBER the peds LAST COORDS
										triggerServerEvent ("onZombieLostPlayer", theZomb, Px, Py, Pz)							
										setElementData ( theZomb, "target", nil )
									end
								end
							end
						end
					end
				end
			end
		end
	end
	for k, ped in pairs( myZombies ) do
		if (isElement(ped) == false) then
			table.remove( myZombies, k)
		end
	end
	oldPx,oldPy,oldPz = getElementPosition( getLocalPlayer () )
end

i ve insert the id on table array, but the zombies still chase me

Link to comment

should work

--THIS CHECKS ALL ZOMBIES EVERY SECOND TO SEE IF THEY ARE IN SIGHT
function zombie_check ()
	if (getElementData (getLocalPlayer (), "zombie") ~= true) and ( isPedDead ( getLocalPlayer () ) == false ) and (getElementModel(getLocalPlayer()) ~= 293) then
		local zombies = getElementsByType ( "ped",getRootElement(),true )
		local id = getElementModel (localPlayer)
		local Px,Py,Pz = getElementPosition( getLocalPlayer () )
		if isPedDucked ( getLocalPlayer ()) then
			local Pz = Pz-1
		end		
		for theKey,theZomb in ipairs(zombies) do
			if (isElement(theZomb)) then
				local Zx,Zy,Zz = getElementPosition( theZomb )
				if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < 45 ) then
					if (getElementData (theZomb, "zombie") == true) then
						if ( getElementData ( theZomb, "status" ) == "idle" ) then --CHECKS IF AN IDLE ZOMBIE IS IN SIGHT
							local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false) 
							if (isclear == true) then
								setElementData ( theZomb, "status", "chasing" )
								setElementData ( theZomb, "target", getLocalPlayer() )
								table.insert( myZombies, theZomb ) --ADDS ZOMBIE TO PLAYERS COLLECTION
								table.remove( zombies, theKey)
								zombieradiusalert (theZomb)
							end
						elseif (getElementData(theZomb,"status") == "chasing") and (getElementData(theZomb,"target") == nil) then --CHECKS IF AN AGGRESSIVE LOST ZOMBIE IS IN SIGHT
							local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false) 
							if (isclear == true) then
								setElementData ( theZomb, "target", getLocalPlayer() )
								isthere = "no"
								for k, ped in pairs( myZombies ) do
									if ped == theZomb then
										isthere = "yes"
									end
								end
								if isthere == "no" then
									table.insert( myZombies, theZomb ) --ADDS THE WAYWARD ZOMBIE TO THE PLAYERS COLLECTION
									if id = 293 then
									table.insert( myZombies, id )
									end
									table.remove( zombies, theKey)
								end
							end
						elseif ( getElementData ( theZomb, "target" ) == getLocalPlayer() ) then --CHECKS IF AN ALREADY AGGRESSIVE ZOMBIE IS IN SIGHT
							local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false) 
							if (isclear == false) then --IF YOUR ZOMBIE LOST YOU, MAKES IT REMEMBER YOUR LAST COORDS
								setElementData ( theZomb, "target", nil )
								triggerServerEvent ("onZombieLostPlayer", theZomb, oldPx, oldPy, oldPz)
							end
						end
					end
				end
			end
		end
	--this second half is for checking peds and zombies
	
		local nonzombies = getElementsByType ( "ped",getRootElement(),true )
		local id = getElementModel (localPlayer)
		for theKey,theZomb in ipairs(zombies) do
			if (isElement(theZomb)) then
				if (getElementData (theZomb, "zombie") == true) then
					local Zx,Zy,Zz = getElementPosition( theZomb )
					for theKey,theNonZomb in ipairs(nonzombies) do
						if (getElementData (theNonZomb, "zombie") ~= true) and (id ~= 293)  then -- if the ped isnt a zombie
							local Px,Py,Pz = getElementPosition( theNonZomb )
							if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < 45 ) then
								local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false ) 
								if (isclear == true) and ( getElementHealth ( theNonZomb ) > 0) then
									if ( getElementData ( theZomb, "status" ) == "idle" ) then --CHECKS IF AN IDLE ZOMBIE IS IN SIGHT
										triggerServerEvent ("onZombieLostPlayer", theZomb, Px, Py, Pz)									
										setElementData ( theZomb, "status", "chasing" )
										setElementData ( theZomb, "target", theNonZomb )
										zombieradiusalert (theZomb)
									elseif ( getElementData ( theZomb, "status" ) == "chasing" ) and ( getElementData ( theZomb, "target" ) == nil) then
										triggerServerEvent ("onZombieLostPlayer", theZomb, Px, Py, Pz)
										setElementData ( theZomb, "target", theNonZomb )									
									end
								end					
							end		
							if ( getElementData ( theZomb, "target" ) == theNonZomb ) then --CHECKS IF AN ALREADY AGGRESSIVE ZOMBIE IS IN SIGHT OF THE PED
								local Px,Py,Pz = getElementPosition( theNonZomb )
								if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < 45 ) then
									local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz+1, true, false, false, true, false, false, false) 
									if (isclear == false) then --IF YOUR ZOMBIE LOST THE PED, MAKES IT REMEMBER the peds LAST COORDS
										triggerServerEvent ("onZombieLostPlayer", theZomb, Px, Py, Pz)							
										setElementData ( theZomb, "target", nil )
									end
								end
							end
						end
					end
				end
			end
		end
	end
	for k, ped in pairs( myZombies ) do
		if (isElement(ped) == false) then
			table.remove( myZombies, k)
		end
	end
	oldPx,oldPy,oldPz = getElementPosition( getLocalPlayer () )
end

 

  • Like 1
Link to comment
1 hour ago, synskidz said:

@fist sorry, am i on wrong forum? which forum should i choose?

Scripting forum itself not Tutorial subforum which is under Scripting. In this subforum tutorials are here only ^^

Edited by Fist
Link to comment

@fist bro, how i add more skin?

if (getElementData (getLocalPlayer (), "zombie") ~= true) and ( isPedDead ( getLocalPlayer () ) == false ) and ((getElementModel(getLocalPlayer()) ~= 293 or (getElementModel(getLocalPlayer()) ~= 294 )) then

its not working, i add local skin = ( 293,294) and subtitute it. but still not work. any suggest?

Link to comment
  • Administrators

Take time to carefully look through what you wrote, you messed up all the syntax. Here's how it should be:

if (getElementData (getLocalPlayer (), "zombie") ~= true) and ( isPedDead ( getLocalPlayer () ) == false ) and (getElementModel(getLocalPlayer()) ~= 293) and (getElementModel(getLocalPlayer()) ~= 294 ) then

Also don't use 'or', use 'and'

When you want to add a new skin, add this onto the end of the 'if' statement:

and (getElementModel(getLocalPlayer()) ~= 294 )

change '294' for the skin id

  • Like 1
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...