SetVehicleGunsEnabled: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(I just guessed the syntax. Someone please check if its correct.)
 
m (Deprecated function)
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Server client function}}
{{Server client function}}
{{Deprecated|ToggleControl}}
__NOTOC__
__NOTOC__
This function enables or disables the weapons on a vehicle
This function enables or disables the weapons on a vehicle
Line 18: Line 20:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function disableFireForHydra ( theVehicle, seat, jacked )
function disableFireForHydra ( theVehicle, seat, jacked )
     if ( getVehicleID ( theVehicle ) == 520 ) then -- if they entered a hydra
     if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra
         setVehicleGunsEnabled ( theVehicle, false ) -- disable their guns
         setVehicleGunsEnabled ( theVehicle, false ) -- disable their guns
     else -- if they entered another vehicle
     else -- if they entered another vehicle
Line 24: Line 26:
     end
     end
end
end
addEventHandler ( "onPlayerEnterVehicle", getRootElement(), disableFireForHydra )
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), disableFireForHydra )
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
Line 31: Line 33:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function disableFireForHydra ( theVehicle, seat )
function disableFireForHydra ( theVehicle, seat )
     if ( getVehicleID ( theVehicle ) == 520 ) then -- if they entered a hydra
     if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra
         setVehicleGunsEnabled ( theVehicle, false ) -- disable their guns
         setVehicleGunsEnabled ( theVehicle, false ) -- disable their guns
     else -- if they entered another vehicle
     else -- if they entered another vehicle

Latest revision as of 00:15, 10 September 2016

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use ToggleControl instead.


This function enables or disables the weapons on a vehicle

Syntax

bool setVehicleGunsEnabled ( vehicle theVehicle, bool gunsEnabled )

Required Arguments

  • theVehicle: The element representing the vehicle whose guns you want to toggle.
  • gunsEnabled: A bool representing whether guns are enabled or disabled. false will disable them, true will enable them.

Returns

Returns true if the guns were toggled succesfully, false if arguments passed were invalid.

Example

Click to collapse [-]
Example 1

This function will disables the ability to fire rockets on a hydra.

function disableFireForHydra ( theVehicle, seat, jacked )
    if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra
        setVehicleGunsEnabled ( theVehicle, false ) -- disable their guns
    else -- if they entered another vehicle
        setVehicleGunsEnabled ( theVehicle, true ) -- enable their guns
    end
end
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), disableFireForHydra )
Click to expand [+]
Example 2

See Also