place this in mapname.gsc at the bottom under everything:
end_game() { user = undefined; cost = 35000; //change to cost that you want self setCursorHint("HINT_NOICON"); self UseTriggerRequireLookAt(); self setHintString("The power must be activated first"); //remove line if you want it to work withoutpower flag_wait( "electricity_on" ); //remove line if you want it to work without power self setHintString("Press &&1 To Win The Game [Cost: "+cost+"]"); //text hint trigger while(1) { self waittill("trigger", user); if( is_player_valid(user) && user.score >= cost ) { play_sound_at_pos( "cha_ching", self.origin ); user thread maps\_zombiemode_score::minus_to_player_score( cost ); self delete(); level notify( "end_game" ); level notify("tom_planes"); level.tom_victory = true; } else { play_sound_at_pos( "no_cha_ching", self.origin ); } } }
Then in the same file above the line:
maps\_zombiemode::main();
Add:
level.tom_victory = false; end_trig = getentarray( "end_game","targetname" ); array_thread( end_trig,::end_game );
Then if you haven't already move _zombiemode.gsc from raw/maps to mods/*YOURMOD*/maps.
Open it and find the function "end_game"(if you don't know what that would look like view the code below that you will be pasting). Replace the entire function with this:
end_game() { level waittill ( "end_game" ); level.intermission = true; update_leaderboards(); game_over = NewHudElem( self ); game_over.alignX = "center"; game_over.alignY = "middle"; game_over.horzAlign = "center"; game_over.vertAlign = "middle"; game_over.y -= 10; game_over.foreground = true; game_over.fontScale = 3; game_over.alpha = 0; game_over.color = ( 1.0, 1.0, 1.0 ); game_over SetText( &"ZOMBIE_GAME_OVER" ); game_over FadeOverTime( 1 ); game_over.alpha = 1; survived = NewHudElem( self ); survived.alignX = "center"; survived.alignY = "middle"; survived.horzAlign = "center"; survived.vertAlign = "middle"; survived.y += 20; survived.foreground = true; survived.fontScale = 2; survived.alpha = 0; survived.color = ( 1.0, 1.0, 1.0 ); if( level.round_number < 2 && level.tom_victory == false ) { survived SetText( &"ZOMBIE_SURVIVED_ROUND" ); } else if( level.tom_victory == false ) { survived SetText( &"ZOMBIE_SURVIVED_ROUNDS", level.round_number ); } if( level.tom_victory == true ) { survived.color = ( 0.423, 0.004, 0 ); survived SetText( "You Won In ", level.round_number, " Rounds!" ); } //TUEY had to change this since we are adding other musical elements setmusicstate("end_of_game"); setbusstate("default"); survived FadeOverTime( 1 ); survived.alpha = 1; wait( 1 ); //play_sound_at_pos( "end_of_game", ( 0, 0, 0 ) ); wait( 2 ); intermission(); wait( level.zombie_vars["zombie_intermission_time"] ); level notify( "stop_intermission" ); array_thread( get_players(), ::player_exit_level ); bbPrint( "zombie_epilogs: rounds %d", level.round_number ); wait( 1.5 ); if( is_coop() ) { ExitLevel( false ); } else { MissionFailed(); } // Let's not exit the function wait( 666 ); }
Open radiant and make a new trigger_use. Place it where you want the ending to be bought from. With the trigger selected open the entity window by pressing "N". Type the kvp of:
Key: "targetname" Value: "end_game"
Save, build mod and compile and you should have a working buyable ending!