Jump to content
Mr. Green Gaming

Puma

Members
  • Posts

    21
  • Joined

  • Last visited

About Puma

  • Birthday 11/06/1991

Profile Information

  • Location
    Westervoort, the Netherlands
  • Interests
    Everything that has to do with Grand Theft Auto, modeling, modding etc.

Recent Profile Visitors

2749 profile views

Puma's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Happy Birthday to you, happy birthday to you, happy birthday dear Puma, happy birthday to you!

  2. -------------------------------------------------------------------------------------------- Creating moving objects in MTA:DM -------------------------------------------------------------------------------------------- Ok, so I promised a few people how to create moving objects in maps for MTA DM, race gamemode. This tutorial might seem a bit long, but that is because everything is explained very detailed an not because of the toughness of it. First of all, if you don't know what I'm talking about: I've made a few maps and they're like by a lot of people, because of the exclusivity. I add scripts to the map, which contain things like gun-pickups and, in this case, movable objects. The movie about my last and, in my opinion, best map I made, you can see what I mean with "movable objects". YouTube: This tutorial is an example of the scripting that causes the first three blocks to move up and down in the video at 0.21. Ok, so how do I do that? -------------------------------------------------------------------------------------------- 1. PREPARATIONS First, you must have a MTA-DM map. Go to the folder of that map (mostly "C:\Program Files\MTA San Andreas\server\mods\deathmatch\resources", you'll find a folder or a .zip-file here named with the name of your map). If it is a .zip-file, you must unpack it first. After that, delete the original .zip file so only a new folder remains with the name of the map and a few files in it. MTA can read both folders and .zip-files as a map, but if you got both a .zip-file ánd a folder that contains the same map, MTA won't see any difference and use them as two seperate maps. NOTE: Make a copy of the map and put it somewhere safe, so you got a backup if anything goes wrong. We start by creating a .lua-script in the map-folder. In this whole tutorial, I'm using Notepad as editor for the script. Start up the programme (Notepad), and save the empty file in the map-folder (menu: File -> Save as). When you do this, choose "All files" in the "Save as type" box, below the box where you fill in the file name. Then, name the file "yourname.lua" (the name must not include spaces). The ".lua" at the end is VERY important. By selecting "All files" in the "Save as type" box, Notepad allows you to choose a filetype yourself, which you can assign to the file by typing the extension right after the name. Save the file. If you now hover over the file in the folder, it should say "LUA-file". If it doesn't, try again. The next step is to tell the map that it must use the script. First, you must know that the folder or the .zip-file that contains the map, always contains two files: the "yourname.map" file, which is the map, and another file called "meta.xml". When MTA reads the map, it first reads "meta.xml", because that's the file that contains valuable information about the map: where can I find the scripts, the map itself, who is the author and even what weather the map uses, if you choose to define that in "meta.xml". -------------------------------------------------------------------------------------------- 2. META.XML Okay, so we need to define the script in "meta.xml". Use Notepad to open the file. The file will contain a few things. First, on top and at the end it should contain a <meta> (the start) and a </meta> (the end) tag. Between these tags, several paths and information are defined (like in html). You'll probably see a "<map src="yourname.map"/>" tag, which defines where the .map-file can be found. The path to the .map file starts in the folder where "meta.xml" is found. "meta.xml" must always be directly in the map folder, otherwise MTA won't recognize the map. Somewhere between the <meta> </meta> tags, you must create a line that defines the path to the .lua-script. If your script has <settings></settings> tags, do not put it between these tags! You can copy-paste this line: <script src="yourname.lua" type="server" /> Don't forget to change some things! First, you must change the name ("yourname.lua") to the name of your script (quite obvious). The second thing that is important to know, is the "type" bit. MTA uses two different sorts of scripts: client-side scripts and server-side scripts. Client-side scripts are scripts that are downloaded to the user's PC and can differ at actions per person in the server. For example, client-side scripts are usded to change models ingame, but also the syntax of some functions can differ depending on the script-type. Server-side scripts are scripts that perform actions which affect everyone in the server, such as explosions and objects that are created by scripts. Our scripts must be server-side, because the objects must threat all players equal at the same time, so there's no player left behind in actions. The type is "server". Save meta.xml and open the .lua-script you made earlier. -------------------------------------------------------------------------------------------- 3. THE SCRIPT: CREATING A FUNCTION, ADDING EVENTHANDLERS AND CREATING OBJECTS I want this tutorial to be clear too for people that are new to .lua-scripting, so I'll explain everything. First, we must tell the script what to do when the map is started. I'll first explain how a .lua-script works. Almost every script-language works with functions. A function contains actions and tells the game what to do when something happens. Every function looks like this: function resource_starts () end Syntax (= what all parts mean): - "function"": Tells the game that this is a new function - "resource_says_hai": The name of the function. A script can not contain multiple functions with the same name. The name must contain spaces ("blabla" is correct, "bla bla" is incorrect). The fact that I used "resource_starts" as name does not have anything to do with the function of the function (if you get what I mean). For example, I can call the function that is executed when the script starts "whazaaahhhhdupdupilikebeeer", because only the name itself is important, not the meaning of the words it contains. - "()": Between these brackets, you can type names that refer to things in the game, such as the player or a vehicle. - "end": This is the end of the function. The amount of "ends" must always be equal to the amount of functions, otherwise the script will crash. Ok, fun, we've got a function now. But erm.. If there is like ten functions in one script, how does MTA know what function to run when something happens? That's not hard to explain. MTA uses "eventhandlers" to link certain events (for example sitting in a car), causes (the person that's sitting in the car) and effects (what happens if that person get's in a car = the function). There is a lot of different eventhandlers. In for this function, I'll use the eventhandler for starting the script: addEventHandler ( "onResourceStart", getRootElement(), resource_starts ) Eventhandlers must be OUTSIDE other functions. The best way to avoid eventhandlers being included in functions, is to simply put all eventhandlers at the top of your script. Syntax: - "addEventHandler": The name of the function (you can't CAN NOT change that name). After the name of the function, the brackets come with the information that is neede for the function between it: - ""onresourcestart"": The name of the event (you can find more events here: http://wiki.multitheftauto.com/wiki/Scripting_Events ) - "getRootElement()": Don't ask my how or why, but this means "all players in the game". You can also put a name here, so only this player will be affected on what happens by this eventhandler. - "resource_starts": What function should be executed when the event (starting the resource) is caused by what element ("getRootElement()" in this case = everyone). So, now we've scripted that our function "resource_starts" will be started when the resource is started! Let's start scripting what happens when the function "resource_starts" is executed. In this tutorial I will use three objects to explain how it works. First, we create three objects by script: addEventHandler ( "onResourceStart", getRootElement(), resource_starts ) function resource_starts () createObject ( 17950, 4520.808105, -1569.693359, 34.411907 ) createObject ( 17950, 4513.611816, -1569.802612, 46.449081 ) createObject ( 17950, 4506.434570, -1569.778076, 34.411907 ) end Syntax (I'm talking about the "createObject" stuff now): createObject ( model-ID, X-coördinate, Y-coördinate, Z-coördinate, X-rotation, Y-rotation, Z-rotation ) If you don't use rotations at all (as in my case), you can simply leave them out of the function. You can not leave the coördinates out of it. NOTE: If you do want a Z-rotation, but not a X- and Y-rotation, you DO HAVE to include the X- and Y-rotation otherwise the script will interpretate the Z-rotation as the X-rotation. Read more about createObject here: http://wiki.multitheftauto.com/wiki/CreateObject We have to define those objects, so we can refer to them later in this tutorial. Do this by simply putting "name =" in front of everything: addEventHandler ( "onResourceStart", getRootElement(), resource_starts ) function resource_starts () object1 = createObject ( 17950, 4520.808105, -1569.693359, 34.411907 ) object2 = createObject ( 17950, 4513.611816, -1569.802612, 46.449081 ) object3 = createObject ( 17950, 4506.434570, -1569.778076, 34.411907 ) end All names that are given to the objects must be different. Now we've created the objects, we must get them to move. -------------------------------------------------------------------------------------------- 4. THE SCRIPT: CREATING A FUNCTION, ADDING EVENTHANDLERS AND CREATING OBJECTS You don't always need an eventhandler to execute a function. You can also just execute the function by putting the name of the function inside another function. I'm using that method in this tutorial because that makes the script a lot clearer: addEventHandler ( "onResourceStart", getRootElement(), resource_starts ) function resource_starts () object1 = createObject ( 17950, 4520.808105, -1569.693359, 34.411907 ) object2 = createObject ( 17950, 4513.611816, -1569.802612, 46.449081 ) object3 = createObject ( 17950, 4506.434570, -1569.778076, 34.411907 ) move1_1 () end Now, after the three objects are created, the script will jump to a function called "move1_1". We'll create that function now: addEventHandler ( "onResourceStart", getRootElement(), resource_starts ) function resource_starts () object1 = createObject ( 17950, 4520.808105, -1569.693359, 34.411907 ) object2 = createObject ( 17950, 4513.611816, -1569.802612, 46.449081 ) object3 = createObject ( 17950, 4506.434570, -1569.778076, 34.411907 ) move1_1 () end function move1_1 () end Let's fill it in. We need a function that makes the objects move: moveObject. With the "moveObject" function, you can make a specific object that is created in the same script (very important) move to a specific coördinate in a specific time. It will look like this: addEventHandler ( "onResourceStart", getRootElement(), resource_starts ) function resource_starts () object1 = createObject ( 17950, 4520.808105, -1569.693359, 34.411907 ) object2 = createObject ( 17950, 4513.611816, -1569.802612, 46.449081 ) object3 = createObject ( 17950, 4506.434570, -1569.778076, 34.411907 ) move1_1 () end function move1_1 () moveObject ( object1, 4500, 4520.808105, -1569.693359, 46.449081 ) moveObject ( object2, 4500, 4513.611816, -1569.802612, 34.411907 ) moveObject ( object3, 4500, 4506.434570, -1569.778076, 46.449081 ) end Syntax of moveObject: moveObject ( name_of_the_object, moving_time, new_x-coördinate, new_y-coördinate, new_z-coördinate, new_x-rotation, new_y-rotation, new_z-rotation ) Again, you can leave the new rotation values out of the function if you want, just like I did. Important to know is that time in scripts is ALWAYS given in milliseconds (1 second is 1000 milliseconds)! What I've scripted: The object called "object1" will be moved in 4500 milliseconds = 4,5 second to X=4520.808105, Y=-1569.693359 and Z=46.449081. The speed depends on the distance between the new and old coördinates. You might need to test it a few times and adjust the speed by changing the times. Read more about moveObject here: http://wiki.multitheftauto.com/wiki/MoveObject Now comes a very important part of the script. After the objects have reached their new destinations, we want them to return to their first position. How do we do that? Simple. We use a timer: addEventHandler ( "onResourceStart", getRootElement(), resource_starts ) function resource_starts () object1 = createObject ( 17950, 4520.808105, -1569.693359, 34.411907 ) object2 = createObject ( 17950, 4513.611816, -1569.802612, 46.449081 ) object3 = createObject ( 17950, 4506.434570, -1569.778076, 34.411907 ) move1_1 () end function move1_1 () moveObject ( object1, 4500, 4520.808105, -1569.693359, 46.449081 ) moveObject ( object2, 4500, 4513.611816, -1569.802612, 34.411907 ) moveObject ( object3, 4500, 4506.434570, -1569.778076, 46.449081 ) setTimer ( move1_2, 4500, 1 ) end Syntax: setTimer ( function_that_is_executed_after_epilapsed_time, time, times_to_execute ) In this case, the function called " "move 1_2" will be executed 4,5 seconds after the timer has started, which is 4,5 seconds after the objects have began to move, which is the moment that they arrive at their new destination! If you want the objects to stand still for a moment, you just increase the time in the setTimer-function so that it's more than the time in the moveObject-function. Read more about "setTimer" here: http://wiki.multitheftauto.com/wiki/SetTimer Next function is the "move1_2" function which is basically the same function as "move1_1" but with other coördinates and a new timer that refers to "move1_1": function resource_starts () object1 = createObject ( 17950, 4520.808105, -1569.693359, 34.411907 ) object2 = createObject ( 17950, 4513.611816, -1569.802612, 46.449081 ) object3 = createObject ( 17950, 4506.434570, -1569.778076, 34.411907 ) move1_1 () end function move1_1 () moveObject ( object1, 4500, 4520.808105, -1569.693359, 46.449081 ) moveObject ( object2, 4500, 4513.611816, -1569.802612, 34.411907 ) moveObject ( object3, 4500, 4506.434570, -1569.778076, 46.449081 ) setTimer ( move1_2, 4500, 1 ) end function move1_2 () moveObject ( object1, 4500, 4520.808105, -1569.693359, 34.411907 ) moveObject ( object2, 4500, 4513.611816, -1569.802612, 46.449081 ) moveObject ( object3, 4500, 4506.434570, -1569.778076, 34.411907 ) setTimer ( move1_1, 4500, 1 ) end What the script does in very short terms: 1. When the script starts, a few objects are created and after that the function called "move1_1" is executed. 2. In "move1_1" the objects are moved to a new position and at exactly the same time that the objects reach their new position, "move1_2" is executed. 3. Function "move1_2" moves the object back to their original position and at exactly the same time that the objects reach their new (= old) position, "move1_1" is executed and the proces (2 and 3) is started over again. 4. This continues forever, until the resource is stopped and the next resource is started. -------------------------------------------------------------------------------------------- Hope you learned something today, a comment would be nice! Have fun with the tutorial. by Puma http://www.pumastudios.nl http://www.youtube.com/StijnLinderman
  3. Person that listens to awesomenitely music!
  4. Well, the map is now finished. I'm working on the map now in the map-editor, adding spawnpoints, checkpoints and pickups. I added a little music to it (it's midi, but I don't know if midi works instead of mp3). Maybe there is a test version on the server today, if Ywa is online..
  5. Ingame. All three files together are 580 kb, so...
  6. Today I've started making a series of tracks for Mta. The tracks are going to be like Mario Kart tracks. I wasn't able to get the original ones, so I decided to make them myself. It's made with SketchUp and I consciously made the model low-poly, so it wouldn't take much time to download. I got the textures from the internet, although I did some tweaking on them myself. I'm going to put it ingame tomorrow and more maps will follow. I'm thinking about a new Kart model, but I think the maps are more important. I'm just waiting for the server to use them .
  7. Puma

    Mariokart on MTA

    I can get you the maps. I can get you also Mariokart-karts, skins and even weapons if you want.. I could even make models for pickups if you want. [Edit] I just looked around for info etc. about getting models from Mariokart64, but I don't know how to get the models from the .z64 files which can be played with an emulator. I need some kind of decompressor, but there isn't one. Anyone got any idea? I think I'm going to make some Mariokart maps myself then...
  8. I was playing MTA on a server and they had Mariokart maps there. Pure fucking genius! So cool...
  9. I got a shitload of that.
  10. Lawl, shapes look ok, thickness etc., but you really need better textures. Cgtextures.com is a great source for textures, but you need to overwork them in programmes like Photoshop to make them tilable. Beachbuggy/hotrod. It's not finished, because I can't myself to finish it. Clavus, which programma do you use for modeling?
  11. Two guys - a Dutch one and an American one - have been covering several beautiful songs in an astonishing way. Watch the video's and you'll see what I mean. I wanted it to share with you guys, because the covers are so friggin' good.
×
×
  • Create New...