Jump to content

Recommended Posts

Hello, I am pretty new to scripting on MTA, I done some visual C in college and was wondering if anyone could direct me to a website/topic about spawning zombies client side, I have looked at other peoples scripting, but as I say, I'm inexperienced, so if there is even a script with comments saying the purpose of the functions etc... could you post the link?  Thanks for reading! :D 

Edited by kieran
Link to comment

well, first you have to spawn some peds near the player
so you need to use 

createPed()

and you have to get the player position so use 

xx,yy,zz = getElementPosition() -- to get player position
setElementPosition(xx+4,yy+3,zz) -- to set the zombie position near the player

and then you have to make the ped go towards the player -- but first you need to make sure the ped is looking at the player
 

myrot = getElementRotation(player) -- to get the player roatition
setElementRotation (theped,-myrot) -- to make the ped look at the player
--now to make the ped go towards the player you can use control state
 setPedControlState(theped,"forwards", true)

and after that you can check if the ped is infront of the player then control state and hit the player

note : there will be a lot of bugs you have to fix it but try to fix it yourself if you can't post and i will help

 

Link to comment
function zombset (player) 

	x,y,z = getElementPosition(player) -- to get player position

	myrot = getElementRotation(player) -- to get the player roatition
	
zomb = createPed(1, x,y,z)

	setElementPosition(zomb, x+4,y+3,z) -- to set the zombie position near the player
	
	setElementRotation (zomb,-myrot) -- to make the ped look at the player

--now to make the ped go towards the player you can use control state

	setPedControlState(zomb,"forwards", true)
end

addCommandHandler ("createPed", zombset)

I don't think this is right... xD 

Link to comment
  • Moderators
  1. function zombset (player) -- this is clientside, not serverside!
  2. Use localPlayer instead of player. (you should be able to see a warning, if you do not use it.)
  3. local _, _, myrot = getElementRotation(localPlayer)

     

Edited by IIYAMA
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...