Hello,
I have a cider RP server that's working well, but I missed something: A hostage weapon so people can hostage people and ask money from them.
Now I have this script, but much things don't work in it. (text when hostaged, runspeed, still can run flashlight etc) Also unhostage with other mouse button don't work.
[lua]
// Variables that are used on both client and server
SWEP.Author = "jdmmer"
SWEP.Contact = "blabla@blabla.nl"
SWEP.Purpose = "Hostage"
SWEP.Instructions = "Left click to hostage.\nRight click to un-hostage."
SWEP.ViewModel = "models/Weapons/V_hands.mdl"
SWEP.WorldModel = "models/weapons/w_fists.mdl"
SWEP.Spawnable = false
SWEP.AdminSpawnable = false
util.PrecacheModel( SWEP.ViewModel )
util.PrecacheModel( SWEP.WorldModel )
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "none"
SWEP.NextUse = 0
SWEP.nextUnHanCuff = 0
/*---------------------------------------------------------
Initialize
---------------------------------------------------------*/
function SWEP:Initialize()
if (!SERVER) then return end
self:SetWeaponHoldType("normal")
end
/*---------------------------------------------------------
Deploy
---------------------------------------------------------*/
function SWEP:Deploy()
if (!SERVER) then return end
self.Owner:DrawWorldModel( false )
end
/*---------------------------------------------------------
Reload does nothing
---------------------------------------------------------*/
function SWEP:Reload()
end
/*---------------------------------------------------------
PrimaryAttack
---------------------------------------------------------*/
function SWEP:PrimaryAttack()
if (!SERVER) then return end
local trace = {}
trace.start = self.Owner:EyePos()
trace.endpos = trace.start + self.Owner:GetAimVector() * 85
trace.filter = self.Owner
local tr = util.TraceLine(trace)
if !tr.Entity:IsValid() then return end
if tr.Entity:IsPlayer() then
if ( tr.Entity.arrested ) then
self.Owner:RedNotify( "This player is already tied up." )
return
elseif ( CurTime() < self.NextUse ) then
self.Owner:RedNotify( "Please wait before using rope on a player again." )
return
end
tr.Entity:SetWalkSpeed( 50 )
tr.Entity:SetRunSpeed( 50 )
tr.Entity:StripWeapons()
tr.Entity.canRun = false
tr.Entity.arrested = true
tr.Entity.arrester = self.Owner
tr.Entity:RedNotify( "You have been hostaged." )
timer.Simple( Configuration["hostagetime"], function()
if tr.Entity:IsValid() then
if ( tr.Entity.arrested ) then
tr.Entity:SetWalkSpeed( 50 )
tr.Entity:SetRunSpeed( 50 )
tr.Entity:LoadOut()
tr.Entity.canRun = false
tr.Entity.arrested = false
tr.Entity.arrester = nil
tr.Entity:GreenNotify( "You have been hostaged." )
end
end
end )
self.NextUse = CurTime() + 5
end
end
/*---------------------------------------------------------
SecondaryAttack
---------------------------------------------------------*/
function SWEP:SecondaryAttack()
if ( CurTime() < self.nextUnHostage) then return end
if (!SERVER) then return end
local trace = {}
trace.start = self.Owner:EyePos()
trace.endpos = trace.start + self.Owner:GetAimVector() * 85
trace.filter = self.Owner
local tr = util.TraceLine(trace)
if tr.Entity:IsValid() then
if ( tr.Entity.arrested ) then
tr.Entity:SetWalkSpeed( 75 )
tr.Entity:SetRunSpeed( 75 )
tr.Entity:LoadOut()
tr.Entity.canRun = false
tr.Entity.arrested = false
tr.Entity.arrester = nil
tr.Entity:GreenNotify( "You have been unhostaged." )
end
else
self.Owner:RedNotify( "You must aim to a person to unhostage him." )
end
self.nextUnHostage = CurTime() + .3
end
/*---------------------------------------------------------
Think does nothing
---------------------------------------------------------*/
function SWEP:Think()
end
[/lua]
Can someone tell me what I did wrong? Thanks
Sorry, you need to Log In to post a reply to this thread.