Quantcast

Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
L1. TGOD Three 6 Mafia / Re: TGOD Mafia Chat & Media
« Last post by [TGOD]WizKhalifa on October 06, 2020, 09:14:22 am »
We own San Andreas.
22
L1. TGOD Three 6 Mafia / Re: TGOD Mafia Chat & Media
« Last post by [TGOD]WizKhalifa on October 04, 2020, 05:35:27 pm »
 8) 8) 8)
23
L1. TGOD Three 6 Mafia / Re: TGOD Mafia Chat & Media
« Last post by [TGOD]WizKhalifa on October 04, 2020, 05:24:24 pm »
Good ol' days

24
L1. TGOD Three 6 Mafia / Re: Congratulations hommies
« Last post by abdrahman on October 04, 2020, 08:46:28 am »
 8)
Keep going hommies lets rock dat shit
From Ca$hout
25
Completed Suggestions / Re: CnR event
« Last post by remaked on October 02, 2020, 10:54:36 pm »
Added with some changes. Rewards will be cash, employment exp and group exp. All cops who helped deliver the cargo to LVPD will get those rewards, including the driver.

Criminals can try to stop the cargo but they won't get any rewards.
26
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)
local playerName = getPlayerName(source) -- get the name of the player who logged in with "getPlayerName"
outputChatBox("JOINQUIT: "..playerName.." has logged in!", root) -- We output a text to everyone online using "outputChatBox"
end
addEventHandler("onPlayerLogin", root, playerLogin) -- Our event handler which will trigger this function every time a player logs in

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)
local playerName = getPlayerName(source) -- Here we are getting the name of the player who logged out with "getPlayerName"
outputChatBox("JOINQUIT: "..playerName.." has logged out!", root) -- We output a text to everyone onine using "outputChatBox"
end
addEventHandler("onPlayerLogout", root, playerLogout) -- Our event which will trigger this function every time a player logs out

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)
local randomPlayer = getRandomPlayer() -- we get a random player
givePlayerMoney(randomPlayer, 50000) -- we give the money
outputChatBox("You got lucky and won 50,000$", randomPlayer, 0, 255, 0) -- we output a text to the player to inform him about the money
end
addCommandHandler("giverandomcash", giveRandomMoney) -- Our function will trigger once this you type this 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
27
Portuguese Board / Re: [Chat & Media] Comunidade Portuguesa e Brasileira
« Last post by ChicoRDL on September 29, 2020, 10:11:44 pm »
28
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.
29
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

30
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.
Pages: 1 2 [3] 4 5 ... 10
SimplePortal 2.3.7 © 2008-2024, SimplePortal