
Posts
22
Respect
Forum Rank
Legless Crawler
Primary Group
Member
Login Issues
Forgot password?Activate Issues
Account activation email not received? Wrong account activation email used?Other Problems?
Contact Support - Help Center Get help on the UGX Discord. Join it now!/******************************************************
// Buildable Power switch script
//******************************************************
#include common_scripts\utility;
#include maps\_utility;
#include maps\_zombiemode_utility;
#include maps\_anim;
//////////////////////////////////
//Credits
//////////////////////////////////
/*
ZK: This script
Don Goony: knuckle_crack()
~ Add yourself here
*/
//////////////////////////////////
main()
{
PrecacheShader( "buildable_panel_shader" );
PrecacheShader( "buildable_handle_shader" );
PrecacheShader( "buildable_wire_shader" );
level.power_build = 0;
power_switch_trig = getEnt("turn_power_on", "targetname");
power_switch_trig disable_trigger();
thread lets_build();
}
lets_build()
{
flag_wait("all_players_connected");
players = get_players();
for(i=0;i<players.size;i++)
{
players[i].part_hud = [];
}
//the panel
panel_pick = getEnt("panel_pick", "targetname"); //panel that you pick up
panel_pick_trig = getEnt("panel_pick_trig", "targetname"); //trigger to pick up panel
panel_build = getEnt("panel_build", "targetname"); //the panel that appears when built
panel_build_trig = getEnt("panel_build_trig", "targetname"); //trigger to build panel
//the handle
handle_pick = getEnt("handle_pick", "targetname"); //handle that you pick up
handle_pick_trig = getEnt("handle_pick_trig", "targetname"); //trigger to pick up handle
handle_build = getEnt("handle_build", "targetname"); //the handle that appears when built
handle_build_trig = getEnt("handle_build_trig", "targetname"); //trigger to build handle
//the wire
wire_pick = getEnt("wire_pick", "targetname"); //wire that you pick up
wire_pick_trig = getEnt("wire_pick_trig", "targetname"); //trigger to pick up wire
wire_build = getEnt("wire_build", "targetname"); //the wire that appears when built
wire_build_trig = getEnt("wire_build_trig", "targetname"); //trigger to build wire
//part 1
thread build_part(panel_pick, panel_pick_trig, panel_build, panel_build_trig, "buildable_panel_shader");
//part 2
thread build_part(handle_pick, handle_pick_trig, handle_build, handle_build_trig, "buildable_handle_shader");
//part 3
thread build_part(wire_pick, wire_pick_trig, wire_build, wire_build_trig, "buildable_wire_shader");
}
power_ready() //this is what runs when you add all the parts
{
power_switch_trig = getEnt("turn_power_on", "targetname");
power_switch = getEnt("handle_build", "targetname");
power_switch_trig enable_trigger();
power_switch_trig SetCursorHint( "HINT_NOICON" );
power_switch_trig UseTriggerRequireLookAt();
power_switch_trig setHintString("Press and hold &&1 to turn on power");
power_switch_trig waittill("trigger");
power_switch_trig delete();
power_switch MoveZ (-9, .5);
flag_set("electricity_on");
level notify("Pack_A_Punch_on");
level notify("sleight_on");
level notify("revive_on");
level notify("juggernog_on");
level notify("doubletap_on");
}
build_part(part, part_trig, place_part, place_part_trig, shader)
{
da_guy = undefined;
place_part hide();
place_part_trig UseTriggerRequireLookAt();
place_part_trig SetCursorHint( "HINT_NOICON" );
place_part_trig setHintString("Parts required");
part_trig UseTriggerRequireLookAt();
part_trig SetCursorHint( "HINT_NOICON" );
part_trig setHintString("Press &&1 to pick up part");
part_trig waittill("trigger", da_guy);
part_trig delete();
part delete();
hud = create_simple_hud( da_guy );
hud.foreground = true;
hud.sort = 1;
hud.hidewheninmenu = false;
hud.alignX = "middle";
hud.alignY = "bottom";
hud.horzAlign = "middle";
hud.vertAlign = "bottom";
hud.x = da_guy.part_hud.size * 45;
hud.y = hud.y - 80;
hud.alpha = 1;
hud SetShader( shader, 40, 40 );
da_guy.part_hud[ shader ] = hud;
place_part_trig enable_trigger();
place_part_trig sethintstring("Press &&1 to add part");
place_part_trig setvisibletoplayer(da_guy);
for(;;)
{
place_part_trig waittill("trigger", da_guy);
if( !isDefined(da_guy.is_adding_part) )
{
da_guy.is_adding_part = true;
place_part_trig delete();
da_guy thread crack_knuckles();
da_guy waittill("part_added");
hud destroy_hud();
place_part show();
level.power_build = level.power_build + 1;
if(level.power_build == 3)
{
thread power_ready();
}
wait 1.5;
da_guy.is_adding_part = undefined;
break;
}
wait .5;
}
}
crack_knuckles()
{
self DisableOffhandWeapons();
self DisableWeaponCycling();
self AllowLean( false );
self AllowAds( false );
self AllowSprint( false );
self AllowProne( false );
self AllowMelee( false );
if ( self GetStance() == "prone" )
{
self SetStance( "crouch" );
}
primaries = self GetWeaponsListPrimaries();
gun = self GetCurrentWeapon();
ammo = self GetWeaponAmmoStock( gun );
weapon = "zombie_knuckle_crack";
self GiveWeapon( weapon );
self SwitchToWeapon( weapon );
self waittill_any( "fake_death", "death", "player_downed", "weapon_change_complete" );
self EnableOffhandWeapons();
self EnableWeaponCycling();
self GiveWeapon( gun );
self SetWeaponAmmoStock( gun, ammo );
self SwitchToWeapon( gun );
self AllowLean( true );
self AllowAds( true );
self AllowSprint( true );
self AllowProne( true );
self AllowMelee( true );
self notify("part_added");
return gun;
}
}
maps\_buildables::main()![]() | Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum. |
![]() | Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum. |
![]() | Has released one or more maps to the UGX-Mods community. |
![]() | Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community. |
![]() BO3 Modtools Alpha | This user has access to the Black Ops 3 Modtools Alpha |
![]() | Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum. |
![]() | Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community. |
ZK's scripts aren't bad for starting out, but there are smarter, more dynamic ways to do things like this build-able. Anytime you see yourself repeating the same things, "except this", meaning like one thing is different, it can be done much better. And also, a good bit of scripting can be improved, by using radiant smarter. When to use auto#'s and prefabs and things like that will help you make better scripts. So take what you learn from this but don't take it as the only way to do it, or even the best way to do it.
You'll find that the main thing with power is the power trigger. The power trigger is handled in dlc3_code.gsc. It gets an ent and waits for it to be triggered. This means the kvp "use_power_switch" can only be in the map as a targetname on an ent once, since getent is used, not getentarray and then a function thread on each. If you had multiple triggers with that kvp, you would get an error, in this case, which would pass as true and allow the power to come on immediately.
So besides writing a script that sets shaders, and picks up parts and sets down parts, and checks when players die or are downed, this is the basic way power is handled. When it is triggered, it then calls power_electric_switch_on() which turns everything with flags and notifications.
There are plenty of scripts out there that handle the rest, and simply adding a level waittill("yournotification"); before the trig waittill("trigger", user); and then adding a level notify("yournotification"); after the item is built, will be one of the easiest ways of handling that. You could also hide or disable the trigger before and enable or show the trigger after it is built if you like.
Good luck.
![]() | Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum. |
// if( isDefined( level.DLC3.useElectricSwitch ) && level.DLC3.useElectricSwitch )
// {
// level thread power_electric_switch();
// }
// else
// {
// level thread power_electric_switch_on();
// }#include common_scripts\utility;
#include maps\_utility;
#include maps\_zombiemode_utility;
#include maps\_anim;
// ****Credits*****
/*
######################################################################################
TheZombieProject:
Now using real switch. Added power / build fx!
I Removed power_ready() function
so now once all parts are added. I *thread maps\dlc3_code::power_electric_switch();*
######################################################################################
ZK: buildable script
Don Goony: knuckle_crack()
######################################################################################
*/
main(){
PrecacheShader( "buildable_panel_shader" ); // name of shader materials
PrecacheShader( "buildable_handle_shader" );
PrecacheShader( "buildable_wire_shader" );
PrecacheItem( "zombie_knuckle_crack" ); // - TZP -
thread build();
}
build(){
flag_wait("all_players_connected");
level.power_build = 0; // moved here // - TZP
level.power_total_parts = 3; // total parts // - TZP
players = get_players();
for(i=0;i<players.size;i++){
players[i].part_hud = [];
}
// ########### PARTS 1 - 3
// part 1
panel_pick = getEnt("panel_pick", "targetname"); // PANEL PICK UP MODEL
panel_pick_trig = getEnt("panel_pick_trig", "targetname"); // PANEL PICK UP TRIGGER
panel_build = getEnt("panel_build", "targetname"); // PANEL BUILD MODEL
panel_build_trig = getEnt("panel_build_trig", "targetname"); // PANEL BUILD TRIGGER
// part 2
handle_pick = getEnt("handle_pick", "targetname"); // HANDLE PICK UP MODEL
handle_pick_trig = getEnt("handle_pick_trig", "targetname"); // HANDLE PICK UP TRIGGER
handle_build = getEnt("power_switch", "targetname"); // HANDLE BUILD MODEL
handle_build_trig = getEnt("handle_build_trig", "targetname"); // HANDLE BUILD TRIGGER
// part 3
pick_up_cord = getEnt("pick_up_cord", "targetname"); // WIRE PICK UP MODEL
pick_up_cord_trig = getEnt("pick_up_cord_trig", "targetname"); // WIRE PICK UP TRIGGER
place_cord = getEnt("place_cord", "targetname"); // WIRE BUILD MODEL
place_cord_trig = getEnt("place_cord_trig", "targetname"); // WIRE BUILD TRIGGER
// part 1
thread build_part(panel_pick, panel_pick_trig, panel_build, panel_build_trig, "buildable_panel_shader");
// part 2
thread build_part(handle_pick, handle_pick_trig, handle_build, handle_build_trig, "buildable_handle_shader");
// part 3
thread build_part(pick_up_cord, pick_up_cord_trig, place_cord, place_cord_trig, "buildable_wire_shader");
}
build_part(part, part_trig, place_part, place_part_trig, shader){
da_guy = undefined;
trig = getent("use_power_switch","targetname"); // - TZP
trig sethintstring("POWER PARTS NEEDED!"); // ADDED HINT FOR POWER FEEL FREE TO DISABLE! // - TZP
place_part hide();
place_part_trig UseTriggerRequireLookAt();
place_part_trig SetCursorHint( "HINT_NOICON" );
place_part_trig setHintString("Parts required");
part_trig UseTriggerRequireLookAt();
part_trig SetCursorHint( "HINT_NOICON" );
part_trig setHintString("Press &&1 to pick up part");
part_trig waittill("trigger", da_guy);
part_trig delete();
part delete();
hud = create_simple_hud( da_guy );
hud.foreground = true;
hud.sort = 1;
hud.hidewheninmenu = false;
hud.alignX = "SUBLEFT"; // i moved shaders to top left so it's not close to perk ones --- tzp
hud.alignY = "top";
hud.horzAlign = "SUBLEFT";
hud.vertAlign = "top";
hud.x = da_guy.part_hud.size * 45;
hud.y = 10;
hud.alpha = 1;
hud SetShader( shader, 40, 40 );
da_guy.part_hud[ shader ] = hud;
place_part_trig enable_trigger();
place_part_trig sethintstring("Press &&1 to add part");
place_part_trig setvisibletoplayer(da_guy);
for(;;){
place_part_trig waittill("trigger", da_guy);
if( !isDefined(da_guy.is_adding_part) ){
da_guy.is_adding_part = true;
place_part_trig delete();
da_guy thread crack_knuckles();
da_guy waittill("part_added");
hud destroy_hud();
// MAKE (ADDPART) FX PLAY ON POWER STRUCT - TZP
playfx(level._effect["powerup_grabbed"] ,getstruct("power_switch_fx","targetname").origin);
place_part show();
level.power_build++; // - TZP
// iPrintLn( "Nice," + level.power_build + " parts added " ); // - TZP
if(level.power_build == level.power_total_parts) // - TZP
{
thread maps\dlc3_code::power_electric_switch(); // - TZP
// iPrintLn( "threading dlc3_code - power ready" ); // - TZP
}
wait 1.5;
da_guy.is_adding_part = undefined;
break;
}
wait .5;
}
}
crack_knuckles()
{
self DisableOffhandWeapons();
self DisableWeaponCycling();
self AllowLean( false );
self AllowAds( false );
self AllowSprint( false );
self AllowProne( false );
self AllowMelee( false );
if ( self GetStance() == "prone" ){
self SetStance( "crouch" );
}
gun = self GetCurrentWeapon();
weapon = "zombie_knuckle_crack";
self GiveWeapon( weapon );
self SwitchToWeapon( weapon );
self waittill_any( "fake_death", "death", "player_downed", "weapon_change_complete" );
self EnableOffhandWeapons();
self EnableWeaponCycling();
self GiveWeapon( gun );
self SwitchToWeapon( gun );
self AllowLean( true );
self AllowAds( true );
self AllowSprint( true );
self AllowProne( true );
self AllowMelee( true );
self notify("part_added");
return gun;
}
/*--------------------
FUNCTION CALLS - PRE _Load
----------------------*/
level thread DLC3_threadCalls();maps\script_name::main();![]() | Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum. |
hey man the script works but how can i fix the hit parts still needed because if you go up and press f it turns on the power with out parts
![]() | Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum. |
Whats you steam name
#include common_scripts\utility;
#include maps\_utility;
#include maps\_zombiemode_utility;
#include maps\_anim;
// ****Credits*****
/*
######################################################################################
TheZombieProject:
Now using real switch. Added power / build fx!
I Removed power_ready() function
so now once all parts are added. I *thread maps\dlc3_code::power_electric_switch();*
######################################################################################
ZK: buildable script
Don Goony: knuckle_crack()
######################################################################################
*/
main(){
PrecacheShader( "buildable_panel_shader" ); // name of shader materials
PrecacheShader( "buildable_handle_shader" );
PrecacheShader( "buildable_wire_shader" );
PrecacheItem( "zombie_knuckle_crack" ); // - TZP -
thread build();
}
build(){
flag_wait("all_players_connected");
level.power_build = 0; // moved here // - TZP
level.power_total_parts = 3; // total parts // - TZP
players = get_players();
for(i=0;i<players.size;i++){
players[i].part_hud = [];
}
// ########### PARTS 1 - 3
// part 1
panel_pick = getEnt("panel_pick", "targetname"); // PANEL PICK UP MODEL
panel_pick_trig = getEnt("panel_pick_trig", "targetname"); // PANEL PICK UP TRIGGER
panel_build = getEnt("panel_build", "targetname"); // PANEL BUILD MODEL
panel_build_trig = getEnt("panel_build_trig", "targetname"); // PANEL BUILD TRIGGER
// part 2
handle_pick = getEnt("handle_pick", "targetname"); // HANDLE PICK UP MODEL
handle_pick_trig = getEnt("handle_pick_trig", "targetname"); // HANDLE PICK UP TRIGGER
handle_build = getEnt("power_switch", "targetname"); // HANDLE BUILD MODEL
handle_build_trig = getEnt("handle_build_trig", "targetname"); // HANDLE BUILD TRIGGER
// part 3
pick_up_cord = getEnt("pick_up_cord", "targetname"); // WIRE PICK UP MODEL
pick_up_cord_trig = getEnt("pick_up_cord_trig", "targetname"); // WIRE PICK UP TRIGGER
place_cord = getEnt("place_cord", "targetname"); // WIRE BUILD MODEL
place_cord_trig = getEnt("place_cord_trig", "targetname"); // WIRE BUILD TRIGGER
// part 1
thread build_part(panel_pick, panel_pick_trig, panel_build, panel_build_trig, "buildable_panel_shader");
// part 2
thread build_part(handle_pick, handle_pick_trig, handle_build, handle_build_trig, "buildable_handle_shader");
// part 3
thread build_part(pick_up_cord, pick_up_cord_trig, place_cord, place_cord_trig, "buildable_wire_shader");
}
build_part(part, part_trig, place_part, place_part_trig, shader){
da_guy = undefined;
trig = getent("use_power_switch","targetname"); // - TZP
// trig sethintstring("POWER PARTS NEEDED!"); // ADDED HINT FOR POWER FEEL FREE TO DISABLE! // - TZP
trig disable_trigger();
place_part hide();
place_part_trig UseTriggerRequireLookAt();
place_part_trig SetCursorHint( "HINT_NOICON" );
place_part_trig setHintString("Parts required");
part_trig UseTriggerRequireLookAt();
part_trig SetCursorHint( "HINT_NOICON" );
part_trig setHintString("Press &&1 to pick up part");
part_trig waittill("trigger", da_guy);
part_trig delete();
part delete();
hud = create_simple_hud( da_guy );
hud.foreground = true;
hud.sort = 1;
hud.hidewheninmenu = false;
hud.alignX = "SUBLEFT"; // i moved shaders to top left so it's not close to perk ones --- tzp
hud.alignY = "top";
hud.horzAlign = "SUBLEFT";
hud.vertAlign = "top";
hud.x = da_guy.part_hud.size * 45;
hud.y = 10;
hud.alpha = 1;
hud SetShader( shader, 40, 40 );
da_guy.part_hud[ shader ] = hud;
place_part_trig enable_trigger();
place_part_trig sethintstring("Press &&1 to add part");
place_part_trig setvisibletoplayer(da_guy);
for(;;){
place_part_trig waittill("trigger", da_guy);
if( !isDefined(da_guy.is_adding_part) ){
da_guy.is_adding_part = true;
place_part_trig delete();
da_guy thread crack_knuckles();
da_guy waittill("part_added");
hud destroy_hud();
// MAKE (ADDPART) FX PLAY ON POWER STRUCT - TZP
playfx(level._effect["powerup_grabbed"] ,getstruct("power_switch_fx","targetname").origin);
place_part show();
level.power_build++; // - TZP
// iPrintLn( "Nice," + level.power_build + " parts added " ); // - TZP
if(level.power_build == level.power_total_parts) // - TZP
{
trig enable_trigger();
thread maps\dlc3_code::power_electric_switch(); // - TZP
// iPrintLn( "threading dlc3_code - power ready" ); // - TZP
}
wait 1.5;
da_guy.is_adding_part = undefined;
break;
}
wait .5;
}
}
crack_knuckles()
{
self DisableOffhandWeapons();
self DisableWeaponCycling();
self AllowLean( false );
self AllowAds( false );
self AllowSprint( false );
self AllowProne( false );
self AllowMelee( false );
if ( self GetStance() == "prone" ){
self SetStance( "crouch" );
}
gun = self GetCurrentWeapon();
weapon = "zombie_knuckle_crack";
self GiveWeapon( weapon );
self SwitchToWeapon( weapon );
self waittill_any( "fake_death", "death", "player_downed", "weapon_change_complete" );
self EnableOffhandWeapons();
self EnableWeaponCycling();
self GiveWeapon( gun );
self SwitchToWeapon( gun );
self AllowLean( true );
self AllowAds( true );
self AllowSprint( true );
self AllowProne( true );
self AllowMelee( true );
self notify("part_added");
return gun;
}