Jump to content

[Guidance] About my gamemode.


Recommended Posts

Hello my dear MTA friends, and community. I am opening this topic because i am lost as a scripter and unsure of where to go and what to do.

I've been learning Lua scripting(MTA related only) for 2/3 months straight now everyday.

I do know how to create basic scripts and addEvents client and server side and triggerEvents. But the gamemode thing is new to me, and i have no references on wiki to look at since i'm not going to be using map manager.

Can u please(pro scripters) provide me with some details on what should i aim first to get my gamemode finished while learning in a short time? And what should the steps be? Sorry for making this long tho. And if anyone has some free time and do like to go into discord and help me learn more, i'd be thankful.

Link to comment

Depends on how you define 'gamemode', because a gamemode is just another script. mapmanager and other related resources provide a standard way to do some things, but you don't have to use them - in fact, I don't remember ever doing that.

I'll assume your confusion is the same as mine was a long time ago, which is getting anything to work at all, so that with the gamemode you would have a minimally playable game. There are several (per-player) things you need to do.

First, a player is not physically present in the game world upon joining the server. You need to call spawnPlayer to make them appear.

Also, their camera is set to some position where only the sky is visible. To make the player's camera follow the player, call setCameraTarget, passing the player element to both arguments.

And last, the screen is black when you start. You have to call fadeCamera for that.

That's how the player gets to run around in the game world. The rest is up to your imagination.

  • Like 2
Link to comment
2 hours ago, Reyomin said:

Depends on how you define 'gamemode', because a gamemode is just another script. mapmanager and other related resources provide a standard way to do some things, but you don't have to use them - in fact, I don't remember ever doing that.

I'll assume your confusion is the same as mine was a long time ago, which is getting anything to work at all, so that with the gamemode you would have a minimally playable game. There are several (per-player) things you need to do.

First, a player is not physically present in the game world upon joining the server. You need to call spawnPlayer to make them appear.

Also, their camera is set to some position where only the sky is visible. To make the player's camera follow the player, call setCameraTarget, passing the player element to both arguments.

And last, the screen is black when you start. You have to call fadeCamera for that.

That's how the player gets to run around in the game world. The rest is up to your imagination.

I do know about those stuff. But i already created an edf for my own gamemode "maps" that way they could be custom. But i'm unsure of how to retrieve the map informations step by step out of the map file without breaking anything.

For example: 

My teams are parents and they contain elements which are spawnpoints, class(which is weapons and skins) and objective markers as if it's a tdm map.

If i wanted to create a spawn selection window for the players to pick one on their own, i'm unsure how to use the same spawn selection area for all the maps that i have, but just with different skin id's and team names. (Hoping that i made my idea clear)

Link to comment

Now the question is much clearer.

You can query the information about elements using functions like getElementsByType, getElementChildren and getElementData. So if you want to create a list in the GUI that represents a list of elements (like teams or skins), you can do so using getElementsByType and looping through the list of elements and creating a GUI element for each element in the list. getElementData allows you to retrieve attributes such as team name so you can pass the result to GUI functions to have it show up in the GUI.

If you use getElementData on map elements from within the client side scripts (like, during the creation of GUI), you need to have <sync_map_element_data>true</sync_map_element_data> in meta.xml of any running resource. But usually a better way to use the team data from the map is to retrieve it on the server side into a table in the beginning, then pass that data to triggerClientEvent when you want to display the spawn selection window for the player.

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...