Jump to content

Model ID to Name


HeresOtis

Recommended Posts

How do you change a car's ID to the model name?

I use this opcode to get the model

 

0441: 6@ = car $TEMPVAR_ACTOR_CAR model 

 

 

I want to make it where it changes the ID number to the model name and display it as a text with this opcode

 

033E: set_draw_text_position 320.0 180.333 GXT 'BJ_PUSH' // Push

 

 

Also, the same with weapon IDs?

Link to comment
Share on other sites

The answer is you can`t since there are no names of loaded models TXD libraries. There are only hashes in case of getting ID by model name, but that`s not what you`re going to.

Take a look how it is loading cars, one of IDE sections.

 

  objID = -1; _p4 = -1; v2 = txdIndexByName((unsigned __int8 *)"vehicle"); v1 = v2; if ( v2 == -1 )   v1 = txdAdd("vehicle"); sscanf(   line,   "%d %s %s %s %s %s %s %s %d %d %x %d %f %f %d",   &objID,   modelName,   texName,   type,   handlingID,   gameName,   anims,   Class,   &frq,   &flags,   &comprules,   &_p1,   &_p2,   &_p3,   &_p4); VehicleInfo = (CModelCars *)allocCarsModel(objID); *((_DWORD *)VehicleInfo + 1) = crc32FromUpcaseString((unsigned __int8 *)modelName); _CModelBase__setTxd(VehicleInfo, (unsigned __int8 *)texName); v3 = *((_WORD *)VehicleInfo + 5); if ( *(_BYTE *)(v3 + *((_DWORD *)TexDictionaryPool + 1)) >= 0 )   v5 = *(_DWORD *)TexDictionaryPool + 12 * v3;

 

 

 

 

  _CModelBase__setTxd(VehicleInfo, (unsigned __int8 *)texName);

 

It is being processed after IMG archives have been already loaded. As you can see the name of model or texture is no longer needed due to the fact only offset of an appropriate packed file is used later to identify file in IMG archive so don`t expect to retrieve a model or TXD library name.

 

On other hand, model name to ID: http://gtag.gtagaming.com/forums/index.php...findpost&p=3572

For whose who are going to do inversely than topic`s author

Edited by fastman92
Link to comment
Share on other sites

If i've understand right, you want to have a car model name on display by a script?

If i'm right here is the way to do it - download & look in to the source file (const section in the begining & some sections in the end)

Link to comment
Share on other sites

he don't need the model name but the gamename (gxt entry)

cleo4 opcode: 0ADB:

Link to comment
Share on other sites

he don't need the model name but the gamename (gxt entry)

cleo4 opcode: 0ADB:

Can you give me example on how to use? Do I just do this?

 

 

0ADB: 0@v = car_model #LANDSTAL namewait 100ADE: 0@ = text_by_GXT_entry 0@v

 

Link to comment
Share on other sites

If you want to display it using regular SA opcodes, 0ADB is enough.

Link to comment
Share on other sites

If you want to display it using regular SA opcodes, 0ADB is enough.

So would it be:

 

 

13@ = Car.Model(10@)wait 100ADB: 0@v = car_model 13@ name033E: set_draw_text_position 320.0 180.333 GXT '0@v'  // Push

 

 

Link to comment
Share on other sites

Without ' ' in 033E, yeah.

 

Edit:

I just noticed - it's better to use 0@s instead of 0@v here.

Link to comment
Share on other sites

Vehicle name is a 8-byte string such as all unhashed GXT entries. It's just a clarification for HeresOtis.

Link to comment
Share on other sites

Can someone give me a small script where it displays a vehicles name in the top-left corner of screen? Not the Player's Vehicle, but a vehicle that will be created in my script.

Link to comment
Share on other sites

aStiffSausage

Well, this is pretty much what I also need. And, is it possible to use the same for current zone?

Link to comment
Share on other sites

Yep.

 

It isn't hard, just do someting like:

 

 

{$CLEO}0000: CARNAME_ZONENAMEwhile true   0001: wait 0 ms   03F0: enable_text_draw 1   if       00DF:   actor $PLAYER_ACTOR driving   then       03C0: 0@ = actor $PLAYER_ACTOR car       0441: 1@ = car 0@ model       0ADB: 2@s = car_model 1@ name              // Format the text anyhow you want       033E: set_draw_text_position 0.0 0.0 GXT 2@s   end   00A0: store_actor $PLAYER_ACTOR position_to 0@ 1@ 2@   0843: get_zone_at 0@ 1@ 2@ nameA_to 3@s // 8-byte string      if        05AD:   3@s == "SAN_AND"  // San Andreas   then       094B: 3@v = get_active_interior_name_from_actor $PLAYER_ACTOR // 16-byte string    end   // Format the text anyhow you want   033E: set_draw_text_position 0.0 0.0 GXT 3@send

 

 

 

Of course you need to adjust the position of your text draw etc.

 

Easy.

Link to comment
Share on other sites

aStiffSausage

Thank you. smile.gif

 

Is this check necessary?

 

 

if 05AD:   3@s == "SAN_AND"  // San Andreas

 

Link to comment
Share on other sites

No, but without it you'll have "San Andreas" all the time instead of "Pizza stack", for example.

Link to comment
Share on other sites

aStiffSausage

I can't seem to get it to work outdoors, only while I'm inside. Is there some other opcode for outdoor names?

EDIT: Ooops, mistake in variables. blush.gif

 

Thank you really much! smile.gif

 

 

Oh, and does high level structure really give any advantages, other than it's easier to read than low level structure?

Edited by oksa8
Link to comment
Share on other sites

It's much easier to read and trace bugs with high level structures.

Link to comment
Share on other sites

Oh, and does high level structure really give any advantages, other than it's easier to read than low level structure?

At first is it an advantage for those people who know it because they allready have experience in other script languages.

A part of them are confused because of the label system. High level looks more clear because it makes free from the label system, no need to put a label here and there to can jump or jump if false.

And it allows some tricky constructs like this tiny loop which you can insert always and everywhere:

 

repeatwait 0until 8AB0: not  key_pressed 8

 

 

after recompiling:

 

:Label0001: wait 0 ms 8AB0:   not key_pressed 8 004D: jump_if_false @Label

 

 

You don't need to learn high level, but you could learn it to expand your knowledge and skills.

For me is it easier to write in low level because the classic scm style was my first script language and sometimes i insert highlevels if it makes sense.

Link to comment
Share on other sites

ZAZ, R* style uses high level statements, so writing a script line-by-line is like creating an ASM routine. ASM is sometimes useful rather than using the compiler programming language, mostly for hook. Writing a code in basic SCM just makes the script hard to understand.

 

I advice you to switch into high level programming completely. Learning compiled code will expand your knowledges and skills. wink.gif

Link to comment
Share on other sites

I would say the same. I converted what is left of the differences between R*'s native code and Sanny's syntax here.

 

With the right setup, it's easy to make coding as R*-ish as possible. The only problem that Sanny Builder has is the slow processing of constants. It seems clear that AudioEvents.txt was used as constants for audio ID's, but Sanny Builder took a whole minute to process them as constants.

 

Anyway, as I say, high constructing makes code not only faster to find mistakes in but also much faster to actually code. And it's more universal since low constructing can be formatted in a lot of strange ways.

Link to comment
Share on other sites

  • 6 years later...
Hayate Kankichi

 

QUOTE (oksa8 @ Saturday, Oct 15 2011, 16:19)

Oh, and does high level structure really give any advantages, other than it's easier to read than low level structure?

At first is it an advantage for those people who know it because they allready have experience in other script languages.

A part of them are confused because of the label system. High level looks more clear because it makes free from the label system, no need to put a label here and there to can jump or jump if false.

And it allows some tricky constructs like this tiny loop which you can insert always and everywhere:

CODE repeat

wait 0

until 8AB0: not key_pressed 8

 

after recompiling:

CODE :Label

0001: wait 0 ms

8AB0: not key_pressed 8

004D: jump_if_false @Label

 

You don't need to learn high level, but you could learn it to expand your knowledge and skills.

For me is it easier to write in low level because the classic scm style was my first script language and sometimes i insert highlevels if it makes sense.

 

well I have A Question.

I have a script which can work as helmet in SAMP. and can protect them from Headshots.

because for noobs players. one helmet is not enough. so I want to make it Look like more realistic.

model Name SWATHgrey

and id 19514

I want it in script. now I can add it with collision. Help please.

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