So lets start with the script, open up your mapname.gsc located in root/usermaps/mapname/scritps/zm/mapname.gsc
Make sure you dont open the CSC
Now somewhere at the top of the gsc, add this
#using scripts\zm\_zm_score;
At the bottom of the main function, add this
thread buyable_powerup();
Now at the bottom of your gsc paste this
function buyable_powerup()
{
level.buyable_powerup_cost = 100; // Cost for powerup
level.buyable_powerup_cooldown = 20; // Cooldown in seconds for buyable trigger
while(1)
{
while(1)
{
buyable_powerup_trig = GetEnt("buyable_powerup_trig", "targetname");
buyable_powerup_trig SetHintString("Press and hold &&1 to spawn Powerup [Cost: " + level.buyable_powerup_cost + "]");
buyable_powerup_trig SetCursorHint("HINT_NOICON");
buyable_powerup_spawn = struct::get( "powerup_spawn", "targetname" );
buyable_powerup_trig waittill("trigger", player);
if(player.score >= level.buyable_powerup_cost)
{
player zm_score::minus_to_player_score(level.buyable_powerup_cost);
break;
}
}
/*
If you want a specific powerup, then uncomment the buyable_powerup_spawn below and delete or comment out the one above it.
Available Powerups: double_points, free_perk, full_ammo, nuke, fire_sale, carpenter, insta_kill, shield_charge, bonfire_sale,
*/
buyable_powerup_spawn thread zm_powerups::special_powerup_drop(buyable_powerup_spawn.origin);
//buyable_powerup_spawn thread zm_powerups::specific_powerup_drop("full_ammo", buyable_powerup_spawn.origin);
buyable_powerup_trig SetHintString("Recharing...");
wait(level.buyable_powerup_cooldown);
}
}
Now for the radiant part, all you need is two things, the trigger to buy the powerup and the script_struct for where the powerup will spawn.
Make a trigger_use with this kvp
"buyable_powerup_trig", "targetname"
"powerup_spawn", "targetname"