5150 Posted July 26, 2015 Share Posted July 26, 2015 i have tried for so long to make one simple script for an admin base i am making... it is a gate allowing access. i know how to make it, but i dont know what to do after i plug the info in (i use a model that apparently is bad or something) can anyone tell me the steps in successfully making this work in the server i play on, and any others i want to add it too... here is the script to check for errors. the tutorials never helped me, ive done my research . . . . . . admingate = createObject(10841, -1641, -36.7998, 1, 0, 0, 135.03295) function gateOpen() moveObject(admingate, 2000, -1641, -36.7998, 5,) end addCommandHandler("/adminbo", gateOpen)--Command /adminbo to open gate function gateClose() moveObject( admingate, 2000, -1641, -36.7998, 1,) end addCommandHandler("/adminbc", gateClose)--Command /adminbc to close gate Link to comment
Annas Posted July 26, 2015 Share Posted July 26, 2015 Try this .. admingate = createObject(10841, -1641, -36.7998, 1, 0, 0, 135.03295) function gateOpen() moveObject(admingate, 2000, -1641, -36.7998, 5) end addCommandHandler("adminbo", gateOpen) --Command /adminbo to open gate function gateClose() moveObject( admingate, 2000, -1641, -36.7998, 1) end addCommandHandler("adminbc", gateClose)--Command /adminbc to close gate By Code's admingate = createObject([Object ID], [X], [Y], [Z], [Rotation.X], [Rotation.Y], [Rotation.Z]) function gateOpen() moveObject(admingate, [Object ID], [X], [Y], [Z]) end addCommandHandler("adminbo", gateOpen) --Command /adminbo to open gate function gateClose() moveObject( admingate, [Object ID], [X], [Y], [Z]) end addCommandHandler("adminbc", gateClose)--Command /adminbc to close gate ||Sorry For My BAd English|| Link to comment
5150 Posted July 26, 2015 Author Share Posted July 26, 2015 Yes thank you, but I do not understand what to do after I have this Link to comment
Perfect Posted July 26, 2015 Share Posted July 26, 2015 What do you mean? Are you new to MTA Scripting? If you are then you should read this page for information: https://wiki.multitheftauto.com/wiki/Sc ... troduction Link to comment
XeRo Posted July 26, 2015 Share Posted July 26, 2015 (server-side) root = getRootElement() gResRoot = getResourceRootElement(getThisResource()) --X Y Z cordinates id,x,y,z,rx,ry,rz = [X],[Y],0,0,90 Xero = "CloseGate" gate = createObject(id,x,y,z,rx,ry,rz) Col = createColSphere(x,y,z,5) function GatePlayerOpen(player) if (getElementType(player) == "player") then if (Xero == "CloseGate") then OpenMyGate(player) else CloseMyGate(player) end end end addEventHandler("onColShapeHit",Col,GatePlayerOpen) addEventHandler("onColShapeLeave",Col,GatePlayerOpen) function GatePlayerOpen2(player) if Xero == "CloseGate" then outputChatBox("Player Open Gate.",player,170,255,0) local x,y,z = getElementPosition(Kapi) moveObject(Gate,2000,x,y,z-5.5) Xero = "OpenGate" end end function ClosePlayerGate(player) if Xero == "OpenGate" then outputChatBox("Player Close Gate.",player,170,255,0) moveObject(Gate,2000,x,y,z) Xero = "CloseGate" end end Link to comment
5150 Posted July 26, 2015 Author Share Posted July 26, 2015 Yes guys, I'm new to scripting but the tutorials don't help. All I need to know is where to put the script when I finish it, and wtf is metA and do I need it? Link to comment
Perfect Posted July 26, 2015 Share Posted July 26, 2015 Yeah. Sometimes the wiki's introduction page doesn't help much. Okay, here are the steps: 1) Copy the below code and save it as "script.lua" admingate = createObject(10841, -1641, -36.7998, 1, 0, 0, 135.03295) function gateOpen() moveObject(admingate, 2000, -1641, -36.7998, 5) outputChatBox("Gate is now opened!", 0, 255, 0, true) end addCommandHandler("adminbo", gateOpen) --Command /adminbo to open gate function gateClose() moveObject( admingate, 2000, -1641, -36.7998, 1) end addCommandHandler("adminbc", gateClose)--Command /adminbc to close gate outputChatBox("Gate is now closed!", 0, 255, 0, true) 2) Copy the below code and save it as "meta.xml" "DeathWatch5150" version="1.0" name="My First Resource" description="This resource open and close a gate by a command" type="script" /> 3) Create a ZIP folder called "myfirstresource" and put the above files in it. 4) Put the newly created ZIP folder in MTA San Andreas 1.4\server\mods\deathmatch\resources\[gameplay] 5) Congratulations! you have successfully created your very first resource. Information regarding meta.xml. The meta.xml should be present in every resource/gamemode/map you make as it tells the server there is a script in the folder. If you didn't include put a meta.xml in your resource folder, your resource/script is never going to run as the server would never know about the presence/existence of your script. So yes, meta.xml is a very important file and you certainly need it. Link to comment
5150 Posted July 26, 2015 Author Share Posted July 26, 2015 Yeah. Sometimes the wiki's introduction page doesn't help much. Okay, here are the steps: 1) Copy the below code and save it as "script.lua" admingate = createObject(10841, -1641, -36.7998, 1, 0, 0, 135.03295) function gateOpen() moveObject(admingate, 2000, -1641, -36.7998, 5) outputChatBox("Gate is now opened!", 0, 255, 0, true) end addCommandHandler("adminbo", gateOpen) --Command /adminbo to open gate function gateClose() moveObject( admingate, 2000, -1641, -36.7998, 1) end addCommandHandler("adminbc", gateClose)--Command /adminbc to close gate outputChatBox("Gate is now closed!", 0, 255, 0, true) 2) Copy the below code and save it as "meta.xml" "DeathWatch5150" version="1.0" name="My First Resource" description="This resource open and close a gate by a command" type="script" /> 3) Create a ZIP folder called "myfirstresource" and put the above files in it. 4) Put the newly created ZIP folder in MTA San Andreas 1.4\server\mods\deathmatch\resources\[gameplay] 5) Congratulations! you have successfully created your very first resource. Information regarding meta.xml. The meta.xml should be present in every resource/gamemode/map you make as it tells the server there is a script in the folder. If you didn't include put a meta.xml in your resource folder, your resource/script is never going to run as the server would never know about the presence/existence of your script. So yes, meta.xml is a very important file and you certainly need it. man youre the best thanks. now once its in [gameplay] it will appear in any server i start, and i will have to send it to the owner of any other server for it to be there? Link to comment
Perfect Posted July 26, 2015 Share Posted July 26, 2015 You are welcome. Yes, if you want the resource to be able to work in a particular server, you have to send your resource to the server's owner. Link to comment
5150 Posted July 26, 2015 Author Share Posted July 26, 2015 You are welcome. Yes, if you want the resource to be able to work in a particular server, you have to send your resource to the server's owner. sorry im such a bother lol, but i just copied what you gave me, edited the output message, saved it to .lua, then saved the meta to .xml, then saved it all to a "winRAR archive", then put it in gameplay. it didnt create the object or output a message when i typed it. did i do something wrong? Link to comment
Perfect Posted July 26, 2015 Share Posted July 26, 2015 Did you start the resource? If you do, type '/debugscript 3' in chat to see if they are any errors/warnings in the script. Link to comment
5150 Posted July 26, 2015 Author Share Posted July 26, 2015 keeps saying access denied... keep in mind you're dealing with a guy that knows barely anything about scripting and dealing with personal servers i do my research but theres barely anything on youtube, and the wiki never seems to help for some reason Link to comment
Perfect Posted July 26, 2015 Share Posted July 26, 2015 Okay, you have to make yourself admin to do that. Here's a tutorial on how to do that: viewtopic.php?f=98&t=89673&p=808707&hilit=how+to+make+yourself+admin#p808707 After making yourself, admin. Start the game and login in the server ('/login name password') and type '/start myfirstresource'. This will start your resource.Then try opening/closing gates. If it doesn't work, type '/debugscript 3' and restart the resource by typing '/restart myfirstresource'. About debugscript 3: Debugscript as the name suggest debug the script and checks if they are any problems in the script and if it has any, it will output them on the screen. 'debugscript 1' will output only errors. 'debugscript 2' will output errors and warnings. 'debugscript 3' will output errors, warnings and info messages. You can read more about it on here: https://wiki.multitheftauto.com/wiki/Debugging Link to comment
5150 Posted July 26, 2015 Author Share Posted July 26, 2015 thanks bro for your help i learned a lot. now im off to go see why i cant start my port forwarded server Link to comment
Perfect Posted July 27, 2015 Share Posted July 27, 2015 You are welcome and good luck for 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