PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : SWep: Remove | UnOwn - SWEP



Stoned
12.11.2008, 21:36
if (SERVER) then
AddCSLuaFile( "shared.lua" )

SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
end

if ( CLIENT ) then
SWEP.Slot = 2
SWEP.SlotPos = 10
SWEP.IconLetter = "x"
SWEP.IconFont = "CSSelectIcons"
SWEP.BounceWeaponIcon = true
SWEP.DrawWeaponInfoBox = false
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
SWEP.ViewModelFOV = 75
SWEP.ViewModelFlip = false
SWEP.CSMuzzleFlashes = true
SWEP.SwayScale = 1.0
SWEP.BobScale = 1.0
SWEP.WepSelectIcon = surface.GetTextureID( "weapons/swep" )
--SWEP.SpeechBubbleLid = surface.GetTextureID( "gui/speech_lid" )

surface.CreateFont( "csd", ScreenScale( 60 ), 500, true, true, "CSSelectIcons" )
surface.CreateFont( "HalfLife2", ScreenScale( 60 ), 500, true, true, "HL2SelectIcons" )
end

SWEP.PrintName = "Multigun"
SWEP.Author = "Stoned"
SWEP.Contact = ""
SWEP.Purpose = "Control Props"
SWEP.Instructions = "Press Left to unown a prop | right to delete it!"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.ViewModel = "models/weapons/v_357.mdl"
SWEP.WorldModel = "models/weapons/w_357.mdl"

SWEP.Primary.Delay = 0.15
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 = false
SWEP.Secondary.Ammo = "none"

module( "UPS", package.seeall )

function SWEP:PrimaryAttack()
if CLIENT then return end
local trace1= {}
trace.start = self.Owner:GetShootPos()
trace.endpos = trace.start + (self.Owner:GetAimVector() * 500)
trace.mask = MASK_SOLID
trace.filter = self.Owner
local tr = util.TraceLine(trace)
if !tr.Entity then return false end
local ent = tr.Entity
if ent:IsValid() ~= true then return false end
if ent:GetClass() == "player" then return false end
if ent:GetClass() == "worldspawn" then return false end
if ent:GetClass() == "gf_bb_spawner" then return false end
if ent:GetClass() == "gf_playerspawn" then return false end
if ent:GetClass() == "func_brush" then return false end
local name = "Unknown" -- Default
local id = ent:UPSGetOwner()
if id == OWNERID_MAP then
name = "1"
elseif id == OWNERID_UPFORGRABS then
name = "2"
elseif id == OWNERID_DEFER then
name = "3"
else
name = nameFromID( id ) or name -- Using "or name" in case we get nil back
end
if name == self.Owner:Name() or self.Owner:IsSuperAdmin() then
self.Owner:EmitSound(Sound("weapons/357/357_spin1.wav"))
ent:UPSClearOwner()
self.Owner:PrintMessage( HUD_PRINTTALK, "Prop has been Cleared!" )
end

self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) -- View model animation
--self.Owner:MuzzleFlash() -- Crappy muzzle light
self.Owner:SetAnimation( PLAYER_ATTACK1 ) -- 3rd Person Animation
end

function SWEP:SecondaryAttack()
if CLIENT then return end
local trace = {}
trace.start = self.Owner:GetShootPos()
trace.endpos = trace2.start + (self.Owner:GetAimVector() * 500)
trace.mask = MASK_SOLID
trace.filter = self.Owner
local tr = util.TraceLine(trace)
if !tr.Entity then return false end
local ent = tr.Entity
if ent:IsValid() ~= true then return false end
if ent:GetClass() == "player" then return false end
if ent:GetClass() == "worldspawn" then return false end
if ent:GetClass() == "gf_bb_spawner" then return false end
if ent:GetClass() == "gf_playerspawn" then return false end
if ent:GetClass() == "func_brush" then return false end
local name = "Unknown" -- Default
local id = ent:UPSGetOwner()
if id == OWNERID_MAP then
name = "1"
elseif id == OWNERID_UPFORGRABS then
name = "2"
elseif id == OWNERID_DEFER then
name = "3"
else
name = nameFromID( id ) or name -- Using "or name" in case we get nil back
end
if name == self.Owner:Name() or name == "2" or self.Owner:IsSuperAdmin() then
self.Owner:EmitSound(Sound("ambient/energy/zap"..math.random(1,3)..".wav"))
ent:Remove()
end

self.Weapon:SendWeaponAnim( ACT_VM_SECONDARYATTACK ) -- View model animation
--self.Owner:MuzzleFlash() -- Crappy muzzle light
self.Owner:SetAnimation( PLAYER_ATTACK2 ) -- 3rd Person Animation
end


Das Problem ist, sie funktioniert ned =|

Pac_187
12.11.2008, 21:40
Hey ich habe die Lösung!

Es liegt am Code! :gmod:

Edit:
Wie wäre es wenn du mal 'n paar mehr Informationen rausrückst?

Was soll das Teil machen?
Was funktioniert genau nicht?

Stoned
13.11.2008, 12:21
Hmm, es soll mit PrimaryAttack den Owner des Props loeschen ( Up for grabs ... )
Falls man Admin ist macht es den OwnerCheck ned

Mit SecondaryAttack soll es das prop loeschen.

Es funktioniert nichts - kein Error - die SWEP wird nicht geladen.

€dit: Ich benutze UPS da ich zurzeit noch nicht ein eigenes Prop-Protect Script habe, daher die functions ...

Pac_187
13.11.2008, 16:34
Wieso machst du das ganze nicht als STOOL?

Ich versuche mich mal für dich dran,
allerdings musst du dann diese PropProtection Zeugs selber reinbauen ;)

Stoned
13.11.2008, 17:15
Wieso machst du das ganze nicht als STOOL?


Weil es nicht fuer SandBox ist.

€dit: zuerst war es nur als Remover, also nur PrimaryAttack und da ging das ganze noch,
jetzt hab ich Secondary geadded und nun ist es kaputt =(

RP-01
15.11.2008, 11:24
Also wenn das removen geklappt hat dann kann es ja bloß am ownen liegen.

ich hab deinen Code mal kopiert und UPS gedownloadet die Waffe is nicht erschienen!

Ich hab das ding mal mit nem besseren code zum removen versehen und sonst noch umgeändert das removen hat dann geklappt aber UPS lässt das ownen nicht zu,das kannst du mit UPS vergessen , denn ganz oben in der Console hat gestanden das diese ganzen "OWNERID_" sachen nicht existieren.

Versuchs mal nochmal und guck was passiert

Mfg,
RP-01