Quantcast

Jump to content

» «
Photo

Debugging some code..

5 replies to this topic
Thesord
  • Thesord

    Lacking time

  • Members
  • Joined: 12 Aug 2003

#1

Posted 21 May 2005 - 07:02 PM Edited by Thesord, 22 May 2005 - 03:50 PM.

Sorry for the long section of code. I've compiled without errors but I crash when the button in the check (look behind) is pressed. I'm almost sure I didn't make any mistakes.. Although I'm not sure, I might've made a mistake due to lack of attention, but still, I ask anyone experienced enough for help debugging this thread:

CODE
:Label00B0A6
0001: wait  250 ms
00D6: if  0
0256:   player $PLAYER_CHAR defined
004D: jump_if_false ££Label00B0A6
00D6: if  0
80E0: NOT    player $PLAYER_CHAR driving
004D: jump_if_false ££Label00B0A6
00D6: if  0
00E1:   key_pressed  0  19
004D: jump_if_false ££Label00B0A6
0209: $VAR5 = random_int 0 1
0209: $VAR6 = random_int 0 1

:LabelGuardRandomization
0001: wait 250 ms
00D6: if  0
0038: egi $VAR5 = 0
004D: jump_if_false ££LabelGuardRandomization1
0247: request_model #PGA
00D6: if  0
0248: model #PGA available
004D: jump_if_false ££LabelGuardRandomization
0002: jump ££LabelWeaponRandomization

:LabelGuardRandomization1
0001: wait 250 ms
00D6: if  0
0038: egi $VAR5 = 1
004D: jump_if_false ££LabelGuardRandomization
0247: request_model #SGa
00D6: if  0
0248: model #SGa available
004D: jump_if_false ££LabelGuardRandomization1

:LabelWeaponRandomization
0001: wait 250 ms
00D6: if  0
0038: egi $VAR6 = 0
004D: jump_if_false ££LabelWeaponRandomization1
0247: request_model #UZI
00D6: if  0
0248: model #UZI available
004D: jump_if_false ££LabelWeaponRandomization
0002: jump ££LabelGuardPossibility1

:LabelWeaponRandomization1
0001: wait 250 ms
00D6: if  0
0038: egi $VAR6 = 1
004D: jump_if_false ££LabelWeaponRandomization
0247: request_model #M4
00D6: if  0
0248: model #M4 available
004D: jump_if_false ££LabelWeaponRandomization1

:LabelGuardPossibility1  
0001: wait 250 ms
00D6: if 1
0038: egi $VAR5 = 0
0038: egi $VAR6 = 0
004D: jump_if_false ££LabelGuardPossibility2
0054: store_player $PLAYER_CHAR position_to  1@  2@  3@  
0007:  4@ =  1.2;; floating-point values
005B:  4@ +=  1@;; floating-point values (never used in VC or GTA 3)
009A:  0@ = create_actor  13 #PGA at  4@  2@  3@
01B2: give_actor  0@ weapon  23 ammo  9999;; Load the weapon model before using this
0002: jump ££Label00B0DC

:LabelGuardPossibility2
0001: wait 250 ms
00D6: if 1
0038: egi $VAR5 = 1
0038: egi $VAR6 = 0
004D: jump_if_false ££LabelGuardPossibility3
0054: store_player $PLAYER_CHAR position_to  1@  2@  3@  
0007:  4@ =  1.2;; floating-point values
005B:  4@ +=  1@;; floating-point values (never used in VC or GTA 3)
009A:  0@ = create_actor  13 #SGa at  4@  2@  3@
01B2: give_actor  0@ weapon  23 ammo  9999;; Load the weapon model before using this
0002: jump ££Label00B0DC

:LabelGuardPossibility3
0001: wait 250 ms
00D6: if 1
0038: egi $VAR5 = 0
0038: egi $VAR6 = 1
004D: jump_if_false ££LabelGuardPossibility4
0054: store_player $PLAYER_CHAR position_to  1@  2@  3@  
0007:  4@ =  1.2;; floating-point values
005B:  4@ +=  1@;; floating-point values (never used in VC or GTA 3)
009A:  0@ = create_actor  13 #PGA at  4@  2@  3@
01B2: give_actor  0@ weapon  26 ammo  9999;; Load the weapon model before using this
0002: jump ££Label00B0DC

:LabelGuardPossibility4
0001: wait 250 ms
00D6: if 1
0038: egi $VAR5 = 1
0038: egi $VAR6 = 1
004D: jump_if_false ££LabelGuardPossibility1
0054: store_player $PLAYER_CHAR position_to  1@  2@  3@  
0007:  4@ =  1.2;; floating-point values
005B:  4@ +=  1@;; floating-point values (never used in VC or GTA 3)
009A:  0@ = create_actor  13 #SGa at  4@  2@  3@
01B2: give_actor  0@ weapon  26 ammo  9999;; Load the weapon model before using this

:Label00B0DC
035E: set_player $PLAYER_CHAR armour_to  100
01ED: reset_actor  0@ flags
0243: set_actor  0@ ped_stats_to  0
0223: set_actor  0@ health_to  180
02E2: set_actor  0@ weapon_accuracy_to  100
01DF: tie_actor_to_player  0@  $PLAYER_CHAR

:Label00B15C
0001: wait  250 ms
00D6: if  0
0118:   actor  0@ dead
004D: jump_if_false ££Label00B15C
0001: wait  2500 ms
034F: destroy_actor_with_fade  0@;; The actor fades away like a ghost
0001: wait  1200 ms

:LabelModelRelease1
0001: wait 250 ms
00D6: if 1  
0038: egi $VAR5 = 0
0038: egi $VAR6 = 0
004D: jump_if_false ££LabelModelRelease2
0249: release_model #PGA
0249: release_model #UZI
0002: jump ££Label00B0A6

:LabelModelRelease2
0001: wait 250 ms
00D6: if 1  
0038: egi $VAR5 = 1
0038: egi $VAR6 = 0
004D: jump_if_false ££LabelModelRelease3
0249: release_model #SGa
0249: release_model #UZI
0002: jump ££Label00B0A6

:LabelModelRelease3
0001: wait 250 ms
00D6: if 1  
0038: egi $VAR5 = 0
0038: egi $VAR6 = 1
004D: jump_if_false ££LabelModelRelease4
0249: release_model #PGA
0249: release_model #M4
0002: jump ££Label00B0A6

:LabelModelRelease4
0249: release_model #SGa
0249: release_model #M4
0002: jump ££Label00B0A6


My bet is that the randomization opcode (0209) is what is making the game crash. Apologies for thr lack of comments.

Craig Kostelecky
  • Craig Kostelecky

    GTA:LC Team Leader

  • The Connection
  • Joined: 28 Jan 2004
  • None

#2

Posted 22 May 2005 - 01:34 AM

You're right that 0209 is the issue. The variable has to be the first parameter. Then you have the lower and upper integers as the second and third parameters. Like this:
CODE
0209: $VAR5 = random_int 0 1

Thesord
  • Thesord

    Lacking time

  • Members
  • Joined: 12 Aug 2003

#3

Posted 22 May 2005 - 03:54 PM

Thanks for the help Craig, now it stopped crashing, but another problem has risen, the randomness never occurs.. I set up $VAR5 and $VAR6 and use them during the script for that purpose, but I've tried more than ten times now, and I always get the actor with #PGA and #UZI models, just like if those 2 global variables were always 0. I know you can never be sure with random numbers, but it just seems to me that it isn't working.

Craig Kostelecky
  • Craig Kostelecky

    GTA:LC Team Leader

  • The Connection
  • Joined: 28 Jan 2004
  • None

#4

Posted 23 May 2005 - 06:24 AM

I'm not sure if the random number generator is inclusive or exclusive. Meaning I'm not sure if rand 0 4 will return 0, 1, 2, 3, or 4 or 1, 2, or 3. Maybe you could solve this by using rand 0 10. Then check if the number is greater or less than 5.

Thesord
  • Thesord

    Lacking time

  • Members
  • Joined: 12 Aug 2003

#5

Posted 26 May 2005 - 03:43 PM

CODE
:Label00B0A6
0001: wait  250 ms
00D6: if  0
0256:   player $PLAYER_CHAR defined
004D: jump_if_false ££Label00B0A6
00D6: if  0
80E0: NOT    player $PLAYER_CHAR driving
004D: jump_if_false ££Label00B0A6
00D6: if  0
00E1:   key_pressed  0  19
004D: jump_if_false ££Label00B0A6
0209: $VAR5 = random_int 0 10
0209: $VAR6 = random_int 0 10

:LabelGuardRandomization
0001: wait 250 ms
00D6: if  1  
002A: gteig  5 >=  $VAR5
004D: jump_if_false ££LabelGuardRandomization1
0247: request_model #PGA
00D6: if  0
0248: model #PGA available
004D: jump_if_false ££LabelGuardRandomization
0002: jump ££LabelWeaponRandomization

:LabelGuardRandomization1
0001: wait 250 ms
00D6: if  0
002A: gteig  5 <=  $VAR5
004D: jump_if_false ££LabelGuardRandomization
0247: request_model #CBa
00D6: if  0
0248: model #SGa available
004D: jump_if_false ££LabelGuardRandomization1

:LabelWeaponRandomization
0001: wait 250 ms
00D6: if  0
002A: gteig  5 >=  $VAR6
004D: jump_if_false ££LabelWeaponRandomization1
0247: request_model #UZI
00D6: if  0
0248: model #UZI available
004D: jump_if_false ££LabelWeaponRandomization
0002: jump ££LabelGuardPossibility1

:LabelWeaponRandomization1
0001: wait 250 ms
00D6: if  0
002A: gteig  5 <=  $VAR6
004D: jump_if_false ££LabelWeaponRandomization
0247: request_model #M4
00D6: if  0
0248: model #M4 available
004D: jump_if_false ££LabelWeaponRandomization1

:LabelGuardPossibility1  
0001: wait 250 ms
00D6: if 1
002A: gteig  5 >=  $VAR5
002A: gteig  5 >=  $VAR6
004D: jump_if_false ££LabelGuardPossibility2
0054: store_player $PLAYER_CHAR position_to  1@  2@  3@  
0007:  4@ =  1.2 ;; floating-point values
005B:  4@ +=  1@ ;; floating-point values (never used in VC or GTA 3)
009A:  0@ = create_actor  13 #PGA at  4@  2@  3@
01B2: give_actor  0@ weapon  23 ammo  9999 ;; Load the weapon model before using this
0002: jump ££Label00B0DC

:LabelGuardPossibility2
0001: wait 250 ms
00D6: if 1
002A: gteig  5 <=  $VAR5
002A: gteig  5 >=  $VAR6
004D: jump_if_false ££LabelGuardPossibility3
0054: store_player $PLAYER_CHAR position_to  1@  2@  3@  
0007:  4@ =  1.2 ;; floating-point values
005B:  4@ +=  1@ ;; floating-point values (never used in VC or GTA 3)
009A:  0@ = create_actor  13 #CBa at  4@  2@  3@
01B2: give_actor  0@ weapon  23 ammo  9999 ;; Load the weapon model before using this
0002: jump ££Label00B0DC

:LabelGuardPossibility3
0001: wait 250 ms
00D6: if 1
002A: gteig  5 >=  $VAR5
002A: gteig  5 <=  $VAR6
004D: jump_if_false ££LabelGuardPossibility4
0054: store_player $PLAYER_CHAR position_to  1@  2@  3@  
0007:  4@ =  1.2 ;; floating-point values
005B:  4@ +=  1@ ;; floating-point values (never used in VC or GTA 3)
009A:  0@ = create_actor  13 #PGA at  4@  2@  3@
01B2: give_actor  0@ weapon  26 ammo  9999 ;; Load the weapon model before using this
0002: jump ££Label00B0DC

:LabelGuardPossibility4
0001: wait 250 ms
00D6: if 1
002A: gteig  5 <=  $VAR5
002A: gteig  5 <=  $VAR6
004D: jump_if_false ££LabelGuardPossibility1
0054: store_player $PLAYER_CHAR position_to  1@  2@  3@  
0007:  4@ =  1.2 ;; floating-point values
005B:  4@ +=  1@ ;; floating-point values (never used in VC or GTA 3)
009A:  0@ = create_actor  13 #CBa at  4@  2@  3@
01B2: give_actor  0@ weapon  26 ammo  9999 ;; Load the weapon model before using this

:Label00B0DC
035E: set_player $PLAYER_CHAR armour_to  100
01ED: reset_actor  0@ flags
0243: set_actor  0@ ped_stats_to  0
0223: set_actor  0@ health_to  180
02E2: set_actor  0@ weapon_accuracy_to  100
01DF: tie_actor_to_player  0@  $PLAYER_CHAR

:Label00B15C
0001: wait  250 ms
00D6: if  0
0118:   actor  0@ dead
004D: jump_if_false ££Label00B15C
0001: wait  2500 ms
034F: destroy_actor_with_fade  0@ ;; The actor fades away like a ghost
0001: wait  1200 ms

:LabelModelRelease1
0001: wait 250 ms
00D6: if 1  
002A: gteig  5 >=  $VAR5
002A: gteig  5 >=  $VAR6
004D: jump_if_false ££LabelModelRelease2
0249: release_model #PGA
0249: release_model #UZI
0002: jump ££Label00B0A6

:LabelModelRelease2
0001: wait 250 ms
00D6: if 1  
002A: gteig  5 <=  $VAR5
002A: gteig  5 >=  $VAR6
004D: jump_if_false ££LabelModelRelease3
0249: release_model #CBa
0249: release_model #UZI
0002: jump ££Label00B0A6

:LabelModelRelease3
0001: wait 250 ms
00D6: if 1  
002A: gteig  5 >=  $VAR5
002A: gteig  5 <=  $VAR6
004D: jump_if_false ££LabelModelRelease4
0249: release_model #PGA
0249: release_model #M4
0002: jump ££Label00B0A6

:LabelModelRelease4
0249: release_model #CBa
0249: release_model #M4
0002: jump ££Label00B0A6


Well I updated and did as you suggested, but now something else happens, it still only spawns the PGA and UZI models, and sometimes the actor doesn't respawn when I press the button, thus seeming like the the thread stopped. I'm not quit sure why this is happening.

Craig Kostelecky
  • Craig Kostelecky

    GTA:LC Team Leader

  • The Connection
  • Joined: 28 Jan 2004
  • None

#6

Posted 27 May 2005 - 03:49 AM

I can see what's wrong with this code. You're using 002A for all of your comparisons. The ">=" or "<=" that show up are only there for a visual aid. They are completely ignored by the compiler. Here's the way those opcodes should be used in MB.

This would check if 5 is greater or less than $VAR5.
CODE
002A:   5 >= $VAR5

If you want to check the opposite way, you need to use 0028.
CODE
0028:   $VAR5 >= 5  




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users