Need help fixing a bug in this script

broken avatar :(
Created 1593 days ago
by AlecKeaneDUB
0 Members and 1 Guest are viewing this topic.
2,106 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 189 days ago
Posts
189
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.
Signature
I'm not always vocal about my atheism. But when I am, I'm just as annoying as religious people
×
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 released my map (The Outpost - Challenge Map) like a month ago and I've gotten feedback about a major bug in this script that keeps you from completing the easteregg/beating the map when playing Co-op. It works great on solo but i dont know what the problem is on Co-op and I really dont have time to look through every bit of my code to try and test things until i fix it. So any scripters, if you can please help me out I'd really appreciate it

I have not personally played my map on co-op, but people say that you cant pickup certain parts or something? I'm not entirely sure but you can play the map with a friend or two yourself or you can check the comments on the map's thread:
http://ugx-mods.com/forum/index.php?topic=6733.0

Here's my entire buildables script: (I know its probably very poorly written and sloppy but this was my first large script)
#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();

}

init_shoot_trig()
{
shoot_trig = getent("shoot_trig","targetname");
requiredWeapon = "zombie_thompson_upgraded";

while(1)
{
shoot_trig waittill("trigger", player);
weapon = player getcurrentweapon();

if(requiredWeapon == "zombie_thomspon_upgraded" || weapon==requiredWeapon)
{
shoot_trig delete();
thread init_end_game();
wait 0.1;
break;
}
}
}

init_end_game()
{
level notify ( "energy_shot" );
wait 0.5;
maps\nazi_zombie_114cabin::end_game();
}
Last Edit: June 13, 2015, 04:22:54 pm by AlecKeaneDUB
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 1214 days ago
Posts
2,794
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
I'm guessing it has something to do with the fact that you use 3 while loops in the same function. The second or third while loop won't start until the first while loop ends. My suggestion would be to put each loop in its own function and just thread call each function. That should atleast fix the issue with players not being able to grab certain parts until they add the part before it.

Last Edit: June 13, 2015, 04:38:48 pm by daedra descent
broken avatar :(
×
broken avatar :(
The King of Zombies
Location: usLouisiana
Date Registered: 24 June 2013
Last active: 521 days ago
Posts
2,152
Respect
Forum Rank
King of the Zombies
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Signature
Donate to me if you enjoy my work. [You are not allowed to view external links. Register or Login to see them]
×
Dust's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Dust's Contact & Social LinksMrZ0mbiesFanaticdust103194MrZ0mbiesFanatic
I played this map on co-op, and I know you said you had to pick up the first part in the spawn room, before you can pick up the second one, and the second one before the third. But when we played it even after we placed the first part, we couldn't pick up the second part, or the third one. On solo, it worked fine though.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 189 days ago
Posts
189
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 played this map on co-op, and I know you said you had to pick up the first part in the spawn room, before you can pick up the second one, and the second one before the third. But when we played it even after we placed the first part, we couldn't pick up the second part, or the third one. On solo, it worked fine though.
Yes thats exactly the problem I want fixed. And like daedra said, the problem of having to pick up and add parts in order is because of the triple while loop. That I can fix but I cant find the issue with co-op :\
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 hours ago
Posts
1,173
Respect
1,365Add +1
Forum Rank
Zombie Colossus
Primary Group
Community Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
Signature
[RELEASED] Greenhouse Realism 3.0: [You are not allowed to view external links. Register or Login to see them]

NUK370WN Realism 3.0: [You are not allowed to view external links. Register or Login to see them]
Industrial Estate Realism 3.0: [You are not allowed to view external links. Register or Login to see them]

Support my work here:  [You are not allowed to view external links. Register or Login to see them]
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntstuffy@BluntZombieBluntStuffyStuffyZombie
...but i dont know what the problem is on Co-op and I really dont have time to look through every bit of my code to try and test things until i fix it...

...I have not personally played my map on co-op, but people say that you cant pickup certain parts or something?

If you dont even want to spend time fixing your scripts why would we want to? Sounds a bit weird  to me, the way you put it there... But ok, maybe this helps.


This really doesn't make too much sense:
				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;

Try reading it like this, maybe that clears it up a bit..
				user = undefined;							

// players = get_players(); // You dont need this
// for(i=0;i<players.size;i++)
// {
wires_trig waittill("trigger",user);

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

else
{
user iprintln( "You picked up the wires" );
user.hasAPart = true;
user.hasWires = true;

wires_trig delete();
wires_part delete();
}
}
// }
wait 0.05;
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 43 days ago
Posts
6,879
Respect
Forum Rank
Immortal
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Signature
If you want scripts / features made for you, then contact me by PM or email / skype etc
it will cost you tho so if you have no intention of reciprocating don't even waste my time ;)
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social Links[email protected]HarryBo21HarryBo000
If you dont even want to spend time fixing your scripts why would we want to? Sounds a bit weird  to me, the way you put it there... But ok, maybe this helps.


This really doesn't make too much sense:
				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;

Try reading it like this, maybe that clears it up a bit..
				user = undefined;							

// players = get_players(); // You dont need this
// for(i=0;i<players.size;i++)
// {
wires_trig waittill("trigger",user);

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

else
{
user iprintln( "You picked up the wires" );
user.hasAPart = true;
user.hasWires = true;

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

lol yea the way he wrote that wasnt really ideal was it lol

"I cant be assed, so can one of you mugs do it for me, what evs ill be back to pick up my completed homework" lol  :troll:
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 September 2014
Last active: 189 days ago
Posts
189
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
If you dont even want to spend time fixing your scripts why would we want to? Sounds a bit weird  to me, the way you put it there...
lol yea the way he wrote that wasnt really ideal was it lol

"I cant be assed, so can one of you mugs do it for me, what evs ill be back to pick up my completed homework" lol  :troll:

I just knew that I'm not good enough at scripting to fix this and I didnt want to admit it :\ I honestly looked at it for a really long time but i still suck so I had no idea where to even look for the problem, so I just said that I didnt have the time to look through it. I didnt mean for it to make me sound like an asshole, so my bad for that
Last Edit: June 14, 2015, 10:33:22 pm by AlecKeaneDUB
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 43 days ago
Posts
6,879
Respect
Forum Rank
Immortal
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social Links[email protected]HarryBo21HarryBo000
I just knew that I'm not good enough at scripting to fix this and I didnt want to admit it :\ I honestly looked at it for a really long time but i still suck so I had no idea where to even look for the problem, so I just said that I didnt have the time to look through it. I didnt mean for it to make me sound like an asshole, so my bad for that
lol its alright, I meant that as a joke ;)  :D

We know what you meant ;)

I have a fully functional craftables script you can use instead if you want, its not the one in the tutorials section here, as I havent released it yet. Hit me up if you want it
Last Edit: June 14, 2015, 11:57:21 pm by Harry Bo21
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 1214 days ago
Posts
2,794
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
I just knew that I'm not good enough at scripting to fix this and I didnt want to admit it :\ I honestly looked at it for a really long time but i still suck so I had no idea where to even look for the problem, so I just said that I didnt have the time to look through it. I didnt mean for it to make me sound like an asshole, so my bad for that

Did putting each loop into its own function and threading it help any? What about BluntStuffy's suggestion?

There really isn't anything else thats wrong with the script besides optimizations that i can see. It should do the job in both SP and COOP.

Edit: Actually now that i look through the whole script, i do see another issue with your shootable trig function:

if(requiredWeapon == "zombie_thomspon_upgraded" || weapon==requiredWeapon)

This if statement will always evaluate to true, regardless of what weapon the player actually has. Not sure if you want it like that or not but if you don't you should change the two pipes '||' with '&&'.
Last Edit: June 15, 2015, 03:28:15 am by daedra descent

 

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 ...