- Initiateur de la discussion
Arthurlepryde
Geek
- Messages
- 29
- Score réaction
- 7
- Points
- 95
Bonjour J'aimerais savoir comment faire un Npc qui exécute une commande de la console
merci
merci
include('shared.lua')
function KILL ()
ply:ConCommand( "kill" )
end
usermessage.Hook("kill", kill)
hook.Add("PostDrawOpaqueRenderables", "kill", function() for _, ent in pairs (ents.FindByClass("kill ")) do if ent:GetPos():Distance(LocalPlayer():GetPos()) < 1000 then local Ang = ent:GetAngles() Ang:RotateAroundAxis( Ang:Forward(), 90) Ang:RotateAroundAxis( Ang:Right(), -90) cam.Start3D2D(ent:GetPos()+ent:GetUp()*79, Ang, 0.20) draw.SimpleTextOutlined( 'kill', "HUDNumber5", 0, 0, Color( 255, 0, 0, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 1, Color(0, 0, 0, 255)) cam.End3D2D() end end
end)
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')
function ENT:Initialize() self:SetModel("models/gman_high.mdl") self:SetHullType(HULL_HUMAN) self:SetHullSizeNormal() self:SetNPCState(NPC_STATE_SCRIPT) self:SetSolid(SOLID_BBOX) self:CapabilitiesAdd(CAP_ANIMATEDFACE) self:SetUseType(SIMPLE_USE) self:DropToFloor() self:SetMaxYawSpeed(90)
end
function ENT:OnTakeDamage() return false
end
util.AddNetworkString( "kill" )
function ENT:AcceptInput( name, activator, caller ) if name == "Use" and caller:IsPlayer() then net.Start("kill") net.Send(caller) end
end
tu utilise un net. combiné à un usermessage ^^Arthurlepryde à dit:Code:AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include('shared.lua') function ENT:Initialize() self:SetModel("models/gman_high.mdl") self:SetHullType(HULL_HUMAN) self:SetHullSizeNormal() self:SetNPCState(NPC_STATE_SCRIPT) self:SetSolid(SOLID_BBOX) self:CapabilitiesAdd(CAP_ANIMATEDFACE) self:SetUseType(SIMPLE_USE) self:DropToFloor() self:SetMaxYawSpeed(90) end function ENT:OnTakeDamage() return false end util.AddNetworkString( "kill" ) function ENT:AcceptInput( name, activator, caller ) if name == "Use" and caller:IsPlayer() then net.Start("kill") net.Send(caller) end end
Cezaw à dit:Util.addnetwork tu connais ?
Arthurlepryde à dit:Code:AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include('shared.lua') function ENT:Initialize() self:SetModel("models/gman_high.mdl") self:SetHullType(HULL_HUMAN) self:SetHullSizeNormal() self:SetNPCState(NPC_STATE_SCRIPT) self:SetSolid(SOLID_BBOX) self:CapabilitiesAdd(CAP_ANIMATEDFACE) self:SetUseType(SIMPLE_USE) self:DropToFloor() self:SetMaxYawSpeed(90) end function ENT:OnTakeDamage() return false end util.AddNetworkString( "kill" ) function ENT:AcceptInput( name, activator, caller ) if name == "Use" and caller:IsPlayer() then net.Start("kill") net.Send(caller) end end
Passe en net.sendtoserver pour voirArthurlepryde à dit:et bien sa marche toujour pas avec le
net.Receive( "kill", function( len, pl )
if ( IsValid( pl ) and pl:IsPlayer() ) then
print( "Message from " .. pl:Nick() .. " received. Its length is " .. len .. "." )
else
print( "Message from server received. Its length is " .. len .. "." )
end
end )