Эта тема аналогична теме "Вопрос-ответ", но вопросы будут не про гмод, а про аддоны. Точнее по их созданию и модернизации. НЕЛЬЗЯ спрашивать про установку и вылеты аддонов которые вы скачали! Не по теме: "Я скачал ваир, а инструменты не работают!" По теме: "Я хочу добавить в свой аддон иконку для меню спавна, но не могу понять как это сделать. Что нужно писать в луа? Или как это делают?" Если тема будет полезна, закрепите. Если нет, то можете удалить.
Вот мой вопрос: Как добавить в оружие иконку, которая будет при выборе пушки (Например когда с физ гана на тул ган переключаешь)? Пытался взять код из других аддонов, пушка ломалась. Вот код луа:
local ShootSound = Sound( "weapons/kaspersky/kaspersky.wav" ) local ShootSound02 = Sound( "weapons/kaspersky/kaspersky1.wav" )
-- -- 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.Weapon:SetNextPrimaryFire( CurTime() + 2.5 )
-- Call 'ThrowChair' on self with this model local ent = self:ThrowMonitor( "models/Shurik1236models/kaspersky/kasperskylogo.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 local ent = self:ThrowChair( "models/Shurik1236models/kaspersky/kasperskylogo.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! --
local Num = math.random(1,2)
if Num == 1 then self:EmitSound( ShootSound ) elseif Num == 2 then self:EmitSound( ShootSound02 )
end
-- -- 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() * 16 ) ) 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 * 3000 velocity = velocity + ( VectorRand() * 2 ) -- a random element velocity = velocity * phys:GetMass() 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( "Monitor" ) undo.AddEntity( ent ) undo.SetPlayer( self.Owner ) undo.Finish()
timer.Simple(2.5, function() ent:Remove() end) return ent
end
function SWEP:ThrowMonitor( model_file )
-- -- Play the shoot sound we precached earlier! --
local Num = math.random(1,2)
if Num == 1 then self:EmitSound( ShootSound ) elseif Num == 2 then self:EmitSound( ShootSound02 )
end
-- -- 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() * 16 ) ) 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 * 3000 velocity = velocity + ( VectorRand() * 2 ) -- a random element velocity = velocity * phys:GetMass() 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( "Monitor" ) undo.AddEntity( ent ) undo.SetPlayer( self.Owner ) undo.Finish()
timer.Simple(10.0, function() ent:Remove() end) return ent
Shurik123, Я так смотрю код без базы , я на таком делал оружки на 10-й гмод , только вместо пропов брал пули. А про иконки , дело в том что название иконки надо писать в точности по названию луа кода в оружие , тоесть берешь название папки где твой свеп :
А потом здесь создай свою иконку размером , как спрей , ну и вообщем вот :
YaGOOBian, Ладно, фиг с этой иконкой. Теперь проблема серьёзней. Я изменил модель, на модель из CSS. Дак этот монитор разбивается. Конечно об бошку зомби мониторы бить это довольно весело, но из карты получается свалка! Удаляются только целые мониторы, а вот обломки нет! Плюс надпись об ошибке скрипта вылазит. Как это исправить?