• ShopMod - Lightweight NPC Shop System
    180 replies, posted
  • Avatar of redx475
  • [release][b]What is this?[/b] This is [b]ShopMod[/b], a lightweight NPC shop system made for RP gamemodes. [b]Details?[/b] A superadmin creates some shops and adds items to them with console commands. Players can then interact with the NPCs and buy items such as weapons (if your a minge), health packs, and other stuff! [b]How to set up[/b] ShopMod is made to work with any RP or money system, and due to that it requires some setting up. You must go into shopmod/lua/autorun/server/hooks.lua and edit it so that each function will work with your RP mod. The only part already set up is for CityRP (a friend requested this mod, and he uses CityRP). [b]Creating shops[/b] To create a shop, stand where and in the direction you want the NPC to spawn. Run the console command: [code]shop_create <shop name> <npc model> [<enabled>][/code] I suggest never setting enabled to anything. Don't know why I put it there in the first place, since there isn't any way to enable something again. Move away from the spot. The NPC will spawn in 5 seconds. [b]Adding items to a shop[/b] Look at the shop NPC and run: [code]shop_getid[/code] The shop's id should print in console. Then run: [code]shop_item_create <shop id> <item name> <entity> <model in shop> <price> <want to use item spawn for this (true/false)>[/code] Done! Go use your NPC! Note that the deletion of items has not been made yet. [b]Creating Item Spawns[/b] Get the shop's id, stand where you want the spawn to be, and run: [code]shop_spawn_create <id>[/code] [b]Deleting shops[/b] Get the shop's id and run: [code]shop_delete <id>[/code] [b]Deleting items[/b] Open the buy menu for the shop and note the id next to the item name and run: [code]shop_item_delete <shop id> <item id>[/code] [b]Notes[/b] -Moving a shop with the physgun will not save its position when the server restarts. -Shops on different maps are saved seperately. [b]Download[/b] [url=http://www.garrysmod.org/downloads/?a=view&id=103986][img]http://www.garrysmod.org/img/?t=dll&id=103986[/img][/url] [b]SVN[/b] Note: The SVN version is the most up to date, but it may also be the most buggy. SVN Address: [url]http://svn2.xp-dev.com/svn/rxdaddons/shopmod/[/url] [b]Changelog[/b] [code]1.5 -Bug fixes (Updated from SVN) 1.4: -Fixed shop_item_delete -There is a bug! shop_delete isn't working. I will fix it in the next release. 1.3: -Added item IDs to the buy menus -Added shop_item_delete 1.2: -Bugfixes 1.1: -Added entity spawn system -Added shop_spawn_create 1.0: -Initial Release[/code] [b]I found a bug![/b] Report it here! [b]Video[/b] [media]http://www.youtube.com/watch?v=tbtM37brj1Y[/media] [/release] [release]This addon is by [url=www.redcubelabs.com]RedCube Labs[/url].[/release]
  • Avatar of redx475
  • Not really much to show in terms of pics... Its a quick derma buy menu and an NPC. I'll post a video though
  • Avatar of jakegadget
  • Looking good (as usual). Here's some ideas: -HUD Item above the npc with the npcs name -make the npc face you when you use it (might already have done that :S) -add an option to have items spawn in a second location (for items that don't use on touch) like a counter Again, seems awesome!
  • Avatar of Kung Fu Jew
  • I also have some suggestions. Shops could have health so you can kill them, press E on the corpse, and take their shit - without paying of course. Health could be something you set and maybe even health regen speed/amount. Shops could also have guards that attack you if you attack it. You could set how much health they have, and if they regenerate health, and what weapons they get... stuff like that.
  • Avatar of redx475
  • It isn't completely done, and I plan to make it so you can have different spawning methods on each item (one might put something in your inventory, another might spawn a car in a parking lot, etc...) [editline]10:25PM[/editline] [QUOTE=Kung Fu Jew;22718324]I also have some suggestions. Shops could have health so you can kill them, press E on the corpse, and take their shit - without paying of course. Health could be something you set and maybe even health regen speed/amount. Shops could also have guards that attack you if you attack it. You could set how much health they have, and if they regenerate health, and what weapons they get... stuff like that.[/QUOTE] Somehow I see this too easily turning into a shop-killing game. I don't like the idea of that, and it just adds another reason to use guns in DarkRp...
  • Avatar of redx475
  • No idea. That's just what my friend's RP is called. It may be private for all I know.
  • Avatar of Abeevau
  • How would you just make the item spawn instead of going into the inventory?
  • Avatar of redx475
  • Well, either write some lua and have it spawn near the player, or wait for me to come out with the next update where you can set spawn points. Right now it only supports simple things like inventories or giving items, but I'll add more soon.
  • Avatar of redx475
  • Yes. You just need to either make the vehicles add to inventory or spawn somewhere (the spawning I am working on). [editline]09:06AM[/editline] I've finished the spawn system. I'm going to test it. [editline]09:28AM[/editline] Uploaded ShopMod v 1.1! There is 1 new command and a new argument to shop_item_create. See the OP. NOTE: The new shopmod is not compatable with v1. Don't worry about deleting the files that store shopmod data (but if you want they are in the data folder). All shopmod data is now stored in data/shopmod
  • Avatar of redx475
  • [QUOTE=Master_Xeon;22729138]hah, this is amazing, I'm gonna use this for vending machines[/QUOTE] lol. You going to use a vending machine model? I'd like a companion cube that sells stuff :D
  • Avatar of Kung Fu Jew
  • [QUOTE=redx475;22718376]It isn't completely done, and I plan to make it so you can have different spawning methods on each item (one might put something in your inventory, another might spawn a car in a parking lot, etc...) [editline]10:25PM[/editline] Somehow I see this too easily turning into a shop-killing game. I don't like the idea of that, and it just adds another reason to use guns in DarkRp...[/QUOTE] That's why I said guards.
  • Avatar of redx475
  • I know, but then it wouldn't be 'lightweight' and 'simple' anymore, would it? If someone wants to do that, then go right ahead, but I really don't like the idea.
  • Avatar of Aide
  • Awesome. Some useful stuff that would help. [lua] function GM:ScaleNPCDamage ( NPC, HitGroup, DmgInfo ) DmgInfo:ScaleDamage(0); return DmgInfo; end function GM:EntityTakeDamage( ent, inflictor, attacker, amount ) if ent:IsNPC() then return false end end function GM:OnNPCKilled ( npc, pl, weapon ) if pl:IsValid() then pl:Ban(0, 'Banned from killing a npc') pl:Kick( 'Banned from killing a npc' ) end for k, v in pairs(player.GetAll()) do timer.Simple(60, v:PrintChat( 'Map restart in 1 minute.' )) timer.Simple(60, RunConsoleCommand, 'changelevel', game.GetMap()) end end [/lua]
  • Avatar of Abeevau
  • Sorry to ask of too much, but would you be able to make it so you can set different items spawn points? Such as shop_spawn_create <id> <entity id>, and if they don't set the entity ID, they all spawn in one place?
  • Avatar of Master_Xeon
  • [QUOTE=redx475;22730069]lol. You going to use a vending machine model? I'd like a companion cube that sells stuff :D[/QUOTE] It dispenses sodas and snacks :P
  • Avatar of redx475
  • [QUOTE=SL0WP0KE;22734709]Sorry to ask of too much, but would you be able to make it so you can set different items spawn points? Such as shop_spawn_create <id> <entity id>, and if they don't set the entity ID, they all spawn in one place?[/QUOTE] Yes. I will do that in the next release. Also I'll add the ability to remove items (I haven't done that yet... I'll have it tomorrow I think) [editline]09:43PM[/editline] [QUOTE=Aide;22731817]Awesome. Some useful stuff that would help. [lua] function GM:ScaleNPCDamage ( NPC, HitGroup, DmgInfo ) DmgInfo:ScaleDamage(0); return DmgInfo; end function GM:EntityTakeDamage( ent, inflictor, attacker, amount ) if ent:IsNPC() then return false end end function GM:OnNPCKilled ( npc, pl, weapon ) if pl:IsValid() then pl:Ban(0, 'Banned from killing a npc') pl:Kick( 'Banned from killing a npc' ) end for k, v in pairs(player.GetAll()) do timer.Simple(60, v:PrintChat( 'Map restart in 1 minute.' )) timer.Simple(60, RunConsoleCommand, 'changelevel', game.GetMap()) end end [/lua][/QUOTE] Not needed. Unless a SWEP or some lua kills the NPC somehow, they can't be killed.
  • Avatar of elowin
  • This + Jakegadgets inventory mod=awesomeness. Also, since i have abselutely no idea how the money works in darkrp, instructions for setting it up for darkrp would be nice.
  • [QUOTE=redx475;22748132]I'll take a look into making it work with darkrp for my next release.[/QUOTE] Aww come on, can't you make a tool for this to make it easier so you don't need console instead of wasting time putting it into that piece of crap.
  • Avatar of redx475
  • ShopMod updated! Some bugs were DESTROYED. I'll get to the new features soon. [editline]10:56AM[/editline] [QUOTE=kill3r;22748316]Aww come on, can't you make a tool for this to make it easier so you don't need console instead of wasting time putting it into that piece of crap.[/QUOTE] A lot of people use it, and it is RP. I don't have to put much time into it to make it work with any RP.