Difference between revisions of "057F"

From GTAMods Wiki
Jump to navigation Jump to search
m
 
Line 14: Line 14:
 
== Disassembled code ==
 
== Disassembled code ==
 
This is disassembled code for this opcode from PC v1.0 US.
 
This is disassembled code for this opcode from PC v1.0 US.
<syntaxhighlight lang="nasm" style="overflow-x: auto;">
+
<syntaxhighlight lang="nasm">
 
loc_637836:
 
loc_637836:
 
     lea    eax, [ebx+10h]                    ; get address of script's current instruction pointer
 
     lea    eax, [ebx+10h]                    ; get address of script's current instruction pointer
     mov    ecx, ebx                          ; get CRunningScript pointer for thiscall
+
     mov    ecx, ebx                          ; get address of script for thiscall
 
     push    1                                ; push 1 for one parameter to collect
 
     push    1                                ; push 1 for one parameter to collect
 
     push    eax                              ; push address of script's current instruction pointer
 
     push    eax                              ; push address of script's current instruction pointer
     call    CRunningScript::CollectParameters ; call CRunningScript::CollectParameters
+
     call    CRunningScript::CollectParameters ; call CRunningScript::CollectParameters(uint *,short)
 
     mov    edi, ds:ScriptParams[0]          ; get value of first parameter, the player handle
 
     mov    edi, ds:ScriptParams[0]          ; get value of first parameter, the player handle
 
     imul    edi, 170h
 
     imul    edi, 170h
Line 27: Line 27:
 
     mov    ecx, [edi]                        ; get address of player ped at CWorld::Players + player handle * 0x170
 
     mov    ecx, [edi]                        ; get address of player ped at CWorld::Players + player handle * 0x170
 
     mov    eax, [ecx+6D4h]                  ; offset player ped address by 0x6D4 to get bus fares collected
 
     mov    eax, [ecx+6D4h]                  ; offset player ped address by 0x6D4 to get bus fares collected
     mov    ecx, ebx                          ; get CRunningScript pointer for thiscall
+
     mov    ecx, ebx                          ; get address of script for thiscall
 
     mov    ds:ScriptParams[0], eax          ; store bus fares collected
 
     mov    ds:ScriptParams[0], eax          ; store bus fares collected
 
     mov    eax, [edi]                        ; get address of player ped at CWorld::Players + player handle * 0x170
 
     mov    eax, [edi]                        ; get address of player ped at CWorld::Players + player handle * 0x170
Line 33: Line 33:
 
     lea    eax, [ebx+10h]                    ; get address of script's current instruction pointer
 
     lea    eax, [ebx+10h]                    ; get address of script's current instruction pointer
 
     push    eax                              ; push address of script's current instruction pointer
 
     push    eax                              ; push address of script's current instruction pointer
     call    CRunningScript::StoreParameters  ; call CRunningScript::StoreParameters
+
     call    CRunningScript::StoreParameters  ; call CRunningScript::StoreParameters(uint *,short)
 
     lea    esp, [ebp-0Ch]
 
     lea    esp, [ebp-0Ch]
 
     xor    al, al                            ; return 0
 
     xor    al, al                            ; return 0

Latest revision as of 17:40, 24 May 2017

Vice City GET_BUS_FARES_COLLECTED_BY_PLAYER


Description
Gets the bus fares collected by the player
Syntax
057F: get_player [player handle] store_coach_passengers_dropped_off_to [var]
Parameter
[player handle]
The handle of the player
[var]
Variable to store the integer value

This opcode gets the bus fares collected by the player so far. Bus fares can only be collected when you are stopped in a Coach at a bus stop. Each fare costs $5 so the value it can return will be in multiples of 5. Once this opcode is called, the bus fares collected will reset to 0 afterwards so you must store the value to another variable if you want to keep track of the total bus fares collected. You do not need to be in a Coach to use this opcode. The original script called this opcode only in the 'BUS' script.

Disassembled code

This is disassembled code for this opcode from PC v1.0 US.

loc_637836:
    lea     eax, [ebx+10h]                    ; get address of script's current instruction pointer
    mov     ecx, ebx                          ; get address of script for thiscall
    push    1                                 ; push 1 for one parameter to collect
    push    eax                               ; push address of script's current instruction pointer
    call    CRunningScript::CollectParameters ; call CRunningScript::CollectParameters(uint *,short)
    mov     edi, ds:ScriptParams[0]           ; get value of first parameter, the player handle
    imul    edi, 170h
    push    1                                 ; push 1 for one parameter to store
    add     edi, offset CWorld::Players
    mov     ecx, [edi]                        ; get address of player ped at CWorld::Players + player handle * 0x170
    mov     eax, [ecx+6D4h]                   ; offset player ped address by 0x6D4 to get bus fares collected
    mov     ecx, ebx                          ; get address of script for thiscall
    mov     ds:ScriptParams[0], eax           ; store bus fares collected
    mov     eax, [edi]                        ; get address of player ped at CWorld::Players + player handle * 0x170
    mov     dword ptr [eax+6D4h], 0           ; offset player ped address by 0x6D4 to set bus fares collected to 0
    lea     eax, [ebx+10h]                    ; get address of script's current instruction pointer
    push    eax                               ; push address of script's current instruction pointer
    call    CRunningScript::StoreParameters   ; call CRunningScript::StoreParameters(uint *,short)
    lea     esp, [ebp-0Ch]
    xor     al, al                            ; return 0

Keywords

get, store, bus, coach, collect, collected, dropped, off, passenger