31
Scripting / Begin your journey with Lua!« Last post by remaked on September 30, 2020, 09:30:27 am »Hello everyone, recently I've been receiving a few DM's about how to learn scripting etc..., so I decided to open this topic to maybe provide help to those who are willing to learn Lua and maybe push those who are just thinking about it and hesitating.
Part 1: First of all, I can't explain better than those links, so you should read them carefully before reading the next part of this topic: 1- https://wiki.multitheftauto.com/wiki/Scripting_Introduction 2- https://www.lua.org/manual/5.1/ 3- https://forum.mtasa.com/topic/34453-lua-tutorials-manuals/ After reading those links carefully, you should now know what 'debugging' is. Infact, debugging may help you fix the errors yourself 99% of the time, here is a link to know what debugging is: - https://wiki.multitheftauto.com/wiki/Debugging Now you can go ahead and save this link in your browser: https://wiki.multitheftauto.com/wiki/Main_Page The last link is the most important of all, it's where you'll be looking every time you are making something(a script). ------------------------------------------- Part 2: (Only read this if you totally understood/read Part 1) Now, you should have a general idea about scripting/Lua, so we'll be making a couple scripts to get you started with. We are gonna make a script which outputs "blabla logged in" whenever a player logs in, and another for when a player logs out. First things first, we are gonna go here(https://wiki.multitheftauto.com/wiki/Server_Scripting_Events) and look for an event that triggers when a player logs in, which is gonna be "onPlayerLogin". Let's go: Code: (Lua) [Select] function playerLogin() -- function name should always be camel case(this is only for Lua) For when a player logs out, we will need an event for that, we go to wiki and we will find "onPlayerLogout", let's go: Code: (Lua) [Select] function playerLogout() -- function name should always be camel case(this is only for Lua) Now let's make a script which will give a random player 50,000$ everytime you type /giverandomcash and output a message to the random player to inform him about the money. We go to the wiki(as always) and we search for a function to get a random player, which will be https://wiki.multitheftauto.com/wiki/GetRandomPlayer, and a function to give the player money, which will be https://wiki.multitheftauto.com/wiki/GivePlayerMoney, finally to inform we will use outputChatBox which we have seen earlier. Let's go! Code: (Lua) [Select] function giveRandomMoney(thePlayer, command) -------------------------------------- Part 3: Here are two tasks for you to test yourself! Task1: - Make a script which removes the player's head once he executes the command '/head', and give it back again when he executes the same command. Task 2: - Create a pickup and make it that when a player enters the pickup, he will get 1,000$ You can then post your work here, same if you face any errors/questions, and someone(or me) will hopefully answer you 32
Portuguese Board / Re: [Chat & Media] Comunidade Portuguesa e Brasileira« Last post by ChicoRDL on September 29, 2020, 10:11:44 pm »Vamos reativar isso novamente!!! 33
Completed Suggestions / Re: Add AT-400 and Andromeda« Last post by remaked on September 29, 2020, 09:57:19 am »Added, trolling with these planes will result in a punishment.
34
L1. TGOD Three 6 Mafia / Re: TGOD Mafia Chat & Media« Last post by ChicoRDL on September 28, 2020, 12:14:43 pm »My Car Show New Spot 35
Completed Suggestions / Re: Disable Tear Gas« Last post by ElJuanpis on September 28, 2020, 11:10:21 am »Criminals may get damage, but they can still move if they get damage by his own tear gas, imagine we are in a pizzeria, the criminal just throw tear gas and kill us, why? because he can move while he is in the smoke, we can't. That's what needs to be fixed.If that's true, a few days ago we faced a criminal, the tear gas only lowered his life, but he could run away when he wanted to, the only way he'd hurt a criminal is by throwing him out by a cop, there's if he hurts both the cop and the criminals, I agree with MrVio4TgL. 36
Completed Suggestions / Re: Vehicle Recovery While Wanted« Last post by External on September 27, 2020, 12:08:56 am »done
37
Completed Suggestions / Re: Disable Tear Gas« Last post by MrViol4TgL on September 26, 2020, 08:28:16 pm »I went to test and I can confirm that both teams receive damage from their own bombs.Criminals may get damage, but they can still move if they get damage by his own tear gas, imagine we are in a pizzeria, the criminal just throw tear gas and kill us, why? because he can move while he is in the smoke, we can't. That's what needs to be fixed. 38
Completed Suggestions / Re: Disable Tear Gas« Last post by ChicoRDL on September 26, 2020, 08:09:55 pm »Downvote lol, tear gas is nice it just need few changes, disable them in interiors, make criminals get damage for his own tear gas and some others, as you know criminals doesn't get any dmg by using his own tear gas and they abuse of it, while crops get damage of it. Just add damage for criminals and disable them for interiors, cool down works. I went to test and I can confirm that both teams receive damage from their own bombs. 39
L1. Department of Defense / Re: Department of Defense - Chat and Media« Last post by remaked on September 26, 2020, 08:01:54 pm »40
Completed Suggestions / Re: Disable Tear Gas« Last post by MrViol4TgL on September 26, 2020, 02:53:06 pm »Downvote lol, tear gas is nice it just need few changes, disable them in interiors, make criminals get damage for his own tear gas and some others, as you know criminals doesn't get any dmg by using his own tear gas and they abuse of it, while crops get damage of it. Just add damage for criminals and disable them for interiors, cool down works.
|