Add limits & dupe support

This commit is contained in:
StyledStrike 2023-07-14 18:44:03 -03:00
parent 5c41429977
commit 3963e9e16b
6 changed files with 36 additions and 8 deletions

View File

@ -2,18 +2,34 @@ AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( "shared.lua" )
function ENT:SpawnFunction( ply, tr )
if not tr.Hit then return end
local function MakeKeyboardSpawner( ply, data )
if IsValid( ply ) and not ply:CheckLimit( "musical_keyboards" ) then return end
local ent = ents.Create( self.ClassName )
ent:SetPos( tr.HitPos )
ent:SetAngles( Angle( 0, ply:EyeAngles().y + 90, 0 ) )
local ent = ents.Create( data.Class )
if not IsValid( ent ) then return end
ent:SetPos( data.Pos )
ent:SetAngles( data.Angle )
ent:Spawn()
ent:Activate()
ply:AddCount( "musical_keyboards", ent )
return ent
end
duplicator.RegisterEntityClass( "ent_musical_keyboard", MakeKeyboardSpawner, "Data" )
function ENT:SpawnFunction( ply, tr )
if tr.Hit then
return MakeKeyboardSpawner( ply, {
Pos = tr.HitPos,
Angle = Angle( 0, ply:EyeAngles().y + 90, 0 ),
Class = self.ClassName
} )
end
end
function ENT:Initialize()
self:SetModel( "models/styledstrike/musical_keyboard.mdl" )
self:PhysicsInit( SOLID_VPHYSICS )

View File

@ -3,6 +3,14 @@ resource.AddWorkshop( "2656563609" )
util.AddNetworkString( "mkeyboard.set_entity" )
util.AddNetworkString( "mkeyboard.notes" )
CreateConVar(
"sbox_maxmusical_keyboards",
"3",
bit.bor( FCVAR_ARCHIVE, FCVAR_NOTIFY, FCVAR_REPLICATED ),
"Maximum musical keyboards a player can create",
0
)
local function FindBroadcastTargets( pos, radius, ignore )
-- make the radius squared, to compare with DistToSqr (faster)
radius = radius * radius

View File

@ -25,4 +25,5 @@ mk.sheets=Sheets
mk.sheets.hidden=(Hidden)
mk.channels=MIDI Channels
mk.channels.usecurrent=<Use current instrument>
mk.channels.mute=<Mute this channel>
mk.channels.mute=<Mute this channel>
SBoxLimit_musical_keyboards=You've hit the Musical Keyboard limit!

View File

@ -27,4 +27,5 @@ mk.sheets=Partitions
mk.sheets.hidden=(Invisible)
mk.channels=Canaux MIDI
mk.channels.usecurrent=<Utiliser l'instrument actuel>
mk.channels.mute=<Assourdir>
mk.channels.mute=<Assourdir>
SBoxLimit_musical_keyboards=Vous avez atteint la limite du clavier musical!

View File

@ -25,4 +25,5 @@ mk.sheets=Partituras
mk.sheets.hidden=(Nenhuma)
mk.channels=Canais MIDI
mk.channels.usecurrent=<Usar instrumento atual>
mk.channels.mute=<Silenciar este canal>
mk.channels.mute=<Silenciar este canal>
SBoxLimit_musical_keyboards=Você atingiu o limite de teclados!

View File

@ -26,3 +26,4 @@ mk.sheets.hidden=(Скрытый)
mk.channels=MIDI-каналы
mk.channels.usecurrent=<Использовать текущий инструмент>
mk.channels.mute=<Заглушить этот канал>
SBoxLimit_musical_keyboards=Вы исчерпали лимит музыкальной клавиатуры!