• NPC car dealer/
    25 replies, posted
Hey does anyone know how i can create a NPC car dealer that will load with the map? i am a real LUA noob only been doing a week. [highlight](User was banned for this post ("Wrong section" - mahalis))[/highlight]
Hm, I would like to see this too, been trying to figure it out.
If you want an NPC to load with a map, I'm pretty sure you have to edit the map itself.
you before we updated darkRP we had one but we no longer have the coder who did it >.< we did not need to edit the map
He probably means the way the stargate auto loader works
its possible PERP has it in the script and its not in the map! i think they are using a entity and the model is a ragdoll and frozen.
well we use DarkRP and we had it set so you could buy HoverBike V2 and a Gocart :D But i need to set rp_evocity_v2d up but we need a car dealer and i don't want to have to do it as a job
[QUOTE=russ939;21347514]HoverBike V2 [/QUOTE] My God, why would you want a hoverbike in a RP gamemode? It's cars like this that ruin modern day RP. But yeah, just create the shell of an NPC and then on ENT:Use() open a derma menu.
I'ts "Role Play" not real life even thought many people do put the two together :P but we are going to use cars not bikes :D [quote]just create the shell of an NPC and then on ENT:Use() open a derma menu.[/quote] Ok how do i go about doing this? and will it spawn when the server changed to the map/restarts? as lately we are going a lot of updates = restarts/reloads
To get it to appear upon map start, you will need to hook the spawning onto [url=http://wiki.garrysmod.com/?title=Gamemode.InitPostEntity]Gamemode.InitPostEntity()[/url]. Sorry I cannot be much more specific.
ok so thats how i set it to spawn? still have no idea how to make the npc car dealer
Entoros made an NPC shop and put it on garrysmod.org , maybe look at that. I'm too lazy to find a link :3 .
hey that could work :D how i spawn a jeep in console to test? lol
[QUOTE=sintwins;21350942]Entoros made an NPC shop and put it on garrysmod.org , maybe look at that. I'm too lazy to find a link :3 .[/QUOTE] -snip- Delivered, gotta love Entoros's descriptions right? [editline]10:55PM[/editline] btw you need glon and datastream which everyone has unless you decided to delete it for some reason
yea i worked most of it out but i get this error >.< RunConsoleCommand: Command has invalid characters! (gm_spawnvehicle hoverbike (' ')) The first parameter of this function should contain only the command, the second parameter should contain arguments. This is coding i am using. (With NPC Seller) [code] SELL = {} /************************ EDIT BELOW THIS LINE ************************/ SELL.Info = { ["gm_construct"] = { { pos = Vector( 0, 0, 0 ), ang = Angle( 0, 50, 0 ), model = "models/Humans/Group03/Male_04.mdl", }, { pos = Vector( 50, 50, 0 ), ang = Angle( 0, 180, 0 ), model = "models/Humans/Group02/male_07.mdl", }, }, } SELL.Weapons = { ["Hoverbike"] = { model = "models/hoverbike.mdl", command = "gm_spawnvehicle hoverbike", desc = [[bob]] }, ["MP5"] = { model = "models/weapons/w_smg_mp5.mdl", command = "cs_real_mp5", desc = [[Pew pew]] }, } /************************ EDIT ABOVE THIS LINE ************************/ SELL.MaxDist = 200 SELL.Sellers = {} if SERVER then function SELL:Initialize() print("NPC SELLERS Initializing [SERVER]") local mapinfo = self.Info[string.lower(game.GetMap())] if not mapinfo then print("NPCSELLERS: No data found for this map!") return end for _,v in pairs( ents.FindByClass( "npc_citizen" ) ) do if string.find( v:GetName(), "npcseller" ) then v:Remove() end end for _,v in pairs(mapinfo) do self:CreateSeller( { pos = v.pos, ang = v.ang, model = v.model } ) end hook.Add("KeyPress","SELLDetectUse",function( pl, key ) if key == IN_USE then local ent = pl:GetEyeTrace().Entity if ValidEntity( ent ) and table.HasValue( self.Sellers, ent ) then pl:ConCommand("sell_menu") end end end) hook.Add("ScaleNPCDamage","SELLInvulnSellers",function( npc, hit, dmg ) if table.HasValue( self.Sellers, npc ) then dmg:SetDamage( 0 ) end end) end function SELL:CreateSeller( args ) local npc = ents.Create("npc_citizen") npc:SetPos( args.pos or Vector(0,0,0) ) npc:SetAngles( args.ang or Angle(0,0,0) ) npc:SetModel( args.model or "models/Humans/Group02/male_07.mdl" ) npc:Spawn() npc:Activate() npc:SetName( "npcseller"..tonumber(#self.Sellers) ) npc:SetAnimation( ACT_IDLE_ANGRY ) npc:CapabilitiesClear() npc:CapabilitiesAdd( CAP_ANIMATEDFACE | CAP_TURN_HEAD ) for _,v in pairs( ents.GetAll() ) do npc:AddEntityRelationship( v, D_LI, 99 ) end self.Sellers[ npc:EntIndex() ] = npc end concommand.Add("sell_init_sv",function( pl ) if pl:EV_IsAdmin() then SELL:Initialize() end end) end if CLIENT then function SELL:Initialize() print("NPC SELLERS Initializing [CLIENT]") concommand.Add("sell_menu",function( pl ) if pl:GetShootPos():Distance( pl:GetEyeTrace().HitPos ) >= self.MaxDist then return end local fr = vgui.Create("DFrame") fr:SetSize( 310, 350 ) fr:Center() fr:SetTitle("") fr:MakePopup() function fr:Paint() draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 30, 30, 30, 220 ) ) draw.DrawText( "Second-Hand vehicle Dealer", "ScoreboardText", self:GetWide() / 2, 4, color_white, 1 ) end local itempan = vgui.Create("DPanel",fr) itempan:SetSize( 165, 290 ) itempan:SetPos( 20, 30 ) local itemtext,itemdesc,itemcmd = "An Item", "A Description","" function itempan:Paint() draw.RoundedBox(0,0,0,self:GetWide(),self:GetTall(),Color(50,50,50,255)) draw.DrawText( itemtext, "ScoreboardText", self:GetWide() / 2, 5, color_white, 1 ) draw.DrawText( string.gsub(itemdesc,"\t",""), "Default", self:GetWide() / 2, 20, color_white, 1 ) end local itemmdl = vgui.Create("DModelPanel",itempan) itemmdl:SetSize( itempan:GetWide() - 20, itempan:GetWide() - 20 ) itemmdl:SetPos( 10, 80 ) local function ModelSet(mdl,mdlname) mdl:SetModel(mdlname) local prop = ents.Create("prop_physics") prop:SetModel(mdlname) function mdl:LayoutEntity(Entity) Entity:SetAngles( Angle( 0, math.fmod(CurTime(),360)*50, 0) ) end mdl:SetCamPos(prop:OBBCenter()-Vector(prop:BoundingRadius()*1.3,prop:BoundingRadius() * 1,-prop:BoundingRadius()/13)) mdl:SetLookAt(prop:OBBCenter()-Vector(0,0,-prop:BoundingRadius()/13)) prop:Remove() end local buybtn = vgui.Create("DButton",itempan) buybtn:SetSize( itempan:GetWide() - 20, 20 ) buybtn:SetPos( 10, itempan:GetTall() - 30 ) buybtn:SetText("Buy Vechicle") buybtn.DoClick = function() if itemcmd == "" then LocalPlayer():ChatPrint("Select a vehicle first!") return end RunConsoleCommand(itemcmd) end local weps = vgui.Create("DPanelList",fr) weps:SetSize( (table.Count(self.Weapons) < 3 && 85 || 100 ), 290 ) weps:SetPos( fr:GetWide() - weps:GetWide() - 20, 30 ) weps:SetPadding( 5 ) weps:SetSpacing( 5 ) weps:EnableVerticalScrollbar( true ) for k,v in pairs( self.Weapons ) do local pan = vgui.Create("DPanel") pan:SetSize( weps:GetWide() - 10, (table.Count(self.Weapons) < 3 && weps:GetWide() || weps:GetWide() - 10 ) ) function pan:Paint() draw.DrawText( k, "Default", self:GetWide() / 2, 2, color_white, 1 ) draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 100, 100, 100, 100 ) ) end local icon = vgui.Create("SpawnIcon",pan) icon:SetModel( v.model ) icon:SetPos( 5, 15 ) icon:SetTooltip( k ) icon.OnMousePressed = function() ModelSet(itemmdl,v.model) itemtext = k itemdesc = v.desc itemcmd = v.command end weps:AddItem( pan ) end end) end concommand.Add("sell_init_cl",function() SELL:Initialize() end) end hook.Add("InitPostEntity","SELLInitialize",function() SELL:Initialize() end) [/code]
[code]SELL.Weapons = { ["Hoverbike"] = { model = "models/hoverbike.mdl", command = "gm_spawnvehicle," "hoverbike", desc = [[bob]] [/code] Im unsure, about the position of the comma. It's on one of the sides of the > " <, at spawnvehicle. Think that'll do it. [editline]15:41[/editline] "NPC Sellers" doesent work properly, not for me atleast. I loaded up rp_downtown_v2, where there were spawnpoints as default. It spawned, I could press E, it showed the menu, but when you tried to buy it, you got an error, saying something's wrong with the "you_bought_x" variable, or something like that.
well it does work for weapons but for cars etc it don't think NPC seller is for us :( back to square 1
[QUOTE=russ939;21385443]well it does work for weapons but for cars etc it don't think NPC seller is for us :( back to square 1[/QUOTE] I did my own car dealer once, but I can't remember where I did upload it to.. I will send a link if I can find it.
thanks :D i really have no idea lol :(
[QUOTE=russ939;21402838]thanks :D i really have no idea lol :([/QUOTE] I got those NPC Sellers working...and believe me I would give it to you but seeing as Entoros deleted that file off his account I don't think he wants anyone else to have it :uhaul: [editline]05:28PM[/editline] oh shit when did I get up to 500 posts
All these files are off garrysmod.org >< cant find nuthing to go off. any one have a working vender?
[QUOTE=mkiplm;21686798]All these files are off garrysmod.org >< cant find nuthing to go off. any one have a working vender?[/QUOTE] Make one. No one is going to want to release something like this.
o ty for the info i was little lost people were saying there were some on garrysmod and stuff like that but file got deleted. but i guess i can give it a go
idk if you ever found out how to do it but here is what i use on my server local Spawn = { } Spawn[ 1 ] = { } Spawn[ 1 ].Entity = "npc_car_dealer" Spawn[ 1 ].Vector = Vector( 4316.769043, -3983.117432, 136.031250 ) Spawn[ 1 ].Angle = Angle( 0, 180, 0 ) function SpawnEnts( ) for k, v in pairs( Spawn ) do local ent = ents.Create( Spawn[ k ].Entity ) ent:SetPos( Spawn[ k ].Vector ) ent:SetAngles( Spawn[ k ].Angle ) ent:Spawn( ) ent:DropToFloor( ) local bubble = ents.Create( "ent_quest_bubble" ) bubble:SetNetworkedEntity( "ChaseEntity", ent ) bubble:SetPos( ent:GetPos( ) + Vector( 0, 0, 64 ) ) bubble:Spawn( ) end end hook.Add( "InitPostEntity", "SpawnEntities", SpawnEnts )
Where do i put this? [editline]13th March 2012[/editline] [QUOTE=minesweeper;25162793]idk if you ever found out how to do it but here is what i use on my server local Spawn = { } Spawn[ 1 ] = { } Spawn[ 1 ].Entity = "npc_car_dealer" Spawn[ 1 ].Vector = Vector( 4316.769043, -3983.117432, 136.031250 ) Spawn[ 1 ].Angle = Angle( 0, 180, 0 ) function SpawnEnts( ) for k, v in pairs( Spawn ) do local ent = ents.Create( Spawn[ k ].Entity ) ent:SetPos( Spawn[ k ].Vector ) ent:SetAngles( Spawn[ k ].Angle ) ent:Spawn( ) ent:DropToFloor( ) local bubble = ents.Create( "ent_quest_bubble" ) bubble:SetNetworkedEntity( "ChaseEntity", ent ) bubble:SetPos( ent:GetPos( ) + Vector( 0, 0, 64 ) ) bubble:Spawn( ) end end hook.Add( "InitPostEntity", "SpawnEntities", SpawnEnts )[/QUOTE] Where do I put this?
Sorry, you need to Log In to post a reply to this thread.