GivePedJetPack: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ {{Server function}} This function is used to give a ped a jetpack. This function is not guaranteed to succeed. There are some cases where the jetpack cannot be given, for exampl...) |
No edit summary |
||
Line 21: | Line 21: | ||
==Example== | ==Example== | ||
This examples adds a "jetpack" console command, which gives or removes a jetpack from the player. | This examples adds a "jetpack" console command, which gives or removes a jetpack from the player. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- Checks whether or not the player has a jetpack, and gives or removes it from the player | -- Checks whether or not the player has a jetpack, and gives or removes it from the player | ||
function consoleJetPack ( thePlayer, commandName ) | function consoleJetPack ( thePlayer, commandName ) |
Revision as of 19:44, 17 February 2010
This function is used to give a ped a jetpack.
This function is not guaranteed to succeed. There are some cases where the jetpack cannot be given, for example:
- If the ped is in a vehicle
- If the ped is falling
- Probably others too.
As such, you should either expect it to fail sometimes, or repeatedly try to give a jetpack every second or so until doesPlayerHaveJetPack returns true. Alternatively, you can force the ped into a 'safe' position (e.g. standing on the ground) before giving the jetpack, or user a pickup to handle it.
Syntax
bool givePedJetPack ( ped thePed )
Required Arguments
- thePed: The ped you want to give a jetpack to.
Returns
Returns true if a jetpack was successfully given to the ped, false if it could not be given.
Example
This examples adds a "jetpack" console command, which gives or removes a jetpack from the player.
-- Checks whether or not the player has a jetpack, and gives or removes it from the player function consoleJetPack ( thePlayer, commandName ) if not doesPedHaveJetPack ( thePlayer ) then -- if the player doesn't have a jetpack local status = givePedJetPack ( thePlayer ) -- give him one if not status then outputConsole ( "Failed to give jetpack.", thePlayer ) -- tell him if it failed end else local status = removePedJetPack ( thePlayer ) -- remove his jetpack if ( not status ) then outputConsole ( "Failed to remove jetpack.", thePlayer ) -- tell him if it failed end end end -- add the function above to handle the "jetpack" command addCommandHandler ( "jetpack", consoleJetPack )
See Also
- addPedClothes
- getPedClothes
- removePedClothes
- createPed
- getPedAmmoInClip
- getPedArmor
- getPedFightingStyle
- getPedOccupiedVehicle
- getPedOccupiedVehicleSeat
- getPedStat
- getPedTarget
- getPedTotalAmmo
- getPedWalkingStyle
- getPedWeapon
- getPedWeaponSlot
- getPedContactElement
- getValidPedModels
- isPedChoking
- isPedDead
- isPedDoingGangDriveby
- isPedDucked
- isPedHeadless
- isPedInVehicle
- isPedOnFire
- isPedOnGround
- isPedWearingJetpack
- killPed
- removePedFromVehicle
- setPedAnimation
- setPedAnimationProgress
- setPedAnimationSpeed
- setPedArmor
- setPedDoingGangDriveby
- setPedFightingStyle
- setPedHeadless
- setPedOnFire
- setPedStat
- setPedWalkingStyle
- setPedWeaponSlot
- warpPedIntoVehicle