- Initiateur de la discussion
L
ludovic.dmtf
Davika
- Messages
- 13
- Score réaction
- 0
- Points
- 75
Salut, j'essaie de modifier un addons du workshop (pointshop npc) pour qu'il marche avec pointshop2 en changeant la commande envoyée a la console mais a chaques fois que je passe l'addon dans gmad extractor l'addon deviens unitilisable et il disparait des entitées avant que je puisse le modifier. J'y connait presque rien a code dcp je peux pas faire grands chose moi meme et je vous met le code juste là merci d'avance
addons->pointshopnpc->entities->cl_init.lua,init.lua,shared.lua
----------
cl_init.lua:
include('shared.lua') -- At this point the contents of shared.lua are ran on the client only.
function NPCShopMenu()
-- We can also do anything else the client can do, like using the chat!
chat.AddText(Color(255,255,128), "Merchant: ",Color(255,255,255), "Welcome to my shop, how can I help you?" )
end
usermessage.Hook("ShopNPCUsed", NPCShopMenu) --Hook to messages from the server so we know when to display the menu.
-------------
init.lua
AddCSLuaFile( "cl_init.lua" ) -- This means the client will download these files
AddCSLuaFile( "shared.lua" )
include('shared.lua') -- At this point the contents of shared.lua are ran on the server only.
function ENT:Initialize( ) --This function is run when the entity is created so it's a good place to setup our entity.
self:SetModel( "models/humans/group01/female_01.mdl" ) -- Sets the model of the NPC.
self:SetHullType( HULL_HUMAN ) -- Sets the hull type, used for movement calculations amongst other things.
self:SetHullSizeNormal( )
self:SetNPCState( NPC_STATE_SCRIPT )
self:SetSolid( SOLID_BBOX ) -- This entity uses a solid bounding box for collisions.
self:CapabilitiesAdd( CAP_ANIMATEDFACE , CAP_TURN_HEAD ) -- Adds what the NPC is allowed to do ( It cannot move in this case ).
self:SetUseType( SIMPLE_USE ) -- Makes the ENT.Use hook only get called once at every use.
selfropToFloor()
self:SetMaxYawSpeed( 90 ) --Sets the angle by which an NPC can rotate at once.
end
function ENT:OnTakeDamage()
return false -- This NPC won't take damage from anything.
end
function ENT:AcceptInput( Name, Activator, Caller )
if Name == "Use" and Caller:IsPlayer() then
umsg.Start("ShopNPCUsed", Caller) -- Prepare the usermessage to that same player to open the menu on his side.
umsg.End() -- We don't need any content in the usermessage so we're sending it empty now.
RunConsoleCommand "pointshop2_toggle"
end
end
----------------
shared.lua
ENT.Base = "base_ai" -- This entity is based on "base_ai"
ENT.Type = "ai" -- What type of entity is it, in this case, it's an AI.
ENT.AutomaticFrameAdvance = true -- This entity will animate itself.
function ENT:SetAutomaticFrameAdvance( bUsingAnim ) -- This is called by the game to tell the entity if it should animate itself.
self.AutomaticFrameAdvance = bUsingAnim
end
-- Since this file is ran by both the client and the server, both will share this information.
addons->pointshopnpc->entities->cl_init.lua,init.lua,shared.lua
----------
cl_init.lua:
include('shared.lua') -- At this point the contents of shared.lua are ran on the client only.
function NPCShopMenu()
-- We can also do anything else the client can do, like using the chat!
chat.AddText(Color(255,255,128), "Merchant: ",Color(255,255,255), "Welcome to my shop, how can I help you?" )
end
usermessage.Hook("ShopNPCUsed", NPCShopMenu) --Hook to messages from the server so we know when to display the menu.
-------------
init.lua
AddCSLuaFile( "cl_init.lua" ) -- This means the client will download these files
AddCSLuaFile( "shared.lua" )
include('shared.lua') -- At this point the contents of shared.lua are ran on the server only.
function ENT:Initialize( ) --This function is run when the entity is created so it's a good place to setup our entity.
self:SetModel( "models/humans/group01/female_01.mdl" ) -- Sets the model of the NPC.
self:SetHullType( HULL_HUMAN ) -- Sets the hull type, used for movement calculations amongst other things.
self:SetHullSizeNormal( )
self:SetNPCState( NPC_STATE_SCRIPT )
self:SetSolid( SOLID_BBOX ) -- This entity uses a solid bounding box for collisions.
self:CapabilitiesAdd( CAP_ANIMATEDFACE , CAP_TURN_HEAD ) -- Adds what the NPC is allowed to do ( It cannot move in this case ).
self:SetUseType( SIMPLE_USE ) -- Makes the ENT.Use hook only get called once at every use.
selfropToFloor()
self:SetMaxYawSpeed( 90 ) --Sets the angle by which an NPC can rotate at once.
end
function ENT:OnTakeDamage()
return false -- This NPC won't take damage from anything.
end
function ENT:AcceptInput( Name, Activator, Caller )
if Name == "Use" and Caller:IsPlayer() then
umsg.Start("ShopNPCUsed", Caller) -- Prepare the usermessage to that same player to open the menu on his side.
umsg.End() -- We don't need any content in the usermessage so we're sending it empty now.
RunConsoleCommand "pointshop2_toggle"
end
end
----------------
shared.lua
ENT.Base = "base_ai" -- This entity is based on "base_ai"
ENT.Type = "ai" -- What type of entity is it, in this case, it's an AI.
ENT.AutomaticFrameAdvance = true -- This entity will animate itself.
function ENT:SetAutomaticFrameAdvance( bUsingAnim ) -- This is called by the game to tell the entity if it should animate itself.
self.AutomaticFrameAdvance = bUsingAnim
end
-- Since this file is ran by both the client and the server, both will share this information.