Jump to content

[HELP] Storing advice


Recommended Posts

Posted

So I want to do quest thing where the players have to look and hit 150 pickups in order to use the command /getgift to get a gift... The problem is, I don't know the best way of storing each pickup to each player so that a player cannot use the same pickup twice.

So yeah... I need a reliable and easy way to store all this in a MySQL database

76561198066470453.png

SP37Ecj.jpg?2MTA:Rust Pre-Alpha Build v.0.3:SP37Ecj.jpg?2

https://forum.mtasa.com/viewtopic.php?f=114&t=97848

2Pac: ''Only God can judge me!''

Posted

I don't think that MySQL database is necessary there. I think normal table will do the work.

Something like

local playerPickups = {} 
  
addEventHandler("onPickupHit", root, function(player) 
    if isElement(player) and getElementType(player) == "player" then 
        if not playerPickups[player] then 
            playerPickups[player] = 1; 
        else 
            return; 
        end 
    else 
        return; 
    end 
end) 

Posted

So you can use databse there. I'll do the project for you.

https://scr.hu/d3DoOe

In 'pickup' you store all players, in 'player' you store all players which picked atleast one pickup and in 'player_pickup' you store id_player and what pickup he picked id_pickup.

Posted
So you can use databse there. I'll do the project for you.

https://scr.hu/d3DoOe

In 'pickup' you store all players, in 'player' you store all players which picked atleast one pickup and in 'player_pickup' you store id_player and what pickup he picked id_pickup.

So there is no efficient way of saving everything in only 1 table?

76561198066470453.png

SP37Ecj.jpg?2MTA:Rust Pre-Alpha Build v.0.3:SP37Ecj.jpg?2

https://forum.mtasa.com/viewtopic.php?f=114&t=97848

2Pac: ''Only God can judge me!''

Posted

Use pickup id's and save them in a table, and then use toJSON(table) to save them to a string, then in the database.

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