Difference between revisions of "0501"

From GTAMods Wiki
Jump to navigation Jump to search
(page updates + disassembly)
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Icon|VC}} {{Icon|SA}} '''SET_PLAYER_CAN_DO_DRIVE_BY'''
+
{{OpCode
<hr />
+
| games      = {{Icon|VC}} {{Icon|SA}}
'''Description'''
+
| command    = SET_PLAYER_CAN_DO_DRIVE_BY
: Sets the player's ability to perform a drive by
+
| description = Sets the player's ability to perform a drive by
'''Syntax'''
+
| syntax1    = 0501: set_player [''player handle''] drive_by_mode_enabled [''int'']
: 0501: set_player [''player handle''] drive_by_mode_enabled [''int'']
+
| p1t        = [''player handle'']
'''Parameter'''
+
| p1d        = The [[0053|handle of the player]]
: [''player handle'']
+
| p2t        = [''int'']
:: [[0053|The handle of the player]]
+
| p2d        = 0 = disable, {{hint|1|or any value other than 0}} = enable (default)
: [''int'']
+
| native      = [[SET_PLAYER_CAN_DO_DRIVE_BY]]
:: 0 = disable, {{hint|1|or any value other than 0}} = enable (default)
+
}}
'''Native analog'''
 
: [[SET_PLAYER_CAN_DO_DRIVE_BY]]
 
  
This opcode sets the player's ability to perform drive-bys (shooting out of vehicles). The value set with this opcode is saved in [[Saves (GTA VC)#Block 18: Player Info|block 18 of the save file]] in Vice City and in [[Saves_(GTA_SA)#Block_15:_Player_data|block 15]] in San Andreas.
+
This opcode sets the player's ability to perform drive-bys (shooting out of vehicles). The value set with this opcode is saved in [[Saves (GTA VC)#Block 18: Player Info|block 18 of the save file]] in Vice City and [[Saves (GTA SA)#Block 15: Player Info|block 15]] in San Andreas.
  
 
== Disassembled code ==
 
== Disassembled code ==
This is disassembled code for this opcode from v1.0 US.
+
This is disassembled code for this opcode from PC v1.0 US.
 
=== Vice City ===
 
=== Vice City ===
<syntaxhighlight lang="asm" style="overflow-x: auto;">
+
<syntaxhighlight lang="nasm">
; call subroutine to collect values from input parameters
+
loc_6320D0:
.text:006320D0                lea    eax, [ebp+10h]
+
    lea    eax, [ebp+10h]                   ; get address of script's current instruction pointer
.text:006320D3                mov    ecx, ebp
+
    mov    ecx, ebp                         ; get address of script for thiscall
.text:006320D5                push    2 ; two parameters to collect
+
    push    2                                 ; push 2 for two parameters to collect
.text:006320D7                push    eax
+
    push    eax                               ; push address of script's current instruction pointer
.text:006320D8                call    CRunningScript__CollectParameters
+
    call    CRunningScript::CollectParameters ; call CRunningScript::CollectParameters(uint *,short)
; read collected content
+
    mov    eax, ds:ScriptParams[0]          ; get value of first parameter, the player handle
.text:006320DD                mov    eax, ds:_opcodeParameter1
+
    imul    eax, 170h
.text:006320E2                imul    eax, 170h
+
    add    eax, offset CWorld::Players      ; get address of the player at CWorld::Players + player handle * 0x170
.text:006320E8                add    eax, offset _playerInfo  ; address of the player info
+
    cmp    ds:ScriptParams[1], 0             ; check whether or not value of second parameter is 0
.text:006320ED                cmp    ds:_opcodeParameter2, 0 ; check whether or not parameter 2 is set to 0
+
    jz      short loc_632100
.text:006320F4                jz      short loc_632100
+
    mov    byte ptr [eax+147h], 1           ; offset player address by 0x147 and set to can do drive by
.text:006320F6                mov    byte ptr [eax+147h], 1 ; offset 0x147 set to enable drive by
+
    jmp    short loc_632107
.text:006320FD                jmp    short loc_632107
+
    align 10h
.text:006320FF                align 10h
+
loc_632100:
.text:00632100 loc_632100:    mov    byte ptr [eax+147h], 0 ; offset 0x147 set to disable drive by
+
     mov    byte ptr [eax+147h], 0           ; offset player address by 0x147 and set to cannot do drive by
; end
+
loc_632107:
.text:00632107 loc_632107:    xor    al, al
+
     xor    al, al                           ; return 0
.text:00632109                add    esp, 1B0h
 
.text:0063210F                pop    ebp
 
.text:00632110                pop    edi
 
.text:00632111                pop    esi
 
.text:00632112                pop    ebx
 
.text:00632113                retn    4
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
== Keywords ==
 
== Keywords ==
 
set, toggle, player, drive-by, driveby
 
set, toggle, player, drive-by, driveby
 
[[Category:OpCodes]]
 

Latest revision as of 17:41, 24 May 2017

Vice City San Andreas SET_PLAYER_CAN_DO_DRIVE_BY


Description
Sets the player's ability to perform a drive by
Syntax
0501: set_player [player handle] drive_by_mode_enabled [int]
Parameter
[player handle]
The handle of the player
[int]
0 = disable, 1 = enable (default)
Native analog
SET_PLAYER_CAN_DO_DRIVE_BY

This opcode sets the player's ability to perform drive-bys (shooting out of vehicles). The value set with this opcode is saved in block 18 of the save file in Vice City and block 15 in San Andreas.

Disassembled code

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

Vice City

loc_6320D0:
    lea     eax, [ebp+10h]                    ; get address of script's current instruction pointer
    mov     ecx, ebp                          ; get address of script for thiscall
    push    2                                 ; push 2 for two parameters to collect
    push    eax                               ; push address of script's current instruction pointer
    call    CRunningScript::CollectParameters ; call CRunningScript::CollectParameters(uint *,short)
    mov     eax, ds:ScriptParams[0]           ; get value of first parameter, the player handle
    imul    eax, 170h
    add     eax, offset CWorld::Players       ; get address of the player at CWorld::Players + player handle * 0x170
    cmp     ds:ScriptParams[1], 0             ; check whether or not value of second parameter is 0
    jz      short loc_632100
    mov     byte ptr [eax+147h], 1            ; offset player address by 0x147 and set to can do drive by
    jmp     short loc_632107
    align 10h
loc_632100:
    mov     byte ptr [eax+147h], 0            ; offset player address by 0x147 and set to cannot do drive by
loc_632107:
    xor     al, al                            ; return 0

Keywords

set, toggle, player, drive-by, driveby