Jump to content

help pls


Jacobob14

Recommended Posts

Posted

as I can do that by executing a command

leave me in chat if the door is open or closed forgive my bad English

this is the script I use

local objeto1 = createObject ( 980, 1460.6999511719, 802.70001220703, 15.199999809265, 0, 0, 0) 
local state = false 
local objeto11 = createObject ( 980, 1441.4000244141, 802.70001220703, 15.199999809265, 0, 0, 0) 
local state = false 
  
function Funcion ( thePlayer ) 
     local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "|LTN|" ) ) then 
        if ( not state ) then 
            moveObject ( objeto1, 2000, 1460.6999511719, 802.70001220703, 22, 0, 0, 0) 
                        state = true 
            moveObject ( objeto11, 2000, 1441.4000244141, 802.70001220703, 22, 0, 0, 0) 
                        state = true 
            outputChatBox ( "#00bbff[base LTN] => #0000ffAbriendo #00ff00Entry", thePlayer, 255, 255, 255, true ) 
            else 
            moveObject ( objeto1, 2000, 1460.6999511719, 802.70001220703, 15.199999809265, 0, 0, 0) 
             state = false 
            moveObject ( objeto11, 2000, 1441.4000244141, 802.70001220703, 15.199999809265, 0, 0, 0) 
             state = false 
            outputChatBox ( "#00bbff[base LTN] => #0000ffCerrando #00ff00 Entry", thePlayer, 255, 255, 255, true ) 
        end 
    end 
end  
addCommandHandler ( "ltnentry", Funcion ) 

  • Moderators
Posted

I'm pretty sure he want's a command that says in the chat if the gate is currently opened or closed:

function gateStateChecker(thePlayer) 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "|LTN|" ) ) then 
        if ( not state ) then 
            outputChatBox("The gate is opened !", thePlayer) 
        else 
            outputChatBox("The gate is closed !", thePlayer) 
        end 
    end 
end 
addCommandHandler("checkgate", false, false) 

Is that what you were looking for ?

Regards,

Citizen

Posted

thank you very much :D

I have another question is possible that if the door is in motion can not close until the end of open

or you can not open until the end of closing forgive my bad English :(

  • Moderators
Posted

Sure you can, but you need to use a third state (and not true or false) so we will likely do like this:

local states = { 
    closed = 1, 
    moving = 2, 
    opened = 3 
} 
local state = false --variable that will hold the current state of our gates 
  
local objeto1 = createObject ( 980, 1460.6999511719, 802.70001220703, 15.199999809265, 0, 0, 0) 
local objeto11 = createObject ( 980, 1441.4000244141, 802.70001220703, 15.199999809265, 0, 0, 0) 
  
function openLTNGate( thePlayer ) --Please use better function names like this one (even if this one is not that accurate) 
    local movingTime = 2000 --time the gates will take to move entirely (in ms) 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup("user."..accName, aclGetGroup ( "|LTN|" ) ) then 
        if state == states.closed then --if gates are closed 
            moveObject( objeto1, movingTime, 1460.6999511719, 802.70001220703, 22, 0, 0, 0) 
            moveObject( objeto11, movingTime, 1441.4000244141, 802.70001220703, 22, 0, 0, 0) 
            outputChatBox ( "#00bbff[base LTN] => #0000ffAbriendo #00ff00Entry", thePlayer, 255, 255, 255, true ) 
            state = states.moving --set the current state as moving to prevent someone to close before 
            setTimer(function () state = states.opened end, movingTime, 1) --set as opened after 2secs in our case 
        elseif state == states.opened then --if gates are opened 
            moveObject ( objeto1, movingTime, 1460.6999511719, 802.70001220703, 15.199999809265, 0, 0, 0) 
            moveObject ( objeto11, movingTime, 1441.4000244141, 802.70001220703, 15.199999809265, 0, 0, 0) 
            outputChatBox ( "#00bbff[base LTN] => #0000ffCerrando #00ff00 Entry", thePlayer, 255, 255, 255, true ) 
            state = states.moving --set the current state as moving to prevent someone to open before 
            setTimer(function () state = states.closed end, movingTime, 1) --set as closed after 2secs in our case 
        end 
    end 
end 
addCommandHandler ( "ltnentry", openLTNGate ) 

Please ask if you don't understand a part of this code.

Regards,

Citizen

Posted
Sure you can, but you need to use a third state (and not true or false) so we will likely do like this:
local states = { 
    closed = 1, 
    moving = 2, 
    opened = 3 
} 
local state = false --variable that will hold the current state of our gates 
  
local objeto1 = createObject ( 980, 1460.6999511719, 802.70001220703, 15.199999809265, 0, 0, 0) 
local objeto11 = createObject ( 980, 1441.4000244141, 802.70001220703, 15.199999809265, 0, 0, 0) 
  
function openLTNGate( thePlayer ) --Please use better function names like this one (even if this one is not that accurate) 
    local movingTime = 2000 --time the gates will take to move entirely (in ms) 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup("user."..accName, aclGetGroup ( "|LTN|" ) ) then 
        if state == states.closed then --if gates are closed 
            moveObject( objeto1, movingTime, 1460.6999511719, 802.70001220703, 22, 0, 0, 0) 
            moveObject( objeto11, movingTime, 1441.4000244141, 802.70001220703, 22, 0, 0, 0) 
            outputChatBox ( "#00bbff[base LTN] => #0000ffAbriendo #00ff00Entry", thePlayer, 255, 255, 255, true ) 
            state = states.moving --set the current state as moving to prevent someone to close before 
            setTimer(function () state = states.opened end, movingTime, 1) --set as opened after 2secs in our case 
        elseif state == states.opened then --if gates are opened 
            moveObject ( objeto1, movingTime, 1460.6999511719, 802.70001220703, 15.199999809265, 0, 0, 0) 
            moveObject ( objeto11, movingTime, 1441.4000244141, 802.70001220703, 15.199999809265, 0, 0, 0) 
            outputChatBox ( "#00bbff[base LTN] => #0000ffCerrando #00ff00 Entry", thePlayer, 255, 255, 255, true ) 
            state = states.moving --set the current state as moving to prevent someone to open before 
            setTimer(function () state = states.closed end, movingTime, 1) --set as closed after 2secs in our case 
        end 
    end 
end 
addCommandHandler ( "ltnentry", openLTNGate ) 

Please ask if you don't understand a part of this code.

Regards,

Citizen

I've tried it and the door does not open :(

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