Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Item Spawner II by H® Shaft
- -- re-write of Item spawner by 002, to include and accomodate rotation of the object, and fixed WeaponPickup function
- -- added x,y,z,r coordinate retrieval: type "coord" to return your x,y,z,rotation values, records in sapp log also
- -- These coordinates are the first race nav locations for each map, but - I didn't have the rotation value, so I put 0
- -- to retrieve coordinates, start the server on the map you want, go to the location you want, turn AND "FACE" in the rotation you want
- -- then, once you are where you want to be and facing the direction you want, type "coord" (no quotes) and it will show you
- -- on screen, and log into the sapp.log file the map name followed by X, Y, Z, Rotation, then you can add/edit these entries
- -- example: open the log, find bloodgulch (or map you were on) and copy the X, Y, Z, R and paste below into the item for that map
- -- you can have more than one entry per map in the items table, and more than one class type, more than one weapon, etc, etc
- -- a full list of tag names, sorted by class is at the bottom except vehicles/bipeds which should not be used in this script (but can)
- -- Configuration:
- -- Format: {"class","tagname",x,y,z,rotation,mapname,respawntime} separating each entry by commas, except for last entry.
- -- Example: {"weap","weapons\\plasma_cannon\\plasma_cannon",13.633, 13.249, -0.606, 0,"beavercreek",90.0},
- items = {
- {"weap","weapons\\plasma_cannon\\plasma_cannon",13.633, 13.249, -0.606, 0,"beavercreek",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",59.785, -121.995, 0.268, 0,"bloodgulch",30.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",16.896, -0.245, -2.280, 0,"boardingaction",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",0.064, -0.037, -0.855, 0,"carousel",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",0.898, 10.113, 0.747, 0,"chillout",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",-0.646, -1.527, 8.201, 0,"damnation",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",-0.800, 40.452, -6.000, 0,"dangercanyon",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",1.499, -55.629, 1.645, 0,"deathisland",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",42.076, -71.727, -12.711, 0,"gephyrophobia",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",20.244, 12.534, -7.949, 0,"hangemhigh",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",-26.061, 32.583, 9.008, 0,"icefields",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",0.461, -158.781, 13.574, 0,"infinity",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",-0.904, -14.556, 0.168, 0,"longest",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",9.959, 4.606, -0.407, 0,"prisoner",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",-3.753, -20.851, 0.903, 0,"putput",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",-3.937, -8.287, -1.379, 0,"ratrace",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",1.800, 54.512, -2.801, 0,"sidewinder",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",17.330, -1.847, -21.034, 0,"timberland",90.0},
- {"weap","weapons\\plasma_cannon\\plasma_cannon",5.555, -3.075, -2.749, 0,"wizard",90.0}
- }
- -- End of configuration
- api_version = "1.9.0.0"
- items_to_use = {}
- function OnScriptLoad()
- register_callback(cb["EVENT_GAME_START"], "GameInit")
- register_callback(cb["EVENT_GAME_END"], "GameEnded")
- register_callback(cb["EVENT_WEAPON_PICKUP"], "WeaponPickup")
- register_callback(cb["EVENT_TICK"], "RespawnObjects")
- register_callback(cb["EVENT_CHAT"], "OnPlayerChat")
- GameInit()
- end
- function GameInit()
- items_to_use = {}
- map = get_var(1,"$map")
- for k,v in pairs(items) do
- if(v[7] == map) then -- values: 1 = class, 2 = tagname, 3 = x, 4 = y, 5 = z, 6 = r, 7 = mapname, 8 = respawn time
- items_to_use[1 + #items_to_use] = v
- end
- end
- execute_command("sv_map_reset")
- end
- function GameEnded()
- items_to_use = {}
- end
- function RespawnObjects()
- if(table.getn(items_to_use) == 0) then return true end
- local time = os.clock()
- for k,v in pairs(items_to_use) do
- if(v.item ~= nil) then
- -- Check if item has despawned. If it has, we can no longer keep track of it.
- if(v.item.object_id ~= nil) then
- if(get_object_memory(v.item.object_id) == 0) then
- v.item.object_id = nil
- end
- end
- -- Check if respawn timer has been exceeded.
- if(time > v.item.destruction_time) then
- if(v.item.object_id ~= nil) then destroy_object(v.item.object_id) end
- v.item = nil
- end
- end
- if(v.item == nil) then
- v.item = {}
- v.item.destruction_time = 0
- end
- -- Respawn deleted items:
- if(time > v.item.destruction_time) then
- v.item = {}
- v.item.object_id = spawn_object(v[1],v[2],v[3],v[4],v[5],v[6]) --values 1 = class, 2 = tagname, 3 = x, 4 = y, 5 = z, 6 = r, 7 = mapname, 8 = respawn time
- local item_object = get_object_memory(v.item.object_id)
- if (item_object ~= 0) then
- if v[1] == "vehi" then
- if (read_dword(item_object + 0x5AC) ~= 0xFFFFFFFF) then -- if in use
- v.item.destruction_time = time + 300 -- allow vehicle use for 5 mins
- else
- write_dword(item_object + 0x5B0, 0xFFFF)
- v.item.destruction_time = time + v[8]
- end
- else
- write_dword(item_object + 0x204, 0xFFFF) -- note: if this is applied to a vehicle/hog it will not be driveable/stays stationary, could be a good hack
- v.item.destruction_time = time + v[8]
- end
- end
- end
- end
- return true
- end
- function WeaponPickup(PlayerIndex,WeaponSlot,WeaponType)
- -- changed: previously it would sometimes delete a players weapon, (if weapon was a spawned item)
- -- as it did not reliably complete the loop via sapps "WeaponSlot" and 002's loop method
- if (WeaponType == "1") then
- local player_dyn = get_dynamic_player(PlayerIndex)
- -- Iterate through all player weapons one-by-one, if a match is found, remove/nil the item from being tracked
- for i=0,3 do
- local object_id = read_dword(player_dyn + 0x2F8 + i * 0x4)
- for k,v in pairs(items_to_use) do
- if(v.item ~= nil) then
- if(v.item.object_id == object_id) then
- v.item.object_id = nil
- end
- end
- end
- end
- end
- end
- function OnPlayerChat(PlayerIndex, Message)
- local response = nil
- local name = get_var(PlayerIndex,"$name")
- local Message = string.lower(Message)
- -- | retrieve your coordinates x,y,z and rotation (yaw)
- if (Message == "coord") then
- response = false
- local player_object = get_dynamic_player(PlayerIndex)
- local player_static = get_player(PlayerIndex)
- local x,y,z = read_vector3d(player_object + 0x5C)
- x = math.round(x, 2)
- y = math.round(y, 2)
- z = math.round(z, 2)
- local rotation = read_float(player_static + 0x138)
- rotation = math.round(rotation, 2)
- local map_name = get_var(0,"$map")
- local data = string.format("%s XYZR: %s, %s, %s, %s", tostring(map_name),tostring(x),tostring(y),tostring(z),tostring(rotation))
- execute_command("log_note \""..data.."\"")
- say(PlayerIndex, "Location written to logs under map: " .. map_name)
- say(PlayerIndex, "X: " .. x .. " Y: " .. y .. " Z: " .. z .. " R: " .. rotation)
- end
- return response
- end
- function math.round(num, idp)
- return tonumber(string.format("%." .. (idp or 0) .. "f", num))
- end
- function OnScriptUnload() end
- function OnError(Message)
- print(debug.traceback())
- end
- -- Created by H® Shaft, original by 002
- -- Visit http://halorace.org/forum/index.php
- -- tag name list by "class"
- -- Note: You must use two backslashes for each backslash in order for Lua to interpret it correctly.
- -- "eqip" = equipment:
- -- "powerups\\active camouflage"
- -- "powerups\\health pack"
- -- "powerups\\over shield"
- -- "weapons\\frag grenade\\frag grenade"
- -- "weapons\\plasma grenade\\plasma grenade"
- -- "weap" = weapons:
- -- "weapons\\assault rifle\\assault rifle"
- -- "weapons\\ball\\ball"
- -- "weapons\\flag\\flag"
- -- "weapons\\flamethrower\\flamethrower"
- -- "weapons\\gravity rifle\\gravity rifle"
- -- "weapons\\needler\\mp_needler"
- -- "weapons\\needler\\needler"
- -- "weapons\\pistol\\pistol"
- -- "weapons\\plasma pistol\\plasma pistol"
- -- "weapons\\plasma rifle\\plasma rifle"
- -- "weapons\\plasma_cannon\\plasma_cannon"
- -- "weapons\\rocket launcher\\rocket launcher"
- -- "weapons\\shotgun\\shotgun"
- -- "weapons\\sniper rifle\\sniper rifle"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement