Jump to content

moveObject help


Dimos7

Recommended Posts

Hello i have a problem i try move a object roty and no go there i want i have for 0 and go 90 i put 270 and he go 180 also change and z for 270 to 0 please help

<meta> 
    <script src="sfb.lua"/> 
</meta> 
  

local barrier = createObject(968, -1572.1, 658.7, 6.8, 0, 270, 270) 
state = 0 
  
function open() 
       if state == 0 then 
          setElementRotation( barrier, 0, 0, 270) 
          state = 1 
        else 
         setElementRotation(barrier, 0, 270, 270) 
          state = 0 
        end 
end 
  
addCommandHandler("gate", open) 

Edited by Guest
Link to comment
local barrier = createObject(968, -1572.19, 658.79, 6.8, 0, 270, 270) 
state = 0  
  
function openb(player) 
        if state == 0  and  getElementPosition(player, -1562.9, 661.9, 7) or getElementPosition(player, -1579.3, 661, 7.1)then 
           
           setElementRotation(barrier, 0, 0, 270) 
           state = 1 
           outputChatBox("opens the barrier.", getPlayerName(player), player, 0, 255, 255) 
        else 
        if state == 1  and getElementPosition(player, -1562.9, 661.9, 7) or getElementPosition(player, -1579.3, 661, 7.1) then 
          setElementRotation(barrier, 0, 270, 270) 
          state = 0 
          outputChatBox("closes the barrier.", getPlayerName(player), player, 0, 255, 255) 
        end   
        end 
end 
addCommandHandler("gate",openb) 

getElementPossition a nill value getLocalPlayer a nil lvalue

Edited by Guest
Link to comment

There you go :P

local barrier = createObject(968, -1572.19, 658.79, 6.8, 0, 270, 270) 
local state = 0 
  
function openb(player) 
    if state == 0  and  getElementPosition(player, -1562.9, 661.9, 7) or getElementPosition(player, -1579.3, 661, 7.1)then          
        setElementRotation(barrier, 0, 0, 270) 
        state = 1 
        outputChatBox("opens the barrier.",player, 0, 255, 255) 
    elseif state == 1  and getElementPosition(player, -1562.9, 661.9, 7) or getElementPosition(player, -1579.3, 661, 7.1) then 
        setElementRotation(barrier, 0, 270, 270) 
        state = 0 
        outputChatBox("closes the barrier.", player, 0, 255, 255) 
    end   
end 
addCommandHandler("gate",openb) 

Also you made some simple errors in the script I suggest you visit the wiki to improve your scripting

Link to comment
local barrier = createObject(968, -1572.19, 658.79, 6.8, 0, 270, 270) 
state = 0  
  
function openb(player) 
        if state == 0 and getElementPosition(player, -1562.9, 661.9, 7)  or  getElementPosition(player, -1579.3, 661, 7.1) then 
           setElementRotation(barrier, 0, 0, 270) 
           state = 1 
           outputChatBox("opens the barrier.", player, 0, 255, 255) 
        else 
          setElementRotation(barrier, 0, 270, 270) 
          state = 0 
          outputChatBox("closes the barrier.", player, 0, 255, 255) 
        end  
end 
addCommandHandler("gate",openb) 

not work only the first if work the else part no work also open even it not in position i put

Link to comment

... You know 'getElementPosition' only has 1 argument, called the element? How could you ever, ever, ever throw those positions into it...

If I was you, I should create a marker or a collshape. As soon as the player hits it (onPlayerMarkerHit/onClientMarkerHit/onElementColShapeHit/onClientElementColShapeHit) open or close it. (Could be done with onPlayerMarkerLeave/onClientMarkerLeave/onElementColShapeLeave/onClientElementColShapeLeave)

Link to comment
local barrier = createObject(968, -1572.19, 658.79, 6.8, 0, 270, 270) 
state = 0 
  
function open(player) 
    local x,y,z = getElementPosition(player) 
        if state == 0 and (x >=-1562.9 and x <= -1579.3) and (y >= 661.9 and y <=661) and (z >= 7.1 and z <=7)then 
           setElementRotation(barrier, 0, 0, 270) 
           state = 1 
           outputChatBox("opens the barrier.", player, 0, 255, 255) 
        else 
          setElementRotation(barrier, 0, 270, 270) 
          state = 0 
          outputChatBox("closes the barrier.", player, 0, 255, 255) 
        end 
end 
addCommandHandler("gate",open) 

no move the object only apreas the second message

http://i.imgur.com/vOzh8AU.png

Link to comment

i need your help idk why i am at position i have put but not working please help

local barrier = createObject(968, 1544.6899414063, -1630.8000488281, 13.10000038147, 0, 90, 90) 
state = 0 
  
function open(player) 
  local x,y,z = getElementPosition(player) 
    if state == 0  and (x >= 1529.63660 and y >= -1628.97876 and z >= 13.38281) and (x <= 1555.20728 and y <= -1627.15662 and z <= 13.38281) then 
       setElementRotation(barrier, 0, 0, 90) 
       state = 1 
    else 
    if state == 1 and (x >= 1529.63660 and y >= -1628.97876 and z >= 13.38281) and (x <= 1555.20728 and y <= -1627.15662 and z <= 13.38281) then 
       setElementRotation(barrier, 0, 90, 90) 
       state = 0 
    end 
    end 
end 
addCommandHandler("gate", open) 

Link to comment
local barrier = createObject(968, 1544.6899414063, -1630.8000488281, 13.10000038147, 0, 90, 90) 
state = 0 
  
function open(player) 
  local x,y,z = getElementPosition(player) 
    if state == 0  and (x >= 1529.63660 and y >= -1628.97876 and z >= 13.38281) and (x <= 1555.20728 and y <= -1627.15662 and z <= 13.38281) then 
       setElementRotation(barrier, 0, 0, 90) 
       state = 1 
    else 
    if state == 1 and (x >= 1529.63660 and y >= -1628.97876 and z >= 13.38281) and (x <= 1555.20728 and y <= -1627.15662 and z <= 13.38281) then 
       setElementRotation(barrier, 0, 90, 90) 
       state = 0 
    end 
    end 
end 
addCommandHandler("gate", open) 

not working i am the position and no do nothing someone help

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