Advertisement
Abnormal202

Untitled

Jun 19th, 2017
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.41 KB | None | 0 0
  1. // ZombieKid164's buyable elevator
  2. #using scripts\zm\_zm_score;
  3. #using scripts\shared\flag_shared;
  4.  
  5. function init()
  6. {
  7.  
  8. //Things you can edit below \/
  9. level.elevator_cost = 10; // Change this to change the cost of the elevator. Leave it undefined to make it free.
  10. level.elevate_height = 250; //This is how far the elevator will travel up.
  11. level.elevator_transition_time = 5; //How long it will take for the elevator travel.
  12. level.elevator_cooldown_time = 30; // Cooldown time of the elevator.
  13. level.zk_debug = true; //Enable or disable this to show action text in game. (Ex: "Debug: Elevator Moving" will be shown on the screen)
  14. level.change_door_direction = false; //Change this to true if your doors slide backwards or forwards instead of side to side.
  15. //Things you can edit above /\
  16.  
  17. level.elevator_trigger = GetEnt( "elevator_trigger", "targetname" );
  18. level.elevator_trigger_top = GetEnt( "elevator_trigger_top", "targetname" );
  19. level.elevator_trigger_outside_bottom = GetEnt( "elevator_trigger_outside_bottom", "targetname");
  20. level.elevator_trigger_outside_top = GetEnt( "elevator_trigger_outside_top", "targetname");
  21. level.elevator_model = GetEnt("elevator", "targetname" );
  22. level.elevator_top_door = GetEnt("top_door", "targetname" );
  23. level.elevator_bottom_door = GetEnt("bottom_door", "targetname" );
  24. level.elevator_called = false;
  25. main();
  26. }
  27.  
  28. function main()
  29. {
  30. level endon( "intermission" );
  31. wait_for_power();
  32. thread bottom_door_open();
  33. level.elevator_trigger_top SetHintString( "" );
  34.  
  35. while(1)
  36. {
  37. thread wait_for_buy_bottom();
  38. thread wait_for_call_top();
  39. thread zk_print("Waiting for Buy or Call");
  40. level waittill("Elevator_Used");
  41. level notify("elevator_moving");
  42. thread zk_print("Elevator Moving");
  43. thread clear_trigger_text();
  44.  
  45. thread bottom_door_close();
  46. wait(1);
  47. thread elevator_rise( level.elevate_height, level.elevator_transition_time );
  48. wait( level.elevator_transition_time );
  49. thread top_door_open();
  50. level.elevator_trigger_top SetHintString( "Elevator is cooling down." );
  51. level.elevator_trigger_outside_bottom SetHintString( "Elevator is cooling down." );
  52. wait( level.elevator_cooldown_time );
  53.  
  54. thread wait_for_buy_top();
  55. thread wait_for_call_bottom();
  56. thread zk_print("Waiting for Buy or Call");
  57. level waittill("Elevator_Used");
  58. level notify("elevator_moving");
  59. thread zk_print("Elevator Moving");
  60. thread clear_trigger_text();
  61.  
  62. level.elevator_trigger_top SetHintString( "" );
  63. thread top_door_close();
  64. wait(1);
  65. thread elevator_fall( level.elevate_height, level.elevator_transition_time );
  66. wait( level.elevator_transition_time );
  67. thread bottom_door_open();
  68. level.elevator_trigger SetHintString( "Elevator is cooling down." );
  69. level.elevator_trigger_outside_top SetHintString( "Elevator is cooling down." );
  70. wait( level.elevator_cooldown_time );
  71. }
  72. }
  73.  
  74. function elevator_rise( height, speed )
  75. {
  76. level.elevator_model movez (height, speed);
  77. level.elevator_model waittill ("movedone");
  78. }
  79.  
  80. function elevator_fall( height, speed )
  81. {
  82. level.elevator_model movez (height - (height * 2), speed);
  83. level.elevator_model waittill ("movedone");
  84. }
  85.  
  86. function bottom_door_open()
  87. {
  88. if(isDefined(level.elevator_bottom_door.script_vector))
  89. {
  90. level.elevator_bottom_door MoveTo(level.elevator_bottom_door.origin + level.elevator_bottom_door.script_vector, 1);
  91. }
  92. else
  93. {
  94. if(!level.change_door_direction == true)
  95. {
  96. level.elevator_bottom_door movex (130, 1);
  97. }
  98. else
  99. {
  100. level.elevator_bottom_door movey (130, 1);
  101. }
  102. }
  103.  
  104. }
  105.  
  106. function bottom_door_close()
  107. {
  108. if(isDefined(level.elevator_bottom_door.script_vector))
  109. {
  110. level.elevator_bottom_door MoveTo(level.elevator_bottom_door.origin - level.elevator_bottom_door.script_vector, 1);
  111. }
  112. else
  113. {
  114. if(!level.change_door_direction == true)
  115. {
  116. level.elevator_bottom_door movex ((-130), 1);
  117. }
  118. else
  119. {
  120. level.elevator_bottom_door movey ((-130), 1);
  121. }
  122. }
  123. }
  124.  
  125. function top_door_open()
  126. {
  127. if(isDefined(level.elevator_top_door.script_vector))
  128. {
  129. level.elevator_top_door MoveTo(level.elevator_top_door.origin + level.elevator_top_door.script_vector, 1);
  130. }
  131. else
  132. {
  133. if(!level.change_door_direction == true)
  134. {
  135. level.elevator_top_door movex (130, 1);
  136. }
  137. else
  138. {
  139. level.elevator_top_door movey (130, 1);
  140. }
  141. }
  142.  
  143. }
  144.  
  145. function top_door_close()
  146. {
  147. if(isDefined(level.elevator_top_door.script_vector))
  148. {
  149. level.elevator_top_door MoveTo(level.elevator_top_door.origin - level.elevator_top_door.script_vector, 1);
  150. }
  151. else
  152. {
  153. if(!level.change_door_direction == true)
  154. {
  155. level.elevator_top_door movex ((-130), 1);
  156. }
  157. else
  158. {
  159. level.elevator_top_door movey ((-130), 1);
  160. }
  161. }
  162. }
  163.  
  164. function wait_for_power()
  165. {
  166. level.elevator_trigger_outside_bottom SetHintString( &"ZOMBIE_NEED_POWER" );
  167. level.elevator_trigger_outside_top SetHintString( &"ZOMBIE_NEED_POWER" );
  168. level flag::wait_till( "power_on" );
  169. level.elevator_trigger_outside_bottom SetHintString( "" );
  170. level.elevator_trigger_outside_top SetHintString( "" );
  171. thread zk_print("Starting Elevator");
  172. }
  173.  
  174. function wait_for_buy_bottom()
  175. {
  176. level endon("elevator_moving");
  177. if( isDefined(level.elevator_cost) )
  178. {
  179. while(1)
  180. {
  181. level.elevator_trigger SetHintString( "Hold ^3&&1^7 to Use Elevator [Cost: "+level.elevator_cost+"]" );
  182. level.elevator_trigger waittill( "trigger", player );
  183. if( isDefined(level.elevator_cost) && player.score >= level.elevator_cost )
  184. {
  185. player zm_score::minus_to_player_score( level.elevator_cost );
  186. level notify("Elevator_Used");
  187. thread zk_print("Elevator Bought");
  188. break;
  189. }
  190. else if( isDefined( level.elevator_cost ) && player.score < level.elevator_cost )
  191. {
  192. level.elevator_trigger SetHintString( "You do not have enough money." );
  193. wait(4);
  194. level.elevator_trigger SetHintString( "Hold ^3&&1^7 to Use Elevator [Cost: "+level.elevator_cost+"]" );
  195. continue;
  196. }
  197. }
  198. }
  199. else
  200. {
  201. level.elevator_trigger SetHintString( "Hold ^3&&1^7 to Use Elevator" );
  202. level.elevator_trigger waittill( "trigger", player );
  203. level.elevator_trigger SetHintString( "" );
  204. level notify("Elevator_Used");
  205. thread zk_print("Elevator Bought [Free]");
  206. }
  207. }
  208.  
  209. function wait_for_buy_top()
  210. {
  211. level endon("elevator_moving");
  212. if( isDefined(level.elevator_cost) )
  213. {
  214. while(1)
  215. {
  216. level.elevator_trigger_top SetHintString( "Hold ^3&&1^7 to Use Elevator [Cost: "+level.elevator_cost+"]" );
  217. level.elevator_trigger_top waittill( "trigger", player );
  218. if( isDefined(level.elevator_cost) && player.score >= level.elevator_cost )
  219. {
  220. player zm_score::minus_to_player_score( level.elevator_cost );
  221. level notify("Elevator_Used");
  222. thread zk_print("Elevator Bought");
  223. break;
  224. }
  225. else if( isDefined( level.elevator_cost ) && player.score < level.elevator_cost )
  226. {
  227. level.elevator_trigger_top SetHintString( "You do not have enough money." );
  228. wait(4);
  229. level.elevator_trigger_top SetHintString( "Hold ^3&&1^7 to Use Elevator [Cost: "+level.elevator_cost+"]" );
  230. continue;
  231. }
  232. }
  233. }
  234. else
  235. {
  236. level.elevator_trigger SetHintString( "Hold ^3&&1^7 to Use Elevator" );
  237. level.elevator_trigger waittill( "trigger", player );
  238. level.elevator_trigger SetHintString( "" );
  239. level notify("Elevator_Used");
  240. thread zk_print("Elevator Bought [Free]");
  241. }
  242. }
  243.  
  244. function wait_for_call_bottom()
  245. {
  246. self endon("elevator_moving");
  247. level.elevator_trigger_outside_bottom SetHintString( "Hold ^3&&1^7 to Call Elevator" );
  248. level.elevator_trigger_outside_bottom waittill( "trigger", player );
  249. level.elevator_trigger_outside_bottom SetHintString( "" );
  250. level notify("Elevator_Used");
  251. thread zk_print("Elevator Called");
  252. }
  253.  
  254. function wait_for_call_top()
  255. {
  256. self endon("elevator_moving");
  257. level.elevator_trigger_outside_top SetHintString( "Hold ^3&&1^7 to Call Elevator" );
  258. level.elevator_trigger_outside_top waittill( "trigger", player );
  259. level.elevator_trigger_outside_top SetHintString( "" );
  260. level notify("Elevator_Used");
  261. thread zk_print("Elevator Called");
  262. }
  263.  
  264. function zk_print( string )
  265. {
  266. if( level.zk_debug == true )
  267. {
  268. iprintlnbold( "Debug: "+string );
  269. }
  270. }
  271.  
  272. function clear_trigger_text()
  273. {
  274. level.elevator_trigger_outside_top SetHintString( "" );
  275. level.elevator_trigger_outside_bottom SetHintString( "" );
  276. level.elevator_trigger SetHintString( "" );
  277. level.elevator_trigger_top SetHintString( "" );
  278. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement