How to make a buymenu

Ello ello

Came onto the forums looking for a thread about buy menus or something, couldn’t find anything. I’ve also looked at the coding for CakeScript and DarkRP, but it was all mashed up in notepad, so I couldn’t make sense of it :S. So yeah, looking for someone who can point me in the direction to making a buy menu.

This? - http://www.garrysmod.org/downloads/?a=view&id=97699

Basically make a money code:

[lua]local meta = FindMetaTable(“Player”)

function LoadMoney(pl)
if file.Exists(“money/”…pl:UniqueID()…".txt") then
pl:SetNWInt(“money”,tonumber(file.Read(“money/”…pl:UniqueID()…".txt")))
else
pl:SetNWInt(“money”,500)
end
end

function SaveMoney()
timer.Create(“money”,120,0,function()
for k,v in pairs(player.GetAll()) do
file.Write(“money/”…v:UniqueID()…".txt",v:GetNWInt(“money”))
end
end)
end

function meta:AddMoney(amt)
self:SetNWInt(“money”,tonumber(self:GetNWInt(“money”))+amt)
end

function meta:GetMoney()
return tonumber(self:GetNWInt(“money”))
end
hook.Add(“PlayerInitialSpawn”,“LoadMoney”,LoadMoney)
hook.Add(“Initialize”,“SaveMoney”,SaveMoney)[/lua]

And then take the code for the Derma menu and items from the point mod, and make it when you buy certain stuff, it removes a certain amount of money from the players wallet, but say “You cannot afford this!” when they don’t have enough, if you’re still not sure, look how Rick Darkliano did it in DarkRP.

Hope this helps :smiley:

Nvars are bad as all clients get the information that they dont need for example one players money will be readable by anyone

Having an individual file for each player is kinda stupid too, especially when you can just use SQL.

Use MySQLite.

You mean SQLite.

I preferr MySQL, its fast and wont corrupt like hell as SQLite tends to do for me :saddowns:

Yeah, it’s kind of a habit to type “My” in front of Sql hah.

Here this may help you, Entoros posted this in another thread for someone, but this is 100% Entoros not mine, all credit goes to him.

http://entoros.pastebin.com/Yk2cX3b4

Danke you all very much for the help :stuck_out_tongue:

You are fucking retarded.
My pointmod does exactly that, but a** lot **better

Yes, i’m fucking retarded, but so are you to flame.

Hows the air up on the high horse o’ yours?
This is the “Newbie questions” section. Don’t flame people who are trying to help others/learn.

The first step is admitting you are well done you have come a long way

This will certainly help, but it´s the most unoptimized way I could ever think of.

You’re seriously stalking HeavyMtl123.

[editline]rawr[/editline]

Nice spelling, btw.