Advertisement
KrazziPro

Doors custom by KrazziPro

Apr 24th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.98 KB | None | 0 0
  1. @name Doors - <USER>'s Custom - By KrazziPro
  2. @inputs Activate AddPlayer DelPlayer Player:entity
  3. @outputs Activated:number Activator:entity Range:number
  4. @persist Settings:array Whitelist:array LastMat:string Sound
  5. @trigger all
  6.  
  7. #————————————-
  8. #When you save your edited version. #Change the <USER> at “@name Doors - #<USER>'s Custom - By KrazziPro” to #your Username.
  9. #————————————-
  10. #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.
  11. #[
  12. ————————————-
  13. if(changed(players():count())) {
  14. for(I=1,players():count()) {
  15. if(players():entity(I):steamID() == "STEAMID") { ##<USER>'s SteamID
  16. Whitelist:pushEntity(players():entity(I))
  17. }
  18. }
  19. }
  20. ————————————-
  21. ]
  22.  
  23.  
  24. if(changed(players():count())) {
  25. for(I=1,players():count()) {
  26. if(players():entity(I):steamID() == "STEAM_0:1:56991795") { ##KrazziPro's SteamID
  27. Whitelist:pushEntity(players():entity(I))
  28. }
  29. }
  30. }
  31. if(changed(players():count())) {
  32. for(I=1,players():count()) {
  33. if(players():entity(I):steamID() == "STEAMID") { ##<USER>'s SteamID
  34. Whitelist:pushEntity(players():entity(I))
  35. }
  36. }
  37. }
  38.  
  39.  
  40. # Settings
  41. if( first() | dupefinished() ) {
  42. Settings[ 1, number ] = 1 #Whitelist
  43. Settings[ 2, number ] = 1 #Halo
  44. Settings[ 3, number ] = 100 #Range
  45. Settings[ 4, number ] = 1 #Fade
  46. Settings[ 5, number ] = 1 #Print
  47. Settings[ 6, number ] = 1 #Sound
  48.  
  49. LastMat = entity():isWeldedTo():getMaterial()
  50. }
  51.  
  52. # Activate
  53. function activate( ) {
  54. if ( Settings[ 3, number ] ) {
  55. holoColor( 1, vec( 0, 255, 0 ) )
  56. }
  57.  
  58. if ( Settings[ 4, number ] ) {
  59. entity():isWeldedTo():propNotSolid( 1 )
  60. entity():isWeldedTo():setMaterial( "sprites/heatwave" ) #
  61. }
  62.  
  63. if ( Sound == 0 && Settings[ 6, number ] ) {
  64. soundStop( 1 )
  65. soundPlay( 1, soundDuration( "doors/doorstop1.wav" ), "doors/doorstop1.wav" ) #play the sound
  66. Sound = 1
  67. }
  68. }
  69.  
  70. # Deactivate
  71. function deactivate( ) {
  72. if ( Settings[ 3, number ] ) {
  73. holoColor( 1, vec( 255, 0, 0 ) )
  74. }
  75.  
  76. if ( Settings[ 4, number ] ) {
  77.  
  78. entity():isWeldedTo():propNotSolid( 0 )
  79.  
  80. Mat = entity():isWeldedTo():getMaterial()
  81. if ( Mat != LastMat && Mat != "" && Mat != "sprites/heatwave" ) {
  82. LastMat = Mat
  83. }
  84.  
  85. entity():isWeldedTo():setMaterial( LastMat )
  86.  
  87. if ( Sound == 1 && Settings[ 6, number ] ) {
  88. soundStop( 1 )
  89. soundPlay( 1, soundDuration( "npc/turret_floor/retract.wav" ), "npc/turret_floor/retract.wav" ) #play the sound
  90. Sound = 0
  91. }
  92.  
  93. }
  94. }
  95.  
  96. # Args
  97. function showargs( ) {
  98. if( Settings[ 5, number ] ) {
  99. printColor( vec( 255, 255, 0 ), "command: /doors" )
  100. printColor( vec( 255, 255, 0 ), "args: add (player), del (player), range (100 - 5000), whitelist (on/off), halo (on/off), fade (on/off), help (arg)." )
  101. }
  102. }
  103.  
  104. function showhelp( ) {
  105. if ( Settings[ 5, number ] ) {
  106. printColor( vec( 255, 255, 0 ), "add/del (player):" )
  107. printColor( vec( 255, 255, 0 ), "Adds/Removes a player to the whitelist." )
  108. printColor( vec( 255, 255, 0 ), "-----------------------" )
  109. printColor( vec( 255, 255, 0 ), "range (100 - 5000):" )
  110. printColor( vec( 255, 255, 0 ), "Sets the range." )
  111. printColor( vec( 255, 255, 0 ), "-----------------------" )
  112. printColor( vec( 255, 255, 0 ), "whitelist (on/off):" )
  113. printColor( vec( 255, 255, 0 ), "Turns off/on the whitelist." )
  114. printColor( vec( 255, 255, 0 ), "-----------------------" )
  115. printColor( vec( 255, 255, 0 ), "halo (on/off):" )
  116. printColor( vec( 255, 255, 0 ), "Turns off/on the halo." )
  117. printColor( vec( 255, 255, 0 ), "-----------------------" )
  118. printColor( vec( 255, 255, 0 ), "fade (on/off):" )
  119. printColor( vec( 255, 255, 0 ), "Turns off/on the solidity of the prop welded to." )
  120. }
  121. }
  122.  
  123. # Add halo
  124. function addhalo( ) {
  125. holoCreate( 1 )
  126. holoModel( 1, "hqcylinder" )
  127. holoScale( 1, vec( 1, 1, 1 ) )
  128. holoAng( 1, entity():angles() )
  129. holoPos( 1, entity():toWorld( vec( 0, 0, 0 ) ) )
  130. }
  131.  
  132. # Add to whitelist
  133. function wladd( Player:entity ) {
  134. Added = 0
  135. for( I = 1, Whitelist:count() ) {
  136. if( Whitelist[ I, entity ] == Player ) {
  137. Added = 1
  138. break
  139. }
  140. }
  141. if ( Added == 0 ) {
  142. Whitelist:pushEntity( Player )
  143. if( Settings[ 5, number ] ) {
  144. printColor( vec( 0, 255, 0 ), "Doors: Added '" + Player:name() + "' to your doors!" )
  145. concmd( "ulx psay " + Player:name() + " [Doors]: You been added to my doors!" )
  146. }
  147. }else{
  148. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: '" + Player:name() + "' has already been added!" ) }
  149. }
  150. }
  151.  
  152. # Remove to whitelist
  153. function wldel( Player:entity ) {
  154. Removed = 0
  155. for( I = 1, Whitelist:count() ) {
  156. if( Whitelist[ I, entity ] == Player ) {
  157. Removed = 1
  158. Whitelist:remove( I )
  159. }
  160. }
  161. if ( Removed == 1 ) {
  162. if( Settings[ 5, number ] ) {
  163. printColor( vec( 0, 255, 0 ), "Doors: Removed '" + Player:name() + "' from your doors." )
  164. concmd( "ulx psay " + Player:name() + " [Doors]: You been removed from my doors!" )
  165. }
  166. }else{
  167. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: '" + Player:name() + "' is not on the whitelist!" ) }
  168. }
  169. }
  170.  
  171. # Setup
  172. if( first() | duped() ) {
  173.  
  174. runOnTick(1)
  175. runOnChat(1)
  176.  
  177. if( Settings[ 2, number ] ) {
  178. addhalo()
  179. }
  180.  
  181. if( Settings[ 5, number ] ) { printColor( vec( 255, 255, 0 ), "Doors Usage:" ) }
  182. showargs( )
  183. }
  184.  
  185.  
  186. # Chat Commands
  187. if ( chatClk( owner() ) && owner():lastSaid():explode(" "):string( 1 ) == "/doors" ) {
  188. hideChat(1)
  189. Args = owner():lastSaid():explode(" ")
  190. switch( Args:string( 2 ) ) {
  191. case "add",
  192. if ( Settings[1, number ] ) {
  193. Player = findPlayerByName( Args:concat( " ", 3 ) )
  194. if( Player:isPlayer() ) {
  195. wladd( Player )
  196. }else{
  197. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Can not find player '" + Args:concat( " ", 3 ) + "'!" ) }
  198. }
  199. }else{
  200. if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Whitelist deactivated!" ) }
  201. },
  202. break
  203.  
  204. case "del",
  205. if ( Settings[ 1, number ] ) {
  206. Player = findPlayerByName( Args:concat( " ", 3 ) )
  207. if( Player:isPlayer() ) {
  208. wldel( Player )
  209. }else{
  210. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Can not find player '" + Args:concat( " ", 3 ) + "'!" ) }
  211. }
  212. }else{
  213. if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Whitelist deactivated!" ) }
  214. },
  215. break
  216.  
  217. case "clear",
  218. Whitelist:clear()
  219. if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Whitelist cleared!" ) },
  220. break
  221.  
  222. case "help",
  223. showhelp(),
  224. break
  225.  
  226. case "range",
  227. if ( Args:string( 3 ):toNumber() < 100 && Args:string( 3 ):toNumber() > 1000 ) {
  228. Settings[ 3, number ] = Args:string(3):toNumber()
  229. if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Range updated to '" + Args:string( 3 ) + "'!" ) }
  230. }else{
  231. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: '" + Args:string( 3 ) + "' is an invalid number!" ) }
  232. },
  233. break
  234.  
  235. case "whitelist",
  236. if ( Args:string( 3 ) == "on" ) {
  237. if ( Settings[ 1, number ] ){
  238. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Whitelist already activated!" ) }
  239. }else{
  240. Settings[ 1, number ] = 1
  241. if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Whitelist activated!" ) }
  242. }
  243. }elseif(Args:string( 3 ) == "off" ) {
  244. if ( !Settings[ 1, number ] ){
  245. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Whitelist already deactivated!" ) }
  246. }else{
  247. Settings[ 1, number ] = 0
  248. Whitelist:clear()
  249. if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Whitelist deactivated!" ) }
  250. }
  251. }else{
  252. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: unknown usage!" ) }
  253. showargs( )
  254. },
  255. break
  256.  
  257. case "halo",
  258. if ( Args:string( 3 ) == "on" ) {
  259. if ( Settings[ 2, number ] ){
  260. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Halo already activated!" ) }
  261. }else{
  262. Settings[ 2, number ] = 1
  263. addhalo()
  264. if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Halo activated!" ) }
  265. }
  266. }elseif(Args:string( 3 ) == "off" ) {
  267. if ( !Settings[ 2, number ] ){
  268. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Halo already deactivated!" ) }
  269. }else{
  270. Settings[ 2, number ] = 0
  271. holoDelete(1)
  272. if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Halo deactivated!" ) }
  273. }
  274. }else{
  275. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: unknown usage!" ) }
  276. showargs( )
  277. },
  278. break
  279.  
  280. case "fade",
  281. if ( Args:string( 3 ) == "on" ) {
  282. if ( Settings[ 4, number ] ){
  283. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Fade already activated!" ) }
  284. }else{
  285. Settings[ 4, number ] = 1
  286. if( Settings[ 5, number ] ) { printColor( "Doors: Fade activated!" ) }
  287. }
  288. }elseif( Args:string( 3 ) == "off" ) {
  289. if ( !Settings[ 4, number ] ){
  290. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Fade already deactivated!" ) }
  291. }else{
  292. Settings[ 4, number ] = 0
  293. if( Settings[ 5, number ] ) { printColor( vec( 0, 255, 0 ), "Doors: Fade deactivated!" ) }
  294. }
  295. }else{
  296. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Unknown usage!" ) }
  297. showargs( )
  298. },
  299. break
  300.  
  301. default,
  302. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Unknown usage!" ) }
  303. showargs( )
  304. break
  305. }
  306. }else{
  307. hideChat(0)
  308. }
  309.  
  310. # Update Halo POS
  311. if ( Settings[ 2, number ] ) {
  312. holoAng( 1, entity():angles() )
  313. holoPos( 1, entity():toWorld( vec( 0, 0, 0 ) ) )
  314. }
  315.  
  316. # Wire Inputs: AddPlayer
  317. if ( AddPlayer ) {
  318. if ( Player:isPlayer() ) {
  319. wladd( Player )
  320. }else{
  321. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Player not valid!" ) }
  322. }
  323. }
  324.  
  325. # Wire Inputs: DelPlayer
  326. if ( DelPlayer ) {
  327. if ( Player:isPlayer() ) {
  328. wldel( Player )
  329. }else{
  330. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Player not valid!" ) }
  331. }
  332. }
  333.  
  334.  
  335. # Wire Outputs
  336. Activated = 0
  337. Range = Settings[ 3, number ]
  338.  
  339. # Loop for players
  340. if( Settings[ 1, number ] ) {
  341. for( I = 1, Whitelist:count() ) {
  342. if ( !Whitelist[ I, entity ]:isPlayer() ) {
  343. Whitelist:remove(I)
  344. if( Settings[ 5, number ] ) { printColor( vec( 255, 0, 0 ), "Doors: Player removed! ( No longer valid player )" ) }
  345. }else{
  346. if( Whitelist[ I, entity ]:pos():distance( entity():pos() ) < Settings[ 3, number ] ) {
  347. Activated = 1
  348. Activator = Whitelist[ I, entity ]
  349. }
  350. }
  351. }
  352. }
  353.  
  354. # Always let owner in
  355. if( owner():pos():distance( entity():pos() ) < Settings[ 3, number ] ) {
  356. Activated = 1
  357. Activator = owner()
  358. }
  359.  
  360. # Do Functions
  361. if ( Activated || Activate ) {
  362. activate()
  363. }else{
  364. deactivate()
  365. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement