• WIP: PointShop
    528 replies, posted
See here: [url]http://www.facepunch.com/showthread.php?t=1228438[/url]
Looks good :)
Would this work on other gamemodes? Also How would I change the default key to something else?
Yes, it should be gamemode independent. Change the key in sh_config.lua.
Hey, if I wanted to make something admin buyable, how would I go about doing that? Also wonderful mod, easier to use then the other one. Thank's in advance.
Add a function under an items 'Functions', like so: [lua] Functions = { CanPlayerBuy = function(ply) if ply:IsAdmin() then return true, "" end return false, "Only admins can buy this!" end } [/lua] Use that for now, and I'll add an option to make each item admin only.
Looking good. I might even use it.
[QUOTE=_Undefined;25848012]Add a function under an items 'Functions', like so: Use that for now, and I'll add an option to make each item admin only.[/QUOTE] Awesome, thank you!
Updated. The headcrab hat is admin only as an example. Few things in the OP which I will add later.
[QUOTE=_Undefined;25848012]Add a function under an items 'Functions', like so: [lua] Functions = { CanPlayerBuy = function(ply) if ply:IsAdmin() then return true, "" end return false, "Only admins can buy this!" end } [/lua] Use that for now, and I'll add an option to make each item admin only.[/QUOTE] [lua]Functions = { CanPlayerBuy = function( ply ) return ply:IsAdmin(), ply:IsAdmin() and "" or "Only admins can buy this!" end }[/lua]
Sexy.
[lua][addons\pointmod\lua\sv_pointshop.lua:76] attempt to call method 'admin' (a nil value)[/lua] I keep getting this error when trying to buy an admin only item...
Does your line 76 look like this? if item.AdminOnly and not ply:IsAdmin() then
[lua]if item.AdminOnly and not ply:admin() then[/lua] I'm using ulx, I don't know if that makes a difference.
On the inventory panel with all the items (the turtle, the frying pan, etc.) I wouldn't have every single item rotating at the same time -- it's a little overwhelming and doesn't serve much of a purpose. Rather, if you wanted to use that effect it would look better to make it so the item rotates whenever you hover over the item -- essentially, transform the rotation animation into a hover state.
I figured it out! [lua]if item.AdminOnly and not ply:admin() then[/lua] Should be [lua]if item.AdminOnly and not ply:IsAdmin() then[/lua] OOOOhhh... I read yours wrong, that could've saved me loads of time... Now I feel dumb. [b]Edit:[/b] Hey I am getting another error, when I buy something it says "[PS] -0 points!" and takes away all of my points. The item was worth 15, but it took away 21.
Updated. See OP for new image. Also should have fixed DarkRP problems, if someone could test and let me know. If people have added the functions provided in this to their gamemode etc, please update them to include the PS_ prefix, for example, ply:GivePoints() is now ply:PS_GivePoints().
[QUOTE=_Undefined;25866946]Updated. See OP for new image. Also should have fixed DarkRP problems, if someone could test and let me know. If people have added the functions provided in this to their gamemode etc, please update them to include the PS_ prefix, for example, ply:GivePoints() is now ply:PS_GivePoints().[/QUOTE] For some reason I can't open the shop any more. I can still get points, but when I press F2 (the key I use) the shop won't even, I tried changing it to F3, and then F4, but it didn't work.
No errors?
[QUOTE=_Undefined;25867199]No errors?[/QUOTE] None
Strange. Could you try moving the addon folder and redownloading from svn to make sure its not corrupt or something?
[QUOTE=_Undefined;25867327]Strange. Could you try moving the addon folder and redownloading from svn to make sure its not corrupt or something?[/QUOTE] Sure hold on... Well that sucks, guess it did. Hopefully I can move over all my items though...
Very strange. I'm going to make it easier to add/remove items shortly, with a folder of files rather than a table in one file, so people can drag and drop items.
I was able to move over the items without any problems. I wonder what broke it. Anyways this update is pretty kickass. Like how the hats and stuff now spin when you hover over them instead of like before when they just spun. Nice job! Can't wait to see more updates.
Are we going to be able to do this: [lua] Functions = { Draw = function(self) self:DrawModel() end } [/lua]
To draw for the item in the shop or in the world?
Sweet ill give this a go on my server see if it works now :)
More errors, now when I try to buy something from the shop (I tried a clean install without changing anything, didn't work) I get this error where there is no limit on how many items: [lua][addons\pointmod\lua\sv_pointshop.lua:100] attempt to call method 'GiveItem' (a nil value)[/lua] And this when there is a limit on how many items you can own: [lua]addons\pointmod\lua\sv_pointshop.lua:90] attempt to call method 'NumItemsFromCategory' (a nil value)[/lua] Here is the function for line 100: [lua] ply:GiveItem(item_id, true) end)[/lua] And for 90: [lua] if category.NumAllowedItems and ply:NumItemsFromCategory(category) >= category.NumAllowedItems then -- More than would never happen, but just incase. ply:PS_Notify('You can only have ' .. category.NumAllowedItems .. ' items from the ' .. category.Name .. ' category!') return end[/lua] I should also note that this error prevents items from spawning/working.
Fixed, thanks.
Working with MySQL?
Sorry, you need to Log In to post a reply to this thread.