Hello, i have some trubels whit this lua code
[lua]
function SWEP:PrimaryAttack()
local trace = { }
trace.start = self.Owner:EyePos();
trace.endpos = trace.start + self.Owner:GetAimVector() * 60;
trace.filter = self.Owner;
local tr = util.TraceLine( trace );
if( tr.Entity:IsValid() and ( tr.Entity:IsPlayer() ) ) then
if( tr.Entity:GetNWBool( "FrozenYay" ) == true ) then
return; end
tr.Entity:SetNWBool( "FrozenYay", true )
LocalPlayer():ConCommand("say /me Taking all your weapons.") -- Deprecated
for _, pl in ipairs( players ) do
pl:StripWeapons()
RunConsoleCommand("say", "/me Taking all your weapons.")
tr.Entity:PrintMessage( HUD_PRINTCENTER, "You are now handcuffed." );
end
end
end
[/lua]
[lua]function SWEP:PrimaryAttack()
local trace = { }
trace.start = self.Owner:EyePos();
trace.endpos = trace.start + self.Owner:GetAimVector() * 60;
trace.filter = self.Owner;
local tr = util.TraceLine( trace );
if( tr.Entity:IsValid() and ( tr.Entity:IsPlayer() ) ) then
if( tr.Entity:GetNWBool( "FrozenYay" ) == true ) then
return; end
tr.Entity:SetNWBool( "FrozenYay", true )
tr.Entity:ChatPrint(tostring(self.Owner:Nick()) .. " Took all of your weapons.")
tr.Entity:StripWeapons()
tr.Entity:PrintMessage( HUD_PRINTCENTER, "You are now handcuffed." );
end
end[/lua]
[QUOTE=Cubar;26316756][lua]function SWEP:PrimaryAttack()
local trace = { }
trace.start = self.Owner:EyePos();
trace.endpos = trace.start + self.Owner:GetAimVector() * 60;
trace.filter = self.Owner;
local tr = util.TraceLine( trace );
if( tr.Entity:IsValid() and ( tr.Entity:IsPlayer() ) ) then
if( tr.Entity:GetNWBool( "FrozenYay" ) == true ) then
return; end
tr.Entity:SetNWBool( "FrozenYay", true )
tr.Entity:ChatPrint(tostring(self.Owner:Nick()) .. " Took all of your weapons.")
tr.Entity:StripWeapons()
tr.Entity:PrintMessage( HUD_PRINTCENTER, "You are now handcuffed." );
end
end[/lua][/QUOTE]
Ty worked perfect :) can you help me whit sec fire also? -> if you will the code are
[lua]
function SWEP:SecondaryAttack()
local trace = { }
trace.start = self.Owner:EyePos();
trace.endpos = trace.start + self.Owner:GetAimVector() * 60;
trace.filter = self.Owner;
local tr = util.TraceLine( trace );
if ( tr.Entity:IsValid() and ( tr.Entity:IsPlayer() ) ) then
if( tr.Entity:GetNWBool( "FrozenYay" ) == true ) then
tr.Entity:SetNWBool( "FrozenYay", false )
else
self.Owner:PrintMessage( HUD_PRINTCENTER, "Target isn't handcuffed." );
end
end
end
[/lua]
Make sure that that is run only on the server, you cannot set networked vars on the client.
It's shared so it wouldn't matter.
@TechLoadV1 what do you want me to do or fix..
Well i just asking if you also could help whit uncuffing (right click) -> i have posted the lua file a bit over :=)
[QUOTE=TechLoadV1;26354237]Well i just asking if you also could help whit uncuffing (right click) -> i have posted the lua file a bit over :=)[/QUOTE]
It's simple work it out your self.
make it so that when they get uncuffed they get simple weapons, like in perp you start over with the keys, hands, and phygun/grav gun. That's it.
[editline]29th November 2010[/editline]
ply:Give()
Okay i have tryed that and tested it on my sever and it dont works, i have made the lua for sec attack like this :
[lua]
function SWEP:SecondaryAttack()
local trace = { }
trace.start = self.Owner:EyePos();
trace.endpos = trace.start + self.Owner:GetAimVector() * 60;
trace.filter = self.Owner;
local tr = util.TraceLine( trace );
if ( tr.Entity:IsValid() and ( tr.Entity:IsPlayer() ) ) then
if( tr.Entity:GetNWBool( "FrozenYay" ) == true ) then
tr.Entity:SetNWBool( "FrozenYay", false )
ply:Give( "weapon_physcannon" )
ply:Give( "gmod_camera" )
ply:Give( "weapon_physgun" )
ply:Give( "gmod_tool" )
tr.Entity:ChatPrint(tostring(self.Owner:Nick()) .. "/me Testing unstrip")
else
self.Owner:PrintMessage( HUD_PRINTCENTER, "Target isn't handcuffed." );
end
end
end
[/lua]
[lua]
function SWEP:SecondaryAttack()
local trace = { }
trace.start = self.Owner:EyePos()
trace.endpos = trace.start + self.Owner:GetAimVector() * 60
trace.filter = self.Owner
local tr = util.TraceLine( trace )
if ( tr.Entity:IsValid() and ( tr.Entity:IsPlayer() ) ) then
local ply = tr.Entity() -- Declare who ply is.
if( ply:GetNWBool( "FrozenYay" ) == true ) then
ply:SetNWBool( "FrozenYay", false )
ply:Give( "weapon_physcannon" )
ply:Give( "gmod_camera" )
ply:Give( "weapon_physgun" )
ply:Give( "gmod_tool" )
ply:PrintMessage( HUD_PRINTCENTER, "You were unhandcuffed by "..self.Owner:Nick().."." )
else
self.Owner:PrintMessage( HUD_PRINTCENTER, ply:Nick().." isn't handcuffed." )
end
end
end
[/lua]
Fixed tell me how it goes :)
Didnt worked that good s: the handcuffs are not showing
Sorry, you need to Log In to post a reply to this thread.