[ZM] Help with GSC Script
-
Hi everyone, I wanted to get the zone_hud function (which shows where the player is) from the 5and5's Strat Tester to be able to make a script that does just that, without the rest of the HUD functions. I tried to edit the code myself and was able to compile it without errors, but unfortunately nothing is shown in the game.
I leave you here the code I am using.#include maps/mp/gametypes_zm/_hud_util; #include maps/mp/zombies/_zm_utility; #include common_scripts/utility; #include maps/mp/_utility; set_hud_offset() { if(level.script == "zm_tomb") { self.zone_hud_offset = 10; } else { self.zone_hud_offset = 0; } self.zone_hud_offset = 15; } zone_hud() { self endon("disconnect"); x = 8; y = -111; if(level.script == "zm_buried") { y = y - 25; } else if(level.script == "zm_tomb") { y = y - 60; } self.zone_hud = newclienthudelem(self); self.zone_hud.alignx = "left"; self.zone_hud.aligny = "bottom"; self.zone_hud.horzalign = "user_left"; self.zone_hud.vertalign = "user_bottom"; self.zone_hud.x = self.zone_hud.x + x; self.zone_hud.y = self.zone_hud.y + y; self.zone_hud.fontscale = 1.3; self.zone_hud.alpha = 0; self.zone_hud.color = 1; self.zone_hud.hidewheninmenu = 1; flag_wait("initial_blackscreen_passed"); } zone_hud_watcher(x, y) { self endon("disconnect"); level endon("end_game"); prev_zone = ""; while(1) { zone = self get_zone_name(); if(prev_zone != zone) { prev_zone = zone; self.zone_hud fadeovertime(0.2); self.zone_hud.alpha = 0; wait(0.2); self.zone_hud settext(zone); self.zone_hud fadeovertime(0.2); self.zone_hud.alpha = 1; wait(0.2); break; } wait(0.05); } self.zone_hud.alpha = 0; } get_zone_name() { zone = self get_current_zone(); if(!isdefined(zone)) { return ""; } name = zone; if(level.script == "zm_transit") { if(zone == "zone_pri") { name = "Bus Depot"; } else if(zone == "zone_pri2") { name = "Bus Depot Hallway"; } else if(zone == "zone_station_ext") { name = "Outside Bus Depot"; } else if(zone == "zone_trans_2b") { name = "Fog After Bus Depot"; } else if(zone == "zone_trans_2") { name = "Tunnel Entrance"; } else if(zone == "zone_amb_tunnel") { name = "Tunnel"; } else if(zone == "zone_trans_3") { name = "Tunnel Exit"; } else if(zone == "zone_roadside_west") { name = "Outside Diner"; } else if(zone == "zone_gas") { name = "Gas Station"; } else if(zone == "zone_roadside_east") { name = "Outside Garage"; } else if(zone == "zone_trans_diner") { name = "Fog Outside Diner"; } else if(zone == "zone_trans_diner2") { name = "Fog Outside Garage"; } else if(zone == "zone_gar") { name = "Garage"; } else if(zone == "zone_din") { name = "Diner"; } else if(zone == "zone_diner_roof") { name = "Diner Roof"; } else if(zone == "zone_trans_4") { name = "Fog After Diner"; } else if(zone == "zone_amb_forest") { name = "Forest"; } else if(zone == "zone_trans_10") { name = "Outside Church"; } else if(zone == "zone_town_church") { name = "Church"; } else if(zone == "zone_trans_5") { name = "Fog Before Farm"; } else if(zone == "zone_far") { name = "Outside Farm"; } else if(zone == "zone_far_ext") { name = "Farm"; } else if(zone == "zone_brn") { name = "Barn"; } else if(zone == "zone_farm_house") { name = "Farmhouse"; } else if(zone == "zone_trans_6") { name = "Fog After Farm"; } else if(zone == "zone_amb_cornfield") { name = "Cornfield"; } else if(zone == "zone_cornfield_prototype") { name = "Nacht"; } else if(zone == "zone_trans_7") { name = "Upper Fog Before Power"; } else if(zone == "zone_trans_pow_ext1") { name = "Fog Before Power"; } else if(zone == "zone_pow") { name = "Outside Power Station"; } else if(zone == "zone_prr") { name = "Power Station"; } else if(zone == "zone_pcr") { name = "Power Control Room"; } else if(zone == "zone_pow_warehouse") { name = "Warehouse"; } else if(zone == "zone_trans_8") { name = "Fog After Power"; } else if(zone == "zone_amb_power2town") { name = "Cabin"; } else if(zone == "zone_trans_9") { name = "Fog Before Town"; } else if(zone == "zone_town_north") { name = "North Town"; } else if(zone == "zone_tow") { name = "Center Town"; } else if(zone == "zone_town_east") { name = "East Town"; } else if(zone == "zone_town_west") { name = "West Town"; } else if(zone == "zone_town_south") { name = "South Town"; } else if(zone == "zone_bar") { name = "Bar"; } else if(zone == "zone_town_barber") { name = "Bookstore"; } else if(zone == "zone_ban") { name = "Bank"; } else if(zone == "zone_ban_vault") { name = "Bank Vault"; } else if(zone == "zone_tbu") { name = "Below Bank"; } else if(zone == "zone_trans_11") { name = "Fog After Town"; } else if(zone == "zone_amb_bridge") { name = "Bridge"; } else if(zone == "zone_trans_1") { name = "Fog Before Bus Depot"; } } else if(level.script == "zm_nuked") { if(zone == "culdesac_yellow_zone") { name = "Yellow House Middle"; } else if(zone == "culdesac_green_zone") { name = "Green House Middle"; } else if(zone == "truck_zone") { name = "Truck"; } else if(zone == "openhouse1_f1_zone") { name = "Green House Downstairs"; } else if(zone == "openhouse1_f2_zone") { name = "Green House Upstairs"; } else if(zone == "openhouse1_backyard_zone") { name = "Green House Backyard"; } else if(zone == "openhouse2_f1_zone") { name = "Yellow House Downstairs"; } else if(zone == "openhouse2_f2_zone") { name = "Yellow House Upstairs"; } else if(zone == "openhouse2_backyard_zone") { name = "Yellow House Backyard"; } else if(zone == "ammo_door_zone") { name = "Yellow House Backyard Door"; } } else if(level.script == "zm_highrise") { if(zone == "zone_green_start") { name = "Green Highrise Level 3b"; } else if(zone == "zone_green_escape_pod") { name = "Escape Pod"; } else if(zone == "zone_green_escape_pod_ground") { name = "Escape Pod Shaft"; } else if(zone == "zone_green_level1") { name = "Green Highrise Level 3a"; } else if(zone == "zone_green_level2a") { name = "Green Highrise Level 2a"; } else if(zone == "zone_green_level2b") { name = "Green Highrise Level 2b"; } else if(zone == "zone_green_level3a") { name = "Green Highrise Restaurant"; } else if(zone == "zone_green_level3b") { name = "Green Highrise Level 1a"; } else if(zone == "zone_green_level3c") { name = "Green Highrise Level 1b"; } else if(zone == "zone_green_level3d") { name = "Green Highrise Behind Restaurant"; } else if(zone == "zone_orange_level1") { name = "Upper Orange Highrise Level 2"; } else if(zone == "zone_orange_level2") { name = "Upper Orange Highrise Level 1"; } else if(zone == "zone_orange_elevator_shaft_top") { name = "Elevator Shaft Level 3"; } else if(zone == "zone_orange_elevator_shaft_middle_1") { name = "Elevator Shaft Level 2"; } else if(zone == "zone_orange_elevator_shaft_middle_2") { name = "Elevator Shaft Level 1"; } else if(zone == "zone_orange_elevator_shaft_bottom") { name = "Elevator Shaft Bottom"; } else if(zone == "zone_orange_level3a") { name = "Lower Orange Highrise Level 1a"; } else if(zone == "zone_orange_level3b") { name = "Lower Orange Highrise Level 1b"; } else if(zone == "zone_blue_level5") { name = "Lower Blue Highrise Level 1"; } else if(zone == "zone_blue_level4a") { name = "Lower Blue Highrise Level 2a"; } else if(zone == "zone_blue_level4b") { name = "Lower Blue Highrise Level 2b"; } else if(zone == "zone_blue_level4c") { name = "Lower Blue Highrise Level 2c"; } else if(zone == "zone_blue_level2a") { name = "Upper Blue Highrise Level 1a"; } else if(zone == "zone_blue_level2b") { name = "Upper Blue Highrise Level 1b"; } else if(zone == "zone_blue_level2c") { name = "Upper Blue Highrise Level 1c"; } else if(zone == "zone_blue_level2d") { name = "Upper Blue Highrise Level 1d"; } else if(zone == "zone_blue_level1a") { name = "Upper Blue Highrise Level 2a"; } else if(zone == "zone_blue_level1b") { name = "Upper Blue Highrise Level 2b"; } else if(zone == "zone_blue_level1c") { name = "Upper Blue Highrise Level 2c"; } } else if(level.script == "zm_prison") { if(zone == "zone_start") { name = "D-Block"; } else if(zone == "zone_library") { name = "Library"; } else if(zone == "zone_cellblock_west") { name = "Cellblock 2nd Floor"; } else if(zone == "zone_cellblock_west_gondola") { name = "Cellblock 3rd Floor"; } else if(zone == "zone_cellblock_west_gondola_dock") { name = "Cellblock Gondola"; } else if(zone == "zone_cellblock_west_barber") { name = "Michigan Avenue"; } else if(zone == "zone_cellblock_east") { name = "Times Square"; } else if(zone == "zone_cafeteria") { name = "Cafeteria"; } else if(zone == "zone_cafeteria_end") { name = "Cafeteria End"; } else if(zone == "zone_infirmary") { name = "Infirmary 1"; } else if(zone == "zone_infirmary_roof") { name = "Infirmary 2"; } else if(zone == "zone_roof_infirmary") { name = "Roof 1"; } else if(zone == "zone_roof") { name = "Roof 2"; } else if(zone == "zone_cellblock_west_warden") { name = "Sally Port"; } else if(zone == "zone_warden_office") { name = "Warden's Office"; } else if(zone == "cellblock_shower") { name = "Showers"; } else if(zone == "zone_citadel_shower") { name = "Citadel To Showers"; } else if(zone == "zone_citadel") { name = "Citadel"; } else if(zone == "zone_citadel_warden") { name = "Citadel To Warden's Office"; } else if(zone == "zone_citadel_stairs") { name = "Citadel Tunnels"; } else if(zone == "zone_citadel_basement") { name = "Citadel Basement"; } else if(zone == "zone_citadel_basement_building") { name = "China Alley"; } else if(zone == "zone_studio") { name = "Building 64"; } else if(zone == "zone_dock") { name = "Docks"; } else if(zone == "zone_dock_puzzle") { name = "Docks Gates"; } else if(zone == "zone_dock_gondola") { name = "Upper Docks"; } else if(zone == "zone_golden_gate_bridge") { name = "Golden Gate Bridge"; } else if(zone == "zone_gondola_ride") { name = "Gondola"; } } else if(level.script == "zm_buried") { if(zone == "zone_start") { name = "Processing"; } else if(zone == "zone_start_lower") { name = "Lower Processing"; } else if(zone == "zone_tunnels_center") { name = "Center Tunnels"; } else if(zone == "zone_tunnels_north") { name = "Courthouse Tunnels 2"; } else if(zone == "zone_tunnels_north2") { name = "Courthouse Tunnels 1"; } else if(zone == "zone_tunnels_south") { name = "Saloon Tunnels 3"; } else if(zone == "zone_tunnels_south2") { name = "Saloon Tunnels 2"; } else if(zone == "zone_tunnels_south3") { name = "Saloon Tunnels 1"; } else if(zone == "zone_street_lightwest") { name = "Outside General Store & Bank"; } else if(zone == "zone_street_lightwest_alley") { name = "Outside General Store & Bank Alley"; } else if(zone == "zone_morgue_upstairs") { name = "Morgue"; } else if(zone == "zone_underground_jail") { name = "Jail Downstairs"; } else if(zone == "zone_underground_jail2") { name = "Jail Upstairs"; } else if(zone == "zone_general_store") { name = "General Store"; } else if(zone == "zone_stables") { name = "Stables"; } else if(zone == "zone_street_darkwest") { name = "Outside Gunsmith"; } else if(zone == "zone_street_darkwest_nook") { name = "Outside Gunsmith Nook"; } else if(zone == "zone_gun_store") { name = "Gunsmith"; } else if(zone == "zone_bank") { name = "Bank"; } else if(zone == "zone_tunnel_gun2stables") { name = "Stables To Gunsmith Tunnel 2"; } else if(zone == "zone_tunnel_gun2stables2") { name = "Stables To Gunsmith Tunnel"; } else if(zone == "zone_street_darkeast") { name = "Outside Saloon & Toy Store"; } else if(zone == "zone_street_darkeast_nook") { name = "Outside Saloon & Toy Store Nook"; } else if(zone == "zone_underground_bar") { name = "Saloon"; } else if(zone == "zone_tunnel_gun2saloon") { name = "Saloon To Gunsmith Tunnel"; } else if(zone == "zone_toy_store") { name = "Toy Store Downstairs"; } else if(zone == "zone_toy_store_floor2") { name = "Toy Store Upstairs"; } else if(zone == "zone_toy_store_tunnel") { name = "Toy Store Tunnel"; } else if(zone == "zone_candy_store") { name = "Candy Store Downstairs"; } else if(zone == "zone_candy_store_floor2") { name = "Candy Store Upstairs"; } else if(zone == "zone_street_lighteast") { name = "Outside Courthouse & Candy Store"; } else if(zone == "zone_underground_courthouse") { name = "Courthouse Downstairs"; } else if(zone == "zone_underground_courthouse2") { name = "Courthouse Upstairs"; } else if(zone == "zone_street_fountain") { name = "Fountain"; } else if(zone == "zone_church_graveyard") { name = "Graveyard"; } else if(zone == "zone_church_main") { name = "Church Downstairs"; } else if(zone == "zone_church_upstairs") { name = "Church Upstairs"; } else if(zone == "zone_mansion_lawn") { name = "Mansion Lawn"; } else if(zone == "zone_mansion") { name = "Mansion"; } else if(zone == "zone_mansion_backyard") { name = "Mansion Backyard"; } else if(zone == "zone_maze") { name = "Maze"; } else if(zone == "zone_maze_staircase") { name = "Maze Staircase"; } } else if(level.script == "zm_tomb") { if(isdefined(self.teleporting) && self.teleporting) { return ""; } if(zone == "zone_start") { name = "Lower Laboratory"; } else if(zone == "zone_start_a") { name = "Upper Laboratory"; } else if(zone == "zone_start_b") { name = "Generator 1"; } else if(zone == "zone_bunker_1a") { name = "Generator 3 Bunker 1"; } else if(zone == "zone_fire_stairs") { name = "Fire Tunnel"; } else if(zone == "zone_bunker_1") { name = "Generator 3 Bunker 2"; } else if(zone == "zone_bunker_3a") { name = "Generator 3"; } else if(zone == "zone_bunker_3b") { name = "Generator 3 Bunker 3"; } else if(zone == "zone_bunker_2a") { name = "Generator 2 Bunker 1"; } else if(zone == "zone_bunker_2") { name = "Generator 2 Bunker 2"; } else if(zone == "zone_bunker_4a") { name = "Generator 2"; } else if(zone == "zone_bunker_4b") { name = "Generator 2 Bunker 3"; } else if(zone == "zone_bunker_4c") { name = "Tank Station"; } else if(zone == "zone_bunker_4d") { name = "Above Tank Station"; } else if(zone == "zone_bunker_tank_c") { name = "Generator 2 Tank Route 1"; } else if(zone == "zone_bunker_tank_c1") { name = "Generator 2 Tank Route 2"; } else if(zone == "zone_bunker_4e") { name = "Generator 2 Tank Route 3"; } else if(zone == "zone_bunker_tank_d") { name = "Generator 2 Tank Route 4"; } else if(zone == "zone_bunker_tank_d1") { name = "Generator 2 Tank Route 5"; } else if(zone == "zone_bunker_4f") { name = "zone_bunker_4f"; } else if(zone == "zone_bunker_5a") { name = "Workshop Downstairs"; } else if(zone == "zone_bunker_5b") { name = "Workshop Upstairs"; } else if(zone == "zone_nml_2a") { name = "No Man's Land Walkway"; } else if(zone == "zone_nml_2") { name = "No Man's Land Entrance"; } else if(zone == "zone_bunker_tank_e") { name = "Generator 5 Tank Route 1"; } else if(zone == "zone_bunker_tank_e1") { name = "Generator 5 Tank Route 2"; } else if(zone == "zone_bunker_tank_e2") { name = "zone_bunker_tank_e2"; } else if(zone == "zone_bunker_tank_f") { name = "Generator 5 Tank Route 3"; } else if(zone == "zone_nml_1") { name = "Generator 5 Tank Route 4"; } else if(zone == "zone_nml_4") { name = "Generator 5 Tank Route 5"; } else if(zone == "zone_nml_0") { name = "Generator 5 Left Footstep"; } else if(zone == "zone_nml_5") { name = "Generator 5 Right Footstep Walkway"; } else if(zone == "zone_nml_farm") { name = "Generator 5"; } else if(zone == "zone_nml_celllar") { name = "Generator 5 Cellar"; } else if(zone == "zone_bolt_stairs") { name = "Lightning Tunnel"; } else if(zone == "zone_nml_3") { name = "No Man's Land 1st Right Footstep"; } else if(zone == "zone_nml_2b") { name = "No Man's Land Stairs"; } else if(zone == "zone_nml_6") { name = "No Man's Land Left Footstep"; } else if(zone == "zone_nml_8") { name = "No Man's Land 2nd Right Footstep"; } else if(zone == "zone_nml_10a") { name = "Generator 4 Tank Route 1"; } else if(zone == "zone_nml_10") { name = "Generator 4 Tank Route 2"; } else if(zone == "zone_nml_7") { name = "Generator 4 Tank Route 3"; } else if(zone == "zone_bunker_tank_a") { name = "Generator 4 Tank Route 4"; } else if(zone == "zone_bunker_tank_a1") { name = "Generator 4 Tank Route 5"; } else if(zone == "zone_bunker_tank_a2") { name = "zone_bunker_tank_a2"; } else if(zone == "zone_bunker_tank_b") { name = "Generator 4 Tank Route 6"; } else if(zone == "zone_nml_9") { name = "Generator 4 Left Footstep"; } else if(zone == "zone_air_stairs") { name = "Wind Tunnel"; } else if(zone == "zone_nml_11") { name = "Generator 4"; } else if(zone == "zone_nml_12") { name = "Generator 4 Right Footstep"; } else if(zone == "zone_nml_16") { name = "Excavation Site Front Path"; } else if(zone == "zone_nml_17") { name = "Excavation Site Back Path"; } else if(zone == "zone_nml_18") { name = "Excavation Site Level 3"; } else if(zone == "zone_nml_19") { name = "Excavation Site Level 2"; } else if(zone == "ug_bottom_zone") { name = "Excavation Site Level 1"; } else if(zone == "zone_nml_13") { name = "Generator 5 To Generator 6 Path"; } else if(zone == "zone_nml_14") { name = "Generator 4 To Generator 6 Path"; } else if(zone == "zone_nml_15") { name = "Generator 6 Entrance"; } else if(zone == "zone_village_0") { name = "Generator 6 Left Footstep"; } else if(zone == "zone_village_5") { name = "Generator 6 Tank Route 1"; } else if(zone == "zone_village_5a") { name = "Generator 6 Tank Route 2"; } else if(zone == "zone_village_5b") { name = "Generator 6 Tank Route 3"; } else if(zone == "zone_village_1") { name = "Generator 6 Tank Route 4"; } else if(zone == "zone_village_4b") { name = "Generator 6 Tank Route 5"; } else if(zone == "zone_village_4a") { name = "Generator 6 Tank Route 6"; } else if(zone == "zone_village_4") { name = "Generator 6 Tank Route 7"; } else if(zone == "zone_village_2") { name = "Church"; } else if(zone == "zone_village_3") { name = "Generator 6 Right Footstep"; } else if(zone == "zone_village_3a") { name = "Generator 6"; } else if(zone == "zone_ice_stairs") { name = "Ice Tunnel"; } else if(zone == "zone_bunker_6") { name = "Above Generator 3 Bunker"; } else if(zone == "zone_nml_20") { name = "Above No Man's Land"; } else if(zone == "zone_village_6") { name = "Behind Church"; } else if(zone == "zone_chamber_0") { name = "The Crazy Place Lightning Chamber"; } else if(zone == "zone_chamber_1") { name = "The Crazy Place Lightning & Ice"; } else if(zone == "zone_chamber_2") { name = "The Crazy Place Ice Chamber"; } else if(zone == "zone_chamber_3") { name = "The Crazy Place Fire & Lightning"; } else if(zone == "zone_chamber_4") { name = "The Crazy Place Center"; } else if(zone == "zone_chamber_5") { name = "The Crazy Place Ice & Wind"; } else if(zone == "zone_chamber_6") { name = "The Crazy Place Fire Chamber"; } else if(zone == "zone_chamber_7") { name = "The Crazy Place Wind & Fire"; } else if(zone == "zone_chamber_8") { name = "The Crazy Place Wind Chamber"; } else if(zone == "zone_robot_head") { name = "Robot's Head"; } } return name; }
Any help is appreciated, thanks in advance!
I also leave here the code from which I am getting the code to use (If there are any errors that's because the decompiler makes a bit of a mess)
https://drive.google.com/file/d/1j1Si33GBDmcn2oX-asCb68XEKgppjGsW/view?usp=sharing
-
I don't know how you compiled it but when compiling it I had an error because your
/
in the includes at the top should be\
insteadSecond your script doesn't have any entry point.
You declare multiple function and some code but you never use/call them so basically your script is never startingI tried fixing it but nothing shows up on screen so it would help if you could tell me what is supposed to be displayed on screen and when. Note that I don't play zombies at all
Also the original script was written in another language or for another platform it has a lot of errors if compiled, includes are wrong, colors are wrong, decimals are wrong etc.
-
Yeah, unfortunately the decompiler makes a lot of mess when you decompile too complex scripts, which is why the includes and some symbols are wrong, in fact in my code I managed to solve all these small errors.
How can i call a function in GSC? I mean, where in the code should i call the function?
The script should show on the lower left of the screen the zone the player is currently in (5and5 uses it in the BO2 Remix Mod).
I am attaching here a screenshot of what should appear on the screen (Center Town):
-
Should i call the functions like this?
init() { self endon("disconnect"); for(;;) { self waittill("spawned_player"); self thread zone_hud(); self thread zone_hud_watcher(x, y); self thread get_zone_name(); }
-
something like that
-
qnda This won't work.
Try this
init() { level thread on_player_connect(); } on_player_connect() { while ( true ) { level waittill( "connected", player ); //add your code here call it on player } }
Definitely don't use spawned_player for this because that would cause duplicate threads to be spawned every time a player respawns. This can cause the game to error.