• Tables putting in 2 values at once?
    7 replies, posted
Hello Facepunch, I'm working on a addon which involves people buying a door and paying rent. What I'm wanting to do is when he buys the door I need to insert the door and the player into a table, how can i do this? Can someone show me the best way on using a table for this method? Something like below.. [CODE] // So when someone buys a door, this will happen below v local Config = {door, client} -- not sure it this would work though... [/CODE] Help is much appreciated.
What you put would work fine. To access door you'd do Config[1], and to get client you'd do Config[2].
[QUOTE=txike;51775253]What you put would work fine. To access door you'd do Config[1], and to get client you'd do Config[2].[/QUOTE] If he was wanting to store the door and the player into a table would he not need to use 3D arrays since I'm assuming a lot of doors and people buying them, that's a lot of data for a 1D array.
Yeah ofcourse, but to make my life easier, for an example when it's time to pay rent I want to retrive the client and the door the client owns if that makes sense? So, even if I bought a door, it should look like this... [CODE] ClientsRenting: Room: 1 ClientName: Jimmy PriceRent: 90 -- Is there anyway I can make it like this? [/CODE]
What's the table being used for? If it's for keeping track of who owns the doors, I'd just have a table of doors with each door being the key and the owner being the value. Or each player has a table of their own doors and you insert the doors into the table.
Could you give me an example please? And yeah, it's so I can grab who owns the door and make him pay, and the door so i can grab the price of that specific door he needs to pay rent for, because not all doors will have the same price of rent...
-snip- Ignore me lol
Yeah, but that just returns doors indexs... [editline]4th February 2017[/editline] [QUOTE=BeZerk;51775297]-snip- Ignore me lol[/QUOTE] You are on the right path tho <3 [editline]4th February 2017[/editline] [QUOTE=sannys;51775282]What's the table being used for? If it's for keeping track of who owns the doors, I'd just have a table of doors with each door being the key and the owner being the value. Or each player has a table of their own doors and you insert the doors into the table.[/QUOTE] That is what I'm trying to decide, which method would be better to use because I'm currently storing a price on the door ( when an admin does /addrent 50 ) that'll then make that door $50 ever x seconds. So, when it's time to pay rent, I need to grab the people who're actually renting, and the specific door they're renting? Any ideas?
Sorry, you need to Log In to post a reply to this thread.