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. Los Santos Summer Special
      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. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

    2. GTA 6

      1. St Andrews Cathedral
    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    9. GTA Vice City

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

      1. Guides & Strategies
      2. Help & Support
    11. 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. DYOM
      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

hmvartak

How to limit max speed ?

Recommended Posts

hmvartak

Please, someone tell me, how to use opcode 00AD? I want to limit the max speed of car to some low value(10KM/h or something). I used 00AD to do that but it doesn't work.

My code is here.

 

:PAT0247: request_model #PATRIOT038B: load_requested_models:CML0001: wait 000D6: if 0248: model #PATRIOT available004D: jump_if_false @CML00A5:$mycar = create_car #PATRIOT at 2463.694 -1658.857 13.3109800AD: set_car $mycar max_speed_to 10.0

 

Thank you!

Share this post


Link to post
Share on other sites
Demarest
I believe that that command is for NPC drivers. If you wanted to limit your own speed, you'd need a loop to see if you're driving or if you're driving a certain car. Then get the speed and if it's greater than the value you want, set speed instantly to what you want to be max.

Share this post


Link to post
Share on other sites
hmvartak

How can I do that? Which opcode should I use?

Share this post


Link to post
Share on other sites
Demarest
Well the reason I said set speed instantly despite that being an awkward way of speaking is because that's what the opcode was labelled. I don't know if you're asking about that one or getting your car's speed, but searching the opcode database will solve either and it's a good habit to get into anyways.

Share this post


Link to post
Share on other sites
hmvartak

I searched both opcode database and existing codes in main. I found opcode 04BA and tried this code.

 

 

:DRIVERwait 0 msif    Actor.Driving($PLAYER_ACTOR)else_jump @DRIVER 0811: $ACTCAR = actor $PLAYER_ACTOR car 02E3: $SPEED = car $ACTCAR speed :SPEEDwait 100 msif  $SPEED > 10.0 // floating-point values else_jump @SPEED04BA: set_car $SPEED speed_instantly 10.0jump @SPEED

 

 

It still not working.

Share this post


Link to post
Share on other sites
Demarest

You need to check if player is defined before addressing the player. Your code dead-ends into the second loop. It should jump back to the beginning, which would kill the need for another wait. Also, you'll want to check to see if player is still driving the same car and if not, remove references to it. Finally, you should use local vars when possible to save space and resources.

 

Unless you leave the first car you enter, I see no reason why this code wouldn't work. Are you sure it's running?

Share this post


Link to post
Share on other sites
Seemann

And don't use 0811 ever, there's 03C0 for that.

 

If you were using 03C0, you don't need to remove references on the vehicle, as 03c0 doesn't make it unique, it just returns its handle.

Share this post


Link to post
Share on other sites
SteaVor

Could this be connected with the strange behaviour I experienced in VC recently? Cars that were caught with 03C0 couldn't be made "accepted" by a garage(021b - set_garage_to_accept_car). When I used a "create_car" 'd vehicle everything worked fine.

Share this post


Link to post
Share on other sites
Seemann

So, you stored car's handle to variable using 03C0 and made garage to accept a vehicle by this variable?

 

As 03c0 just returns car's handle (in other words its index in vehicles pool), you make garage to accept a vehicle with this index. But as the car wasn't unique, its index may be changed when game generates traffic, player exit it, etc. So, for example garage waits for the car 1000, but player's car handle may be 2000 at that moment.

Create_car opcode makes it unique, so its handle is never changed.

 

Just my thoughts, I don't know how engine operates with garages accepting cars. Take a look later.

Share this post


Link to post
Share on other sites
SteaVor
So, you stored car's handle to variable using 03C0 and made garage to accept a vehicle by this variable?

Exactly, and when I did some testing with this I drew the same conclusion that you've presented. So it's not possible to make a garage accept cars with a dynamic handle? sad.gif

Is there an opcode to make the handle permanent?

Share this post


Link to post
Share on other sites
Seemann

In SA there's one I posted recently at the opcodes topic. I don't know if there's one for VC though.

 

You may try 053e to get the player car handle. 053e (btw, it named wrong, should be 'get_random_car_with_model') makes the car unique.

Share this post


Link to post
Share on other sites
SteaVor

That's exactly what came to my mind a moment ago! I was about to ask if I could do it this way, but you've answered it already. Thanks! (I remembered your post in SA's opcode topic, but knew I couldn't use it.)

 

btw:

If you're right about 03C0, then it can't be used for the original purpose of the topic, because even a wait 0 would make the variable point to another car than the one you want to modify and therefore break the code, wouldn't it?

 

@Demarest:

The error is obvious to such an extent that you failed to see it:

 

04BA: set_car $SPEED speed_instantly 10.0

 

There is no car named $SPEED! tounge.gif Replace it with $ACTCAR (or better yet, a local var). I don't know if it's working then. It won't if my train of thought outlined above is right.

Edited by SteaVor

Share this post


Link to post
Share on other sites
Seemann

 

If you're right about 03C0, then it can't be used for the original purpose of the topic, because even a wait 0 would make the variable point to another car than the one you want to modify and therefore break the code, wouldn't it?

I think while player's driving, his car's handle not changed. But when if he leave the car, it could be changed. Otherwise, you're right - even wait 0 between 03c0 and any referring to the car may cause the error in theory.

 

ps. Nice find about $SPEED, I missed it also lol.gif

Share this post


Link to post
Share on other sites
SteaVor
I think while player's driving, his car's handle not changed. But when if he leave the car, it could be changed.

Tested it right now and you're absolutely right again.

Share this post


Link to post
Share on other sites
hmvartak

Finally I have got the working code. There were two bugs in my code. Player was not defined and wrong car handle.

 

I found that this code works with 0811 as well as 03c0.

 

Here is the code

 

:DEFINEwait 0 msif0256:player $PLAYER_CHAR defined else_jump @DEFINE:DRIVER    ifActor.Driving($PLAYER_ACTOR)else_jump @DEFINE 0811: [email protected] = actor $PLAYER_ACTOR car 02E3: [email protected] = car [email protected] speed :SPEEDif  [email protected] > 10.0 // floating-point values else_jump @DEFINE04BA: set_car [email protected] speed_instantly 10.0jump @DEFINE

 

 

Thanks to all of you!

Share this post


Link to post
Share on other sites
Demarest

Looking good! Just so you know, you don't need those extra labels as nothing jumps to them.

 

Now take it to the next level. After you capture the car, instead of just jumping back to the beginning after you check the speed, check to see if player is still driving the same car and if not, remove references to it. Then it will be perfect code smile.gif

Share this post


Link to post
Share on other sites
Seemann

Demarest;

 

There's no need to remove references to the car at all. Firstly it's useless (read posts above), secondly it may cause a problem when say during the mission player will drive the unique car with references and this code remove them. The mission car may disappear then.

Share this post


Link to post
Share on other sites
Demarest

"posts above" says 03C0. He's using 0811. If you're going to make a statement like "no need... at all," then please explain why after years of needing to, suddenly we don't need to? You know this stuff more than I do, so I'll take your word for it. But please clarify.

 

Also, if two different threads are handling a vehicle and one removes references, the other will still retain it.

Share this post


Link to post
Share on other sites
Seemann

Well, I don't mean that you NEVER need to remove_references, may be I said it wrong. In some cases you NEED, but doing it after 03c0/0811 it isn't necessary.

 

0811 doesn't make a car unique as well. In fact only limited number of opcodes adds references to the car (such as create_car, get_random_car, etc).

Years of needing to, you says? Well, why do opcode 00E2 was listed with 2 parameters for years, if it has 3 ones? Why 00d7 was named create_thread_with_wasted_busted_check if it do nothing with that check? I don't know.

 

You may complete a quick test: get player's car to variable using 03c0 or 0811, leave it, get another car and drive away. After 3-5 minutes return to the place where you left the car and you will not find it. It happens to me. The referenced cars never disappear, so 03c0/0811 make no references.

 

If you don't believe me I could post the code listing of opcode 03c0 from exe where is no any references stuff, only storing car handle to variable.

 

Have a nice day tounge.gif

 

 

 

Share this post


Link to post
Share on other sites
Demarest

 

Years of needing to, you says? Well, why do opcode 00E2 was listed with 2 parameters for years, if it has 3 ones?
If you don't believe me...

confused.gif

 

Were you trying to be argumentative, or what? No GTA3D has used 00E2, so there's no correlation between that and suddenly not needing to remove references. At first, you said no need at all. Since then, you've clarified. Why not leave it at that?

 

And if I don't believe you? I won't kiss your feet, but I've already stated that you would know better than I would and that I was just seeking for clarification. Which you provided. There was no need for the combativeness when it was a genuine inquiry. I don't know if you've noticed, but I have this thing where I like to understand SCM and how/why things work the way they do. Thanks for the decent parts of your post anyways.

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.