IsButtonBeingReleased
Description
Use this to trigger actions only once per button release, rather than while it is up.
Check here
for more info about the button ID and the controller ID.
function IsButtonBeingReleased(button, controller) --[[ ... ]] end
Parameters
button
:integer
- The button ID to check.controller
:integer
- The controller index.
Return Values
state
:boolean
- Returns true if the button was just released this frame, false otherwise.
Example
function main()
print("Hold down Space Bar to spawn a character...")
while true do
if IsButtonBeingReleased("8", 0) then
SpawnCharacterInFrontOfPlayer()
end
Wait(0)
end
end
function SpawnCharacterInFrontOfPlayer()
-- Get position 1 unit in front of the player
local x, y, z = PedGetOffsetInWorldCoords(gPlayer, 0, 1, 0)
-- Create a new character at that position
local character = PedCreateXYZ(75, x, y, z)
-- Set the character's health to 30
PedSetHealth(character, 30)
end
See Also
- Game's Native