Mission Coding for Dummies - Status Bars

A Tutorial for Grand Theft Auto: San Andreas

Hello world. We are one of the oldest mod sites on the Interwebs. Sign up and maximize your browsing experience.

  • Subscribe: Get notified of new submissions like this.
  • Say Thanks: Show your appreciation by sending Arman Ossi Loko points.
  • Post: Give Arman Ossi Loko your thoughts on this Tutorial.
  • Vote: Help Arman Ossi Loko win the Monthly Awards.
  • Rate: Give this Tutorial a rating out of 10.
  • Flag: Alert moderators and warn members of a problem with this Tutorial.
  • Watch: Get notified when this Tutorial is updated.
Mascot

Sound fun?

Sign up

Already a Bananite? Login

Status Bars This tutorial is about Status Texts, or "bars". You can find them in SA missions like "Drive-By" and "supply-lines". CODE > :SWEET4_47 Model.Load(#GREENWOO) 038B: load_requested_models :SWEET4_103 if not Model.Available(#GREENWOO) else_jump @SWEET4_152 wait 0 jump @SWEET4_103 :SWEET4_152 1@ = 2508.16 2@ = -1666.47 3@ = 13.0 4@ = 16.0 0395: clear_area 1 at 1@ 2@ 3@ range 6.0 5@ = Car.Create(#GREENWOO, 1@, 2@, 3@) 0229: set_car 5@ color_to 59 34 Car.Angle(5@) = 4@ Car.Health(5@) = 1450 $health = Car.Health(5@) This code is just spawning a vehicle, the Greenwood. In addition the health of the car is stored in variable $health. First I will explain the principle. The bar goes from 0 to 100, it are percentages. The initial health of the car is 1450. Under the 250, the car will be destroyed. So 250 will be the 0 of the bar. When 250 is in the bar 0, then the 1450 is 1200 (1450 - 250). Because you have only from 0 to 100, you have to divide it by 12. You have to code it like this: CODE > 0084: $health2 = $health // integer values and handles if $health2 > 250 // integer values else_jump @SWEET4_11472 $health2 -= 250 // integer values :SWEET4_11472 $health2 /= 12 // integer values Before you can subtract 250, you have to check if it is more then 250. Otherwise it will be a negative number, which can't be in the bar. If the number is beneath the 250, you have to go to the next label (with the jump). If the number is above the 250, you have to subtract the 250. Then you have to divide the number by 12, so it is a number between the 0 and the 100. CODE > 0151: remove_status_text $health2 03C4: set_status_text_to $health2 1 'SWE4_08' // CAR HEALTH This is the code of the "bar". You won't see the "car health" text, because the GXT is not correct, but we will ignore that here. You can place a 0 instead of the 1, but then it will be displayed as number ingame, and it won't be a bar. CODE > repeat wait 0 ms $health = Car.Health(5@) 0084: $health2 = $health // integer values and handles if $health2 > 250 // integer values else_jump @SWEET4_11472 $health2 -= 250 // integer values :SWEET4_11472 $health2 /= 12 // integer values until $health < 250 0151: remove_status_text $health2 end_thread We want to make a bar until the car is wrecked, so when the variable is 0, the bar has to disappear. This is a repeat-wait-until structure, so it has to repeat everything from the repeat-command until the condition is true. The condition is that $health has to be below the 250. He has to check the car health every time, and has to make it a number between 0 and 100. That's why it has to be between the repeat and until. When you don't do that, it will be the same number, because the variable $health2 won't be changed. So you have to wait until the health of the car is below the 250, then the car will be wrecked. After that you have to let the bar disappear with the 0151 opcode. After that you have to use the end_thread opcode, because else the game will crash if you don't properly end tha thread. [When you add the code in a stripped SCM file, you will see the bar.](http://pastebin.com/f5e476374 "")

Posts

None found

Share

Shareable Image:
Share banner
HTML embed code:
BB embed code:
Markdown embed code:

More embeddable images

Bookmark and Share

Credits

Original Authors
Dutchy3010

Submitter

Arman Ossi Loko avatar
Arman Ossi Loko avatar Lurkin'
Admin Joined 10y
71,925 points Ranked 56th
63 medals 9 legendary 16 rare
  • GTAV First Adopter Medal icon
  • Submitted 15 Tools Medal icon
  • Submitted 30 Tutorials Medal icon
  • 1st place - 2015 Uberstyles Contest Medal icon
  • Achieved Admin clearance Medal icon
  • 15+ Entries! GameBanana’s Christmas Giveaway 2015 Medal icon

Arman Ossi Loko avatar
Arman Ossi Loko
KOPASSUS Incorporated Flag
KOPASSUS Incorporated

Redistributor
Are you the owner? Request Ownership
Sign up to access this!
Sign up to access this!
Sign up to access this!
Sign up to access this!

Category

Details

Difficulty Level
Beginner Difficulty

Attributes

Stats

Posts
0
Views
1,990
Date Added
5y
Date Modified
4y
bcp.crwdcntrl.net tracking pixel