Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Doors - <USER>'s Custom - By KrazziPro
- @inputs Activate AddPlayer DelPlayer Player:entity
- @outputs Activated:number Activator:entity Range:number
- @persist Settings:array Whitelist:array LastMat:string Sound
- @trigger all
- #————————————-
- #When you save your edited version. #Change the <USER> at “@name Doors - #<USER>'s Custom - By KrazziPro” to #your Username.
- #————————————-
- #Find the section in the beginning of the #code that says this. Copy and paste it #with your friends SteamID. Please do not #remove mine as I am the creator of the #code and if I ever show on the server. I #am #no threat in-game and come into #you’re #base peacefully.
- #[
- ————————————-
- if(changed(players():count())) {
- for(I=1,players():count()) {
- if(players():entity(I):steamID() == "STEAMID") { ##<USER>'s SteamID
- Whitelist:pushEntity(players():entity(I))
- }
- }
- }
- ————————————-
- ]
- if(changed(players():count())) {
- for(I=1,players():count()) {
- if(players():entity(I):steamID() == "STEAM_0:1:56991795") { ##KrazziPro's SteamID
- Whitelist:pushEntity(players():entity(I))
- }
- }
- }
- if(changed(players():count())) {
- for(I=1,players():count()) {
- if(players():entity(I):steamID() == "STEAMID") { ##<USER>'s SteamID
- Whitelist:pushEntity(players():entity(I))
- }
- }
- }
- # Settings
- if( first() | dupefinished() ) {
- Settings[ 1, number ] = 1 #Whitelist
- Settings[ 2, number ] = 1 #Halo
- Settings[ 3, number ] = 100 #Range
- Settings[ 4, number ] = 1 #Fade
- Settings[ 5, number ] = 1 #Print
- Settings[ 6, number ] = 1 #Sound
- LastMat = entity():isWeldedTo():getMaterial()
- }
- # Activate
- function activate( ) {
- if ( Settings[ 3, number ] ) {
- holoColor( 1, vec( 0, 255, 0 ) )
- }
- if ( Settings[ 4, number ] ) {
- entity():isWeldedTo():propNotSolid( 1 )
- entity():isWeldedTo():setMaterial( "sprites/heatwave" ) #
- }
- if ( Sound == 0 && Settings[ 6, number ] ) {
- soundStop( 1 )
- soundPlay( 1, soundDuration( "doors/doorstop1.wav" ), "doors/doorstop1.wav" ) #play the sound
- Sound = 1
- }
- }
- # Deactivate
- function deactivate( ) {
- if ( Settings[ 3, number ] ) {
- holoColor( 1, vec( 255, 0, 0 ) )
- }
- if ( Settings[ 4, number ] ) {
- entity():isWeldedTo():propNotSolid( 0 )
- Mat = entity():isWeldedTo():getMaterial()
- if ( Mat != LastMat && Mat != "" && Mat != "sprites/heatwave" ) {
- LastMat = Mat
- }
- entity():isWeldedTo():setMaterial( LastMat )
- if ( Sound == 1 && Settings[ 6, number ] ) {
- soundStop( 1 )
- soundPlay( 1, soundDuration( "npc/turret_floor/retract.wav" ), "npc/turret_floor/retract.wav" ) #play the sound
- Sound = 0
- }
- }
- }
- # Args
- function showargs( ) {
- if( Settings[ 5, number ] ) {
- printColor( vec( 255, 255, 0 ), "command: /doors" )
- printColor( vec( 255, 255, 0 ), "args: add (player), del (player), range (100 - 5000), whitelist (on/off), halo (on/off), fade (on/off), help (arg)." )
- }
- }
- function showhelp( ) {
- if ( Settings[ 5, number ] ) {
- printColor( vec( 255, 255, 0 ), "add/del (player):" )
- printColor( vec( 255, 255, 0 ), "Adds/Removes a player to the whitelist." )
- printColor( vec( 255, 255, 0 ), "-----------------------" )
- printColor( vec( 255, 255, 0 ), "range (100 - 5000):" )
- printColor( vec( 255, 255, 0 ), "Sets the range." )
- printColor( vec( 255, 255, 0 ), "-----------------------" )
- printColor( vec( 255, 255, 0 ), "whitelist (on/off):" )
- printColor( vec( 255, 255, 0 ), "Turns off/on the whitelist." )
- printColor( vec( 255, 255, 0 ), "-----------------------" )
- printColor( vec( 255, 255, 0 ), "halo (on/off):" )
- printColor( vec( 255, 255, 0 ), "Turns off/on the halo." )
- printColor( vec( 255, 255, 0 ), "-----------------------" )
- printColor( vec( 255, 255, 0 ), "fade (on/off):" )
- printColor( vec( 255, 255, 0 ), "Turns off/on the solidity of the prop welded to." )
- }
- }
- # Add halo
- function addhalo( ) {
- holoCreate( 1 )
- holoModel( 1, "hqcylinder" )
- holoScale( 1, vec( 1, 1, 1 ) )
- holoAng( 1, entity():angles() )
- holoPos( 1, entity():toWorld( vec( 0, 0, 0 ) ) )
- }
- # Add to whitelist
- function wladd( Player:entity ) {
- Added = 0
- for( I = 1, Whitelist:count() ) {
- if( Whitelist[ I, entity ] == Player ) {
- Added = 1
- break
- }
- }
- if ( Added == 0 ) {
- Whitelist:pushEntity( Player )
- if( Settings[ 5, number ] ) {
- printColor( vec( 0, 255, 0 ), "Doors: Added '" + Player:name() + "' to your doors!" )
- concmd( "ulx psay " + Player:name() + " [Doors]: You been added to my doors!" )
- }
- }else{
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: '" + Player:name() + "' has already been added!" ) }
- }
- }
- # Remove to whitelist
- function wldel( Player:entity ) {
- Removed = 0
- for( I = 1, Whitelist:count() ) {
- if( Whitelist[ I, entity ] == Player ) {
- Removed = 1
- Whitelist:remove( I )
- }
- }
- if ( Removed == 1 ) {
- if( Settings[ 5, number ] ) {
- printColor( vec( 0, 255, 0 ), "Doors: Removed '" + Player:name() + "' from your doors." )
- concmd( "ulx psay " + Player:name() + " [Doors]: You been removed from my doors!" )
- }
- }else{
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: '" + Player:name() + "' is not on the whitelist!" ) }
- }
- }
- # Setup
- if( first() | duped() ) {
- runOnTick(1)
- runOnChat(1)
- if( Settings[ 2, number ] ) {
- addhalo()
- }
- if( Settings[ 5, number ] ) { printColor( vec( 255, 255, 0 ), "Doors Usage:" ) }
- showargs( )
- }
- # Chat Commands
- if ( chatClk( owner() ) && owner():lastSaid():explode(" "):string( 1 ) == "/doors" ) {
- hideChat(1)
- Args = owner():lastSaid():explode(" ")
- switch( Args:string( 2 ) ) {
- case "add",
- if ( Settings[1, number ] ) {
- Player = findPlayerByName( Args:concat( " ", 3 ) )
- if( Player:isPlayer() ) {
- wladd( Player )
- }else{
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Can not find player '" + Args:concat( " ", 3 ) + "'!" ) }
- }
- }else{
- if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Whitelist deactivated!" ) }
- },
- break
- case "del",
- if ( Settings[ 1, number ] ) {
- Player = findPlayerByName( Args:concat( " ", 3 ) )
- if( Player:isPlayer() ) {
- wldel( Player )
- }else{
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Can not find player '" + Args:concat( " ", 3 ) + "'!" ) }
- }
- }else{
- if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Whitelist deactivated!" ) }
- },
- break
- case "clear",
- Whitelist:clear()
- if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Whitelist cleared!" ) },
- break
- case "help",
- showhelp(),
- break
- case "range",
- if ( Args:string( 3 ):toNumber() < 100 && Args:string( 3 ):toNumber() > 1000 ) {
- Settings[ 3, number ] = Args:string(3):toNumber()
- if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Range updated to '" + Args:string( 3 ) + "'!" ) }
- }else{
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: '" + Args:string( 3 ) + "' is an invalid number!" ) }
- },
- break
- case "whitelist",
- if ( Args:string( 3 ) == "on" ) {
- if ( Settings[ 1, number ] ){
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Whitelist already activated!" ) }
- }else{
- Settings[ 1, number ] = 1
- if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Whitelist activated!" ) }
- }
- }elseif(Args:string( 3 ) == "off" ) {
- if ( !Settings[ 1, number ] ){
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Whitelist already deactivated!" ) }
- }else{
- Settings[ 1, number ] = 0
- Whitelist:clear()
- if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Whitelist deactivated!" ) }
- }
- }else{
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: unknown usage!" ) }
- showargs( )
- },
- break
- case "halo",
- if ( Args:string( 3 ) == "on" ) {
- if ( Settings[ 2, number ] ){
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Halo already activated!" ) }
- }else{
- Settings[ 2, number ] = 1
- addhalo()
- if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Halo activated!" ) }
- }
- }elseif(Args:string( 3 ) == "off" ) {
- if ( !Settings[ 2, number ] ){
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Halo already deactivated!" ) }
- }else{
- Settings[ 2, number ] = 0
- holoDelete(1)
- if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Halo deactivated!" ) }
- }
- }else{
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: unknown usage!" ) }
- showargs( )
- },
- break
- case "fade",
- if ( Args:string( 3 ) == "on" ) {
- if ( Settings[ 4, number ] ){
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Fade already activated!" ) }
- }else{
- Settings[ 4, number ] = 1
- if( Settings[ 5, number ] ) { printColor( "Doors: Fade activated!" ) }
- }
- }elseif( Args:string( 3 ) == "off" ) {
- if ( !Settings[ 4, number ] ){
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Fade already deactivated!" ) }
- }else{
- Settings[ 4, number ] = 0
- if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Fade deactivated!" ) }
- }
- }else{
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Unknown usage!" ) }
- showargs( )
- },
- break
- default,
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Unknown usage!" ) }
- showargs( )
- break
- }
- }else{
- hideChat(0)
- }
- # Update Halo POS
- if ( Settings[ 2, number ] ) {
- holoAng( 1, entity():angles() )
- holoPos( 1, entity():toWorld( vec( 0, 0, 0 ) ) )
- }
- # Wire Inputs: AddPlayer
- if ( AddPlayer ) {
- if ( Player:isPlayer() ) {
- wladd( Player )
- }else{
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Player not valid!" ) }
- }
- }
- # Wire Inputs: DelPlayer
- if ( DelPlayer ) {
- if ( Player:isPlayer() ) {
- wldel( Player )
- }else{
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Player not valid!" ) }
- }
- }
- # Wire Outputs
- Activated = 0
- Range = Settings[ 3, number ]
- # Loop for players
- if( Settings[ 1, number ] ) {
- for( I = 1, Whitelist:count() ) {
- if ( !Whitelist[ I, entity ]:isPlayer() ) {
- Whitelist:remove(I)
- if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Player removed! ( No longer valid player )" ) }
- }else{
- if( Whitelist[ I, entity ]:pos():distance( entity():pos() ) < Settings[ 3, number ] ) {
- Activated = 1
- Activator = Whitelist[ I, entity ]
- }
- }
- }
- }
- # Always let owner in
- if( owner():pos():distance( entity():pos() ) < Settings[ 3, number ] ) {
- Activated = 1
- Activator = owner()
- }
- # Do Functions
- if ( Activated || Activate ) {
- activate()
- }else{
- deactivate()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement