SetVehicleGunsEnabled

From Multi Theft Auto: Wiki
Revision as of 14:54, 29 August 2007 by Talidan (talk | contribs) (I just guessed the syntax. Someone please check if its correct.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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 ( getVehicleID ( 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 ( "onPlayerEnterVehicle", getRootElement(), disableFireForHydra )
Click to expand [+]
Example 2

See Also