Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Spawn LOTS of Peds in random places


MrRobinson
 Share

Recommended Posts

MrRobinson

Anyone know how to do this? I tried this,

local ZombieTest = {}ZombieTest.peds = {}ZombieTest.howMany = 0function ZombieTest.unload()endfunction ZombieTest.tick()		if(get_key_pressed(110)) then --Numpad 3		local ZombieTestSkinID = GAMEPLAY.GET_HASH_KEY("u_m_y_zombie_01")		local playerPed = PLAYER.PLAYER_PED_ID()		local player = PLAYER.GET_PLAYER_PED(playerPed)		local playerID = PLAYER.PLAYER_ID()		local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)		local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0)		ZombieTest.unload()		STREAMING.REQUEST_MODEL(ZombieTestSkinID)		while(not STREAMING.HAS_MODEL_LOADED(ZombieTestSkinID)) do				wait(50)		end		for i = 0 ,ZombieTest.howMany,1 do		   PED.GET_CLOSEST_PED(playerPosition.x, playerPosition.y, playerPosition.z, 1000, ZombieTestSkinID)		   PED.CREATE_GROUP(int > Zombies)		   PED.SET_PED_AS_GROUP_MEMBER(ZombieTest.peds[i], Zombies)		   PED.SET_PED_CAN_SWITCH_WEAPON(ZombieTest.peds[i],true)		   WEAPON.GIVE_DELAYED_WEAPON_TO_PED(ZombieTest.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_PISTOL"), 1000, false)		   AI.TASK_COMBAT_PED(ZombieTest.peds[i], playerPed, 1, 1)		   ENTITY.SET_ENTITY_INVINCIBLE(ZombieTest.peds[i], false);		   print("Brainssssss!")		end		STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(ZombieTestSkinID)    end	endreturn ZombieTest

But it didn't work, Can anyone help me?

Link to comment
Share on other sites

im not familiar with V natives or lua but some issues (im assuming) I notice...

 

1. ZombieTest.howMany = 0 so your loop wont even run once, also, I would assume you need to write out the condition of the loop like this...

 

i <= ZombieTest.howMany

 

(no clue since i never used lua but i am familiar with loops in other langs)

 

2.You aren't creating peds but looking for existing peds with the zombie model. I assume whereever you are in the game these peds with this model do not exist. You need to call a native that creates the ped. In IV it was something like CREATE_PED... i forget, i mainly used the scripthookdotnet wrapper.

 

Edit: plus i also notice when you call GET_CLOSEST_PED, you dont have any argument that saves the ped reference nor does the function return the ped. I'm thinking your using these natives wrong. I also heard for lua, any functions that have pointer args dont work and you need to wait for an update. You better check with the authour of the lua lib.

 

this looks wrong as i dont see how you are saving this reference to the closest ped. I bet you if I go check the header it wants a pointer argument that you later use to reference the ped:

 

PED.GET_CLOSEST_PED(playerPosition.x, playerPosition.y, playerPosition.z, 1000, ZombieTestSkinID)

Edited by c39687
Link to comment
Share on other sites

MrRobinson

im not familiar with V natives or lua but some issues (im assuming) I notice...

 

1. ZombieTest.howMany = 0 so your loop wont even run once, also, I would assume you need to write out the condition of the loop like this...

 

i <= ZombieTest.howMany

 

(no clue since i never used lua but i am familiar with loops in other langs)

 

2.You aren't creating peds but looking for existing peds with the zombie model. I assume whereever you are in the game these peds with this model do not exist. You need to call a native that creates the ped. In IV it was something like CREATE_PED... i forget, i mainly used the scripthookdotnet wrapper.

 

Edit: plus i also notice when you call GET_CLOSEST_PED, you dont have any argument that saves the ped reference nor does the function return the ped. I'm thinking your using these natives wrong. I also heard for lua, any functions that have pointer args dont work and you need to wait for an update. You better check with the authour of the lua lib.

Yes I know I need to create the peds, the code above is me trying to change peds model to Zombie model, but...

Link to comment
Share on other sites

 

im not familiar with V natives or lua but some issues (im assuming) I notice...

 

1. ZombieTest.howMany = 0 so your loop wont even run once, also, I would assume you need to write out the condition of the loop like this...

 

i <= ZombieTest.howMany

 

(no clue since i never used lua but i am familiar with loops in other langs)

 

2.You aren't creating peds but looking for existing peds with the zombie model. I assume whereever you are in the game these peds with this model do not exist. You need to call a native that creates the ped. In IV it was something like CREATE_PED... i forget, i mainly used the scripthookdotnet wrapper.

 

Edit: plus i also notice when you call GET_CLOSEST_PED, you dont have any argument that saves the ped reference nor does the function return the ped. I'm thinking your using these natives wrong. I also heard for lua, any functions that have pointer args dont work and you need to wait for an update. You better check with the authour of the lua lib.

Yes I know I need to create the peds, the code above is me trying to change peds model to Zombie model, but...

 

im not following you. So did you create peds in other parts of your code? (not pasted)

 

In game go stand next to a ped with this model and test your code. Although I don't see how you are making a reference to the closest ped with the zombie model...

 

Also in GTAIV (pretty much same game) you were not able to set the models of existing peds... you need to create a ped... so in your case... delete the existing ped and create your ped in the same position and heading

Edited by c39687
Link to comment
Share on other sites

MrRobinson

 

 

im not familiar with V natives or lua but some issues (im assuming) I notice...

 

1. ZombieTest.howMany = 0 so your loop wont even run once, also, I would assume you need to write out the condition of the loop like this...

 

i <= ZombieTest.howMany

 

(no clue since i never used lua but i am familiar with loops in other langs)

 

2.You aren't creating peds but looking for existing peds with the zombie model. I assume whereever you are in the game these peds with this model do not exist. You need to call a native that creates the ped. In IV it was something like CREATE_PED... i forget, i mainly used the scripthookdotnet wrapper.

 

Edit: plus i also notice when you call GET_CLOSEST_PED, you dont have any argument that saves the ped reference nor does the function return the ped. I'm thinking your using these natives wrong. I also heard for lua, any functions that have pointer args dont work and you need to wait for an update. You better check with the authour of the lua lib.

Yes I know I need to create the peds, the code above is me trying to change peds model to Zombie model, but...

 

im not following you. So did you create peds in other parts of your code? (not pasted)

 

In game go stand next to a ped with this model and test your code. Although I don't see how you are making a reference to the closest ped with the zombie model...

 

Also in GTAIV (pretty much same game) you were not able to set the models of existing peds... you need to create a ped... so in your case... delete the existing ped and create your ped in the same position and heading

 

I can't post my working code that when you press a button 2 zombies spawn and attack you, But thats what my unposted code does, now I'm trying to spawn peds in a 100 radius in random places

Link to comment
Share on other sites

 

 

 

im not familiar with V natives or lua but some issues (im assuming) I notice...

 

1. ZombieTest.howMany = 0 so your loop wont even run once, also, I would assume you need to write out the condition of the loop like this...

 

i <= ZombieTest.howMany

 

(no clue since i never used lua but i am familiar with loops in other langs)

 

2.You aren't creating peds but looking for existing peds with the zombie model. I assume whereever you are in the game these peds with this model do not exist. You need to call a native that creates the ped. In IV it was something like CREATE_PED... i forget, i mainly used the scripthookdotnet wrapper.

 

Edit: plus i also notice when you call GET_CLOSEST_PED, you dont have any argument that saves the ped reference nor does the function return the ped. I'm thinking your using these natives wrong. I also heard for lua, any functions that have pointer args dont work and you need to wait for an update. You better check with the authour of the lua lib.

Yes I know I need to create the peds, the code above is me trying to change peds model to Zombie model, but...

 

im not following you. So did you create peds in other parts of your code? (not pasted)

 

In game go stand next to a ped with this model and test your code. Although I don't see how you are making a reference to the closest ped with the zombie model...

 

Also in GTAIV (pretty much same game) you were not able to set the models of existing peds... you need to create a ped... so in your case... delete the existing ped and create your ped in the same position and heading

 

I can't post my working code that when you press a button 2 zombies spawn and attack you, But thats what my unposted code does, now I'm trying to spawn peds in a 100 radius in random places

 

i think im lost on your meaning of spawn, do you mean teleport? as in set their position?

 

to me, spawn means... CREATE_PED

Link to comment
Share on other sites

MrRobinson
to me, spawn means... CREATE_PED

 

 

 

This is what I mean

Link to comment
Share on other sites

 

to me, spawn means... CREATE_PED

 

 

 

This is what I mean

 

ok yeah, so your code is looking for peds, not creating them. So like I first said... use CREATE_PEDS, you keep going back n forth on what you are saying... be consistent with what you say.

Link to comment
Share on other sites

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
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.