Jump to content

How to freeze a player for a few seconds when he "onColShapeHit"


Lord Henry

Recommended Posts

  • Other Languages Moderators

Well...I need to freeze a player during 3 seconds when he collides a ColCuboid, independent if he is in a vehicle or not.
After this time, the player is unfreezed and will be only freeze again if he goes out the collider and enters it again.

The collider is on a serverside script, but I read at the "Wiki MTA" an information that Freeze commands are only clientside...

I tried to make all the script clientside but when I did, the script simply doesn't work and don't show any error.

Reason: The player must wait the gate's movement ending so he can pass. The gate's movement lasts 3 seconds.
PS: The gate is already working fine with the collider.

Here is the serverside script working well without the freeze commands:

gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open (source)
	if	isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("MapEditor")) then
		moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
		outputChatBox ( "Acesso permitido.", source, 0, 255, 0, true )
	else
	outputChatBox ( "Acesso negado.", source, 255, 0, 0, true )
	end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ()
    moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

And here is the script with the freeze command and timer:

gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open (source, player)
local player = getLocalPlayer()
	if	isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("MapEditor")) then
		outputChatBox ( "Acesso permitido.", source, 0, 255, 0, true )
    	moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
		setElementFrozen( player, true )
		toggleAllControls( player, false ) 
		setTimer ( function( source )
			setElementFrozen( player, false )
			toggleAllControls( player, true ) 
		end, 3000, 1 )
		outputChatBox ( "Aguarde o portão se abrir.", source, 0, 255, 0, true )
	else
	outputChatBox ( "Acesso negado.", source, 255, 0, 0, true )
	end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ()
    moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

How to create a Freeze with collider and timer?

Edited by lordhenry
Avoid misinterpretation
Link to comment
gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open (source, player)
local player = getLocalPlayer()
	if	isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("MapEditor")) then
		outputChatBox ( "Acesso permitido.", source, 0, 255, 0, true )
    	moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
		setElementFrozen( player, true )
		toggleAllControls( player, false ) 
		setTimer ( function( thePlayer )
			setElementFrozen( thePlayer, false )
			toggleAllControls( thePlayer, true ) 
		end, 3000, 1, player )
		outputChatBox ( "Aguarde o portão se abrir.", source, 0, 255, 0, true )
	else
	outputChatBox ( "Acesso negado.", source, 255, 0, 0, true )
	end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ()
    moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

Try this

Link to comment
  • Other Languages Moderators
1 minute ago, iPrestege said:

Using 'getLocalPlayer' in the server side is wrong way to check that if the hit was a player use 'getElementType' instead .

I know it, but I tried it on clientside and nothing happened...

Link to comment

Try this in the server side this code :

 

gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open ( player )
    if player and getElementType ( player ) == 'player' then
    if  isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("MapEditor")) then
        outputChatBox ( "Acesso permitido.", player, 0, 255, 0, true )
        moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
        setElementFrozen( player, true )
        toggleAllControls( player, false ) 
        setTimer ( function( thePlayer )
            setElementFrozen( thePlayer, false )
            toggleAllControls( thePlayer, true ) 
        end, 3000, 1, player )
        outputChatBox ( "Aguarde o portão se abrir.", player, 0, 255, 0, true )
    else
    outputChatBox ( "Acesso negado.", player, 255, 0, 0, true )
        end
    end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ( player )
    if player and getElementType ( player ) == 'player' then
    moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
    end
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

 

Link to comment
  • Other Languages Moderators
6 minutes ago, Dzsozi said:

gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open (source, player)
local player = getLocalPlayer()
	if	isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("MapEditor")) then
		outputChatBox ( "Acesso permitido.", source, 0, 255, 0, true )
    	moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
		setElementFrozen( player, true )
		toggleAllControls( player, false ) 
		setTimer ( function( thePlayer )
			setElementFrozen( thePlayer, false )
			toggleAllControls( thePlayer, true ) 
		end, 3000, 1, player )
		outputChatBox ( "Aguarde o portão se abrir.", source, 0, 255, 0, true )
	else
	outputChatBox ( "Acesso negado.", source, 255, 0, 0, true )
	end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ()
    moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

Try this

ERROR: editor_test\portaoilhaFAs.lua:8: attempt to call global 'getLocalPlayer' (a nil value)

Link to comment
gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open ()
	if	isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("MapEditor")) then
		outputChatBox ( "Acesso permitido.", source, 0, 255, 0, true )
    	moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
		setElementFrozen( source, true )
		toggleAllControls( source, false ) 
		setTimer ( function( player )
			setElementFrozen( player, false )
			toggleAllControls( player, true ) 
		end, 3000, 1, source )
		outputChatBox ( "Aguarde o portão se abrir.", source, 0, 255, 0, true )
	else
	outputChatBox ( "Acesso negado.", source, 255, 0, 0, true )
	end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ()
    moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

 

Link to comment
  • Other Languages Moderators
5 minutes ago, iPrestege said:

Try this in the server side this code :

 


gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open ( player )
    if player and getElementType ( player ) == 'player' then
    if  isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("MapEditor")) then
        outputChatBox ( "Acesso permitido.", player, 0, 255, 0, true )
        moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
        setElementFrozen( player, true )
        toggleAllControls( player, false ) 
        setTimer ( function( thePlayer )
            setElementFrozen( thePlayer, false )
            toggleAllControls( thePlayer, true ) 
        end, 3000, 1, player )
        outputChatBox ( "Aguarde o portão se abrir.", player, 0, 255, 0, true )
    else
    outputChatBox ( "Acesso negado.", player, 255, 0, 0, true )
        end
    end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ( player )
    if player and getElementType ( player ) == 'player' then
    moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
    end
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

 

This worked by foot, but not with vehicle.
The vehicle needs to be freezed too.

Edited by lordhenry
Link to comment
gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open ()
	if	isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("MapEditor")) then
		outputChatBox ( "Acesso permitido.", source, 0, 255, 0, true )
    	moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
    	local veh = getPedOccupiedVehicle ( source )
   		if veh then
      		setElementFrozen( veh, true )
      	end
    	setElementFrozen( source, true )
		toggleAllControls( source, false ) 
		setTimer ( function( player )
        	local veh = getPedOccupiedVehicle ( player )
            if veh then
                setElementFrozen( veh, false )
            end
        	setElementFrozen( player, false )
			toggleAllControls( player, true ) 
		end, 3000, 1, source )
		outputChatBox ( "Aguarde o portão se abrir.", source, 0, 255, 0, true )
	else
	outputChatBox ( "Acesso negado.", source, 255, 0, 0, true )
	end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ()
    moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

Try this

 

** EDITED THE SCRIPT, I MISSED SOMETHING, REPLACE YOURS WITH THIS ONE

Edited by Dzsozi
Link to comment
  • Other Languages Moderators
3 minutes ago, Dzsozi said:

gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open ()
	if	isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("MapEditor")) then
		outputChatBox ( "Acesso permitido.", source, 0, 255, 0, true )
    	moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
    	local theVehicle = getPedOccupiedVehicle ( source )
   		if theVehicle then
      		setElementFrozen( theVehicle, true )
      		setElementFrozen( source, true )
      	else
			setElementFrozen( source, true )
      	end
		toggleAllControls( source, false ) 
		setTimer ( function( player )
        	local veh = getPedOccupiedVehicle ( player )
            if theVehicle then
                setElementFrozen( theVehicle, false )
          		setElementFrozen( player, false )
            else
                setElementFrozen( player, false )
            end
			toggleAllControls( player, true ) 
		end, 3000, 1, source )
		outputChatBox ( "Aguarde o portão se abrir.", source, 0, 255, 0, true )
	else
	outputChatBox ( "Acesso negado.", source, 255, 0, 0, true )
	end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ()
    moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

Try this

WARNING: editor_test\portaoilhaFAs.lua:8: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean]
ERROR: editor_test\portaoilhaFAs.lua:8: attempt to concatenate a boolean value

Link to comment
gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open (hitElement)
	if	isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitElement)), aclGetGroup("MapEditor")) then
		outputChatBox ( "Acesso permitido.", hitElement, 0, 255, 0, true )
    	moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
		setElementFrozen( hitElement, true )
		toggleAllControls( hitElement, false ) 
		setTimer ( function( player )
            setElementFrozen( player, false )
			toggleAllControls( player, true ) 
		end, 3000, 1, hitElement )
		outputChatBox ( "Aguarde o portão se abrir.", hitElement, 0, 255, 0, true )
	else
	outputChatBox ( "Acesso negado.", hitElement, 255, 0, 0, true )
	end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ()
    moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

Sorry, I just realised that the source of the "onColShapeHit" event is the colshape, not the player or the vehicle. Try this one please.

Link to comment
  • Other Languages Moderators
3 minutes ago, Dzsozi said:

gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open (hitElement)
	if	isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitElement)), aclGetGroup("MapEditor")) then
		outputChatBox ( "Acesso permitido.", hitElement, 0, 255, 0, true )
    	moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
		setElementFrozen( hitElement, true )
		toggleAllControls( hitElement, false ) 
		setTimer ( function( player )
            setElementFrozen( player, false )
			toggleAllControls( player, true ) 
		end, 3000, 1, hitElement )
		outputChatBox ( "Aguarde o portão se abrir.", hitElement, 0, 255, 0, true )
	else
	outputChatBox ( "Acesso negado.", hitElement, 255, 0, 0, true )
	end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ()
    moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

Sorry, I just realised that the source of the "onColShapeHit" event is the colshape, not the player or the vehicle. Try this one please.

It just let me with no control of the vehicle during the time, but not Freeze the vehicle. The vehicle must stop immediately when it collides.

But this time, none error happened.

Link to comment
gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open (hitElement)
	if	isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitElement)), aclGetGroup("MapEditor")) then
		outputChatBox ( "Acesso permitido.", hitElement, 0, 255, 0, true )
    	moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
    	local veh = getPedOccupiedVehice(hitElement)
    	if veh then
      		setElementFrozen(veh, true)
      	end
		setElementFrozen( hitElement, true )
		toggleAllControls( hitElement, false ) 
		setTimer ( function( player )
        	local veh = getPedOccupiedVehice(player)
            if veh then
                setElementFrozen(veh, false)
            end
            setElementFrozen( player, false )
			toggleAllControls( player, true ) 
		end, 3000, 1, hitElement )
		outputChatBox ( "Aguarde o portão se abrir.", hitElement, 0, 255, 0, true )
	else
	outputChatBox ( "Acesso negado.", hitElement, 255, 0, 0, true )
	end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ()
    moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

 

Link to comment
  • Other Languages Moderators
3 minutes ago, Dzsozi said:

gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open (hitElement)
	if	isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitElement)), aclGetGroup("MapEditor")) then
		outputChatBox ( "Acesso permitido.", hitElement, 0, 255, 0, true )
    	moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
    	local veh = getPedOccupiedVehice(hitElement)
    	if veh then
      		setElementFrozen(veh, true)
      	end
		setElementFrozen( hitElement, true )
		toggleAllControls( hitElement, false ) 
		setTimer ( function( player )
        	local veh = getPedOccupiedVehice(player)
            if veh then
                setElementFrozen(veh, false)
            end
            setElementFrozen( player, false )
			toggleAllControls( player, true ) 
		end, 3000, 1, hitElement )
		outputChatBox ( "Aguarde o portão se abrir.", hitElement, 0, 255, 0, true )
	else
	outputChatBox ( "Acesso negado.", hitElement, 255, 0, 0, true )
	end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ()
    moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

 

WARNING: editor_test\portaoilhaFAs.lua:8: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean]
ERROR: editor_test\portaoilhaFAs.lua:8: attempt to concatenate a boolean value

Link to comment

 

gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open (hitElement)
	if hitElement and getElementType ( hitElement ) == 'player' then 
      if	isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitElement)), aclGetGroup("MapEditor")) then
          outputChatBox ( "Acesso permitido.", hitElement, 0, 255, 0, true )
          moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
          local veh = getPedOccupiedVehice(hitElement)
          if veh then
              setElementFrozen(veh, true)
          end
          setElementFrozen( hitElement, true )
          toggleAllControls( hitElement, false ) 
          setTimer ( function( player )
              local veh = getPedOccupiedVehice(player)
              if veh then
                  setElementFrozen(veh, false)
              end
              setElementFrozen( player, false )
              toggleAllControls( player, true ) 
          end, 3000, 1, hitElement )
          outputChatBox ( "Aguarde o portão se abrir.", hitElement, 0, 255, 0, true )
      else
      outputChatBox ( "Acesso negado.", hitElement, 255, 0, 0, true )
      end
	end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ()
    moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

 

Link to comment
  • Other Languages Moderators
13 minutes ago, Dzsozi said:

 


gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.function GateIlha1Open (hitElement)	if hitElement and getElementType ( hitElement ) == 'player' then       if	isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitElement)), aclGetGroup("MapEditor")) then          outputChatBox ( "Acesso permitido.", hitElement, 0, 255, 0, true )          moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )          local veh = getPedOccupiedVehice(hitElement)          if veh then              setElementFrozen(veh, true)          end
          setElementFrozen( hitElement, true )
          toggleAllControls( hitElement, false ) 
          setTimer ( function( player )
              local veh = getPedOccupiedVehice(player)
              if veh then
                  setElementFrozen(veh, false)
              end
              setElementFrozen( player, false )
              toggleAllControls( player, true ) 
          end, 3000, 1, hitElement )
          outputChatBox ( "Aguarde o portão se abrir.", hitElement, 0, 255, 0, true )
      else
      outputChatBox ( "Acesso negado.", hitElement, 255, 0, 0, true )
      end
	end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ()
    moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

 

 ERROR: editor_test\portaoilhaFAs.lua:12: attempt to call global 'getPedOccupiedVehice' (a nil value)

Solved!
 

gateilhaFA1 = createObject ( 968, -3341.7001953125, 458.5, 10.5, 0, 270, 270 )
ZonailhaFA1 = createColCuboid ( -3356.7001953125, 459.89999389648, 9.6999998092651, 15.0, 5, 5.0 )--Zona em cubo de colisão.

function GateIlha1Open (hitElement)
	if hitElement and getElementType ( hitElement ) == 'player' then 
      if	isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitElement)), aclGetGroup("MapEditor")) then
          outputChatBox ( "Acesso permitido.", hitElement, 0, 255, 0, true )
          moveObject ( gateilhaFA1, 3000, -3341.7001953125, 458.5, 10.5, 0, 90, 0 )
          local veh = getPedOccupiedVehicle(hitElement)
          if veh then
              setElementFrozen(veh, true)
          end
          setElementFrozen( hitElement, true )
          toggleAllControls( hitElement, false ) 
          setTimer ( function( player )
              local veh = getPedOccupiedVehicle(player)
              if veh then
                  setElementFrozen(veh, false)
              end
              setElementFrozen( player, false )
              toggleAllControls( player, true ) 
          end, 3000, 1, hitElement )
          outputChatBox ( "Aguarde o portão se abrir.", hitElement, 0, 255, 0, true )
      else
      outputChatBox ( "Acesso negado.", hitElement, 255, 0, 0, true )
      end
	end
end
addEventHandler ( "onColShapeHit", ZonailhaFA1, GateIlha1Open )

function GateIlha1Close ()
    moveObject ( gateilhaFA1, 1000, -3341.7001953125, 458.5, 10.5, 0, -90, 0 )
end
addEventHandler ( "onColShapeLeave", ZonailhaFA1, GateIlha1Close )

 

8. local veh = getPedOccupiedVehice(hitElement)
and
15. local veh = getPedOccupiedVehice(player)

I changed to "Vehicle".

Thanks by the help!
It's working well now :D

Edited by lordhenry
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...