Saml1er Posted February 10, 2014 Share Posted February 10, 2014 Hello everybody, this is a tutorial by my friend ( Dreddy from DDC ) : It's my first lesson to you, as Subject says, today I will teach you how to create resources. Well, If you wanna create a simple resource, like with fun commands. You have to make only 2 files in folder (.xml one and .lua) Well, Let's get started from beginning. 1. Open MTA Folder/server/mods/deathmatch/resources. 2. Create a new folder, called "Script01" http://i.imgur.com/ZU72Kor.jpg As you see now, It's empty, Let's make something there. 3. Create a new Text File and call it "meta.xml" and Let's start with meta settings. "Author" version="1.0" name="Script01" type="script"/> Congratulations my boy, we created a simple meta code. 4. Create a new Text File an call it "script.lua" DANGEROUS: If you're going to do some script, look carefully to which side that function belongs. Here's not all functions belong to Client/Server side. If you will put Client-side event into the Server-side .lua file, It will not work at all. 5. Well, Let's make a simple script: When new map starts, It says us "Hello World" addEvent('onRaceStateChanging', true) addEventHandler('onRaceStateChanging', root, function(new) if new=='LoadingMap' then outputChatBox ('Hello World', root, 255, 255, 255, true) end end ) 6. Paste that code into our created .lua file and save it. 7. Adding Lua file in meta. Here's nothing hard at all, just place that line into your .xml file AFTER or BEFORE Now your meta.xml should look like "Author" version="1.0" name="Script01" type="script"/> 8. Come to server, and use "/start Script01" and try to start some map on gamemode. NOTE: If you don't understand anything here then please post it right here so I can help you. Link to comment
xeon17 Posted February 10, 2014 Share Posted February 10, 2014 Good Tutorial for begginers , will help much players. Good work. Link to comment
Aditya Posted February 21, 2014 Share Posted February 21, 2014 Hello. Can I know what does the "onRaceStateChanging" event is? If possible, please explain in the simpliest form, as much as you can. Thank you. Link to comment
Saml1er Posted February 21, 2014 Author Share Posted February 21, 2014 Hello. Can I know what does the "onRaceStateChanging" event is? If possible, please explain in the simpliest form, as much as you can. Thank you. Its an Event ( race event ). You can also change the 'LoadingMap' with following states and the 2 parameters. Parameters string newState, string oldState newState: the new state oldState: the old state Possible states: undefined NoMap LoadingMap PreGridCountdown GridCountdown Running MidMapVote SomeoneWon TimesUp EveryoneFinished PostFinish NextMapSelect NextMapVote ResourceStopping More info can be found here: https://wiki.multitheftauto.com/wiki/Resource:Race Link to comment
bul188 Posted February 25, 2014 Share Posted February 25, 2014 Apparently my resource "could not be found" and I've no idea why. http://pasteboard.co/VWzb0WD.png Link to comment
Anubhav Posted February 25, 2014 Share Posted February 25, 2014 script.lua is not found. thats why. Link to comment
Saml1er Posted February 25, 2014 Author Share Posted February 25, 2014 Apparently my resource "could not be found" and I've no idea why.http://pasteboard.co/VWzb0WD.png Type refresh or go to your server and type "/refresh". This will load the resource(You must have admin rights). Also At the top there's an option "Organize">Folder and search options>view> scroll down> and untick "hide extensions for known file types. Then rename the script and meta text documents (change the suffixes to .xml and .lua) There should come up and label, you should click yes and the file type is now changed to .xml and .lua. Its important to do this because this will make it lua file from .txt. Link to comment
Anubhav Posted February 25, 2014 Share Posted February 25, 2014 Did see my post? And his picture shows that script.lua wasn't found. That's why it was failed to start it. Link to comment
Saml1er Posted February 25, 2014 Author Share Posted February 25, 2014 Did see my post? And his picture shows that script.lua wasn't found. That's why it was failed to start it. Allow me to educate you. "Resource not found" has nothing to do with script.lua. "Resource not found" means the Resource Is not loaded or it does not exist. If script.lua was missing then it would have output error in debug something like "script.lua file missing". Common sensé. Link to comment
bul188 Posted February 25, 2014 Share Posted February 25, 2014 They were already in .lua and .xml, I have disabled the hiding of file formats in the name. http://pbrd.co/1cNcMsT This is the error I get when I type 'refresh'. Link to comment
Saml1er Posted February 26, 2014 Author Share Posted February 26, 2014 They were already in .lua and .xml, I have disabled the hiding of file formats in the name.http://pbrd.co/1cNcMsT This is the error I get when I type 'refresh'. Open your méta.xml and paste This: <meta> <info author="Author" version="1.0" name="Script01" type="script"/> <script src="script.lua" type="server"></script> </meta> This will fix it and if still no Luck then I'll help you in teamviewer. Link to comment
bul188 Posted February 26, 2014 Share Posted February 26, 2014 Still having trouble, I'll pm you. Link to comment
Anubhav Posted February 26, 2014 Share Posted February 26, 2014 LOOOOOL. Did see the whole console message ? see script.lua wasn't found. Realy man how can you help without seeing whole picture? Link to comment
Saml1er Posted February 26, 2014 Author Share Posted February 26, 2014 Still having trouble, I'll pm you. When you go to">Folder and search options>view> scroll down> Now take a screen with snipping tool and post it here also right click on script.lua and click properties and take a screen shot with snipping tool and post it here as well. I got the problem thats why I'm saying this. Anyways also right click on script.lua and rename it script.lua > Now right click on méta.xml and rename it meta.xml Link to comment
bul188 Posted February 26, 2014 Share Posted February 26, 2014 Still having trouble, I'll pm you. When you go to">Folder and search options>view> scroll down> Now take a screen with snipping tool and post it here also right click on script.lua and click properties and take a screen shot with snipping tool and post it here as well. I got the problem thats why I'm saying this. Anyways also right click on script.lua and rename it script.lua > Now right click on méta.xml and rename it meta.xml http://pbrd.co/1fGGYr0 I didn't scroll the whole way down I assumed you just wanted to see the "Hide extensions for known file types" Link to comment
Anubhav Posted February 26, 2014 Share Posted February 26, 2014 I know this problem. Rename your folder to anything. Rename your script to server.lua. Remember to change the meta. I hope it fixs. It happend to me. If din't work try make it zipped. Link to comment
Moderators Citizen Posted March 3, 2014 Moderators Share Posted March 3, 2014 [LUA] LESSON #1 Creating a resource The wiki tutorial wasn't good enough ?! https://wiki.multitheftauto.com/wiki/Sc ... ing_script Link to comment
Noki Posted March 4, 2014 Share Posted March 4, 2014 His file is called scipt.lua, when the meta asks for script.lua... Amateurs. Link to comment
Saml1er Posted March 4, 2014 Author Share Posted March 4, 2014 [LUA] LESSON #1 Creating a resource The wiki tutorial wasn't good enough ?! https://wiki.multitheftauto.com/wiki/Sc ... ing_script Do you really think everyone finds this easy? I posted a tut so people can easily understand how to make a Resource. Can't help people who don't even put an effort to create a Resource. Nevermind. His file is called scipt.lua, when the meta asks for script.lua...Amateurs. You beat me. Link to comment
Recommended Posts