1. Post #1
    NnyAskC's Avatar
    April 2006
    101 Posts
    I don't know why only some people are affected, but I have no clue what's up that the swep could break a whole gamemode and it only be for SOME people.

    It's basicly a taser edit.

    if ( SERVER ) then
     AddCSLuaFile( "shared.lua" )
     
     SWEP.Weight    = 2
    SWEP.AutoSwitchTo  = true
    SWEP.AutoSwitchFrom  = true
     SWEP.HoldType   = "pistol"
     
    end
    if ( CLIENT ) then
    SWEP.PrintName = "Taser";
    SWEP.Slot = 3;
    SWEP.SlotPos = 1;
    SWEP.DrawAmmo = false;
    SWEP.DrawCrosshair = true;
    
    end
    SWEP.Author = "Joe Mammy";
    SWEP.Contact = "";
    SWEP.Purpose = "Tasering";
    SWEP.Instructions = "Left click to bring down.";
    SWEP.Spawnable   = false
    SWEP.AdminSpawnable  = true
    SWEP.ViewModel   = "models/weapons/v_pistol.mdl"
    SWEP.WorldModel   = "models/weapons/w_pistol.mdl"
    SWEP.Primary.ClipSize  = 1
    SWEP.Primary.DefaultClip = 40
    SWEP.Primary.Automatic  = false
    SWEP.Primary.Ammo   = "357"
    SWEP.Secondary.ClipSize  = -1
    SWEP.Secondary.DefaultClip = -1
    SWEP.Secondary.Automatic = true
    SWEP.Secondary.Ammo   = ""
    local taseredrags = {}
    local taseruniquetimer1 = 0
    local taseruniquetimer2 = 0
    function SWEP:Reload()
     if ( CurTime() < GetGlobalInt("mReloadTimer") ) then
      local mTime = CurTime()-GetGlobalInt("mReloadTimer")
      self.Owner:PrintMessage( HUD_PRINTCENTER, "Tazer recharging...\n"..tostring(math.ceil(mTime*-1)).." seconds left.") 
     else
      self.Weapon:DefaultReload( ACT_VM_RELOAD ) //animation for reloading
     end
    end 
     
     function SWEP:PrimaryAttack()
     if ( !self:CanPrimaryAttack() ) then return end
     local eyetrace = self.Owner:GetEyeTrace(); 
     if !eyetrace.Entity:IsPlayer() then 
      if !eyetrace.Entity:IsNPC() then return end       // Check to see if what the player is aiming at is an NPC or Player
      
     end 
     
    self.Weapon:EmitSound("Weapon_StunStick.Activate") 
     
    if (!SERVER) then return end
     
    distx = eyetrace.Entity:GetPos().x - self.Owner:GetPos().x
    disty = eyetrace.Entity:GetPos().y - self.Owner:GetPos().y
    distz = eyetrace.Entity:GetPos().z - self.Owner:GetPos().z
    distLong = (distx*distx)+(disty*disty)+(distz*distz)
    dist = math.sqrt(distLong)
     if dist > 200 then
     self.Owner:PrintMessage(HUD_PRINTCENTER, "Too Far Away!") 
     return end
     
    self.BaseClass.ShootEffects( self ) 
    self:TakePrimaryAmmo(1) 
     
     
    if eyetrace.Entity:IsPlayer() then  
     self:tasePlayer(eyetrace.Entity)    // If the it is a player then bring them down tranqPlayer()
     SetGlobalInt("mReloadTimer",CurTime()+10)
     end
     if eyetrace.Entity:IsNPC() then
     self:taseNPC(eyetrace.Entity, self.Owner)    // If the it is a NPC then bring them down with tranqNPC()
     SetGlobalInt("mReloadTimer",CurTime()+10)
     end
     end
    
    function SWEP:tasePlayer(ply)
     -- create ragdoll
     local rag = ents.Create( "prop_ragdoll" )
        if not rag:IsValid() then return end
     -- build rag
     rag:SetModel( ply:GetModel() )
        rag:SetKeyValue( "origin", ply:GetPos().x .. " " .. ply:GetPos().y .. " " .. ply:GetPos().z )
     rag:SetAngles(ply:GetAngles())
       
     -- player vars
     rag.taseredply = ply
     table.insert(taseredrags, rag)
      
     -- "remove" player
     ply:StripWeapons()
     ply:DrawViewModel(false)
     ply:DrawWorldModel(false)
     ply:Spectate(OBS_MODE_CHASE)
     ply:SpectateEntity(rag)
     
     -- finalize ragdoll
        rag:Spawn()
        rag:Activate()
     
     -- make ragdoll fall
     rag:GetPhysicsObject():SetVelocity(4*ply:GetVelocity())
     
     -- bring the motherfucker back
         self:setrevivedelay(rag)
     
    end
     
    
    function SWEP:taseNPC(npc, npcShooter)
     -- get info about npc
     local skin = npc:GetSkin()
     local wep = ""
     local possibleWep = ents.FindInSphere(npc:GetPos(),0.01) -- find anything in the center basically
     for k, v in pairs(possibleWep) do 
      if string.find(v:GetClass(),"weapon_") == 1 then 
       wep = v:GetClass()
      end
     end
     local citType = "" -- citizen type
     local citMed = 0 -- is it a medic? assume no
     if npc:GetClass() == "npc_citizen" then
      citType = string.sub(npc:GetModel(),21,21) -- get group number (e.g. models/humans/group0#/whatever)
      if string.sub(npc:GetModel(),22,22) == "m" then citMed = 1 end -- medic skins have an "m" after the number
     end
     -- make ragdoll now that all info is gathered 
     local rag = ents.Create( "prop_ragdoll" )
        if not rag:IsValid() then return end
     
     -- build rag
     rag:SetModel( npc:GetModel() )
        rag:SetKeyValue( "origin", npc:GetPos().x .. " " .. npc:GetPos().y .. " " .. npc:GetPos().z )
     rag:SetAngles(npc:GetAngles())
     
     -- npc vars
     rag.tasewasNPC = true
     rag.tasenpcType = npc:GetClass()
     rag.tasenpcWep = wep
     rag.tasenpcCitType = citType
     rag.tasenpcCitMed = citMed
     rag.tasenpcSkin = skin
     rag.tasenpcShooter = npcShooter
     table.insert(taseredrags, rag)
     
     --finalize
     rag:Spawn()
        rag:Activate()
     
     -- make ragdoll fall
      rag:GetPhysicsObject():SetVelocity(8*npc:GetVelocity())
      
     --remove npc
     npc:Remove()
     self:setrevivedelay(rag)
     
     end
    function SWEP:setrevivedelay(rag)
    if taseruniquetimer1 > 30 then
    taseruniquetimer1 = 0
    end
    taseruniquetimer1 = taseruniquetimer1 + 1
    timer.Create("revivedelay"..taseruniquetimer1, 5, 1, self.taserevive, self, rag ) 
    end
    function SWEP:taserevive(ent)
     -- revive player
     if !ent then return end
     
     if ent.taseredply then
       if ( !ent.taseredply:IsValid() ) then return end
       local phy = ent:GetPhysicsObject()
      ent:SetSolid(SOLID_NONE)
        ent.taseredply:DrawViewModel(true)
     ent.taseredply:DrawWorldModel(true)
     ent.taseredply:Spawn()
     ent.taseredply:SetPos(ent:GetPos())
     ent.taseredply:SetVelocity(ent:GetPhysicsObject():GetVelocity())
    ent.taseredply:SetMoveType(MOVETYPE_WALK)
    ent.taseredply:ConCommand("pp_motionblur 1")
    ent.taseredply:ConCommand("pp_motionblur_addalpha 0.06 ")
    ent.taseredply:ConCommand("pp_motionblur_delay 0")
    ent.taseredply:ConCommand("pp_motionblur_drawalpha 0.99 ")
    if taseruniquetimer2 > 30 then
    taseruniquetimer2 = 0
    end
    taseruniquetimer2 = taseruniquetimer2 + 1
    timer.Create("pauseplayer"..taseruniquetimer2, 3, 1, self.pauseplayer, self, ent.taseredply) 
     -- revive npc
     elseif ent.tasewasNPC then
      local npc = ents.Create(ent.tasenpcType) -- create the entity
      
      util.PrecacheModel(ent:GetModel()) -- precache the model
      npc:SetModel(ent:GetModel()) -- and set it
      local spawnPos = ent:GetPos()+Vector(0,0,0) -- position to spawn it
      
      npc:SetPos(spawnPos) -- position
      npc:SetSkin(ent.tasenpcSkin)
      npc:SetAngles(Angle(0,ent:GetAngles().y,0))
      
      if ent.tasenpcWep != "" then -- if it's an NPC and we found a weapon for it when it was spawned, then
       npc:SetKeyValue("additionalequipment",ent.tasenpcWep) -- give it the weapon
      end
      
      if ent.taseentType == "npc_citizen" then
       npc:SetKeyValue("citizentype",ent.tasenpcCitType) -- set the citizen type - rebel, refugee, etc.
       if ent.tasenpcCitType == "3" && ent.tasenpcCitMed==1 then -- if it's a rebel, then it might be a medic, so check that
        npc:SetKeyValue("spawnflags","131072") -- set medic spawn flag
       end
      end
        
      npc:Spawn()
      npc:Activate()
      
    cleanup.Add (uplayer, "NPC", npc);
    undo.Create ("Tasered NPC");
    undo.AddEntity (npc);
    undo.SetPlayer (ent.tasenpcShooter);
    undo.Finish();
      
     -- don't deal with other ents
     else 
      return
     end
     
      for k, v in pairs(taseredrags) do 
      if v == ent then 
        table.remove( taseredrags, k ) 
      end
     end
     ent:Remove()
    end
    
    function SWEP:pauseplayer(ply)
    ply:SetMoveType(MOVETYPE_WALK )
    ply:ConCommand("pp_motionblur 0")
    end
     
    
     function SWEP:SecondaryAttack()
     end
    

  2. Post #2
    wishbone's Avatar
    October 2008
    454 Posts
    How is it breaking for people? Any lua errors for them at all? Also use [lua] tags.
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Informative Informative x 1 (list)

  3. Post #3
    NnyAskC's Avatar
    April 2006
    101 Posts
    My bad, edited to LUA tags. I didn't even know they existed. =P.
    Here is all someone recorded. (It worked fine for me or I'd have more info)
    I was told that the display looked like sandbox, no Q menu or TAB menu and no toolgun. Only physgun and gravgun. He was still able to spawn stoves with a bind he had though.
    Also worth saying, the gamemode was DarkRP. The second I removed the taser, things worked fine again.


    GamemodeError(RenderScreenspaceEffects): No Gamemode!
    GamemodeError(PostRenderVGUI): No Gamemode!
    GamemodeError(Think): No Gamemode!
    GamemodeError(Tick): No Gamemode!
    GamemodeError(DrawMonitors): No Gamemode!
    GamemodeError(RenderScreenspaceEffects): No Gamemode!
    GamemodeError(PostRenderVGUI): No Gamemode!
    GamemodeError(Think): No Gamemode!
    GamemodeError(DrawMonitors): No Gamemode!
    GamemodeError(RenderScreenspaceEffects): No Gamemode!
    GamemodeError(PostRenderVGUI): No Gamemode!
    GamemodeError(Think): No Gamemode!
    GamemodeError(Tick): No Gamemode!
    GamemodeError(DrawMonitors): No Gamemode!
    GamemodeError(RenderScreenspaceEffects): No Gamemode!
    GamemodeError(PostRenderVGUI): No Gamemode!
    GamemodeError(Think): No Gamemode!
    

  4. Post #4
    PencilOnDesk's Avatar
    October 2011
    120 Posts
    They uploaded your SWEP and did not bother to update the cache on their FastDL, most likely.
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Disagree Disagree x 1 (list)

  5. Post #5
    NnyAskC's Avatar
    April 2006
    101 Posts
    It doesn't use FastDL.

  6. Post #6
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,852 Posts
    then they have downloads disabled

  7. Post #7
    HTMLfreak's Avatar
    October 2011
    162 Posts
    Or the coding isn't sending the SWEP to the client, it MIGHT be possible to use AddCSFile to change this, but im not 100% positive
    Reply With Quote Edit / Delete Reply Windows XP United Kingdom Show Events Disagree Disagree x 2 (list)

  8. Post #8
    NnyAskC's Avatar
    April 2006
    101 Posts
    then they have downloads disabled
    Looked at their server.cfg unless it needs to be somewhere else too, it seems fine. Should I have them add it to autoexe incase it's not reading from this correctly?

    //Downloading
    sv_downloadurl ""
    sv_allowdownload 1
    sv_allowupload 1
    net_maxfilesize 20