Quantcast

Jump to content

» «
Photo

[SA]Opcode 03C5

6 replies to this topic
Danikov
  • Danikov

    The Fake Russian

  • Members
  • Joined: 27 Aug 2009
  • Israel

#1

Posted 20 January 2014 - 04:27 PM

I have been trying to mess around with Opcode 03C5 but it appears to be that it doesn't spawn me any vehicle at the specified location...why?

And also I saw somewhere that it doesn't spawn a vehicle more than once,is there any way to get around this?

I want to have a randomized car generator,and not making multiple uses of 014B if anyone was going to suggest that.


aStiffSausage
  • aStiffSausage

    Formerly Oksu

  • Members
  • Joined: 30 Sep 2010
  • Finland

#2

Posted 20 January 2014 - 04:38 PM

Take a look of external script #70, CARPARK1. I haven't tried opcode myself ever, but seems that the best solution for using it is exactly like... Well, like Rockstar used it. :p

 

Here's a little snippet of the external script, should be enough to show how it's used.

:CARPRK1_85
0001: wait 0 ms 
00D6: if 
0256:   player $PLAYER_CHAR defined 
004D: jump_if_false @CARPRK1_2769 
00D6: if 
00A4:   actor $PLAYER_ACTOR sphere 0 in_cube_cornerA 2037.568 2366.152 9.8203 cornerB 2119.283 2472.418 14.1172 
004D: jump_if_false @CARPRK1_251 
00D6: if 
0039:   0@ == 0 
004D: jump_if_false @CARPRK1_244 
03C5: create_random_car_for_carpark 2077.872 2398.657 9.8203 z_angle 89.6383 
03C5: create_random_car_for_carpark 2087.099 2414.177 9.8203 z_angle 90.4575 
03C5: create_random_car_for_carpark 2104.859 2416.439 9.8203 z_angle 270.7819 
0006: 0@ = 1 

:CARPRK1_244
0002: jump @CARPRK1_308 

:CARPRK1_251
00D6: if 
0039:   0@ == 1 
004D: jump_if_false @CARPRK1_308 
03BA: clear_cars_from_cube_cornerA 2052.432 2366.152 9.8203 cornerB 2117.283 2441.002 14.1172 
0006: 0@ = 0 
  • Danikov likes this

Danikov
  • Danikov

    The Fake Russian

  • Members
  • Joined: 27 Aug 2009
  • Israel

#3

Posted 20 January 2014 - 06:03 PM

Thank you very much Stiffy!

I am now facing a problem of defining the "corners" for this generator,I took some co-ords that are basically the borders/corners in which the car will generate but when I am near the vehicle position,it is floating,and I can see the randomizing of the different vehicle models continuously happening.

If anyone could explain me how to use those corners in the two different opcodes properly,that'd be great :)

aStiffSausage
  • aStiffSausage

    Formerly Oksu

  • Members
  • Joined: 30 Sep 2010
  • Finland

#4

Posted 20 January 2014 - 06:12 PM

Well, apparently you didn't use a check like in the snippet I posted to see if the cars are already spawned. As you can see, the snippet uses variable 0@ to check if the cars are already spawned, or not. 

 

First, the external script defines all of those variables to 0. Zero means they are not spawned, and one means cars are spawned. There's variable for each area, meaning that area A uses 0@, area B uses 1@ and so on. Once player goes into area A, the script then checks if the variable is zero or one. If it's zero, it spawns the random cars and sets the variable to one. Now, the script doesn't try to spawn new cars, until player leaves area A, which sets variable back to zero, and when he re-enters it, it once again spawns cars and sets it to one.

I hope that didn't sound too complicated. If it did, I can post a small example how it should work properly. :)


Danikov
  • Danikov

    The Fake Russian

  • Members
  • Joined: 27 Aug 2009
  • Israel

#5

Posted 20 January 2014 - 07:35 PM

Well, apparently you didn't use a check like in the snippet I posted to see if the cars are already spawned. As you can see, the snippet uses variable 0@ to check if the cars are already spawned, or not. 
 
First, the external script defines all of those variables to 0. Zero means they are not spawned, and one means cars are spawned. There's variable for each area, meaning that area A uses 0@, area B uses 1@ and so on. Once player goes into area A, the script then checks if the variable is zero or one. If it's zero, it spawns the random cars and sets the variable to one. Now, the script doesn't try to spawn new cars, until player leaves area A, which sets variable back to zero, and when he re-enters it, it once again spawns cars and sets it to one.

I hope that didn't sound too complicated. If it did, I can post a small example how it should work properly. :)


I did follow your snippet and even took a look in the main.scm .
I guess I have messed up in one of the labels,I will post here again if I am still stuck.

Thank you very much!

Danikov
  • Danikov

    The Fake Russian

  • Members
  • Joined: 27 Aug 2009
  • Israel

#6

Posted 21 January 2014 - 03:15 PM Edited by Danikov, 21 January 2014 - 03:32 PM.

Ugh,I just can't seem to make it work.

I did it pretty much like you showed me and how it is done in the main.scm .

Stiffy or anyone else could please show me how it can be done *...for a signle cube area ?

 

Btw,here's my script,the vehicles are placed near Rusty Brown's donuts shop in LS.

{$CLEO .cs}

:CARPRKLS_1
thread 'CARPRKLS'  
0@ = 0

:CARPRKLS_2
0001: wait 0 ms 
00D6: if 
0256:  player $PLAYER_CHAR defined 
004D: jump_if_false @CARPRKLS_2 
00D6: if 
00A4:  actor $PLAYER_ACTOR sphere 0 in_cube_cornerA 954.5 -1487.6 12.1654 cornerB 1089.5 -1145.518 22.1172
004D: jump_if_false @CARPRKLS_3
00D6: if 
0039:   0@ == 0 
004D: jump_if_false @CARPRKLS_3   
03C5: create_random_car_for_carpark 1065.4 -1359.7113 13.1654 z_angle 0.0 
03C5: create_random_car_for_carpark 1065.3 -1351.83 13.1636 z_angle 0.0
0@ = 1

:CARPRKLS_3
00D6: if 
0039:   0@ == 1 
004D: jump_if_false @CARPRKLS_2
03BA: clear_cars_from_cube_cornerA 1064.5 -1360.0 12.1654 cornerB 1066.0 -1351.8 13.4
0002: jump @CARPRKLS_2   
end_thread

TheGodfather.
  • TheGodfather.

    Nobody likes me here...I think...

  • Members
  • Joined: 19 Jun 2012

#7

Posted 22 January 2014 - 08:14 AM

It is not working because you have cleared the area after spawning the cars:

 

Fixed Script (UNTESTED):

 

{$CLEO .cs}

:CARPRKLS_1
thread 'CARPRKLS' 
0@ = 0

:CARPRKLS_2
0001: wait 0 ms 
00D6: if 
0256: player $PLAYER_CHAR defined 
004D: jump_if_false @CARPRKLS_2 
00D6: if 
00A4: actor $PLAYER_ACTOR sphere 0 in_cube_cornerA 954.5 -1487.6 12.1654 cornerB 1089.5 -1145.518 22.1172
004D: jump_if_false @CARPRKLS_3
00D6: if 
0039: 0@ == 0 
004D: jump_if_false @CARPRKLS_3 
03BA: clear_cars_from_cube_cornerA 1064.5 -1360.0 12.1654 cornerB 1066.0 -1351.8 13.4
03C5: create_random_car_for_carpark 1065.4 -1359.7113 13.1654 z_angle 0.0 
03C5: create_random_car_for_carpark 1065.3 -1351.83 13.1636 z_angle 0.0
0@ = 1

:CARPRKLS_3
00D6: if 
0039: 0@ == 1 
004D: jump_if_false @CARPRKLS_2

 
end_thread

 

Also sometime the cars may not appear if that happens use 0734:opcode at last. 

Note: The script will only work with an original main.scm 





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users