NPC Store Script

How can I make an NPC on my server that when people walk up to him and hit E (action), he will have a menu where people can buy things from it. Like a NPC Store. Its kinda like PERP RolePlay. Does anyone know? It would be amazing to have that.

Edited:

I DO NOT KNOW how to script, so I wouldnt be able to do that…

Why do people make 1 thread a day of these kinds of request? Look at the other thousands.

Because this is one of the most wanted things ever and people are going to reqeust it every day until somone will actualy make it.

It would be easyer if somone who can lua code just made it…

I’ve already made it.
If anybody wants to buy it they can.
If i decide to sell looool.

SkillGamingClan.net
<Skill>> Where RP gets serious!

Well, it is pretty simple in theory. You have to create an entity using the model of the NPC you want. Then you create a command that opens a derma panel, and run this function when ‘use’ is pressed on that entity.

In order to do this you make a directory with the entity’s name you want to make. then create 3 lua files inside, cl_init, shared, and init. In init you have to initialize your entity with
[lua]function ENT:Initialize( )
self.Entity:SetModel( “” )
self.Entity:SetHullType( HULL_HUMAN )
self.Entity:SetUseType( SIMPLE_USE )
self.Entity:SetHullSizeNormal( )
self.Entity:SetSolid( SOLID_BBOX )
self.Entity:CapabilitiesAdd( CAP_MOVE_GROUND | CAP_OPEN_DOORS | CAP_ANIMATEDFACE | CAP_USE_SHOT_REGULATOR | CAP_TURN_HEAD | CAP_AIM_GUN )
self.Entity:SetMaxYawSpeed( 5000 )
local PhysAwake = self.Entity.Entity:GetPhysicsObject( )
if PhysAwake:IsValid( ) then
PhysAwake:Wake( )
end
end[/lua]

Then with

[lua]function ENT:AcceptInput( name, activator, caller )[/lua]

you put the command that it will run when you press ‘use’
then you create a command.

In cl_init you write the function to create the Derma panels you want to appear when you press ‘use’

then create a console command for this function ex:
[lua]concommand.Add(“nameofcommand”,nameoffunction)[/lua]

then finally in shared you do this to set information about the entity

[lua]ENT.Base = “base_ai”
ENT.Type = “ai”
ENT.PrintName = “”
ENT.Author = “”
ENT.Contact = “”
ENT.Purpose = “t”
ENT.Instructions = “”
ENT.AutomaticFrameAdvance = true – i’m honestly not sure what this does, but just include it. You could look it up on the wiki if you want to find out.

function ENT:SetAutomaticFrameAdvance( bUsingAnim )
self.AutomaticFrameAdvance = bUsingAnim
end[/lua]

Hope this helps. Just edit how you want.

^ Im almost a 100% sure, that he wont even read that.

He just wants the code.

It has been answered a shitload of times, in the different threads. Look it up.

Nobody cares.

[editline]06:34PM[/editline]

Go advertise your shitty server in the proper forum for it.

And i make code for these weasels, last time I help anyone in requests section.

HeavyMtl123, do I just compile the code you have me together or I have to add more to it? Thanks.

You have to add more.

I dont know lua at all so I couldnt add any more… can anyone give me the whole script? THey say it has already been posted but I cant find it…

Well, if anyone want’s to, you can just add to mine, it works fine, I’ve tested it, just add the tidbits needed to finish it off for this guy.

:psyduck:

Entoros made this and released it on garrysmod.org

He removed it again if I remember right :3

Well this is the request section thats how it works

Guys i just want the code, its probably not much anyway. It just 5 minutes of your time… !!

It’s not just 5 minutes, the entity is 5 minutes, yes, but the derma menu, one that interacts with darkrp which you’re no doubt using, would take longer, especially considering you probably want it to also interact with an addentities-like file.

Granted none of these things are extremely hard, but it’s not 5 minutes.

THANK YOU I’VE BEEN LOOKING FOR THAT FUNCTION ALL DAY!
However, in the init code you forgot to add
self.Entity:SetMoveType( MOVETYPE_STEP )
which will make him stay on the ground =p

What? A guy can’t have a floating NPC once in a while? I always enjoy a good space GMan

Why dont you use 1 minute of your time, to look at the other threads or make it yourself.

Make a SNPC which in init.lua uses the function posted earlier.

Then make it run a console command, to open up your Derma Menu, which you have created in cl_init.lua.

[editline]10:05PM[/editline]

I hate it when people like “hey gimme dis please use you time to make dis for me wedout get anyting plzthx”