Jump to content

Opcode help


sgtpepper901

Recommended Posts

sgtpepper901

Hi, I need help finding, or making, an opcode. It's to be placed under If and here is how it goes. I want it to be (If) the player's car has no empty seats.

 

I tried this

 

 

00D6: if0000: actor $PLAYER_ACTOR car_max_passengers

 

 

I'm not sure if that would work or is even close to being right. Please help me.

 

 

Link to comment
Share on other sites

 

//  Example of use://  if// 0AB1: call_scm_func @ActorCar_SeatsFull 1 Actor $PLAYER_ACTOR:ActorCar_SeatsFull{Actor}03C0: 0@ = actor 0@ carif 0@ <> -1then   01E9: 1@ = car 0@ num_passengers   01EA: 2@ = car 0@ max_passengers   1@ > 2@else   0485: return_trueend0AB2: ret 0

 

 

Not sure if this part "1@ > 2@" is right, I didn't test.

Edited by Link2012
Link to comment
Share on other sites

sgtpepper901

If this works then by God you are amazing. cookie.gifcookie.gifcookie.gifcookie.gifcookie.gifcookie.gifcookie.gifcookie.gifcookie.gifcookie.gif Many cookies for you. Will test it tomorrow.

 

 

Link to comment
Share on other sites

 

Not sure if this part "1@ > 2@" is right, I didn't test.

It isn't. The compiler is unable to understand that syntax because it doesn't know the type of those local variables, so it cannot decide arbitrarily which opcode is better to use. They must be declared first:

 

[...]if00DF:  actor $PLAYER_ACTOR drivingthen  03C0: 0@ = actor $PLAYER_ACTOR car  if  0AB1: call_scm_func @areVehicleSeatsFull 1 vehicle 0@   then    // Player's vehicle seats are full  endend[...]//  Example of use://  if//  0AB1: call_scm_func @areVehicleSeatsFull 1 vehicle 0@:areVehicleSeatsFull{handle}var  1@: Integer  2@: Integerendif 0@ <> -1then  01E9: 1@ = car 0@ num_passengers  01EA: 2@ = car 0@ max_passengers  1@ == 2@else  059A: return_falseend0AB2: ret 0

 

I fixed the code a little bit. wink.gif

Link to comment
Share on other sites

 

Not sure if this part "1@ > 2@" is right, I didn't test.

It isn't. The compiler is unable to understand that syntax because it doesn't know the type of those local variables, so it cannot decide arbitrarily which opcode is better to use.

This is'nt a error at all tounge.gif

Link to comment
Share on other sites

Fixed the code a little bit yet tounge.gif

 

 

//  Example of use://  if//  0AB1: call_scm_func @areVehicleSeatsFull 1 vehicle 0@:areVehicleSeatsFull{handle}var 1@: Integer 2@: Integerendif 0@  -1then 01E9: 1@ = car 0@ num_passengers 01EA: 2@ = car 0@ max_passengers 1@ == 2@end0AB2: ret 0

 

return_false was still useless.

Edited by SilentPL
Link to comment
Share on other sites

Who said it's not valid? It's perfectly valid.

Link to comment
Share on other sites

 

This isn't an error at all. tounge.gif

No, the last comparing condition was wrong. tounge.gif

 

 

return_false was still useless.

Indeed, the first condition already returns false, so returning a false value again is inefficent. smile.gif

Link to comment
Share on other sites

Fixed the code a little bit yet tounge.gif

 

 

//  Example of use://  if//  0AB1: call_scm_func @areVehicleSeatsFull 1 vehicle 0@:areVehicleSeatsFull{handle}var 1@: Integer 2@: Integerendif 0@ <> -1then 01E9: 1@ = car 0@ num_passengers 01EA: 2@ = car 0@ max_passengers 1@ == 2@end0AB2: ret 0

 

return_false was still useless.

Create functions is an efficient way to solve common problems in time to make the script. The function above is a good example. Does anyone know if exist others???

Link to comment
Share on other sites

Despite everything, I'm thinking (or hoping, rather) coding and programming modification is getting more advanced. Or at least I'm able to see that there are other modders who can handle the most demanding of challenges in modding. My website, GTAG (no links this time, I'm still not sure enough to say that wouldn't cause a drama), changed from a really lax effort at a GTA fansite to a place with a reasonably heavy amount of good modding content, particularly around the coding areas. So I'm trying to drive that forward and expand to more areas of modding that I also still have to learn.

 

Anyway, my there's a coding snippets topic which has gathered a nice amount coding tricks and many 'SCM functions' and even some good tricks which can be used when creating your own SCM Funcs. Because it's still a small community of knowledgable modders, not a lot else aside from documentation and code gets posted. Just a small, managable amount of help topics. Not trying to pat myself on the back, of course. I'm just (a bit psychotically) eager to have more people working towards breakthroughs in modding. I want the information to be open and easily accessible. You've played your role in the past in helping set the way for future and it's nice to think that my contributions will too help other people to go that further step (and in turn, I'll learn from their discoveries).

 

I really shouldn't be allowed to post unless it's about modding.

 

PS: I had a pretty stressful day, I'm probably talking a lot of junk, it's one of those appreciate the good things times tounge2.gif

Link to comment
Share on other sites

sgtpepper901

Wow, I am honored to have the creator of one of these sites post that on my own thread!

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.