devildead622 Posted February 12, 2013 Share 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) Link to comment
iPrestege Posted February 12, 2013 Share Posted February 12, 2013 You mean you want it for admin group or what ? Link to comment
DNL291 Posted February 12, 2013 Share Posted February 12, 2013 addCommandHandler getPlayerAccount getAccountName isObjectInACLGroup aclGetGroup createObject moveObject Link to comment
csiguusz Posted February 12, 2013 Share 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 Link to comment
devildead622 Posted February 12, 2013 Author Share 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 Link to comment
csiguusz Posted February 12, 2013 Share Posted February 12, 2013 There is a setTimer function in MTA Link to comment
devildead622 Posted February 12, 2013 Author Share Posted February 12, 2013 not yet put the SetTimer but ta giving an error http://i.imgur.com/AsiOafd.png Link to comment
csiguusz Posted February 12, 2013 Share Posted February 12, 2013 This happens when you write the command? Do you you use the code on server or client-side? Link to comment
csiguusz Posted February 12, 2013 Share Posted February 12, 2013 how so? Hm? Just answer my question Link to comment
devildead622 Posted February 12, 2013 Author Share Posted February 12, 2013 Do not understand your question! Maybe Google Translate is complicating everything! Link to comment
csiguusz Posted February 12, 2013 Share 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? Link to comment
Gr0x Posted February 12, 2013 Share 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) Link to comment
csiguusz Posted February 12, 2013 Share 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. Link to comment
Gr0x Posted February 12, 2013 Share 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. Link to comment
csiguusz Posted February 12, 2013 Share 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 Link to comment
devildead622 Posted February 12, 2013 Author Share Posted February 12, 2013 Thanks csiguusz and Gr0x! Got it! Link to comment
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