UGX-Mods 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 Facebook
Sign In with Twitch

Co-Op glitch with this script - Please help

broken avatar :(
Created 9 years ago
by AlecKeaneDUB
0 Members and 1 Guest are viewing this topic.
1,938 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 2 months ago
Posts
191
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Let's all just light up a blunt, and make stuff.
×
AlecKeaneDUB's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
AlecKeaneDUB's Contact & Social LinksaleckeanedubAlecKeaneDUBAlecKeaneDUB
I made this buildables script for my first map release: The Outpost. This script works great on solo (with one exception which I'll explain soon), but on Co-Op it does not work, ruling the map broken and unbeatable.

The issue people have had is that they can pick up the first buildable part and add it to the work bench, but then they(or any of the other players) aren't able to pick up either of the other two. Now, the one exception when playing on solo, is that you must pick up the three parts in a certain order. I'm not sure why this happens, but this was all scripted by me so it doesn't surprise me that it has bugs.

I didn't want to use others' pre-made buildable scripts, because I wanted to take on the challenge of making my own, and not waste time failing at trying to figure out others'. I believe that when I made it, I both succeeded and failed. So I'd love someone to tell me where I went wrong, and maybe help me fix this.

I already know that there are probably things that don't need to be in there, don't make sense, or in the wrong place. So I'd really love help on what I can do to make my map enjoyable to play on Co-Op.

Here's the script:
Code Snippet
Plaintext
#include common_scripts\utility;
#include maps\_utility;
#include maps\_zombiemode_utility;
#include maps\_hud_util;

Precache_buildables()
{
PrecacheModel( "zombie_sumpf_zipcage_switch" );
PrecacheModel( "zombie_sumpf_zipcage_box" );
PrecacheModel( "zombie_modular_wires_single" );
}

main()
{
players = get_players();
for(i=0;i<players.size;i++)
{
players[i].hasAPart = false;
players[i].hasSwitch = false;
players[i].hasWires = false;
players[i].hasBox = false;
}

level.buildTime = 2.5;
level.buildCompleted = false;
level.switchAdded = false;
level.wiresAdded = false;
level.boxAdded = false;

thread init_parts();
thread init_work_bench();
thread init_end_trigger();
}

init_parts(part)
{
//sets up the switch part and trigger
switch_part = getent("switch_part","targetname");
switch_trig = getent("switch_trig","targetname");

switch_trig SetCursorHint("HINT_NOICON");
switch_trig UseTriggerRequireLookAt();
switch_trig SetHintString("Press &&1 To Pick Up Switch");

//sets up the wires part and trigger
wires_part = getent("wires_part","targetname");
wires_trig = getent("wires_trig","targetname");

wires_trig SetCursorHint("HINT_NOICON");
wires_trig UseTriggerRequireLookAt();
wires_trig SetHintString("Press &&1 To Pick Up Wires");

//sets up the box part and trigger
box_part = getent("box_part","targetname");
box_trig = getent("box_trig","targetname");

box_trig SetCursorHint("HINT_NOICON");
box_trig UseTriggerRequireLookAt();
box_trig SetHintString("Press &&1 To Pick Up Electrical Box");

while(isDefined(wires_trig))
{
players = get_players(); // Get all player entities
for(i=0;i<players.size;i++)
{
wires_trig waittill("trigger",player);

if(!players[i] maps\_laststand::player_is_in_laststand() && !players[i].being_revived)
{
if(players[i].hasAPart == true)
{
players[i] iprintln( "You are already carrying a part" );
}

else
{
players[i] iprintln( "You picked up the wires" );
players[i].hasAPart = true;
players[i].hasWires = true;

wires_trig delete();
wires_part delete();
}
}
}
wait 0.05;
}

while(isDefined(switch_trig))
{
players = get_players(); // Get all player entities
for(i=0;i<players.size;i++)
{
switch_trig waittill("trigger",player);

if(!players[i] maps\_laststand::player_is_in_laststand() && !players[i].being_revived)
{
if(players[i].hasAPart == true)
{
players[i] iprintln( "You are already carrying a part" );
}

else
{
players[i] iprintln( "You picked up the switch" );
players[i].hasAPart = true;
players[i].hasSwitch = true;

switch_trig delete();
switch_part delete();
}
}
}
wait 0.05;
}

while(isDefined(box_trig))
{
players = get_players(); // Get all player entities
for(i=0;i<players.size;i++)
{
box_trig waittill("trigger",player);

if(!players[i] maps\_laststand::player_is_in_laststand() && !players[i].being_revived)
{
if(players[i].hasAPart == true)
{
players[i] iprintln( "You are already carrying a part" );
}

else
{
players[i] iprintln( "You picked up the electric box" );
players[i].hasAPart = true;
players[i].hasBox = true;

box_trig delete();
box_part delete();
}
}
}
wait 0.05;
}
}

init_work_bench()
{
bench_trig = getent("add_part_trig","targetname");

bench_trig SetCursorHint("HINT_NOICON");
bench_trig UseTriggerRequireLookAt();
bench_trig SetHintString("Press &&1 To Replace Part");

while(level.buildCompleted == false)
{
players = get_players();
for(i=0;i<players.size;i++)
{
bench_trig waittill("trigger",player);

if(players[i].hasAPart == true && players[i].hasSwitch == true && level.switchAdded == false)
{
players[i] thread do_knuckle_crack();

players[i] iprintln( "Replacing switch..." );
wait(level.buildTime);
players[i] iprintln( "A new switch has been added!" );
level notify( "buildable_complete" );

players[i].hasAPart = false;
players[i].hasSwitch = false;
level.switchAdded = true;
wait 0.1;
continue;
}

if(players[i].hasAPart == true && players[i].hasWires == true && level.wiresAdded == false)
{
players[i] thread do_knuckle_crack();

players[i] iprintln( "Replacing wires..." );
wait(level.buildTime);
players[i] iprintln( "Some new wires have been added!" );
level notify( "buildable_complete" );

players[i].hasAPart = false;
players[i].hasWires = false;
level.wiresAdded = true;
wait 0.1;
continue;
}

if(players[i].hasAPart == true && players[i].hasBox == true && level.boxAdded == false)
{
players[i] thread do_knuckle_crack();

players[i] iprintln( "Replacing electrical box..." );
wait(level.buildTime);
players[i] iprintln( "A new electrical box has been added!" );
level notify( "buildable_complete" );

players[i].hasAPart = false;
players[i].hasbox = false;
level.boxAdded = true;
wait 0.1;
continue;
}

if(players[i].hasAPart == false)
{
players[i] iprintln( "You don't have a part..." );
}
}

if(level.switchAdded == true && level.wiresAdded == true && level.boxAdded == true)
{
bench_trig delete();
level.buildCompleted = true;
level notify( "all_parts_added" );
wait 0.2;
iprintlnbold( "All parts fixed" );
}
}
}

do_knuckle_crack()
{
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();
self GiveWeapon( "zombie_knuckle_crack" );
self SwitchToWeapon( "zombie_knuckle_crack" );
self waittill_any( "fake_death", "death", "player_downed", "weapon_change_complete", "buildable_complete" );

self EnableOffhandWeapons();
self EnableWeaponCycling();
self TakeWeapon( "zombie_knuckle_crack" );
self SwitchToWeapon( gun );

self AllowLean(true);
self AllowAds(true);
self AllowSprint(true);
self AllowProne(true);
self AllowMelee(true);
self notify("knuckle_crack_done");
}

init_end_trigger()
{
end_game = getent("end_game","targetname");
end_game SetCursorHint("HINT_NOICON");
end_game UseTriggerRequireLookAt();
end_game SetHintString("This switch seems to be broken...");

self waittill( "all_parts_added" );

end_game SetHintString("You need a source of energy...");
//thread init_shoot_trig();

}

I really hope someone can help me, so thanks in advance.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Wait, didn't you already ask this before? I definitely remember someone having this issue with this exact script.

Ah well. Your issue is caused by having a while loop that never ends, so the script won't continue. Unfortunately i don't see a way to really fix it without rewriting the function.
Last Edit: September 16, 2015, 10:56:30 pm by daedra descent
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 3 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
Signature
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
this should help with the co-op but im not 100% positive if it will fix the issue. it will for sure help with the having to pick up items in a certain order in solo.
replace your init_parts() method with this method
Code Snippet
Plaintext
init_parts()
{
//sets up the switch part and trigger
switch_part = getent("switch_part","targetname");
switch_trig = getent("switch_trig","targetname");

switch_trig SetCursorHint("HINT_NOICON");
switch_trig UseTriggerRequireLookAt();
switch_trig SetHintString("Press &&1 To Pick Up Switch");

//sets up the wires part and trigger
wires_part = getent("wires_part","targetname");
wires_trig = getent("wires_trig","targetname");

wires_trig SetCursorHint("HINT_NOICON");
wires_trig UseTriggerRequireLookAt();
wires_trig SetHintString("Press &&1 To Pick Up Wires");

//sets up the box part and trigger
box_part = getent("box_part","targetname");
box_trig = getent("box_trig","targetname");

box_trig SetCursorHint("HINT_NOICON");
box_trig UseTriggerRequireLookAt();
box_trig SetHintString("Press &&1 To Pick Up Electrical Box");

box_trig thread part_trig_wait(box_part);
wires_trig thread part_trig_wait(wires_part);
switch_trig thread part_trig_wait(switch_part);

}
and then add this method somewhere in your file
Code Snippet
Plaintext
part_trig_wait(part)
{
while(isDefined(self))
{
self waittill("trigger",player);

if(!player maps\_laststand::player_is_in_laststand() && !player.being_revived)
{
if(player.hasAPart)
{
player iprintln( "You are already carrying a part" );
}

else
{
player.hasAPart = true;
switch(part.targetname)
{
case "box_part" :
player.hasBox = true;
player iprintln( "You picked up the electric box" );
break;
case "wires_part" :
player.hasWires = true;
player iprintln( "You picked up the switch" );
break;
case "switch_part" :
player.hasSwitch = true;
iprintln( "You picked up the wires" );
break;
}

player.hasAPart = true;
player.hasBox = true;

self delete();
part delete();
}
}

wait 0.05;
}
}

beyond this is point is just a few programming tips:
1 when using the
Code Snippet
Plaintext
waittill("trigger",player);

there is no need to fun a for loop for the players since the waittill returns the player that used the trigger
for instance instead of doing this after the trigger waittill("trigger",player);
Code Snippet
Plaintext
				if(players[i].hasAPart == true)
{
players[i] iprintln( "You are already carrying a part" );
}
you can do this(player is no defined as the player that triggered the trigger)
Code Snippet
Plaintext
				if(player.hasAPart == true)
{
player iprintln( "You are already carrying a part" );
}
2. instead of checking if a boolean value is == true such as in your if statment here
Code Snippet
Plaintext
if(players[i].hasAPart == true)
you can do this instead
Code Snippet
Plaintext
if(players[i].hasAPart)
and for false values use
Code Snippet
Plaintext
if(!players[i].hasAPart)
theres a couple of pointers and hopefully helps with your code :)
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 10 October 2013
Last active: 3 months ago
Posts
541
Respect
Forum Rank
Zombie Enslaver
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
×
ProGamerzFTW's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Wait, didn't you already ask this before? I definitely remember someone having this issue with this exact script.

Indeed http://ugx-mods.com/forum/index.php/topic,7063.msg76743.html#msg76743
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 2 months ago
Posts
191
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Let's all just light up a blunt, and make stuff.
×
AlecKeaneDUB's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
AlecKeaneDUB's Contact & Social LinksaleckeanedubAlecKeaneDUBAlecKeaneDUB
Wait, didn't you already ask this before? I definitely remember someone having this issue with this exact script.

Ah well. Your issue is caused by having a while loop that never ends, so the script won't continue. Unfortunately i don't see a way to really fix it without rewriting the function.
I did. I asked a while back but I never really got the answer I was looking for. Besides, I worded the whole thread completely wrong...and I wanted to fix all that and clean it up with a new thread

Double Post Merge: September 17, 2015, 04:12:52 pm
this should help with the co-op but im not 100% positive if it will fix the issue. it will for sure help with the having to pick up items in a certain order in solo.
replace your init_parts() method with this method
Code Snippet
Plaintext
init_parts()
{
//sets up the switch part and trigger
switch_part = getent("switch_part","targetname");
switch_trig = getent("switch_trig","targetname");

switch_trig SetCursorHint("HINT_NOICON");
switch_trig UseTriggerRequireLookAt();
switch_trig SetHintString("Press &&1 To Pick Up Switch");

//sets up the wires part and trigger
wires_part = getent("wires_part","targetname");
wires_trig = getent("wires_trig","targetname");

wires_trig SetCursorHint("HINT_NOICON");
wires_trig UseTriggerRequireLookAt();
wires_trig SetHintString("Press &&1 To Pick Up Wires");

//sets up the box part and trigger
box_part = getent("box_part","targetname");
box_trig = getent("box_trig","targetname");

box_trig SetCursorHint("HINT_NOICON");
box_trig UseTriggerRequireLookAt();
box_trig SetHintString("Press &&1 To Pick Up Electrical Box");

box_trig thread part_trig_wait(box_part);
wires_trig thread part_trig_wait(wires_part);
switch_trig thread part_trig_wait(switch_part);

}
and then add this method somewhere in your file
Code Snippet
Plaintext
part_trig_wait(part)
{
while(isDefined(self))
{
self waittill("trigger",player);

if(!player maps\_laststand::player_is_in_laststand() && !player.being_revived)
{
if(player.hasAPart)
{
player iprintln( "You are already carrying a part" );
}

else
{
player.hasAPart = true;
switch(part.targetname)
{
case "box_part" :
player.hasBox = true;
player iprintln( "You picked up the electric box" );
break;
case "wires_part" :
player.hasWires = true;
player iprintln( "You picked up the switch" );
break;
case "switch_part" :
player.hasSwitch = true;
iprintln( "You picked up the wires" );
break;
}

player.hasAPart = true;
player.hasBox = true;

self delete();
part delete();
}
}

wait 0.05;
}
}

beyond this is point is just a few programming tips:
1 when using the
Code Snippet
Plaintext
waittill("trigger",player);

there is no need to fun a for loop for the players since the waittill returns the player that used the trigger
for instance instead of doing this after the trigger waittill("trigger",player);
Code Snippet
Plaintext
				if(players[i].hasAPart == true)
{
players[i] iprintln( "You are already carrying a part" );
}
you can do this(player is no defined as the player that triggered the trigger)
Code Snippet
Plaintext
				if(player.hasAPart == true)
{
player iprintln( "You are already carrying a part" );
}
2. instead of checking if a boolean value is == true such as in your if statment here
Code Snippet
Plaintext
if(players[i].hasAPart == true)
you can do this instead
Code Snippet
Plaintext
if(players[i].hasAPart)
and for false values use
Code Snippet
Plaintext
if(!players[i].hasAPart)
theres a couple of pointers and hopefully helps with your code :)
Thanks a lot man. I'm still learning, so I figured some stuff would be totally wrong. I'll give this a try when I get home and I'll let you know how it goes
Last Edit: September 17, 2015, 04:12:52 pm by AlecKeaneDUB

 
Loading ...