Difference between revisions of "057F"

From GTAMods Wiki
Jump to navigation Jump to search
(Created page with "{{Icon|VC}} '''GET_BUS_FARES_COLLECTED_BY_PLAYER''' <hr /> '''Description''' : Gets the bus fares collected by the player '''Syntax''' : 057F: get_player [''player handle''] s...")
 
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Icon|VC}} '''GET_BUS_FARES_COLLECTED_BY_PLAYER'''
+
{{OpCode
<hr />
+
| games      = {{Icon|VC}}
'''Description'''
+
| command    = GET_BUS_FARES_COLLECTED_BY_PLAYER
: Gets the bus fares collected by the player
+
| description = Gets the bus fares collected by the player
'''Syntax'''
+
| syntax1    = 057F: get_player [''player handle''] store_coach_passengers_dropped_off_to [''var'']
: 057F: get_player [''player handle''] store_coach_passengers_dropped_off_to [''var'']
+
| p1t        = [''player handle'']
'''Parameter'''
+
| p1d        = The [[0053|handle of the player]]
: [''player handle'']
+
| p2t        = [''var'']
:: The handle of the [[0053|player]]
+
| p2d        = Variable to store the integer value
: [''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' thread.
+
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.
 +
<syntaxhighlight lang="nasm">
 +
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
 +
</syntaxhighlight>
  
 
== Keywords ==
 
== Keywords ==
 
get, store, bus, coach, collect, collected, dropped, off, passenger
 
get, store, bus, coach, collect, collected, dropped, off, passenger
 
[[Category:OpCodes]]
 

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