Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Global Vehicle Meta-Ids (Utility Script for scripting with SAPP, not a game-play script)
- -- by H® Shaft
- -- edited 11/26/2016 corrected an omitted map name
- -- This script will display a list of vehicle meta-ids listed in the maps global tag
- -- Works with BOTH protected and unprotected Halo PC/CE maps
- -- This will display and log: 1) a meta-id list, or: 2) a single vehicle meta-id into sapps log file with the map name
- -- see USAGE below.
- -- Usage:
- -- to see and save a list of all global vehicle meta-ids, type: "all_vehicles" (without quotes)
- -- to see and save the meta-id of the vehicle you are IN, type "this_vehicle" (without quotes)
- -- Sample Output (all_vehicles) Displayed on screen, and logged into sapp.log:
- -- There are 6 vehicles listed in the map bloodgulch (PC/CE):
- -- Vehicle # 1: Meta ID: 3822322272
- -- Vehicle # 2: Meta ID: 3837199171
- -- Vehicle # 3: Meta ID: 3830907619
- -- Vehicle # 4: Meta ID: 3846177740
- -- Vehicle # 5: Meta ID: 3899197173
- -- Vehicle # 6: Meta ID: 3842311057
- -- Each map has a standard list of SIX vehicle 'slots', this is the "stock" slot list.
- -- This slot list matches the multiplayer gametype 'vehicle options' screen, in the halo lobby 'Edit Gametypes' section:
- -- Slot 1: Warthog
- -- Slot 2: Ghost
- -- Slot 3: Scorpion
- -- Slot 4: Rocket Warthog
- -- Slot 5: Banshee
- -- Slot 6: Gun Turret
- -- Notes:
- -- 'Stock' PC/CE maps always follow the above order, BUT, - not all "custom" Halo CE maps follow the above order.
- -- The Custom map's author may have 'mixed the slot order', or - may not have used all six slots, or
- -- some vehicles in the map may have been spawned by a 'built-in' halo script. If so, they may NOT all be listed in the output
- -- Slots 1, 2 & 4 are the vehicles typically setup for RACE gametypes, and others will not 'usually' spawn during race games.
- -- Stock PC/CE maps use the same meta-ids for each slot for both PC and CE stock maps (Warthog meta-id for PC and CE is 3822322272)
- -- "Custom Maps" use meta-ids that are unique to each map.
- -- sapp api version
- api_version = "1.9.0.0"
- function OnScriptLoad()
- register_callback(cb['EVENT_CHAT'], "OnPlayerChat")
- vehicle_index = {}
- end
- function OnPlayerChat(PlayerIndex, Message)
- local response = nil
- local Message = string.lower(Message)
- map_name = get_var(0,"$map")
- -- | retrieve and show/save the meta-id list for map from globals tag
- if (Message == "all_vehicles") then
- response = false
- if (get_var(0, "$gt") ~= "n/a") then
- local globals_tag = lookup_tag("matg", "globals\\globals")
- local globals_data = read_dword(globals_tag + 0x14)
- local mp_info_data = read_dword(globals_data + 0x168)
- local vehicles_count = read_dword(mp_info_data + 0x20)
- local vehicles_data = read_dword(mp_info_data + 0x24)
- vehicle_index[map_name] = {}
- if vehicles_count > 0 then
- local str1 = string.format("There are %s vehicles listed in the map %s:", tostring(vehicles_count),tostring(map_name))
- execute_command("log_note \""..str1.."\"")
- say(PlayerIndex,str1)
- local veh_index = 1
- for i=0,vehicles_count-1 do
- local vehicle_metaid = read_dword(vehicles_data + i*16 + 0xC)
- if (vehicle_metaid ~= 0) then
- vehicle_index[map_name][1] = veh_index
- vehicle_index[map_name][2] = vehicle_metaid
- local str2 = string.format("Vehicle #%s: Meta ID: %s", tostring(vehicle_index[map_name][1]), tostring(vehicle_index[map_name][2]))
- say(PlayerIndex, str2)
- execute_command("log_note \""..str2.."\"")
- veh_index = veh_index + 1
- end
- end
- say(PlayerIndex, "This list was saved in the sapp log file.")
- else
- local str3 = string.format("There are no vehicles listed in %s, or there was an error.", tostring(map_name))
- say(PlayerIndex, str3)
- execute_command("log_note \""..str3.."\"")
- end
- end
- end
- -- | retrieve and show/save the meta-id for your current vehicle (you must be in a vehicle)
- if (Message == "this_vehicle") then
- response = false
- if isinvehicle(PlayerIndex) then
- local player_object = get_dynamic_player(PlayerIndex)
- local vehicle_id = read_dword(player_object + 0x11C)
- local veh_object = get_object_memory(vehicle_id)
- if (veh_object ~= 0) then
- local vehicle_metaid = read_dword(veh_object)
- if (vehicle_metaid ~= 0) then
- local data = string.format("Map: %s Vehicle MetaId: %s", tostring(map_name),tostring(vehicle_metaid))
- execute_command("log_note \""..data.."\"")
- say(PlayerIndex, data)
- say(PlayerIndex, "This vehicle's meta-id was saved in the sapp log file.")
- else
- say(PlayerIndex, "Sorry, there was an error, no meta-data available.")
- end
- end
- else
- say(PlayerIndex, "You must be in a vehicle to retrieve it's meta-data.")
- end
- end
- return response
- end
- function isinvehicle(PlayerIndex)
- local player_object = get_dynamic_player(PlayerIndex)
- if player_object ~= 0 then
- local vehicleId = read_dword(player_object + 0x11C)
- if vehicleId == 0xFFFFFFFF then
- return false
- else
- return true
- end
- else
- return false
- end
- end
- function OnScriptUnload()
- vehicle_index = {}
- end
- function OnError(Message)
- print(debug.traceback())
- end
- -- Created by H® Shaft, special thanks to Giraffe
- -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement