IsPedDoingGangDriveby: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 7: Line 7:
bool isPedDoingGangDriveby ( ped thePed )
bool isPedDoingGangDriveby ( ped thePed )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[ped]]:isDoingGangDriveby|doingGangDriveby|setPedDoingGangDriveby}}


===Required Arguments===  
===Required Arguments===  
Line 12: Line 13:


===Returns===
===Returns===
* '''Server-Side:'''
Returns '''1''' if the driveby state is enabled, '''0''' otherwise.
* '''Client-Side:'''
Returns '''true''' if the driveby state is enabled, '''false''' otherwise.
Returns '''true''' if the driveby state is enabled, '''false''' otherwise.


Line 22: Line 20:
<syntaxhighlight lang="lua">function setDoingDriveby ( )
<syntaxhighlight lang="lua">function setDoingDriveby ( )
         -- we check if local player isn't currently doing a gang driveby
         -- we check if local player isn't currently doing a gang driveby
         if not isPedDoingGangDriveby ( getLocalPlayer () ) then
         if not isPedDoingGangDriveby ( localPlayer ) then
                 -- if he got driveby mode off, turn it on
                 -- if he got driveby mode off, turn it on
                 setPedWeaponSlot ( getLocalPlayer (), 4 )
                 setPedWeaponSlot ( localPlayer, 4 )
                 setPedDoingGangDriveby ( getLocalPlayer (), true )
                 setPedDoingGangDriveby ( localPlayer, true )
         else
         else
                 -- otherwise, turn it off
                 -- otherwise, turn it off
                 setPedWeaponSlot ( getLocalPlayer (), 0 )
                 setPedWeaponSlot ( localPlayer, 0 )
                 setPedDoingGangDriveby ( getLocalPlayer (), false )
                 setPedDoingGangDriveby ( localPlayer, false )
         end
         end
end
end

Latest revision as of 09:31, 11 February 2019

This function checks if the ped is in the driveby state.

Syntax

bool isPedDoingGangDriveby ( ped thePed )

OOP Syntax Help! I don't understand this!

Method: ped:isDoingGangDriveby(...)
Variable: .doingGangDriveby
Counterpart: setPedDoingGangDriveby


Required Arguments

  • thePed: The ped element whose state is to be checked.

Returns

Returns true if the driveby state is enabled, false otherwise.

Example

Click to collapse [-]
Client

This example turns on driveby mode when the local player types driveby in the console.

function setDoingDriveby ( )
        -- we check if local player isn't currently doing a gang driveby
        if not isPedDoingGangDriveby ( localPlayer ) then
                -- if he got driveby mode off, turn it on
                setPedWeaponSlot ( localPlayer, 4 )
                setPedDoingGangDriveby ( localPlayer, true )
        else
                -- otherwise, turn it off
                setPedWeaponSlot ( localPlayer, 0 )
                setPedDoingGangDriveby ( localPlayer, false )
        end
end
addCommandHandler ( "driveby", setDoingDriveby )

See Also