Jump to content

Help with storing elements


Recommended Posts

Hi MTA,

I am creating a bassiclly car modification with a NPC,

i have already made the GUI and Ped etc, now i want to be able to allow the player to buy say a colour change and it is stored in say setAccountData and then when the person presses a key to open up another GUI which allows the player to use that upgrade in the current car he is in.

and for colour i will have like a colour picker to change the colour or RGB colours but what functions do i need in order to do this. i already have an idea of most of the functions i need but unsure on how to make the colour its own element then combine it with setVehicleColor

Cheers

Link to comment
  • Moderators

Use this resource to show a fancy colorpicker:

https://community.multitheftauto.com/ind ... anddescr=1

And use the onColorPickerOK event to know when the player selected his colour.

Then use setElementData "to store it on the player element".

Use the event onPlayerLogin to load all the account datas and set the element datas. (I mean copy all account datas to place them as element data)

Then use the onPlayerQuit and onPlayerLogout to save the element datas back into his account datas.

(I don't know if the event onPlayerLogout is triggered if a player qui the game. It might be logic but well, i don't know. If yes, then you don't even need onPlayerQuit)

Link to comment
  • Moderators

Because players can buy nitros ? I mean if a player buy 10 nitros, uses 1 nitro, then reconnect later, the player will still have 9 nitros ready to use ?

If yes, then yeah you can save the number of nitro the player has in an element data on the player. Save that data in his account when he logs off and load that data to put it in an element data on the player and then use that element data wherever you have to.

It will also means that if a player steal his car, he won't get his 9 nitros. (I don't know what your server will be, but if it's based on race gamemode, then ofc no one can steal cars).

If it wasn't the reply you expected, then please give me more details about what you want do with the nitros by giving a step by step example.

Link to comment

Yeah Citizen,

that is bassically what i mean. where the the player can can buy from the NPC and use at anytime he wants on anycar because he/she bought one,

so i would use to apply the object

addVehicleUpgrade ( playersource, 1010 ) because 1010 is 10x nitro so he can use it 10 times unless his care is destroyed.

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