[Tutorial] How to add a buyable elevator (V2) [Now with call feature]

broken avatar :(
Created 882 days ago
by ZombieKid164
0 Members and 1 Guest are viewing this topic.
6,121 views

Poll

Question: Did this script help you?

Yes
2 (66.7%)
No
1 (33.3%)

Total Members Voted: 3

Voting closed: June 18, 2017, 01:28:57 am

broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 26 March 2016
Last active: 346 days ago
Posts
14
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Hi. I like to map and script stuff :P
Signature
Hi. I like to script and map stuff :P
×
ZombieKid164's Groups
(Note: Again, I originally posted this on modme, but I decided to post it here in case any ugx-only users needed it  :alone:)


Hello again! (I know it's been a while...)
I recreated my elevator script, which adds one main feature: You can now call the elevator. This should fix prior problems with having to make it start at the top, plus some people here and lots on Modme were asking for the call feature.

In case you never saw the first post, here are the features:
-Sliding Doors
-Elevator
-Call Feature
-Editable numbers (You can adjust the elevator to your liking)

All of the things you will need are in the download (I've made it so you no longer need a separate download if your doors open sideways)
[You are not allowed to view external links. Register or Login to see them]

IMPORTANT: Please DO NOT re-upload this script. If you are going to use this in your map or video, please credit me. (Ex: "ZombieKid164 - Youtube: [You are not allowed to view external links. Register or Login to see them] ")

Also, if you want to turn off the debug text, set zk_debug to false in the script (Forgot to add that to instructions).
I hope you enjoy this script!
Thanks, and happy modding! -ZombieKid164
broken avatar :(
×
broken avatar :(
Location: gbnottingham
Date Registered: 1 February 2017
Last active: 749 days ago
Posts
14
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
qbm1's Groups
qbm1's Contact & Social Linksdavid binding
Im getting this error when trying to compile  ??? ERR(0) scripts/zm/zm_five.gsc (58,6) : syntax error, unexpected TOKEN USING, expecting TOKEN SEMICOLON : #using
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 26 March 2016
Last active: 346 days ago
Posts
14
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Hi. I like to map and script stuff :P
×
ZombieKid164's Groups
Im getting this error when trying to compile  ??? ERR(0) scripts/zm/zm_five.gsc (58,6) : syntax error, unexpected TOKEN USING, expecting TOKEN SEMICOLON : #using

It seems you've put the script into your yourmapname.gsc file incorrectly. Here is an example of what it should look like:
//Note that this is starting after "#using scripts\zm\zm_usermap;".

#using scripts\_ZK\zk_buyable_elevator_v2;

//*****************************************************************************
// MAIN
//*****************************************************************************

function main()
{
zm_usermap::main();

level._zombie_custom_add_weapons =&custom_add_weapons;

//Setup the levels Zombie Zone Volumes
level.zones = [];
level.zone_manager_init_func =&usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );

level.pathdist_type = PATHDIST_ORIGINAL;
level thread zk_buyable_elevator_v2::init();
}

//Also there would be more after this


Hope this helps!
broken avatar :(
×
broken avatar :(
Location: usSouth Florida
Date Registered: 10 July 2016
Last active: 231 days ago
Posts
106
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
Signature
Let he who has not sinned cast the first stone.
×
Archaicvirus's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Archaicvirus's Contact & Social Links
(Note: Again, I originally posted this on modme, but I decided to post it here in case any ugx-only users needed it  :alone:)

(Content removed from quote.)
Hello again! (I know it's been a while...)
I recreated my elevator script, which adds one main feature: You can now call the elevator. This should fix prior problems with having to make it start at the top, plus some people here and lots on Modme were asking for the call feature.

In case you never saw the first post, here are the features:
-Sliding Doors
-Elevator
-Call Feature
-Editable numbers (You can adjust the elevator to your liking)

All of the things you will need are in the download (I've made it so you no longer need a separate download if your doors open sideways)
[You are not allowed to view external links. Register or Login to see them]

IMPORTANT: Please DO NOT re-upload this script. If you are going to use this in your map or video, please credit me. (Ex: "ZombieKid164 - Youtube: [You are not allowed to view external links. Register or Login to see them] ")

Also, if you want to turn off the debug text, set zk_debug to false in the script (Forgot to add that to instructions).
I hope you enjoy this script!
Thanks, and happy modding! -ZombieKid164

Nice, scripting. Just one suggestion though, I've done elevator scripts before, and the problem is that players glitch through the floor iif they jump around or move too much. You can solve that problem by using this function on the elevator floor:
void SetMovingPlatformEnabled()

CATEGORY:
CLIENT/SERVER: Server
SUMMARY: Enbles the moving platfrom.
EXAMPLE: platform SetMovingPlatformEnabled( true ) //Elevator gets threaded as self here
// elevator thread SetMovingPlatformEnabled(true);

This will match the player's velocity with the elevator's, and prevent any derpy behavior.
*edit - Also I believe in radiant there is an option on script_model and script_brushmodels to enable them as a moving platform. It's in the kvp's, I have only tested the function via script though so you'd have to test that.
Last Edit: June 11, 2017, 01:42:59 pm by Archaicvirus
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 28 June 2015
Last active: 15 days ago
Posts
72
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
Wolfilms's Groups
Wolfilms's Contact & Social Links
Quote
Also I believe in radiant there is an option on script_model and script_brushmodels to enable them as a moving platform. It's in the kvp's, I have only tested the function via script though so you'd have to test that.

I have tested this out by ticking the setting in radiant, and I have found that it works without having to need any code.
broken avatar :(
×
broken avatar :(
Location: usSouth Florida
Date Registered: 10 July 2016
Last active: 231 days ago
Posts
106
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
×
Archaicvirus's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Archaicvirus's Contact & Social Links
I have tested this out by ticking the setting in radiant, and I have found that it works without having to need any code.

Cool, I figured it would work. That definitely helps when you have multiple elevators, or you could do it dynamically via script either way
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 7 March 2015
Last active: 800 days ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
TotiJr's Groups
TotiJr's Contact & Social LinksBrian Thomas AlvarezmcusherstyleTotiJrTotiJrTotiJr
Can one of you explain how you did it? I'm not sure where to put the script or which ksp to add or change.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 28 June 2015
Last active: 15 days ago
Posts
72
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
Wolfilms's Groups
Wolfilms's Contact & Social Links
Can one of you explain how you did it? I'm not sure where to put the script or which ksp to add or change.

I personally think the radiant way is easier, so here's how to do it in radiant.

  • Select the platform that you stand on for the elevator
  • Hit the 'N' key to open the entity info
  • select the option that says "moving_platform_enabled" so it says "true"
Last Edit: July 21, 2017, 03:16:33 pm by Wolfilms
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 7 March 2015
Last active: 800 days ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
TotiJr's Groups
TotiJr's Contact & Social LinksBrian Thomas AlvarezmcusherstyleTotiJrTotiJrTotiJr
Thanks, it worked. Does anyone know how to use multiple of these at a time? As soon as i turn on the power the game crashes. Im assuming it has to do with the triggers being the exact same, as well as the debugger saying the same thing. Would i just change the trigger names? How do i get rid of the debugger on only one so that it wont say everything twice?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 28 June 2015
Last active: 15 days ago
Posts
72
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
Wolfilms's Groups
Wolfilms's Contact & Social Links
I believe you would have to change all the kvp's on the elevator parts, and the triggers. You would then have to make sure all those kvp's are in the script and have all the code necessary assigned to them. I could be wrong as I haven't really taken a glance at the code, but I'm guessing that is how it would be done. I can try and explain more if this doesn't really help/make sense :)
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 7 March 2015
Last active: 800 days ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
TotiJr's Groups
TotiJr's Contact & Social LinksBrian Thomas AlvarezmcusherstyleTotiJrTotiJrTotiJr
Yeah, I've been able to successfully duplicate the files and change the target names, but when i go in game whenever i turn on power the new one i made works 100%, but the original still says it needs power. Any ideas? Maybe its conflicting functions to wait for power, but I'm not sure how to resolve that. And if it was that I'd think that the original one would work rather than the new one or the game would just crash.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 28 June 2015
Last active: 15 days ago
Posts
72
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
Wolfilms's Groups
Wolfilms's Contact & Social Links
Did you change the name of the wait_for_power() function? That might be a problem if you haven't done that.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 7 March 2015
Last active: 800 days ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
TotiJr's Groups
TotiJr's Contact & Social LinksBrian Thomas AlvarezmcusherstyleTotiJrTotiJrTotiJr
Change what? Because there are only 3 statements that involve power? 

function wait_for_power()
level flag::wait_till( "power_on" );
wait_for_power();
 I already tried adding a 1 in each statement after the word "power" but the problem seems to consist, and for some reason after I change it on level flag it doesn't even bother showing up the debug text from that elevator.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 28 June 2015
Last active: 15 days ago
Posts
72
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
Wolfilms's Groups
Wolfilms's Contact & Social Links
Change what? Because there are only 3 statements that involve power? 

function wait_for_power()
level flag::wait_till( "power_on" );
wait_for_power();
 I already tried adding a 1 in each statement after the word "power" but the problem seems to consist, and for some reason after I change it on level flag it doesn't even bother showing up the debug text from that elevator.

Can you post your code here so I can see what you are working with?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 7 March 2015
Last active: 800 days ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
TotiJr's Groups
TotiJr's Contact & Social LinksBrian Thomas AlvarezmcusherstyleTotiJrTotiJrTotiJr
//This is the gsc file for the elevator
// ZombieKid164's buyable elevator
#using scripts\zm\_zm_score;
#using scripts\shared\flag_shared;

function init()
{

//Things you can edit below \/
level.elevator_cost = 500; // Change this to change the cost of the elevator. Leave it undefined to make it free.
level.elevate_height = 250; //This is how far the elevator will travel up.
level.elevator_transition_time = 5; //How long it will take for the elevator travel.
level.elevator_cooldown_time = 30; // Cooldown time of the elevator.
level.zk_debug = true; //Enable or disable this to show action text in game. (Ex: "Debug: Elevator Moving" will be shown on the screen)
level.change_door_direction = true; //Change this to true if your doors slide backwards or forwards instead of side to side.
//Things you can edit above /\

level.elevator_trigger = GetEnt( "elevator_trigger1", "targetname" );
level.elevator_trigger_top = GetEnt( "elevator_trigger_top1", "targetname" );
level.elevator_trigger_outside_bottom = GetEnt( "elevator_trigger_outside_bottom1", "targetname");
level.elevator_trigger_outside_top = GetEnt( "elevator_trigger_outside_top1", "targetname");
level.elevator_model = GetEnt("elevator1", "targetname" );
level.elevator_top_door = GetEnt("top_door1", "targetname" );
level.elevator_bottom_door = GetEnt("bottom_door1", "targetname" );
level.elevator_called = false;
main();
}

function main()
{
level endon( "intermission" );
wait_for_power();
thread bottom_door_open();
level.elevator_trigger_top SetHintString( "" );

while(1)
{
thread wait_for_buy_bottom();
thread wait_for_call_top();
thread zk_print("Awaiting Activation Protocol 13255");
level waittill("Elevator_Used");
level notify("elevator_moving");
thread zk_print("Activation Protocol 13255");
thread clear_trigger_text();

thread bottom_door_close();
wait(1);
thread elevator_rise( level.elevate_height, level.elevator_transition_time );
wait( level.elevator_transition_time );
thread top_door_open();
level.elevator_trigger_top SetHintString( "Performing Integrity Check: Stand By" );
level.elevator_trigger_outside_bottom SetHintString( "Performing Integrity Check: Stand By" );
wait( level.elevator_cooldown_time );

thread wait_for_buy_top();
thread wait_for_call_bottom();
thread zk_print("Awaiting Activation Protocol 13255");
level waittill("Elevator_Used");
level notify("elevator_moving");
thread zk_print("Activation Protocol 13255 Recieved");
thread clear_trigger_text();

level.elevator_trigger_top SetHintString( "" );
thread top_door_close();
wait(1);
thread elevator_fall( level.elevate_height, level.elevator_transition_time );
wait( level.elevator_transition_time );
thread bottom_door_open();
level.elevator_trigger SetHintString( "Performing Integrity Check: Stand By.." );
level.elevator_trigger_outside_top SetHintString( "Performing Integrity Check: Stand By.." );
wait( level.elevator_cooldown_time );
}
}

function elevator_rise( height, speed )
{
level.elevator_model movez (height, speed);
level.elevator_model waittill ("movedone");
}

function elevator_fall( height, speed )
{
level.elevator_model movez (height - (height * 2), speed);
level.elevator_model waittill ("movedone");
}

function bottom_door_open()
{
if(!level.change_door_direction == true)
{
level.elevator_bottom_door movex (130, 1);
}
else
{
level.elevator_bottom_door movey (130, 1);
}
}

function bottom_door_close()
{
if(!level.change_door_direction == true)
{
level.elevator_bottom_door movex ((-130), 1);
}
else
{
level.elevator_bottom_door movey ((-130), 1);
}
}

function top_door_open()
{
if(!level.change_door_direction == true)
{
level.elevator_top_door movex (130, 1);
}
else
{
level.elevator_top_door movey (130, 1);
}
}

function top_door_close()
{
if(!level.change_door_direction == true)
{
level.elevator_top_door movex ((-130), 1);
}
else
{
level.elevator_top_door movey ((-130), 1);
}
}

function wait_for_power()
{
level.elevator_trigger_outside_bottom SetHintString( &"ZOMBIE_NEED_POWER" );
level.elevator_trigger_outside_top SetHintString( &"ZOMBIE_NEED_POWER" );
level flag::wait_till( "power_on" );
level.elevator_trigger_outside_bottom SetHintString( "" );
level.elevator_trigger_outside_top SetHintString( "" );
thread zk_print("Auxilary Power Active: All Systems Operational");
}

function wait_for_buy_bottom()
{
level endon("elevator_moving");
if( isDefined(level.elevator_cost) )
{
while(1)
{
level.elevator_trigger SetHintString( "Hold ^3&&1^7 to Activate Protocol 935 [Cost: "+level.elevator_cost+"]" );
level.elevator_trigger waittill( "trigger", player );
if( isDefined(level.elevator_cost) && player.score >= level.elevator_cost )
{
player zm_score::minus_to_player_score( level.elevator_cost );
level notify("Elevator_Used");
thread zk_print("Activation Protocol Accepted");
break;
}
else if( isDefined( level.elevator_cost ) && player.score < level.elevator_cost )
{
level.elevator_trigger SetHintString( "You do not have sufficient permissions." );
wait(4);
level.elevator_trigger SetHintString( "Hold ^3&&1^7 to Activate Protocol 935 [Cost: "+level.elevator_cost+"]" );
continue;
}
}
}
else
{
level.elevator_trigger SetHintString( "Hold ^3&&1^7 to Activate Protocol 935" );
level.elevator_trigger waittill( "trigger", player );
level.elevator_trigger SetHintString( "" );
level notify("Elevator_Used");
thread zk_print("Activation Protocol Accepted [Free]");
}
}

function wait_for_buy_top()
{
level endon("elevator_moving");
if( isDefined(level.elevator_cost) )
{
while(1)
{
level.elevator_trigger_top SetHintString( "Hold ^3&&1^7 to Activate Protocol 13255 [Cost: "+level.elevator_cost+"]" );
level.elevator_trigger_top waittill( "trigger", player );
if( isDefined(level.elevator_cost) && player.score >= level.elevator_cost )
{
player zm_score::minus_to_player_score( level.elevator_cost );
level notify("Elevator_Used");
thread zk_print("Activation Protocol Accepted");
break;
}
else if( isDefined( level.elevator_cost ) && player.score < level.elevator_cost )
{
level.elevator_trigger_top SetHintString( "You do not have sufficient permissions" );
wait(4);
level.elevator_trigger_top SetHintString( "Hold ^3&&1^7 to Activate Protocol 13255 [Cost: "+level.elevator_cost+"]" );
continue;
}
}
}
else
{
level.elevator_trigger SetHintString( "Hold ^3&&1^7 to Activate Protocol 13255" );
level.elevator_trigger waittill( "trigger", player );
level.elevator_trigger SetHintString( "" );
level notify("Elevator_Used");
thread zk_print("Activation Protocol Accepted [Free]");
}
}

function wait_for_call_bottom()
{
self endon("elevator_moving");
level.elevator_trigger_outside_bottom SetHintString( "Hold ^3&&1^7 to Activate Protocol 935" );
level.elevator_trigger_outside_bottom waittill( "trigger", player );
level.elevator_trigger_outside_bottom SetHintString( "" );
level notify("Elevator_Used");
thread zk_print("Requested Activation Protocol 935");
}

function wait_for_call_top()
{
self endon("elevator_moving");
level.elevator_trigger_outside_top SetHintString( "Hold ^3&&1^7 to Activate Protocol 13255" );
level.elevator_trigger_outside_top waittill( "trigger", player );
level.elevator_trigger_outside_top SetHintString( "" );
level notify("Elevator_Used");
thread zk_print("Requested Activation Protocol 13255");
}

function zk_print( string )
{
if( level.zk_debug == true )
{
iprintlnbold( "Brother Eye: "+string );
}
}

function clear_trigger_text()
{
level.elevator_trigger_outside_top SetHintString( "" );
level.elevator_trigger_outside_bottom SetHintString( "" );
level.elevator_trigger SetHintString( "" );
level.elevator_trigger_top SetHintString( "" );
}
Last Edit: July 27, 2017, 02:20:27 am by TotiJr

 

Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Twitch
Loading ...