Jump to content

Problems with gates


Recommended Posts

I have this problem when making gates. The gate just flops around randomly and then ends in a random position. I am not sure what is going on. I am getting no errors. Here is my code.

EDIT: I also keep getting a Protocol Error (15) when on my server it happens to everyone when one person disconnects. I am running version 1.3.3 Client and Server.

EDIT #2: The Protocol Error (15) was fixed by me just re-installing the server. That Error is now gone.

EDIT #3: Problem Fixed. I was just using the wrong parameters to rotate the object. :oops:

local objGateg = createObject(968, 1544.69995, -1630.80005, 13.1, 0, 269.87, 270.149) 
exports.pool:allocateElement(objGateg) 
  
local open = false 
  
-- Gate code 
function usePDFrontGarageGate(thePlayer) 
    local x, y, z = getElementPosition(thePlayer) 
    local distance = getDistanceBetweenPoints3D(1544.69995, -1630.80005, 13.1, x, y, z) 
         
    if (distance<=10) and (open==false) then 
        if (exports.global:hasItem(thePlayer, 64)) then 
            open = true 
            outputChatBox("LSPD Garage is now Open!", thePlayer, 0, 255, 0) 
            moveObject(objGateg, 3000, 1544.69922, -1630.80005, 13.1, 0, 357.87, 270.148) 
            setTimer(closePDFrontGarageGate, 5000, 1, thePlayer) 
        end 
    end 
end 
addCommandHandler("gate", usePDFrontGarageGate) 
  
function closePDFrontGarageGate(thePlayer) 
    setTimer(resetState8, 3000, 1) 
    moveObject(objGateg, 3000, 1544.69995, -1630.80005, 13.1, 0, 269.87, 270.149) 
end 
  
function resetState8() 
    open = false 
end 

Edited by Guest
Link to comment

try this:

local gx,gy,gz = 1544.69995, -1630.80005, 13.1 
local objGateg = createObject(968, gx, gy, gz, 0, 269.87, 270.149) 
exports.pool:allocateElement(objGateg) 
  
local open = false 
  
-- Gate code 
function usePDFrontGarageGate(thePlayer) 
    local x, y, z = getElementPosition(thePlayer) 
    local distance = getDistanceBetweenPoints3D(gx, gy, gz, x, y, z) 
  
    if (distance<=10) and (open==false) then 
        if (exports.global:hasItem(thePlayer, 64)) then 
            open = true 
            outputChatBox("LSPD Garage is now Open!", thePlayer, 0, 255, 0) 
            moveObject(objGateg, 3000, 1544.69922, -1630.80005, 13.1, 0, 357.87, 270.148) 
            setTimer(closePDFrontGarageGate, 5000, 1) 
        end 
    end 
end 
addCommandHandler("gate", usePDFrontGarageGate) 
  
function closePDFrontGarageGate() 
    setTimer(function() 
        open = false 
    end, 3000, 1) 
    moveObject(objGateg, 3000, gx, gy, gz, 0, 269.87, 270.149) 
end 

Link to comment

Just whats is already in the map. I have not mapped anything else around it as of yet. I added that here and it didnt seem to fix it.

if (distance<=10) and (open==false) then 
        if (exports.global:hasItem(thePlayer, 64)) then 
            open = true 
            outputChatBox("LSPD Garage is now Open!", thePlayer, 0, 255, 0) 
            moveObject(objGateg, 3000, 1544.69922, -1630.80005, 13.1, 0, 357.87, 270.148) 
            setTimer(closePDFrontGarageGate, 5000, 1) 
            setElementCollisionsEnabled(objgateg, false) 
        end 
    end 

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