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

trying to build a generator that needs points(fuel) to keep power on [SOLVED]

broken avatar :(
Created 3 years ago
by Deleted User
0 Members and 1 Guest are viewing this topic.
796 views
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
EDIT: SOLVED

here is what i have so far. im new to coding so do forgive me.

```
//generator (to keep power on, which includes lights) that way players will always need to "fuel" the generator using points
/*
walk upto power switch & it will say "the grid is out! find the generator".
once gen is found, it will then say "Generator Main Switch". you can/need to flip the main gen switch but power will remain off
in order to turn it on, points need to be deposited. 1k for 5mins. 5k max (5 lots of 1k, 25mins total)

gen will then say "[Cost 1000] for 5mins of power]. press X to deposit fuel." once deposited the gen timer will start counting down.
if gen timer hits 0. power will cut-out. if this happens then once the gen has been "fueled" again by adding points, the power will turn back on.
*/

generator()
{
    trig = getEnt("gen_switch_trig","targetname");
    trig setCursorHint("HINT_NOICON");
    trig setHintString("Generator Main Switch");
    gen_switch = getEnt("gen_switch","targetname");
   
    trig waittill("trigger", player);
   
    trig setHintString("");
    gen_switch rotateRoll(-90,.3);
    playfx(level._effect["switch_sparks"] ,getstruct("gen_switch_fx","targetname").origin);
   
    gen_on();
}

gen_on()
{    
    give_points_trig = getEnt("give_points_trig","targetname");
    give_points_trig setHintString("[Cost 100] for 5mins of power]. press X to deposit points.");
   
    while(1)
    {
        current_fuel = 0;

        for(;; )
        {
            give_points_trig waittill ("trigger", player);              ***when i activate this, and deposit fuel***
            give_points_trig setCursorHint("HINT_NOICON");

            if(current_fuel < 500)
            {
                if(player.score >= 100)
                {
                    player maps\_zombiemode_score::minus_to_player_score( 100 );
                    current_fuel = current_fuel + 100;
                    iPrintLnBold("Fuel deposited. 10 seconds of power acquired");
                   
                    if(current_fuel >= 500)
                    {
                    iPrintLnBold("Tank Full");
                    }
                   
                    if(current_fuel >= 100)
                    {
                        wait 10;    ***it gets to here & stops. it wont let me deposit anymore fuel***  how can i get it to continue to let me purchase whilst this wait is in effect***
                        current_fuel = current_fuel - 100;
                        gen_off();
                    }
                    if(current_fuel >= 200)
                    {
                        wait 10;  ***and once ive managed to deposit more fuel, so say ive deposited once, then its started the wait, and 2 seconds later i deposit a 2nd lot of fuel, i need it to then stop the 1st wait and go to the 2nd wait. and so forth.***
                        current_fuel = current_fuel - 100;
                        iPrintLn("10 seconds of power left");
                        wait 10;
                        current_fuel = current_fuel - 100;
                        gen_off();
                    }
                    if(current_fuel >= 300)
                    {
                        wait 20;
                        current_fuel = current_fuel - 100;
                        iPrintLn("10 seconds of power left");
                        wait 10;
                        current_fuel = current_fuel - 100;
                        gen_off();
                    }
                    if(current_fuel >= 400)
                    {
                        wait 30;
                        current_fuel = current_fuel - 100;
                        iPrintLn("10 seconds of power left");
                        wait 10;
                        current_fuel = current_fuel - 100;
                        gen_off();
                    }
                    if(current_fuel >= 500)
                    {
                        wait 40;
                        current_fuel = current_fuel - 100;
                        iPrintLn("10 seconds of power left");
                        wait 10;
                        current_fuel = current_fuel - 100;
                        gen_off();
                    }
                }
               
                else
                {
                    iPrintLnBold("Insuficient Funds Available");
                }
            }
        }
    }
}

gen_off()
{
    flag_clear("gen_on"); // this doesnt work. i am yet to figure out how to turn the power off.
    iPrintLn("gen is empty");
    gen_switch = getEnt("gen_switch","targetname");
    gen_switch rotateRoll(90,.3);
}
```
broken avatar :(
×
broken avatar :(
Location: nl
Date Registered: 20 September 2013
Last active: 10 days ago
Posts
645
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
No code is bug free
Signature
My published cod maps:

Subzero
Djinncaves
Enclosed (a.k.a baconcube)
Bayern
Snowblind
Furtrelock

Black Ops Perks: https://www.ugx-mods.com/forum/scripts/55/call-of-duty-world-at-war-black-ops-perks/22180/
×
gympie6's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
gympie6's Contact & Social LinksTheRevenantSkullTeffrieTeffrieGympie5#5971
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
Maybe these topics can help you solve the problem:
https://www.ugx-mods.com/forum/mods-releases/61/origins-generators-and-pap/16032
https://www.ugx-mods.com/forum/scripts/55/map-add-on-7-origins-generators/2929
i managed to get bluntstuffy's generator script/prefabs to work that you send me the other day & i just checked out the link for the other generator also & neither are what im looking for. im trying to get the generator to work exactly the same as my player health concept. only the gen would start when triggered and not on game start & instead of player dying when it hits 0, the power would simply turn off.

i had a hunt around online and it mentioned that (for the 1st time you can turn power off) in b02, tranzit. so i dont know how that works as i dont have that game and i also saw that someone posted something on here regarding turning the power off but that was for bo3 which included _zm_power.gsc & set_global_power(false) but waw doesnt have its own power gsc and in dlc3_code i couldnt see a "global_power" thing. so maybe power cant be turned off in waw. idk. i also remembered that in advanced warefare each exo-perk area has its own power. but i dont have that game either. so no acces to its scripts.
broken avatar :(
×
broken avatar :(
Location: nl
Date Registered: 20 September 2013
Last active: 10 days ago
Posts
645
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
No code is bug free
×
gympie6's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
gympie6's Contact & Social LinksTheRevenantSkullTeffrieTeffrieGympie5#5971
Turning the power off was an easter egg for Black Ops 2. Nothing important and not included in Call of Duty World at War.

About Bluntstuffy's generators, they work fine. There is maybe a small bug while being down near the generator it was still doing it's work but that can be solved with some scripting?

There is indeed no invading generator script for this feature.
So you have to turn off the power somehow. :)

It's best to start taking some programming lessons if you don't know how to turn it off...
Because you need change the model to off, delete or hide the fx, disable the trigger and stop playing the jingle.
Last Edit: December 31, 2020, 01:16:48 am by gympie6
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
Turning the power off was an easter egg for Black Ops 2. Nothing important and not included in Call of Duty World at War.

About Bluntstuffy's generators, they work fine. There is maybe a small bug while being down near the generator it was still doing it's work but that can be solved with some scripting?

There is indeed no invading generator script for this feature.
So you have to turn off the power somehow. :)

It's best to start taking some programming lessons if you don't know how to turn it off...
Because you need change the model to off, delete or hide the fx, disable the trigger and stop playing the jingle.
i thought when the power got turned on it "activated" something "big" in the background. something like a mainframe or network that interwinds with other stuff. if this isnt the case and all the power does is-

"change the model to off, delete or hide the fx, disable the trigger and stop playing the jingle.* for the power switch & perks. then i guess it more simple than i thought.

i should be able  to reverse the model,fx,trig & sound for all. i just thought theres something "bigger" to the power coz in dlc3_code it says-#
power_electric_switch_on()
{
    flag_set( "electricity_on" );
    wait_network_frame();

i presumed that "wait_network_frame();" is something big. i cant find the right words to explain properly but yh i just thought that "wait_network_frame();" had its fingers in several pies so i didnt think it would be as simple as reversing the power/perk model,fx,trig & jingle

Double Post Merge: December 31, 2020, 06:55:50 pm

i was thinking what else might be similar to what im trying to acheive by having something constantly change whilst still being able to use the trigger to alter it.
& i thought about the flame thrower. that is constantly regenerating (going up) and the trigger is always active/usable to (lower it).

 
Loading ...