KrazziPro

Doors - <USER>'s Custom - By KrazziPro

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