Ergebnis 1 bis 4 von 4

Thema: Problem mit erstellter Waffe auf dedicated server

  1. #1

    Standard Problem mit erstellter Waffe auf dedicated server

    Hallo,

    ich habe vor kurzem mit lua angefangen und mir mit diesem code eine Waffe erstellt: http://wiki.garrysmod.com/page/Chair_Throwing_Gun

    Im Singleplayer funktioniert die Waffe so wie sie sollte, sie schießt mit linkem und rechtem Mausklick Stühle. Dann habe ich die Waffe auf meinen dedicated Server geladen und sie funktioniert nicht mehr so. Mit der linken Maustaste spawnt der Stuhl vor mir und fällt einfach runter während bei der rechten Maustaste der Stuhl viel zu stark weggeschleudert wird. Warum ist das so und wie kann ich es beheben?

    Mfg Maik


    Ich habe den Code etwas abgeändert als wie er da auf der Website steht.
    Mein Code:
    Code:
    SWEP.PrintName			= "Chair Thrower"			
    SWEP.Author			= "( your name )"
    SWEP.Instructions		= "Left mouse to fire a chair!"
    SWEP.Spawnable = true
    
    SWEP.Primary.ClipSize		= -1
    SWEP.Primary.DefaultClip	= -1
    SWEP.Primary.Automatic		= true
    SWEP.Primary.Ammo		= "none"
    
    SWEP.Secondary.ClipSize		= -1
    SWEP.Secondary.DefaultClip	= -1
    SWEP.Secondary.Automatic	= false
    SWEP.Secondary.Ammo		= "none"
    
    SWEP.Weight			= 5
    SWEP.AutoSwitchTo		= false
    SWEP.AutoSwitchFrom		= false
    
    SWEP.Slot			= 1
    SWEP.SlotPos			= 1
    SWEP.DrawAmmo			= false
    SWEP.DrawCrosshair		= true
    
    SWEP.ViewModel			= "models/weapons/v_pistol.mdl"
    SWEP.WorldModel			= "models/weapons/w_pistol.mdl"
    
    local ShootSound = Sound( "Metal.SawbladeStick" )
    
    --
    -- Called when the left mouse button is pressed
    --
    function SWEP:PrimaryAttack()
    
    	-- This weapon is 'automatic'. This function call below defines
    	-- the rate of fire. Here we set it to shoot every 0.5 seconds.
    	self:EmitSound( ShootSound )
    	self.Weapon:SetNextPrimaryFire( CurTime() + 0.25 )	
    
    	-- Call 'ThrowChair' on self with this model
    	self:ThrowChair( "models/props/cs_office/Chair_office.mdl" )
    
    end
    	
    
    --
    -- Called when the rightmouse button is pressed
    --
    function SWEP:SecondaryAttack()
    
    	-- Note we don't call SetNextSecondaryFire here because it's not
    	-- automatic and so we let them fire as fast as they can click.	
    
    	-- Call 'ThrowChair' on self with this model
    	self:ThrowChair( "models/props_c17/FurnitureChair001a.mdl" )
    
    end
    
    --
    -- A custom function we added. When you call this the player will fire a chair!
    --
    function SWEP:ThrowChair( model_file )
    
    	-- 
    	-- Play the shoot sound we precached earlier!
    	--
    	
    
    	
    	--
    	-- If we're the client ) then this is as much as we want to do.
    	-- We play the sound above on the client due to prediction.
    	-- ( if ( we didn't they would feel a ping delay during multiplayer )
    	--
    	if ( CLIENT ) then return end
    
    	--
    	-- Create a prop_physics entity
    	--
    	local ent = ents.Create( "prop_physics" )
    
    	--
    	-- Always make sure that created entities are actually created!
    	--
    	if ( !IsValid( ent ) ) then return end
    
    	--
    	-- Set the entity's model to the passed in model
    	--
    	ent:SetModel( model_file )
    	
    	--
    	-- Set the position to the player's eye position plus 16 units forward.
    	-- Set the angles to the player'e eye angles. Then spawn it.
    	--
    	ent:SetPos( self.Owner:EyePos() + ( self.Owner:GetAimVector() * 32 ) )
    	ent:SetAngles( self.Owner:EyeAngles() )
    	ent:Spawn()
    	
    
    	--
    	-- Now get the physics object. Whenever we get a physics object
    	-- we need to test to make sure its valid before using it.
    	-- If it isn't ) then we'll remove the entity.
    	--
    	local phys = ent:GetPhysicsObject()
    	if ( !IsValid( phys ) ) then ent:Remove() return end
    	
    	
    	--
    	-- Now we apply the force - so the chair actually throws instead 
    	-- of just falling to the ground. You can play with this value here
    	-- to adjust how fast we throw it.
    	--
    	local velocity = self.Owner:GetAimVector()
    	velocity = velocity * 1000000 
    	--velocity = velocity + ( VectorRand() * 10 ) -- a random element
    	phys:ApplyForceCenter( velocity )
    	
    	--
    	-- Assuming we're playing in Sandbox mode we want to add this
    	-- entity to the cleanup and undo lists. This is done like so.
    	--
    	cleanup.Add( self.Owner, "props", ent )
    	
    	undo.Create( "Thrown_Chair" )
    		undo.AddEntity( ent )
    		undo.SetPlayer( self.Owner )
    	undo.Finish()
    end

  2. #2
    Avatar von Mentos
    Registriert seit
    08.09.2007
    Ort
    München

    Standard AW: Problem mit erstellter Waffe auf dedicated server

    Dem Code zufolge gibt es keinen unterscheid zwischen Rechts- und Linksklick abgesehen von der Automatik. Daher kann deine Aussage, dass der Stuhl bei einer Taste fällt und bei der andreren weggeschossen wird nicht stimmen.
    Vergewissere dich, dass du nicht 2 verschiedene Versionen dieses Scripts hast. Lade das richtige einfach nocheinmal auf den Server und es sollte funktionieren.

    Gruß
    Zitat Zitat von pacmcmax Beitrag anzeigen
    ich kann mich nicht in kurzen worten zusammen fassen

  3. #3

    Standard AW: Problem mit erstellter Waffe auf dedicated server

    Das ist ja grade das Problem, es macht halt in meinen Augen auch keinen Unterschied aber es ist leider so. Im Singleplayer werden beide gleich weggeschossen, auf dem dedicated Server wird links der Stuhl nur fallen gelassen und rechts viel stärker weggeschossen als im Singleplayer. Ich hab das Script genau so auf den Server kopiert.

  4. #4

    Standard AW: Problem mit erstellter Waffe auf dedicated server

    Hat sich erledigt, ich weiß nicht woran es lag, hab das addon komplett umgeschrieben und jetzt gehts.

Ähnliche Themen

  1. Dedicated Server IP Problem
    Von timontro im Forum Server
    Antworten: 1
    Letzter Beitrag: 15.01.2011, 15:20
  2. Dedicated Server IP Problem
    Von timontro im Forum Hilfe & Support
    Antworten: 0
    Letzter Beitrag: 20.12.2010, 18:05
  3. Problem mit dedicated server!
    Von coolman3 im Forum Server
    Antworten: 9
    Letzter Beitrag: 26.07.2007, 17:25
  4. Dedicated Server Problem
    Von Torekk im Forum Server
    Antworten: 4
    Letzter Beitrag: 14.01.2007, 01:34
  5. Dedicated Server Problem
    Von W|CK3D im Forum Hilfe & Support
    Antworten: 0
    Letzter Beitrag: 23.12.2006, 04:21

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •