Jump to content

Command for determined tag


devildead622

Recommended Posts

Hello, I am new to Scripts for MTA, and I wonder, as I do for anyone who has "[out]" in its name can use the commands "/ open" and "/ close"? And it's not for everyone!

function createTheGate () 
  
         myGate1 = createObject ( 988, 313.599, -61.799, 1.6499, 0, 0, 0 ) 
  
  
      end 
  
      addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
  
  
  
  
 function openMyGate ( ) 
 moveObject ( myGate1, 2500, 308.5, -61.799, 1.6499 ) 
 end 
 addCommandHandler("open",openMyGate) 
  
  
 function movingMyGateBack () 
 moveObject ( myGate1, 2500, 313.599, -61.799, 1.6499 ) 
 end 
 addCommandHandler("close",movingMyGateBack) 

I am PT-BR and translate the topic by google translator, sorry if you have anything wrong (it is not my fault)

Link to comment

I think he meant something like this:

function createTheGate () 
    myGate1 = createObject ( 988, 313.599, -61.799, 1.6499, 0, 0, 0 ) 
end 
  
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
function openMyGate ( player ) 
    if string.find( getPlayerName( player ) , "[out]", 1, true ) then 
        moveObject ( myGate1, 2500, 308.5, -61.799, 1.6499 ) 
    end 
end 
addCommandHandler("open",openMyGate) 
  
  
function movingMyGateBack ( player ) 
    if string.find( getPlayerName( player ) , "[out]", 1, true ) then 
        moveObject ( myGate1, 2500, 313.599, -61.799, 1.6499 ) 
    end 
end 
addCommandHandler("close",movingMyGateBack) 

But of course, it's not the best way to check permissions by the name

Link to comment
  
function createTheGate () 
    myGate1 = createObject ( 988, 313.599, -61.799, 1.6499, 0, 0, 0 ) 
end 
  
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
function openMyGate ( player ) 
    if string.find( getPlayerName( player ) , "[out]", 1, true ) then 
        moveObject ( myGate1, 2500, 308.5, -61.799, 1.6499 ) 
        setTimer(movingMyGateBack,5000,1,player) 
    end 
end 
addCommandHandler("open",openMyGate) 
  
  
function movingMyGateBack ( player ) 
    if string.find( getPlayerName( player ) , "[out]", 1, true ) then 
        moveObject ( myGate1, 2500, 313.599, -61.799, 1.6499 ) 
    end 
end 
addCommandHandler("close",movingMyGateBack) 
  

Link to comment
that should work if he would use it on server side.
  
addEventHandler ( "[b]onResourceStart[/b]", getResourceRootElement ( getThisResource () ), createTheGate ) 
  

It's already server-side, he used server-side event, and it worked. He only forgot the "player" from setTimer, i think.

Link to comment

Yes, i saw this, and i also tought its server-sided. But in his original script the command handler functions did not have a player argumet, so i added it. Now he has an error that this player element is nil... that can only happen if he tried to use it on client side or he called the function without adding player element ( that's not likely ).

He said that he hadn't put yet the setTimer when he got that error. So, strange :)

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