Modme Forums

Buyable Powerups

Game Modding | Call of Duty: Black Ops 3 | Scripting


Nikon:

In my custom map I want to create a buyable max ammo on the wall. An example would be Pistol Defense from WaW, in 2 boxes of the map there were two buyable max ammos and I can't seem to find a script that allows me to put in a buyable max ammo or really any powerup that works. Hence why I'm asking here.


KillJoy:

//in yourmapname.gsc add these #usings

#using scripts\zm\_zm_score;
#using scripts\zm\_zm_stats;


//directly under zm_usermap::main();

thread buyable_powerup_1();


//at very bottom of gsc

function buyable_powerup_1()
{
cost = 1000;
trig = GetEnt("trig_1", "targetname"); //add trigger_use in radiant
trig SetHintString("Hold [{+activate}] To Buy [Cost: "+cost+"]");
trig SetCursorHint("HINT_NOICON");

struct = struct::get("struct_1", "targetname"); //add script_struct in radiant

    while(1)
    {
            trig waittill("trigger", player);
            if( player.score >= cost && zm_utility::is_player_valid( player ) )
            {
                player PlayLocalSound( "zmb_cha_ching" );
                player zm_score::minus_to_player_score( cost );
                thread zm_powerups::specific_powerup_drop("full_ammo", struct.origin); //free_perk
                trig Delete();
                break; //kill the loop
            }
    }
}


Nikon:

Hey, I added everything correctly and my map just won't load. Here's exactly what I did in these images. What am I doing wrong?






KillJoy:

its not the powerup script, your problem persists elsewhere


Nikon:

its not the powerup script, your problem persists elsewhere


Okay, I got it working, the script only allows for one buyable max ammo location. I had 3 other locations and the script couldn't figure out which one it had to use so the map wouldn't load.


Nikon:

its not the powerup script, your problem persists elsewhere

But now I can't get the other 3 spots to work. I tried coping the script 3 extra times and copied the "trig and struct" lines 3 times too and that didn't work either. How can I get 4 locations to have buyable max ammos?


Sleepy216:

in your main function replace:
thread buyable_powerup_1();
with:

trigs = getentarray( "trig_1", "targetname" );    //give every trig this targetname
foreach(trig in trigs)
{
    trig thread buyable_powerup_1();
}

then remove:
trig = getent( "trig_1", "targetname" );
from your function buyable_powerup_1

then replace every other instance of "trig" in the same function with "self".
example of what you should change:

trig setcursorhint("hint_noicon");

//should now be:

self setcursorhint("hint_noicon");

that should let you have as many buyable locations as you like.

edit whoops I forgot to mention the struct, you want to change that to:
struct = struct::get(self.target, "targetname");

then in radiant remove the targetname you have set to the struct, deselect it afterward.
then select the trigger for the ammo, then select the struct again. press w.
Now you can copy those two for each location. each trigger needs to target just one struct.
sorry about that, I just assumed the script gave the player ammo, not spawned the actual max ammo powerup.
I can be smooth brained sometimes.


Nikon:

in your main function replace:
thread buyable_powerup_1();
with:
trigs = getentarray( "trig_1", "targetname" );    //give every trig this targetname
foreach(trig in trigs)
{
    trig thread buyable_powerup_1();
}

then remove:
trig = getent( "trig_1", "targetname" );
from your function buyable_powerup_1

then replace every other instance of "trig" in the same function with "self".
example of what you should change:

trig setcursorhint("hint_noicon");

//should now be:

self setcursorhint("hint_noicon");

that should let you have as many buyable locations as you like.

edit whoops I forgot to mention the struct, you want to change that to:
struct = struct::get(self.target, "targetname");

then in radiant remove the targetname you have set to the struct, deselect it afterward.
then select the trigger for the ammo, then select the struct again. press w.
Now you can copy those two for each location. each trigger needs to target just one struct.
sorry about that, I just assumed the script gave the player ammo, not spawned the actual max ammo powerup.
I can be smooth brained sometimes.


So I did everything that was said and I'm getting this error when I link and compile my map.
Here are screenshots of the mod launcher and my gsc file.



Sleepy216:

that's because you have to change every instance of the word "trig" to "self" in the function buyable_powerup_1()

you only changed the example one i gave, all the other lines still say trig.


Nikon:

that's because you have to change every instance of the word "trig" to "self" in the function buyable_powerup_1()

you only changed the example one i gave, all the other lines still say trig.


Ahhh I'm sorry. I wasn't reading that properly. I can't believe I just overlooked that. It works now! Thanks for the help man!


Sleepy216:

Ahhh I'm sorry. I wasn't reading that properly. I can't believe I just overlooked that. It works now! Thanks for the help man!

Hey it happens! No problem at all! I am glad it's working for you now.