Hello everyone,
I would like to create an item that is unique, to give you an example I would like to ensure that for an identity card the item saves the coordinates of the player and that if a player has given it to another the coordinates correspond to the first player. So then what makes the items stackable. Thank you for your answer, have a good evening.
Hey
What framework are you using ? (ESX or QBcore)
Regarding ESX, I already thought about what would be a way to do it (for a credit card I wanted to work on). The only way I found was to create 1 item for each card (or else) in the âitemsâ database table and link the item to the data (playerâs name/age etc⌠for example) by making a unique ID that you concatenate with the name of the item and that will allow you to create a âabstract relationâ between the item and the data you want to be linked to it (that could be stored in another table).
A Little example might be better to understand my thinking :
Items table :
- fields : name - label - weight
- data : IDcard45685 - Id card - 1
ID table :
- fields : id - name - age - sexe - height
- data : 45685 - john - 30 - male - 196
Script algo :
IdCard = item.GetItemName()
IdNumber = IdCard.sub("IDcard")
result = Query("SELECT * from IDTable WHERE id ="..idNumber)
--Here is your data that are related to the card
print(result)
I think I understood your approach, but in this case the item will not be unique because by giving the card to another player the coordinates will change to take those of the new playerv ⌠i think
im use ESX frameworkâŚ
thanks
No the opposite, I came up with the idea after looking the issue from all possible angles. Itâs pretty simple to see in my example above, each player have an entry in the âIDTableâ that is linked to a specific card by the suffix in the itemâs name(second part of the item name).
With my approach you need to create 1 item per IDcard. You have 10 players = 10 Items, each item will avec a different suffix (IDcard45685, IDcard54768, IDcard549304).
If player A datas are linked to the card IDcard45685 when player B steal (for example) playerâs A ID card the car name still will be IDcard45685 and so the data linked to it still will be the one of player A.
Kind of how a vehicle is identified by the plate number? Unless of course the server has a way to buy new plates or apply a fake plate. Youâd just have to create a unique ID for whatever item. And make certain no script can ever modify that ID.
This means that it would take 1 item per person, so if I have 100 players there will be 100 items?
Unfortunatly, yes. Thatâs why I gave up regarding my creditcard system for now, as this is in my opinion the only way to do it with ESX at the moment.
That being said, most of the servers donât have 100 players at the same time and if the server doesnât have that much item already, MYSQL should be able to handle it (to be sure some testing should be done, but I donât think it would have a major performances impact).
ok I see, I think this is possible in another way: Do like the clothes in the inventory example when you buy a piece of clothing this becomes an item that is not managed by MYSQL, I think that that would be the solution but i donât know how to do it
Itâs only my opinion, I still spent quite some time to think about it though (and I work with ESX pretty often).
Regarding the clothes Iâm not familiar with it (I never made a script around that or look at the clothing system). But if the clothes you are talking are persistant (meaning you still have same or else), they are stored in the database somewhere.
I was wondering, when you say âClothing becomes an itemâ what do you mean by that ?
The cloth becomes an object in the sense that the garment becomes a unique item, when you buy a garment it becomes an item
My question wasnât really well put together.
What is was wondering is :
You keep mentionning the word âitemâ but in my head I donât really get what you are talking about (specifically).
For me (if iâm not mistaking) there is :
-
âEntitiesâ (ped, cars etcâŚ), âPropsâ (coffee cup, phone etcâŚ) and âWeaponsâ ; that are part of the game engine.
-
Items (burger, weed, id card) that are only existing in a framworkâs context (ESX,QBcore,VRP).
Clothes to me are just textures that are applied to a pedâs model, you can then register thoses clothes in the databse in order to applie them back to the playerâs ped model when he connects back to the server, but that doesnât make them âItemsâ in the framwork sense of it (which in my opinion would be the only one in that case) and that doesnât make them âPropsâ either (If iâm not mistaking).
Thatâs why I think we cannot draw a parallel between the way âItemsâ and âClothesâ are managed by the framework (or even by the game). In the end the âItemâ (for ESX at least) will end up in the âusersâ table, âInventoryâ field and only have a pair key/value (name/quantity) which doesnât allow us to attach any more datas to him (unless by doing what I was talking about earlier)
Furthermore, when I was working on finding a solution a few weeks ago another idea poped into my head (that I didnât mentionned earlier); adding the creditcard item inside the âInventoryâ field in the âusersâ table but not through ESX (through a roundabout way), but this wasnât an idea I kept in mind because the friend I was trying to help by creating a creditcard system wanted the cards to be in the playerâs inventory (as an ESX item) and with this way of doing things the creditcards wouldâve needed her own NUI/menu, so I let this approach on the side.
But our talk about âItemsâ made me wanna check if this other idea would work, and not even this sketchy approach would work. I just did some tests and the Inventory of the player getâs overwrite when he connects if any âItemâ that isnât registered in the âItemsâ table is found it getâs removed.
Which proved that the point I was making earlier was right, that the only way to do it at the moment would be by creating 1 âItemâ par card (if you want the cards to be usable as any ESX âItemsâ, linked to a player and be stored and displayed by the inventory of your choice)
Is there any way we can discuss this topic further?
He maybe mean metadata inventory look it up I think you will understand
You have the link? since I couldnât find it
For example ox inventory for esx