Jump to content

LSPD gate didn't move.


Sparrow

Recommended Posts

Posted

I'm trying to set a gate for LSPD that opens for whogot polices skins, the problem is the gate didn't move.

he is the script:

local policeSkins = { [280]=true, [281]=true, [282]=true, [283]=true, [284]=true, [285]=true, [286]=true } 
local theMarker = createMarker (1545.400, -1627.600, 13.400, "cylinder", 6, 255, 255, 255, 0) 
local gate = createObject (968, 1544.6999511719, -1631, 13.199999809265, 0, 270, 270) 
  
function openGate(thePlayer) 
    if policeSkins[getElementModel (thePlayer)] then 
        moveObject (gate, 1500, 1544.700, -1630.800, 13.300) 
    end 
end 
addEventHandler("onMarkerHit", theMarker, openGate) 
  
function closeGate(thePlayer) 
    if policeSkins[getElementModel (thePlayer)] then 
        moveObject (gate, 1500, 1544.6999511719, -1631, 13.199999809265) 
    end 
end 
addEventHandler( "onMarkerLeave", theMarker, closeGate) 

Posted
local policeSkins = { [280] = true, [281] = true, [282] = true, [283] = true, [284] = true, [285] = true, [286] = true } 
local theMarker = createMarker ( 1545.400, -1627.600, 13.400, "cylinder", 6, 255, 255, 255, 0 ) 
local gate = createObject ( 968, 1544.6999511719, -1631, 13.199999809265, 0, 270, 270 ) 
  
local state = { } 
  
local function gateState( hitElement,dim ) 
    local el 
    if getElementType( hitElement ) == 'player' then 
        el = hitElement 
    elseif getElementType( hitElement ) == 'vehicle' then 
        el = getVehicleController( hitElement ) 
    end 
    if policeSkins[ getElementModel ( el ) ] then 
        state[ el ] = not state[ el ] 
        if state then 
            moveObject ( gate, 1500, 1544.700, -1630.800, 13.300 ) 
        else 
            moveObject ( gate, 1500, 1544.6999511719, -1631, 13.199999809265 ) 
        end  
    end  
end 
addEventHandler( "onMarkerHit", theMarker, gateState ) 
  
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        state[ source ] = nil 
    end 
)    

Updated.

Posted

Oh my bad :/ i forgot call index table.

local policeSkins = { [280] = true, [281] = true, [282] = true, [283] = true, [284] = true, [285] = true, [286] = true } 
local theMarker = createMarker ( 1545.400, -1627.600, 13.400, "cylinder", 6, 255, 255, 255, 0 ) 
local gate = createObject ( 968, 1544.6999511719, -1631, 13.199999809265, 0, 270, 270 ) 
  
local state = { } 
  
local function gateState( hitElement,dim ) 
    local el 
    if getElementType( hitElement ) == 'player' then 
        el = hitElement 
    elseif getElementType( hitElement ) == 'vehicle' then 
        el = getVehicleController( hitElement ) 
    end 
    if policeSkins[ getElementModel ( el ) ] then 
        state[ el ] = not state[ el ] 
        if state[ el ] then 
            moveObject ( gate, 1500, 1544.700, -1630.800, 13.300 ) 
        else 
            moveObject ( gate, 1500, 1544.6999511719, -1631, 13.199999809265 ) 
        end  
    end  
end 
addEventHandler( "onMarkerHit", theMarker, gateState ) 
  
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        state[ source ] = nil 
    end 
)    

Tested.

Posted (edited)

ok, I'll try.

EDIT: I test it with others X, Y and Z coordination, nothing happend, gate didn't work.

Edited by Guest
Posted

I don't know how you test.

It working..

local policeSkins = { [280] = true, [281] = true, [282] = true, [283] = true, [284] = true, [285] = true, [286] = true } 
local theMarker = createMarker ( 1545.400, -1627.600, 13.400, "cylinder", 6, 255, 255, 255, 255 ) 
local gate = createObject ( 968, 1544.6999511719, -1631, 13.199999809265, 0, 270, 270 ) 
  
local state = { } 
  
local function gateState( hitElement,dim ) 
    local el 
    if getElementType( hitElement ) == 'player' then 
        el = hitElement 
    elseif getElementType( hitElement ) == 'vehicle' then 
        el = getVehicleController( hitElement ) 
    end 
    if policeSkins[ getElementModel ( el ) ] then 
        state[ el ] = not state[ el ] 
        if state[ el ] then 
            moveObject ( gate, 1500, 1544.700, -1630.800, 13.300 ) 
        else 
            moveObject ( gate, 1500, 1544.6999511719, -1631, 23.199999809265 ) 
        end  
    end  
end 
addEventHandler( "onMarkerHit", theMarker, gateState ) 
  
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        state[ source ] = nil 
    end 
)    

Marker visible.

Just try.

Updated.

Posted

Working

local policeSkins = { [280] = true, [281] = true, [282] = true, [283] = true, [284] = true, [285] = true, [286] = true } 
local theMarker = createMarker ( 1545.400, -1627.600, 13.400, "cylinder", 6, 255, 255, 255, 255 ) 
local gate = createObject ( 968, 1544.6999511719, -1631, 13.199999809265, 0, 270, 270 ) 
  
local state = { } 
  
local function gateState( hitElement,dim ) 
    local el 
    if getElementType( hitElement ) == 'player' then 
        el = hitElement 
    elseif getElementType( hitElement ) == 'vehicle' then 
        el = getVehicleController( hitElement ) 
    end 
    if policeSkins[ getElementModel ( el ) ] then 
        state[ el ] = not state[ el ] 
        if state[ el ] then 
            moveObject ( gate, 1500, 1544.6999511719, -1631, 23.199999809265 ) 
        else 
            moveObject ( gate, 1500, 1544.700, -1630.800, 13.300 ) 
        end  
    end  
end 
addEventHandler( "onMarkerHit", theMarker, gateState ) 
  
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        state[ source ] = nil 
    end 
)    

Just need interchange :/

But you only hit marker and done ( you not re hit again ) ..

Posted (edited)

Lol i tested it now.

Idk why it not working for you.

You use this script in server side?

Edited by Guest

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