Set physgun to default weapon

This commit is contained in:
Redox 2024-10-29 19:04:40 +01:00 committed by GitHub
parent 6519f837b4
commit 9be414493d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -172,6 +172,12 @@ local function setSpawnProtectionForPvpSpawn( ply )
if not isValidPlayer( ply ) then return end
if not playerIsInPvp( ply ) then return end
timer.Simple( 0.11, function()
if not IsValid( ply ) then return end
ply:Give( "weapon_physgun" )
ply:SelectWeapon( "weapon_physgun" )
end )
if playerSpawnedAtEnemySpawnPoint( ply ) then return end
setSpawnProtection( ply )
@ -229,6 +235,14 @@ hook.Add( "PlayerExitPvP", "CFCremoveSpawnProtectionOnExitPvP", function( ply )
instantRemoveSpawnProtection( ply, "You've left pvp mode and lost spawn protection." )
end )
hook.Add( "PlayerSwitchWeapon", "CFCspawnProtectionSwitch", function( ply, _, wep )
if not playerHasSpawnProtection( ply ) then return end
if not weaponIsAllowed( wep ) then
instantRemoveSpawnProtection( ply, "You've switched weapons and lost spawn protection" )
end
end )
-- Remove spawn protection when player enters vehicle
hook.Add( "PlayerEnteredVehicle", "CFCremoveSpawnProtectionOnEnterVehicle", function( ply )
if not playerHasSpawnProtection( ply ) then return end
@ -236,6 +250,12 @@ hook.Add( "PlayerEnteredVehicle", "CFCremoveSpawnProtectionOnEnterVehicle", func
instantRemoveSpawnProtection( ply, "You've entered a vehicle and lost spawn protection." )
end )
hook.Add( "CLoadoutOverridePreferredWeapon", "CFCSpawnProtection", function( ply, prefWeapon )
if not playerHasSpawnProtection( ply ) then return end
return "weapon_physgun"
end )
-- Physgun activity
hook.Add( "OnPhysgunPickup", "CFCremoveSpawnProtectionOnPhysgunPickup", function( ply )
if not playerHasSpawnProtection( ply ) then return end