Jump to content

Open gate, getDistanceBetweenPoints3D, help


Adde

Recommended Posts

Hello, I am thinking of creating a small gatesystem. When the players position is, let´s say less than 10 from the gate, it should move up or down. I can decide that later. And if no one is that, it should be closed. I have already done a part of it. But it complains in debug.

1.bad argument at getElementPosition

2.bad argument at getDistanceBetweenPoints3D

3.a nil value somewhere, didn´t say where.

I am using it server side, should it be client side?

but this is the script:

  
gate1 = createObject(980, -23, 1423, -23, 0, 0, 94, false) 
function openclose() 
if ( "source" == "player" ) then 
local x, y, z = getElementPosition(source) 
if ( getDistanceBetweenPoints3D(x, y, z, -23, 1423, -23) <= "20" ) then 
moveObject(gate1, 2000, -23, 1423, -23 - 4, 0, 0, 94) 
end 
end 
end 
  

Anyone got any ideas of why this doesn´t work or how I can make it work. I appreciate if someone helps me.

And does anyone know why objects in "moveObject" are turning and twisting when they are being moved? I know that since another script i had with a command instead.

Link to comment
  • Moderators

Serverside is for everybody visible, client only for the pc that executed it.

- For client, BieHDC sample.

<<<

- For server

  
  
if isElement(source) then  
  
--[[ or when you are to foolish to send a vehicle/object/ped instead of player then:]] 
if isElement(source) and getElementType(source) == "player" then 

Also:

  
if ( getDistanceBetweenPoints3D(x, y, z, -23, 1423, -23) <= "20" ) then 
  
if ( getDistanceBetweenPoints3D(x, y, z, -23, 1423, -23) <= 20 ) then 

Also addCommandHandler doesn't give a player as source, if you did that!

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...