Adde Posted October 17, 2013 Posted October 17, 2013 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. My ingame nickname is: Mr.Snus
Castillo Posted October 17, 2013 Posted October 17, 2013 if ( "source" == "player" ) then What is that...? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Adde Posted October 17, 2013 Author Posted October 17, 2013 if ( "source" == "player" ) then is ment to check if the elemnt that is near the gate is a player. Is it totally wrong? I tried colshapes, I found that in another forum topic but did not work.. My ingame nickname is: Mr.Snus
BieHDC Posted October 17, 2013 Posted October 17, 2013 you compare strings! change it to: if source == localPlayer then if you wanna use that, but i think its not needed
Moderators IIYAMA Posted October 19, 2013 Moderators Posted October 19, 2013 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! Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Adde Posted October 23, 2013 Author Posted October 23, 2013 Thx for helping, but I used markers instead. My ingame nickname is: Mr.Snus
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now