Le stunstick des Protections Civil

  • Initiateur de la discussion Lyko5102
  • Date de début
  • Initiateur de la discussion
Lyko5102

Lyko5102

Geek suprême
Messages
88
Score réaction
4
Points
115
Bonsoir/Bonjour à tous

J'ai un petit soucis j'aimerais trouver un stunstick normal mais qui fait exactement la même chose que le stunstick du DarkRP mais je n'aimerais pas que ce stunstick soit blue translucide j'aimerais pouvoir mettre mon model a moi j'ai tenté de copier coller le code du stunstick tout en enlevant les code qui font qu'il est bleue translucide rajouter les lignes de models mais rien y fait..

Je vous met le code mais a mon avis cela ne servirais a rien on va surement me dire que de prendre le code du stunstick du DarkRP me donnera toujours un stunstick translucide..

CODE
AddCSLuaFile()

if CLIENT then
SWEP.PrintName = "Combine_Stunstick "
SWEP.Slot = 1
SWEP.SlotPos = 3
SWEP.ViewModel = "models/dpfilms/weapons/v_stunbaton.mdl"
SWEP.WorldModel = "models/dpfilms/weapons/w_stunbaton.mdl"

killicon.AddAlias("stunstick", "weapon_stunstick")
end

DEFINE_BASECLASS("stick_base")

SWEP.Instructions = "Left click pour punir\nClic droit pour blessé\nMaintenir R pour charger le stun."

SWEP.Spawnable = true
SWEP.Category = "Combine_Stunstick"

function SWEP:Initialize()
BaseClass.Initialize(self)

self.Hit = {
Sound("weapons/stunstick/stunstick_impact1.wav"),
Sound("weapons/stunstick/stunstick_impact2.wav")
}

self.FleshHit = {
Sound("weapons/stunstick/stunstick_fleshhit1.wav"),
Sound("weapons/stunstick/stunstick_fleshhit2.wav")
}

end


function SWEP:SetupDataTables()
BaseClass.SetupDataTables(self)
-- Float 0 = LastPrimaryAttack
-- Float 1 = ReloadEndTime
-- Float 2 = BurstTime
-- Float 3 = LastNonBurst
-- Float 4 = SeqIdleTime
-- Float 5 = HoldTypeChangeTime
self:NetworkVar("Float", 6, "LastReload")
end

function SWEP:Think()
BaseClass.Think(self)
if self.WaitingForAttackEffect and self:GetSeqIdleTime() ~= 0 and CurTime() >= self:GetSeqIdleTime() - 0.35 then
self.WaitingForAttackEffect = false

local effectData = EffectData()
effectData:SetOrigin(self:GetOwner():GetShootPos() + (self:GetOwner():EyeAngles():Forward() * 45))
effectData:SetNormal(self:GetOwner():EyeAngles():Forward())
util.Effect("StunstickImpact", effectData)
end
end

function SWEP: DoFlash(ply)
if not IsValid(ply) or not ply:IsPlayer() then return end

ply:ScreenFade(SCREENFADE.IN, color_white, 1.2, 0)
end

local entMeta = FindMetaTable("Entity")
function SWEP: DoAttack(dmg)
if CLIENT then return end

self:GetOwner():LagCompensation(true)
local trace = util.QuickTrace(self:GetOwner():EyePos(), self:GetOwner():GetAimVector() * 90, {self:GetOwner()})
self:GetOwner():LagCompensation(false)
if IsValid(trace.Entity) and trace.Entity.onStunStickUsed then
trace.Entity:eek:nStunStickUsed(self:GetOwner())
return
elseif IsValid(trace.Entity) and trace.Entity:GetClass() == "func_breakable_surf" then
trace.Entity:Fire("Shatter")
self:GetOwner():EmitSound(self.Hit[math.random(1,#self.Hit)])
return
end

self.WaitingForAttackEffect = true

local ent = self:GetOwner():getEyeSightHitEntity(self.stickRange, 15, fn.FAnd{fp{fn.Neq, self:GetOwner()}, fc{IsValid, entMeta.GetPhysicsObject}})

if not IsValid(ent) then return end
if ent:IsPlayer() and not ent:Alive() then return end

if not ent:isDoor() then
ent:SetVelocity((ent:GetPos() - self:GetOwner():GetPos()) * 7)
end

if dmg > 0 then
ent:TakeDamage(dmg, self:GetOwner(), self)
end

if ent:IsPlayer() or ent:IsNPC() or ent:IsVehicle() then
self:DoFlash(ent)
self:GetOwner():EmitSound(self.FleshHit[math.random(1,#self.FleshHit)])
else
self:GetOwner():EmitSound(self.Hit[math.random(1,#self.Hit)])
if FPP and FPP.plyCanTouchEnt(self:GetOwner(), ent, "EntityDamage") then
if ent.SeizeReward and not ent.beenSeized and not ent.burningup and self:GetOwner():isCP() and ent.Getowning_ent and self:GetOwner() ~= ent:Getowning_ent() then
self:GetOwner():addMoney(ent.SeizeReward)
DarkRP.notify(self:GetOwner(), 1, 4, DarkRP.getPhrase("you_received_x", DarkRP.formatMoney(ent.SeizeReward), DarkRP.getPhrase("bonus_destroying_entity")))
ent.beenSeized = true
end
ent:TakeDamage(1000-dmg, self:GetOwner(), self) -- for illegal entities
end
end
end

function SWEP:primaryAttack()
BaseClass.PrimaryAttack(self)
self:SetNextSecondaryFire(self:GetNextPrimaryFire())
self:DoAttack(5)
end
 
Yoh Sambre ♪

Yoh Sambre ♪

Shaman Fou
Messages
16 289
Score réaction
9 688
Points
1 845
Give du stunstick weapons des combine > profit
 
  • Initiateur de la discussion
Lyko5102

Lyko5102

Geek suprême
Messages
88
Score réaction
4
Points
115
Yoh Sambre ♪

Yoh Sambre ♪

Shaman Fou
Messages
16 289
Score réaction
9 688
Points
1 845
  • Initiateur de la discussion
Lyko5102

Lyko5102

Geek suprême
Messages
88
Score réaction
4
Points
115
Yoh Sambre ♪ à dit:
Prenez le swep stunstick de base
Oui sauf que le stunstick de base c'est celui du darkRP le bleue apres c'est celui de HL2 mais il garde l'arme lever.

J'ai trouver comment le modifier merci :)
 
Dernière édition:
  • Initiateur de la discussion
Lyko5102

Lyko5102

Geek suprême
Messages
88
Score réaction
4
Points
115
Tu as 2 choix soit tu crée un nouveau dossier dans garrysmod/gamemode/darkrp/entities/weapons/ tu le nomme comme tu veux tu prend ensuite le shared.lua qui se trouve dans le dossier stunstick la ou tu as créé ton dossier tu copie colle dans ton nouveau dossier et tu édite le fichier en retirant ce que j'ai mis en gras.

AddCSLuaFile()

if CLIENT then
SWEP.PrintName = "Stun Stick" --Tu renomme en ce que tu veux.
SWEP.Slot = 0
SWEP.SlotPos = 5
SWEP.RenderGroup = RENDERGROUP_BOTH

killicon.AddAlias("stunstick", "weapon_stunstick")
end

DEFINE_BASECLASS("stick_base") -- Ca tu ne touche pas je te l'ais mis en gras pour après !!!

SWEP.Instructions = "Left click to discipline\nRight click to kill\nHold reload to threaten" --Tu renomme en ce que tu veux.
SWEP.IsDarkRPStunstick = true

SWEP.Spawnable = true
SWEP.Category = "DarkRP (Utility)"--Tu renomme en ce que tu veux.

SWEP.StickColor = Color(0, 0, 255)-- tu enlève ca !C'estcequi rendle stunstick bleue.



function SWEP:Initialize()
BaseClass.Initialize(self)

self.Hit = {
Sound("weapons/stunstick/stunstick_impact1.wav"),
Sound("weapons/stunstick/stunstick_impact2.wav")
}

self.FleshHit = {
Sound("weapons/stunstick/stunstick_fleshhit1.wav"),
Sound("weapons/stunstick/stunstick_fleshhit2.wav")
}

if SERVER then return end

CreateMaterial("darkrp/stunstick_beam", "UnlitGeneric", {
["$basetexture"] = "sprites/lgtning",
["$additive"] = 1
})
end

function SWEP:SetupDataTables()
BaseClass.SetupDataTables(self)
-- Float 0 = LastPrimaryAttack
-- Float 1 = ReloadEndTime
-- Float 2 = BurstTime
-- Float 3 = LastNonBurst
-- Float 4 = SeqIdleTime
-- Float 5 = HoldTypeChangeTime
self:NetworkVar("Float", 6, "LastReload")
end

function SWEP:Think()
BaseClass.Think(self)
if self.WaitingForAttackEffect and self:GetSeqIdleTime() ~= 0 and CurTime() >= self:GetSeqIdleTime() - 0.35 then
self.WaitingForAttackEffect = false

local effectData = EffectData()
effectData:SetOrigin(self:GetOwner():GetShootPos() + (self:GetOwner():EyeAngles():Forward() * 45))
effectData:SetNormal(self:GetOwner():EyeAngles():Forward())
util.Effect("StunstickImpact", effectData)
end
end

function SWEP:DoFlash(ply)
if not IsValid(ply) or not ply:IsPlayer() then return end

ply:ScreenFade(SCREENFADE.IN, color_white, 1.2, 0)
end

function SWEP:postDrawViewModel(vm)
if self:GetSeqIdleTime() ~= 0 or self:GetLastReload() >= CurTime() - 0.1 then
local attachment = vm:GetAttachment(1)
local pos = attachment.Pos
cam.Start3D(EyePos(), EyeAngles())
render.SetMaterial(Material("effects/stunstick"))
render.DrawSprite(pos, 12, 12, Color(180, 180, 180))
for i = 1, 3 do
local randVec = VectorRand() * 3
local offset = (attachment.Ang:Forward() * randVec.x) + (attachment.Ang:Right() * randVec.y) + (attachment.Ang:Up() * randVec.z)
render.SetMaterial(Material("!darkrp/stunstick_beam"))
render.DrawBeam(pos, pos + offset, 3.25 - i, 1, 1.25, Color(180, 180, 180))
pos = pos + offset
end
cam.End3D()
end
end

function SWEP:DrawWorldModelTranslucent()
if CurTime() <= self:GetLastReload() + 0.1 then
local bone = self:GetOwner():LookupBone("ValveBiped.Bip01_R_Hand")
if not bone then self:DrawModel() return end
local bonePos, boneAng = self:GetOwner():GetBonePosition(bone)
if bonePos then
local pos = bonePos + (boneAng:Up() * -16) + (boneAng:Right() * 3) + (boneAng:Forward() * 6.5)
render.SetMaterial(Material("sprites/light_glow02_add"))
render.DrawSprite(pos, 32, 32, Color(255, 255, 255))
end
end
self:DrawModel()
end

local entMeta = FindMetaTable("Entity")
function SWEP:DoAttack(dmg)
if CLIENT then return end

self:GetOwner():LagCompensation(true)
local trace = util.QuickTrace(self:GetOwner():EyePos(), self:GetOwner():GetAimVector() * 90, {self:GetOwner()})
self:GetOwner():LagCompensation(false)
if IsValid(trace.Entity) and trace.Entity.onStunStickUsed then
trace.Entity:eek:nStunStickUsed(self:GetOwner())
return
elseif IsValid(trace.Entity) and trace.Entity:GetClass() == "func_breakable_surf" then
trace.Entity:Fire("Shatter")
self:GetOwner():EmitSound(self.Hit[math.random(1,#self.Hit)])
return
end

self.WaitingForAttackEffect = true

local ent = self:GetOwner():getEyeSightHitEntity(self.stickRange, 15, fn.FAnd{fp{fn.Neq, self:GetOwner()}, fc{IsValid, entMeta.GetPhysicsObject}})

if not IsValid(ent) then return end
if ent:IsPlayer() and not ent:Alive() then return end

if not ent:isDoor() then
ent:SetVelocity((ent:GetPos() - self:GetOwner():GetPos()) * 7)
end

if dmg > 0 then
ent:TakeDamage(dmg, self:GetOwner(), self)
end

if ent:IsPlayer() or ent:IsNPC() or ent:IsVehicle() then
self:DoFlash(ent)
self:GetOwner():EmitSound(self.FleshHit[math.random(1,#self.FleshHit)])
else
self:GetOwner():EmitSound(self.Hit[math.random(1,#self.Hit)])
if FPP and FPP.plyCanTouchEnt(self:GetOwner(), ent, "EntityDamage") then
if ent.SeizeReward and not ent.beenSeized and not ent.burningup and self:GetOwner():isCP() and ent.Getowning_ent and self:GetOwner() ~= ent:Getowning_ent() then
self:GetOwner():addMoney(ent.SeizeReward)
DarkRP.notify(self:GetOwner(), 1, 4, DarkRP.getPhrase("you_received_x", DarkRP.formatMoney(ent.SeizeReward), DarkRP.getPhrase("bonus_destroying_entity")))
ent.beenSeized = true
end
ent:TakeDamage(1000-dmg, self:GetOwner(), self) -- for illegal entities
end
end
end

function SWEP:primaryAttack()
BaseClass.PrimaryAttack(self)
self:SetNextSecondaryFire(self:GetNextPrimaryFire())
self:DoAttack(5)-- Tu modifie les dégats que fait le stunstick clic gauche.En changeant le chiffre dans la parenthèse.
end

function SWEP:SecondaryAttack()
BaseClass.PrimaryAttack(self)
self:SetNextSecondaryFire(self:GetNextPrimaryFire())
self:DoAttack(20) Tu modifie les dégats que fait le stunstick clic droit.En changeant le chiffre dans la parenthèse.
end

function SWEP:Reload()
self:SetHoldType("melee")
self:SetHoldTypeChangeTime(CurTime() + 0.1)

if self:GetLastReload() + 0.1 > CurTime() then self:SetLastReload(CurTime()) return end
self:SetLastReload(CurTime())
self:EmitSound("weapons/stunstick/spark" .. math.random(1, 3) .. ".wav")
end

ensuite toujours dans le dossier weapons juste au-dessus du dossier stunstick tu a un autre dossier nommé stick-base.Tu a déjà vu ce terme dans le lua que tu viens d'éditer c'est le coeur même justement des stunstick du DarkRP c'est ce qui va te permettre de changer ce que tu veux.

AddCSLuaFile()

if CLIENT then
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
end

DEFINE_BASECLASS("weapon_cs_base2")

SWEP.Author = "DarkRP Developers"
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.IconLetter = ""

SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false
SWEP.AnimPrefix = "stunstick"

SWEP.AdminOnly = true

SWEP.StickColor = Color(255, 255, 255)--Tu peux le laisser cela n'affecte en rien ton nouveau stunstick.

SWEP.ViewModel = Model("models/dpfilms/weapons/v_hd_stunbaton.mdl")--Modifie le chemin du model en mettant le tiens ViewModel et WorldModel.
SWEP.WorldModel = Model("models/dpfilms/weapons/w_hd_stunbaton.mdl")--

SWEP.Sound = Sound("weapons/stunstick/stunstick_swing1.wav")

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = 0
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = ""

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = ""

function SWEP:Initialize()
self:SetHoldType("normal")
CreateMaterial("darkrp/" .. self:GetClass(), "VertexLitGeneric", {
["$basetexture"] = "models/debug/debugwhite",
["$surfaceprop"] = "metal",
["$envmap"] = "env_cubemap",
["$envmaptint"] = "[ .5 .5 .5 ]",
["$selfillum"] = 0,
["$model"] = 1
}):SetVector("$color2", self.StickColor:ToVector()) --Si tu n'enlève pas se bloc de code ton stunstick restera blanc.


self.stickRange = 90
end

function SWEP:SetupDataTables()
BaseClass.SetupDataTables(self)
-- Bool 0 = Ironsights
-- Bool 1 = Reloading
self:NetworkVar("Bool", 2, "SeqIdling")
-- Float 0 = LastPrimaryAttack
-- Float 1 = ReloadEndTime
-- Float 2 = BurstTime
-- Float 3 = LastNonBurst
self:NetworkVar("Float", 4, "SeqIdleTime")
self:NetworkVar("Float", 5, "HoldTypeChangeTime")
end

function SWEP:Deploy()
BaseClass.Deploy(self)
if SERVER then
self:SetMaterial("!darkrp/" .. self:GetClass())
end

local vm = self:GetOwner():GetViewModel()
if not IsValid(vm) then return true end

vm:SendViewModelMatchingSequence(vm:LookupSequence("idle01"))

return true
end

function SWEP:preDrawViewModel(vm)
if not IsValid(vm) then return end
for i = 9, 15 do
vm:SetSubMaterial(i, "!darkrp/" .. self:GetClass())
end
end

function SWEP:ViewModelDrawn(vm)
if not IsValid(vm) then return end
vm:SetSubMaterial() -- clear sub-materials
end

function SWEP:ResetStick()
if not IsValid(self:GetOwner()) then return end
if SERVER then
self:SetMaterial() -- clear material
end
self:SetSeqIdling(false)
self:SetSeqIdleTime(0)
self:SetHoldTypeChangeTime(0)
end

function SWEP:Holster()
BaseClass.Holster(self)
self:ResetStick()
return true
end

function SWEP:Think()
if self:GetSeqIdling() then
self:SetSeqIdling(false)

if not IsValid(self:GetOwner()) then return end
self:GetOwner():SetAnimation(PLAYER_ATTACK1)
self:EmitSound(self.Sound)

local vm = self:GetOwner():GetViewModel()
if not IsValid(vm) then return end
vm:SendViewModelMatchingSequence(vm:LookupSequence("attackch"))
vm:SetPlaybackRate(1 + 1 / 3)
local duration = vm:SequenceDuration() / vm:GetPlaybackRate()
local time = CurTime() + duration
self:SetSeqIdleTime(time)
self:SetNextPrimaryFire(time)
end
if self:GetSeqIdleTime() ~= 0 and CurTime() >= self:GetSeqIdleTime() then
self:SetSeqIdleTime(0)

if not IsValid(self:GetOwner()) then return end
local vm = self:GetOwner():GetViewModel()
if not IsValid(vm) then return end
vm:SendViewModelMatchingSequence(vm:LookupSequence("idle01"))
end
if self:GetHoldTypeChangeTime() ~= 0 and CurTime() >= self:GetHoldTypeChangeTime() then
self:SetHoldTypeChangeTime(0)
self:SetHoldType("normal")
end
end

function SWEP:primaryAttack()
self:SetHoldType("melee")
self:SetHoldTypeChangeTime(CurTime() + 0.3)

self:SetNextPrimaryFire(CurTime() + 0.51) -- Actual delay is set later.

local vm = self:GetOwner():GetViewModel()
if IsValid(vm) then
vm:SendViewModelMatchingSequence(vm:LookupSequence("idle01"))
self:SetSeqIdling(true)
end
end

function SWEP:SecondaryAttack()
-- Do nothing
end

function SWEP:Reload()

end

Voilà suite à ça tu redémarre ton serveur et tu test.Au final tu peux tout faire en éditant simplement le shared.lua des 2 dossiers tu n'es pas obligé de créer un dossier pour faire un autre swep c'est juste si tu veux garder le stunstick bleue du DarkRP a ce moment la tu crée un dossier :).
 
  • J'aime
Réactions: Charles10000
Discord d'entraide
Rejoignz-nous sur Discord