Quantcast

Jump to content

» «
Photo

How to call function

2 replies to this topic
HeresOtis
  • HeresOtis

    The SCM Undergrad

  • Members
  • Joined: 29 Apr 2011
  • United-States

#1

Posted 01 April 2013 - 04:22 PM

I was looking at this in mtasa source:
CODE
#define FUNC_GetNearestCarPassengerDoor         0x650BB0
bool        GetNearestCarPassengerDoor  ( CPed * pPed, CVehicle * pVehicle, CVector * pVector, int * pDoor,


What opcode to use for this? And how do I decipher this function?
Is this correct - CPed * pPed = actor struct handle, CVehicle * pVehicle = target vehicle struct, CVector * pVector = ?, int * pDoor = returned door number?

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci Racing
  • Joined: 19 Aug 2006
  • Unknown

#2

Posted 02 April 2013 - 05:57 PM

You need to take advantage of call-opcodes:
  • 0AA5, calls a procedure by arguments;
  • 0AA6, calls a method by class pointer and arguments;
  • 0AA7, calls a function by arguments;
  • 0AA8, calls a method by class pointer and arguments and returns a value.
In your particular case, use this line of code:
CODE
0AA7: call_function 0x00650BB0 num_params 7 pop 7 bCheckIfRoomToGetIn 0 bUnknown2 0 bUnknown 0 piDoor 0x00000000 pclVector 0x00000000 pclVehicle 0x00000000 pclPed 0x00000000 bReturn 0@

You MUST pop all the arguments because 0x00650BB0 is a __cdecl routine, that is arguments are popped off the stack after the function call returns. Moreover, arguments MUST be passed from right to left in the same manner they are pushed onto the stack in assembly.

_DK
  • _DK

    Call me 'The Bald Guy"

  • Members
  • Joined: 12 Apr 2009
  • None

#3

Posted 11 April 2013 - 10:29 PM

Try this (CLEO4 only).
CODE
// 0@ - ped handle, 1@ - vehicle handle, 2@ - var to store door number, 3@, 4@, 5@ - vars to store position, 6@ - true/false returned
0A96: 7@ = actor 0@ struct
0A97: 8@ = car 1@ struct
0AA7: call_function 0x650BB0 num_params 7 pop 7 1 1 1 2@v 3@v 8@ 7@ 6@




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users