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

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

Get objects in a group/pack


Bierbuikje
 Share

Recommended Posts

Hello, I've made a mod to spawn bushes/plants and when a player presses '.' then only the last bush explodes. And not all the bushes that where spawned explodes. I don't know how to let explode all the bushes. Does someone know how tot fix this? dontgetit.gif

 

 

:1$Plant = 0jump @Begin:BeginModel.Load(-201)038B: load_requested_models :Checkwait 0if   not Model.Available(-201)else_jump @Check2wait 0jump @Check:Check2wait 0if0AB0:  key_pressed 191else_jump @Check2wait 0jump @Plant:Plant$Plant += 104C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 0.0 1.0 -1.00107: $Plant = create_object -201 at [email protected] [email protected] [email protected] 0:Check3wait 0if0AB0:  key_pressed 191else_jump @Check4wait 0jump @Plant:Check4wait 0if0AB0:  key_pressed 190else_jump @Check3wait 0jump @Explosie:Explosie0400: store_coords_to $Plant1 $Plant2 $Plant3 from_object $Plant with_offset 0.0 0.0 0.00565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 50565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 100565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 150565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 200565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 250565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 300565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 350565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 400565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 450565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 50wait 001C4: remove_references_to_object $Plant // This object will now disappear when the player looks awaywait 0Model.Destroy(-201)wait 0jump @Begin

 

Link to comment
Share on other sites

When you are using a variable, and you use it again, the first one is rewritten. You can't use variables twice (well, you can, but it will only "remember" one value). That is why it only deletes one, the last one. The other values are gone. It is possible to make a "variable within a variable", so you can change the variable (called an array).

 

Most of the time, coders use "$idx" for the second variable. I wrote a code with an array. If you don't understand a part, feel free to ask. wink.gif Everytime you press Y, an actor will spawn. When you press N, you have to delete all actors. Make sure you add the "var ... end" in the beginning, because else it won't work. $ACTOR[$idx] is just a variable, so when $idx is 1, it becomes $ACTOR[1] and when $idx is 2, it becomes $ACTOR[2]. Just keep that in mind, when you are coding this. wink.gif

 

 

:STARTthread 'START'var$idx : integer$ACTOR: array 20 of Actorend$idx = 0:PRESSwait 100if00E1:   player 0 pressed_key 11 then$idx += 104C4: store_coords_to $TEMPVAR_FLOAT_1 $TEMPVAR_FLOAT_2 $TEMPVAR_FLOAT_3 from_actor $PLAYER_ACTOR with_offset 0.0 3.0 0.0 009A: $ACTOR[$idx] = create_actor_pedtype 4 model #MALE01 at $TEMPVAR_FLOAT_1 $TEMPVAR_FLOAT_2 $TEMPVAR_FLOAT_3endif and00E1:   player 0 pressed_key 10$idx > 0 then0084: $idx2 = $idx$idx = 0repeat wait 0$idx += 10321: kill_actor $ACTOR[$idx]until 003A: $idx == $idx2 endjump @PRESS

 

 

Good luck. smile.gif

 

EDIT: I forgot to tell, you can only spawn 20 actors with this code. So you have to check if the player has more then 20... And beware for the limites of the engine.

Edited by Dutchy3010
Link to comment
Share on other sites

To understand what Dutschy has written..

 

When you are using a variable, and you use it again, the first one is rewritten. You can't use variables twice (well, you can, but it will only "remember" one value). That is why it only deletes one, the last one. The other values are gone. It is possible to make a "variable within a variable", so you can change the variable (called an array).

.. you need first to release the object instance $Plant from script before creating one more in same creation line like in this simple script below

 

I changed object number with original object ID number and changed also the key_press numbers

 

//DEFINE OBJECT GRASSPLANT               // Object number -201//3409, grassplant:1thread 'PLANT'$Plant = 0:2wait 0 if   Player.Defined($PLAYER_CHAR)jf @2if0AB0:  key_pressed 55//------------ 7else_jump @2Model.Load(3409)038B: load_requested_models:Checkwait 0if  not Model.Available(3409)else_jump @Plantwait 0jump @Check:Plant//$Plant += 104C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 0.0 1.0 -1.00107: $Plant = create_object 3409 at [email protected] [email protected] [email protected] 1000:Check4wait 0if0AB0:  key_pressed 57//-------- 9else_jump @Check4:Explosie0400: store_coords_to $Plant1 $Plant2 $Plant3 from_object $Plant with_offset 0.0 0.0 0.00565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 1001C4: remove_references_to_object $Plant // This object will now disappear when the player looks awayModel.Destroy(3409)jump @2

 

 

To understand what Dutschy has written..

 

Most of the time, coders use "$idx" for the second variable. I wrote a code with an array. If you don't understand a part, feel free to ask. wink.gif Everytime you press Y, an actor will spawn. When you press N, you have to delete all actors. Make sure you add the "var ... end" in the beginning, because else it won't work. $ACTOR[$idx] is just a variable, so when $idx is 1, it becomes $ACTOR[1] and when $idx is 2, it becomes $ACTOR[2]. Just keep that in mind, when you are coding this. wink.gif
... the script below shows how to create multiple object instance of grassplants in same creation line by using arrays

 

 

 

//DEFINE OBJECT GRASSPLANT               // Object number -201//3409, grassplant:GPLANTthread 'GPLANT'0004: $PlantObj[0] = 0 // PED handle  0004: $PlantObj[1] = 0 // PED handle0004: $PlantObj[2] = 0 // PED handle0004: $PlantObj[3] = 0 // PED handle0004: $PlantObj[4] = 0 // PED handle0004: $PlantObj[5] = 0 // PED handle0004: $PlantObj[6] = 0 // PED handle0004: $PlantObj[7] = 0 // PED handle0004: $PlantObj[8] = 0 // PED handle0004: $PlantObj[9] = 0 // PED handle0004: $PlantObj[10] = 0 // PED handle$Plantcounter = 0:GPLANT_1wait 0 if   Player.Defined($PLAYER_CHAR)jf @GPLANT_1if0AB0:  key_pressed 55//------------key = 7else_jump @GPLANT_1Model.Load(3409)038B: load_requested_models:GPLANT_3wait 0if  not Model.Available(3409)else_jump @GPLANT_5wait 0jump @GPLANT_3:GPLANT_5wait 004C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 0.0 1.0 -1.00107: $PlantObj($Plantcounter,16i) = create_object 3409 at [email protected] [email protected] [email protected]$Plantcounter += 1wait 1000:GPLANT_7wait 0if001A:   10 > $Plantcounter else_jump @GPLANT_9if8AB0:  not key_pressed 55//------------key = 7else_jump @GPLANT_5:GPLANT_9if0AB0:  key_pressed 57//--------key = 9else_jump @GPLANT_7:GPLANT_10wait 50000C: $Plantcounter -= 10400: store_coords_to $Plant1 $Plant2 $Plant3 from_object $PlantObj($Plantcounter,16i) with_offset 0.0 0.0 0.00565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 1001C4: remove_references_to_object $PlantObj($Plantcounter,16i) // This object will now disappear when the player looks awayif0038:   $Plantcounter == 0 else_jump @GPLANT_10Model.Destroy(3409)jump @GPLANT_1

 

Edited by ZAZ
Link to comment
Share on other sites

I have a question about this:

 

 

$idx : integer$ACTOR: array 20 of Actor

 

 

What is it meaning? And how to do this for an object? Is it then: ?

 

 

 

$idx : integer$Plant: array 20 of Object

 

Link to comment
Share on other sites

I tried the same as the script of ZAZ but my script is crashing ingame. I can spawn bushes/plants but when I press '.' (explode button) it crashes. The '.' butten is layer @Check4.

 

 

{$CLEO .CS}:1jump @Begin:Begin0004: $Plant[0] = 00004: $Plant[1] = 00004: $Plant[2] = 00004: $Plant[3] = 00004: $Plant[4] = 00004: $Plant[5] = 00004: $Plant[6] = 00004: $Plant[7] = 00004: $Plant[8] = 00004: $Plant[9] = 00004: $Plant[10] = 00004: $Plant[11] = 00004: $Plant[12] = 00004: $Plant[13] = 00004: $Plant[14] = 00004: $Plant[15] = 00004: $Plant[16] = 00004: $Plant[17] = 00004: $Plant[18] = 00004: $Plant[19] = 0$Count = 0jump @Begin2:Begin2Model.Load(-201)038B: load_requested_models :Checkwait 0if   not Model.Available(-201)else_jump @Check2wait 0jump @Check:Check2wait 0if0AB0:  key_pressed 191else_jump @Check2wait 0jump @Plant:Plantwait 004C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 0.0 10.0 -1.00107: $Plant($Count,16i) = create_object -201 at [email protected] [email protected] [email protected]$Count += 1wait 0:Check3wait 0if and0AB0:  key_pressed 191001A:   19 > $Count else_jump @Check4wait 0jump @Plant:Check4wait 0if0AB0:  key_pressed 190else_jump @Check3wait 00084: $Count2 = $Countjump @Explosie:Explosierepeat$Count -= 10400: store_coords_to $Plant1 $Plant2 $Plant3 from_object $Plant($Count,16i) with_offset 0.0 0.0 0.00565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 50565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 100565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 150565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 200565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 250565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 300565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 350565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 400565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 450565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 50until 0084: $Count = 0wait 00084: $Count = $Count2repeat$Count -= 101C4: remove_references_to_object $Plant($Count,16i) // This object will now disappear when the player looks awayuntil 0084: $Count = 0Model.Destroy(-201)wait 0jump @Eind:Eindjump @Begin0A93: end_custom_thread

 

Link to comment
Share on other sites

Twice you are using the following code:

 

until 0084: $Count = 0

 

This isn't possible. The opcode after 0084, has to be a condition. This isn't a condition, with this opcode you are saying: the variable $count has to be 0. I think you mean that the condition is true, when the variable count is 0. Then you have to use ==:

 

003A: $Count == $Count2 

 

 

Second:

 

repeat$Count -= 101C4: remove_references_to_object $Plant($Count,16i) // This object will now disappear when the player looks awayuntil 0084: $Count = 0

 

You don't have a wait in this repeat-wait-until loop.

Link to comment
Share on other sites

$Plant($Count,16i)

16 is the maximum of possible instances in the array or other words: it defines the max counting

you must increase it to can create 19 instances

e.g. $Plant($Count,32i)

 

 

Edited by ZAZ
Link to comment
Share on other sites

Bierbuikje,

 

 

Model.Load(-201)...Model.Available(-201)...etc

 

This is wrong. You can't use such ID (-201) there. Use model name (#..).

 

Your code is full of unnecessary wait 0 and jump to the next label commands. You only need for 2 waits in your code: one for the key_pressed loop and one for the model_available loop.

 

You dont have the player_defined check loop.

 

And do not use global variables in CLEO scripts.

 

 

 

Second:

 

repeat$Count -= 101C4: remove_references_to_object $Plant($Count,16i) // This object will now disappear when the player looks awayuntil 0084: $Count = 0

 

You don't have a wait in this repeat-wait-until loop.

And he doesn't have to. In other words, wait is not needed there, as this loop is finite and doesnt expect any input from the player or environment (for example key_pressed check is expecting player input, so the wait command must be there).

Link to comment
Share on other sites

Second:

 

repeat$Count -= 101C4: remove_references_to_object $Plant($Count,16i) // This object will now disappear when the player looks awayuntil 0084: $Count = 0

 

You don't have a wait in this repeat-wait-until loop.

And he doesn't have to. In other words, wait is not needed there, as this loop is finite and doesnt expect any input from the player or environment (for example key_pressed check is expecting player input, so the wait command must be there).

Yeah, you are right, I didn't look at what was in the loop. suicidal.gif

Link to comment
Share on other sites

 

Bierbuikje,

 

 

Model.Load(-201)...Model.Available(-201)...etc

 

This is wrong. You can't use such ID (-201) there. Use model name (#..).

 

That's because it is a cleo script and this is working too.

 

 

My script ain't working. dontgetit.gif I did everything you said, tried, editted, tried again. But it crashes all the time when I try to explode the bushes/plants.

 

{$CLEO .CS}:1jump @Begin:Begin0004: $Plant[0] = 00004: $Plant[1] = 00004: $Plant[2] = 00004: $Plant[3] = 00004: $Plant[4] = 00004: $Plant[5] = 00004: $Plant[6] = 00004: $Plant[7] = 00004: $Plant[8] = 00004: $Plant[9] = 00004: $Plant[10] = 00004: $Plant[11] = 00004: $Plant[12] = 00004: $Plant[13] = 00004: $Plant[14] = 00004: $Plant[15] = 00004: $Plant[16] = 00004: $Plant[17] = 00004: $Plant[18] = 00004: $Plant[19] = 0$Count = 0jump @Begin2:Begin2Model.Load(-201)038B: load_requested_models:Checkwait 0if  not Model.Available(-201)else_jump @Check2wait 0jump @Check:Check2wait 0if0AB0:  key_pressed 191else_jump @Check2:Plantwait 0$Count += 104C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 0.0 10.0 -1.00107: $Plant($Count,32i) = create_object -201 at [email protected] [email protected] [email protected]:Check3wait 0if and0AB0:  key_pressed 191001A:   19 > $Countelse_jump @Check4wait 0jump @Plant:Check4wait 0if0AB0:  key_pressed 190else_jump @Check3wait 00084: $Count2 = $Count:Explosierepeat$Count -= 10400: store_coords_to $Plant1 $Plant2 $Plant3 from_object $Plant($Count,32i) with_offset 0.0 0.0 0.00565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 50565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 100565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 150565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 200565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 250565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 300565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 350565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 400565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 450565: create_temporary_explosion_fire $Plant1 $Plant2 $Plant3 50until 003A: $Count == 0wait 00084: $Count = $Count2repeatwait 0$Count -= 101C4: remove_references_to_object $Plant($Count,32i) // This object will now disappear when the player looks awayuntil 003A: $Count == 0Model.Destroy(-201):Eindjump @Begin0A93: end_custom_thread

 

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.