Quantcast

Jump to content

» «
Photo

Opcode help

14 replies to this topic
sgtpepper901
  • sgtpepper901

    Player Hater

  • Members
  • Joined: 13 Apr 2012

#1

Posted 16 April 2012 - 10:35 PM

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

CODE

00D6: if
0000: actor $PLAYER_ACTOR car_max_passengers


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


Rapier
  • Rapier

    Retired scripter

  • Members
  • Joined: 14 Aug 2005

#2

Posted 16 April 2012 - 10:57 PM

First of all, that game is? GTA3, VC, SA?

sgtpepper901
  • sgtpepper901

    Player Hater

  • Members
  • Joined: 13 Apr 2012

#3

Posted 16 April 2012 - 11:15 PM

Sorry. It is for GTA SA.

LINK/2012
  • LINK/2012

    LIVIN' IN CODE

  • Feroci
  • Joined: 30 Jan 2011
  • Brazil

#4

Posted 17 April 2012 - 02:54 AM Edited by Link2012, 17 April 2012 - 05:24 AM.

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


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

sgtpepper901
  • sgtpepper901

    Player Hater

  • Members
  • Joined: 13 Apr 2012

#5

Posted 17 April 2012 - 03:40 AM

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


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown

#6

Posted 17 April 2012 - 10:12 AM

QUOTE (Link2012 @ Tuesday, Apr 17 2012, 03:54)
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:
CODE
[...]

if
00DF:  actor $PLAYER_ACTOR driving
then
  03C0: 0@ = actor $PLAYER_ACTOR car
  if
  0AB1: call_scm_func @areVehicleSeatsFull 1 vehicle 0@
  then
    // Player's vehicle seats are full
  end
end

[...]

//  Example of use:
//  if
//  0AB1: call_scm_func @areVehicleSeatsFull 1 vehicle 0@
:areVehicleSeatsFull{handle}
var
  1@: Integer
  2@: Integer
end
if 0@ <> -1
then
  01E9: 1@ = car 0@ num_passengers
  01EA: 2@ = car 0@ max_passengers
  1@ == 2@
else
  059A: return_false
end
0AB2: ret 0

I fixed the code a little bit. wink.gif

LINK/2012
  • LINK/2012

    LIVIN' IN CODE

  • Feroci
  • Joined: 30 Jan 2011
  • Brazil

#7

Posted 17 April 2012 - 04:03 PM

QUOTE (Wesser @ Tuesday, Apr 17 2012, 07:12)
QUOTE (Link2012 @ Tuesday, Apr 17 2012, 03:54)
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

Silent
  • Silent

    Moderating Cookie Monster

  • Feroci
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#8

Posted 17 April 2012 - 05:02 PM Edited by SilentPL, 17 April 2012 - 05:05 PM.

Fixed the code a little bit yet tounge.gif

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

return_false was still useless.

sgtpepper901
  • sgtpepper901

    Player Hater

  • Members
  • Joined: 13 Apr 2012

#9

Posted 17 April 2012 - 08:15 PM

But "then" isn't valid, it should work without that right?

Silent
  • Silent

    Moderating Cookie Monster

  • Feroci
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#10

Posted 17 April 2012 - 08:19 PM

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

sgtpepper901
  • sgtpepper901

    Player Hater

  • Members
  • Joined: 13 Apr 2012

#11

Posted 17 April 2012 - 08:34 PM

My bad, I put it in wrong.

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown

#12

Posted 18 April 2012 - 07:48 AM

QUOTE (Link2012 @ Tuesday, Apr 17 2012, 17:03)
This isn't an error at all. tounge.gif

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

QUOTE (SilentPL @ Tuesday, Apr 17 2012, 18:02)
return_false was still useless.

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

Rapier
  • Rapier

    Retired scripter

  • Members
  • Joined: 14 Aug 2005

#13

Posted 18 April 2012 - 11:50 PM

QUOTE (SilentPL @ Tuesday, Apr 17 2012, 15:02)
Fixed the code a little bit yet tounge.gif

CODE
//  Example of use:
//  if
//  0AB1: call_scm_func @areVehicleSeatsFull 1 vehicle 0@
:areVehicleSeatsFull{handle}
var
 1@: Integer
 2@: Integer
end
if 0@ <> -1
then
 01E9: 1@ = car 0@ num_passengers
 01EA: 2@ = car 0@ max_passengers
 1@ == 2@
end
0AB2: 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???

Deji
  • Deji

    Coding like a Rockstar!

  • Feroci
  • Joined: 24 Dec 2007
  • None

#14

Posted 19 April 2012 - 12:44 AM

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

sgtpepper901
  • sgtpepper901

    Player Hater

  • Members
  • Joined: 13 Apr 2012

#15

Posted 19 April 2012 - 02:27 AM

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




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users