Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Cayo Perico Heist
      2. The Diamond Casino Heist
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

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

    1. Red Dead Redemption 2

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

    1. Grand Theft Auto Series

    2. GTA VI

      1. St. Andrews Cathedral
    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. Guides & Strategies
      2. Help & Support
    6. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    7. GTA III

      1. Guides & Strategies
      2. 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. 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
    3. Gangs

    1. Announcements

    2. Support

    3. Suggestions

Nesthor

Random Variables

Recommended Posts

Nesthor

Hello everyone, I am beginning to experiment in randomizing variables to be able to activate events randomly, use a small script that creates a kind of checkpoint on the outskirts of Blueberry, however, I know that my code is wrong, because the actors always appear and Vehicles, I guess it's because I don't tell you to do if the variable is not the one you select, but I don't know how to solve this problem, any suggestions?

 

this code:

 

{$CLEO .cs}
//-------------MAIN---------------
03A4: name_thread 'RETEN_BY_NES'

:START
IF AND
0256:   player $PLAYER_CHAR defined 
00FE:   actor $PLAYER_ACTOR sphere 0 in_sphere 155.4824 70.0681 2.0781 radius 150.0 150.0 60.0
ELSE_JUMP @START 
0209: [email protected] = random_int_in_ranges 0 2

:CREATE
IF
0039:   [email protected] == 0
ELSE_JUMP @START
Model.Load(#COPCARRU)
Model.Load(#CSHER)
04ED: load_animation  "POLICE"
04ED: load_animation  "COP_AMBIENT"
04ED: load_animation  "SMOKING"
04ED: load_animation  "GANGS"
038B: load_requested_models
00A5: [email protected] = create_car #COPCARRU at 156.4801 59.901 2.6615
0175: set_car [email protected] Z_angle_to 68.8089
0397: enable_car [email protected] siren 1
009A: [email protected] = create_actor_pedtype 4 model #CSHER at 202.9969 62.3105 2.4297
0173: set_actor [email protected] Z_angle_to 247.9763
0605: actor [email protected] perform_animation "COPTRAF_COME" IFP "POLICE" framedelta 4.0 loop 1 lockX 0 lockY 0 lockF 0 time -1
009A: [email protected] = create_actor_pedtype 4 model #CSHER at 158.4368 80.3215 2.4297
0173: set_actor [email protected] Z_angle_to 260.5351
0605: actor [email protected] perform_animation "M_SMKstnd_LOOP" IFP "SMOKING" framedelta 4.0 loop 1 lockX 0 lockY 0 lockF 0 time -1
009A: [email protected] = create_actor_pedtype 4 model #CSHER at 160.3822 80.207 2.4411
0173: set_actor [email protected] Z_angle_to 161.9391
0605: actor [email protected] perform_animation "COPLOOK_LOOP" IFP "COP_AMBIENT" framedelta 4.0 loop 1 lockX 0 lockY 0 lockF 0 time -1
00A5: [email protected] = create_car #COPCARRU at 153.2333 80.7611 2.6612
0175: set_car [email protected] Z_angle_to 246.711
0397: enable_car [email protected] siren 1
009A: [email protected] = create_actor_pedtype 4 model #CSHER at 143.6744 67.8617 2.2795
0173: set_actor [email protected] Z_angle_to 60.9769
0605: actor [email protected] perform_animation "COPTRAF_COME" IFP "POLICE" framedelta 4.0 loop 1 lockX 0 lockY 0 lockF 0 time -1
009A: [email protected] = create_actor_pedtype 4 model #CSHER at 153.4338 62.1767 2.4297
0173: set_actor [email protected] Z_angle_to 45.9539
0605: actor [email protected] perform_animation "M_SMKLEAN_LOOP" IFP "SMOKING" framedelta 4.0 loop 1 lockX 0 lockY 0 lockF 0 time -1
009A: [email protected] = create_actor_pedtype 4 model #CSHER at 150.9635 59.4893 2.3984
0173: set_actor [email protected] Z_angle_to 316.9135
0605: actor [email protected] perform_animation "M_SMKstnd_LOOP" IFP "SMOKING" framedelta 4.0 loop 1 lockX 0 lockY 0 lockF 0 time -1

:FIN_01
wait 0
if 
80FE:   not actor $PLAYER_ACTOR sphere 0 in_sphere 155.4824 70.0681 2.0781 radius 130.0 130.0 50.0 
else_jump @FIN_01
00A6: destroy_car [email protected]
009B: destroy_actor [email protected]
009B: destroy_actor [email protected]
009B: destroy_actor [email protected]
00A6: destroy_car [email protected]
009B: destroy_actor [email protected]
009B: destroy_actor [email protected]
009B: destroy_actor [email protected]
03BD: destroy_sphere [email protected]
03BD: destroy_sphere [email protected]
04EF: release_animation "Smoking"
04EF: release_animation "POLICE"
04EF: release_animation "GANGS"
04EF: release_animation "COP_AMBIENT"
JUMP @START

Thanks

Share this post


Link to post
Share on other sites
ZAZ

This code is correct:

0209: 17@ = random_int_in_ranges 0 2

:CREATE
IF
0039:   17@ == 0
ELSE_JUMP @START

it works like it should for your plan

 

My experience with randomization in gtasa:

The game engine often select same value of the random pool

Then I had to do a more complex solution

 

In your case, the engine must select 1 value of 3

The more choises the engine have, the bigger is the chance to get a propper randomization

 

The jumptable code is a good method to extend the randomization

0209: 4@ = random_int  0  6
0871: init_jump_table 4@ total_jumps  7  0 @Carshow_01 jumps  0 @Carshow_1  1 @Carshow_2  2 @Carshow_3  3 @Carshow_4  4 @Carshow_5  5 @Carshow_6 6 @Carshow_7

:Carshow_1
0209: 5@ = random_int  533  536
jump @Carshow_02

:Carshow_2
0209: 5@ = random_int  565  567
jump @Carshow_02

:Carshow_3
0209: 5@ = random_int  575  576
jump @Carshow_02

:Carshow_4
0209: 5@ = random_int  409  412
jump @Carshow_02

:Carshow_5
0209: 5@ = random_int  502  508
jump @Carshow_02

:Carshow_6
0209: 5@ = random_int  400  402
jump @Carshow_02

:Carshow_7
0209: 5@ = random_int  494  496
jump @Carshow_02

:Carshow_01
0209: 5@ = random_int  558  562
jump @Carshow_02

:Carshow_02
0247: request_model 5@
038B: load_requested_models
00A5: 1@ = create_car 5@ at 11@ 12@  13@

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
Nesthor

perfect, then it should be enough to increase the number of values to be randomized, the problem was that the actors always appeared, I will try.  Thank you very much for the help

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


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