SetPedDoingGangDriveby: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: {{Client function}} __NOTOC__ This function sets the driveby state of a ped. ==Syntax== <syntaxhighlight lang="lua"> bool setPedDoingGangDriveby ( ped ped, bool state ) </syntaxhighlight> ===Required Arguments=...)
 
No edit summary
Line 1: Line 1:
{{Client function}}
{{Server client function}}
__NOTOC__
__NOTOC__
This function sets the driveby state of a ped.
This function sets the driveby state of a ped.
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setPedDoingGangDriveby ( ped ped, bool state )
bool setPedDoingGangDriveby ( ped thePed, bool state )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''ped:''' the PED element whose state is to be changed
*'''thePed:''' The [[ped]] element whose state is to be changed.
*'''state:''' the new visibility state
*'''state:''' A [[boolean]] value representing the drive-by state, ''true'' meaning enabled and ''false'' disabled.


===Returns===
===Returns===
Line 16: Line 16:


==Example==  
==Example==  
This example turns on driveby mode when the local player types '/driveby'.
<section name="Client" class="client" show="true">
 
This example turns on driveby mode when the local player types ''driveby'' in the console.
<syntaxhighlight lang="lua">function setDoingDriveby ( )
<syntaxhighlight lang="lua">function setDoingDriveby ( )
         -- we check if the gui element is visible
         -- we check if local player isn't currently doing a gang driveby
         if getPedWeapon ( getLocalPlayer () ) == 0 then
         if not isPedDoingGangDriveby ( getLocalPlayer () ) then
                 -- if he got driveby mode off, turn it on
                 -- if he got driveby mode off, turn it on
                 setPedWeaponSlot( getLocalPlayer (), 4 )
                 setPedWeaponSlot ( getLocalPlayer (), 4 )
                 setPedDoingGangDriveby( getLocalPlayer (), true )
                 setPedDoingGangDriveby ( getLocalPlayer (), true )
         else
         else
                 -- otherwise, turn it off
                 -- otherwise, turn it off
                 setPedWeaponSlot( getLocalPlayer (), 0 )
                 setPedWeaponSlot ( getLocalPlayer (), 0 )
                 setPedDoingGangDriveby( getLocalPlayer (), false )
                 setPedDoingGangDriveby ( getLocalPlayer (), false )
         end
         end
end
end
addCommandHandler( "driveby", setDoingDriveby, false )</syntaxhighlight>
addCommandHandler ( "driveby", setDoingDriveby )</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Ped functions}}
{{Ped functions}}

Revision as of 09:01, 3 May 2009

This function sets the driveby state of a ped.

Syntax

bool setPedDoingGangDriveby ( ped thePed, bool state )

Required Arguments

  • thePed: The ped element whose state is to be changed.
  • state: A boolean value representing the drive-by state, true meaning enabled and false disabled.

Returns

Returns true if the driveby state could be changed, 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 ( getLocalPlayer () ) then
                -- if he got driveby mode off, turn it on
                setPedWeaponSlot ( getLocalPlayer (), 4 )
                setPedDoingGangDriveby ( getLocalPlayer (), true )
        else
                -- otherwise, turn it off
                setPedWeaponSlot ( getLocalPlayer (), 0 )
                setPedDoingGangDriveby ( getLocalPlayer (), false )
        end
end
addCommandHandler ( "driveby", setDoingDriveby )

See Also