Trying to figure out the best way to accomplish this...

So im working on a shop system, i know how to code the shop it self (for the most part), but im looking for convenient ways to do this, (not new to programming, new to lua)

How could i make a dynamic grid using SpawnIcons, say static 4 across, then how every many items are in a dataset would dictate how many rows

What would be the best way to create a “database” that i can add onto? (atm im just guessing a table, which to my understanding is just lua for an array?)

Im going to sort through the darkrp code to see if i can find something, is there a luabin site for darkrp?

You can browse the source here.

A table in Lua, can be an array, but it can also be like a map from programming languages.

local mytable = { 1, 2, 3, 4, 5 } – normal array

local mytable2 = {}
mytable2[ “hello” ] = player.GetAll()[1] – map style behaviour

Any anywhere in between is fine too.

For your grid, you don’t even have to do as much as your saying, you can use a DPanelList (See Derma) which will organise the icons for you, according to the methods you use on it.

Oh i forgot darkrp was on googlecode thanks for reminding me lol

And i thought PanelList only worked on a few things not everything, thanks for the info!

Edit: found the entity add snippit

DarkRPEntities = {}
function AddEntity(name, entity, model, price, max, command, classes)
if not name or not entity or not price or not command then
hook.Add(“PlayerSpawn”, “ItemError”, function(ply)
if ply:IsAdmin() then ply:ChatPrint(“WARNING: Item made incorrectly, failed to load!”) end end)
if type(classes) == “number” then
classes = {classes}
table.insert(DarkRPEntities, {name = name, ent = entity, model = model, price = price, max = max, cmd = command, allowed = classes})
AddEntityCommands(name, entity, max, price)

on line11 did it just add a table in a table? Or what is it doing there.

You can (pretty much) have as many tables within tables within tables (etc) as you like in Lua.


The DPanelList should work on anything derived from a panel, which is pretty much (if not) everything.

Well it the thing is It wrks in singeplayer but when i try it on a server the shopsystem he trys to make wont popup at all (Blackravens’s friend)

I posted in the other thread why it doesn’t work, he’s forgotten to do require( “datastream” ) in the files that use it. I think it works in singleplayer because there’s no networking involved.