Jump to content

[HELP] Need some explanations


Recommended Posts

I'm so sorry if this isnt correct i'm just confused lot of topics and sections at forum, just want to know is there is anyone who can explain me how actualy those resources work , i dont mean to give me lessons 5 hours per day, no, just to explain me about client and server scripts, actualy on the next few questions:

1. If i'm making resource does it must contain both of side client and server side or it doesnt metter

2. Can i call function(not MTA source funcion,my own) from other .lua files in resource zip file(for example to call function from client.lua to server.lua file)

3. How to make structure of making resource, where to start how to start is it metter which funcions and lines of code u write first.

4. if i'm making resource called "welcomeSong.zip" and add event handler when someone joins server to some random .mp3 song start and "start" resource and to make resource for example "welcomeMessage.zip" and that resource sending message in chatBox "welcome to some server.." and "start" it too will every of those resources do their job or only one start(i believe they both will work but want make sure my self)

5. Ye, I dont understand some stuff about those MTA Functions..

Ok here is an example:

function gimmeATeam ( source, commandName, teamName ) 
  local newTeam = createTeam ( teamName )  
  if newTeam then  
    setPlayerTeam ( source, newTeam ) 
  end 
end 
addCommandHandler("giveteam", gimmeATeam) 

- Why there are "source", "commandName", "teamName" what is that? why that? why not "cmd", i mean is it metter what i type for arguments?

- source is element?(why it isnt thePlayer ? is it metter? it can be thePlayer too or?

- How to know when i need to put "getRootElement" ?

Here is my skype if someone have some extra time those days or whenever it doesnt metter, just add me at skype: Lacarone1997, i'ill write down everything i dont understand and send it to some who would help mey with understanding how MTA resources works,

Thank you for reading. :wink:

Link to comment

- Why there are "source", "commandName", "teamName" what is that? why that? why not "cmd", i mean is it metter what i type for arguments?

- source is element?(why it isnt thePlayer ? is it metter? it can be thePlayer too or?

- How to know when i need to put "getRootElement" ?

1.No it doesn't matter what you type for your arguments.

2.Same with 1.

3.addCommandHandler has no element, normal event handlers have.

i suggest you the wiki:

https://wiki.multitheftauto.com/wiki/Sc ... troduction

Link to comment

1- No you're not supposed to put both server and client, except if it's needed.

2-You can't call functions from server to client or from client to server, that's impossible, but you can call from client to client or from server to server

3-Okey, well you can't call a function without it being loaded, so if you want it on start you must keep the addEventHandler after the function, that's it

4-Yes, every one will do it's job.

5-functions arguments doesn't matter, like if i tell you goeat(cheese,milk) those are the arguments of go eat, so in the call back function you can name them as you want, like:

  
function goeat(blabla1,blabla2) 
eat(blabla1) 
drink(blabla2) 
end 
  

and For addEventHandler, you showed a server side example, when using it server side it gives the first two arguments as

1.the player who executed the command

2.what command this is.

3...4...5...6..7...8... are the words the guy wrote after the command

like /goeat cheese milk

it will be the arguments

and for client it only gives command name

hope this was helpful :)

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...