Jump to content

Problems with gates


Recommended Posts

Posted (edited)

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
Posted

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 

Posted (edited)

By any chance does it touch any other objects when it's moving?

Because the only thing I fixed that with was setting the collision off.

setElementCollisionsEnabled 

Edited by Guest
Posted

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 

Posted
Which are you using roleplay scripts, PotatoHead?

I got one from a friend. I am not quite sure what it is. I think its just a lot mixed together. He sold it to me for 5 dollars CAD.

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