Jump to content

Opening a Parachute with setControlState failed


Recommended Posts

Hey guys.

I Made a skydive script and i want to open the Parachute of the Player who type the command. I tried to use setControlState with the control "fire" but it won`t work in the air. Someone who know what to do?

Example (not tested)

  
-- SERVER 
function skyD(player) 
local px,py,pz = getElementModel(player) 
setElementPosition(player, px,py,(pz + 300)) 
  
giveWeapon ( player,46 ,1, true ) 
  
-- Here i trigger client event 
triggerClientEvent("clientStartFiring", player, true) 
setTimer(function() 
    triggerClientEvent("clientStartFiring", player, false) 
end, 500, 1) 
  
end 
addCommandHandler("letMeFly", skyD) 
  
-- CLIENT 
function clientStartFiring(state) 
    setControlState("fire", state) 
end 
addEvent("clientStartFiring", true) 
addEventHandler("clientStartFiring", getRootElement(), clientStartFiring) 
  

Link to comment
  • Moderators

I have never made a script like this before, but this may help you.

  
--client 
setElementFrozen (localPlayer) 
  
addEventHandler("onClientPreRender",root, 
function () 
  local x,y,z = getElementPositon(localPlayer) 
  setElementPosition (localPlayer,x,y,z+.0001,false) -- false is not interrupt animations. 
end) 

Link to comment
  • Moderators

Because you wanted to shoot while skydiving? "setControlState("fire", state)" = shooting.....

or was it for opening the parachute?

  
-- SERVER 
function skyD(player) 
local px,py,pz = getElementModel(player) 
setElementPosition(player, px,py,(pz + 300),false) 
  
giveWeapon ( player,46 ,1, true ) 
  
setControlState(player,"fire", true) 
setTimer(function() 
if isElement(player) then 
     setControlState(player,"fire", false) 
end 
end, 500, 1) 
  
end 
addCommandHandler("letMeFly", skyD) 
  
--[[CLIENT 
function clientStartFiring(state) 
    setControlState("fire", state) 
end 
addEvent("clientStartFiring", true) 
addEventHandler("clientStartFiring", getRootElement(), clientStartFiring) 
]] 
  

Edited by Guest
Link to comment
  • Moderators

Btw there wasn't much wrong with your code. Maybe the triggerClientEvent did had a root argument, but that should not make it not working.

triggerClientEvent("clientStartFiring", player, false) 
-- to 
triggerClientEvent(player,"clientStartFiring", player, false) 
  

sendTo: The event will be sent to all players that are children of the specified element. By default this is the root element, and hence the event is sent to all players. If you specify a single player it will just be sent to that player.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...