devildead622 Posted February 12, 2013 Posted February 12, 2013 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)
iPrestege Posted February 12, 2013 Posted February 12, 2013 You mean you want it for admin group or what ?
DNL291 Posted February 12, 2013 Posted February 12, 2013 addCommandHandler getPlayerAccount getAccountName isObjectInACLGroup aclGetGroup createObject moveObject
csiguusz Posted February 12, 2013 Posted February 12, 2013 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
devildead622 Posted February 12, 2013 Author Posted February 12, 2013 Thanks! And how: after 5 seconds, the "movingMyGateBack" is called automatically after typing the command "open"? In SAMP was a function called setTime, do not know how it works here at MTA
devildead622 Posted February 12, 2013 Author Posted February 12, 2013 not yet put the SetTimer but ta giving an error http://i.imgur.com/AsiOafd.png
csiguusz Posted February 12, 2013 Posted February 12, 2013 This happens when you write the command? Do you you use the code on server or client-side?
devildead622 Posted February 12, 2013 Author Posted February 12, 2013 Do not understand your question! Maybe Google Translate is complicating everything!
csiguusz Posted February 12, 2013 Posted February 12, 2013 Maybe... then you'd better learn english isntead of using google translate I asked, that how do you use the code what i gave you? Is your LUA script file client-sided or server-sided?
Gr0x Posted February 12, 2013 Posted February 12, 2013 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)
csiguusz Posted February 12, 2013 Posted February 12, 2013 Thanks Gr0x that, i could not make it him cause im from my phone now... that should work if he would use it on server side.
Gr0x Posted February 12, 2013 Posted February 12, 2013 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.
csiguusz Posted February 12, 2013 Posted February 12, 2013 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
devildead622 Posted February 12, 2013 Author Posted February 12, 2013 Thanks csiguusz and Gr0x! Got it!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now