Jump to content

Help with 50p's Modshop upgrades


AlexMiller

Recommended Posts

What type of variable is it? A table? Are you trying to modify my resource or make your own? Because there is a custom event that is triggered by modshop to let you do whatever you want when vehicle is upgraded... It is possible to store the upgrades in 1 line as a string.

Link to comment

Alright, thanks 50p for answering me. I'm trying to modify your resource a little, just to save the upgrades made by the shop on another DB, where my char datas are saved. Then, to save everything as a string, I just have to do to following?:

stringupgrades = tostring( upgrades )
setAccountData(getPlayerAccount(source, "carupgrs",stringupgrades))

EDIT:

I tried to, and I got no error during the server run, but by having a look in the char table I can see this where there should be upgrade IDs:

table: 03DF45B8

Link to comment

If you open "server.lua" and scroll down to line 220, you should find a new event "onVehicleMod". This is triggered when you exit mod shop and your vehicle get modded. So, you can make your own resource and use this event to save upgrades.

To get all the upgrades into 1 string, you have to iterate upgrades table and add the id to the string.. Something like:

addEventHandler( "onVehicleMod", getRootElement(),
function( upgrades )
local str = "";
for i, id in pairs( upgrades ) do
           str = str .. tostring( id ) .. ",";
end
       str = str:sub( 1, -2 ); -- remove the last comma (,)
local player = getVehicleOccupant( source );
setAccountData( getPlayerAccount( player ), "carupgrs", str );
end
)

NOTE: You should make a check if player's account is guest account before you set its data.

Link to comment

Alright, it works, but I did this:

function( upgrades, colors, paintjob )
 
local player = getVehicleOccupant( source )
local actupgrds = getAccountData( getPlayerAccount( player ), "carupg")
local str = "";
for i, id in pairs( upgrades ) do
           str = str .. tostring( id ) .. ",";
end
       str = str:sub( 1, -2 )
local str = actupgrds.. "," .. tostring(str)
setAccountData( getPlayerAccount( player ), "carupg", str )
setAccountData( getPlayerAccount( player ), "paintjob", paintjob )
end)

Thanks 50p :P

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