Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Setup Weapons for stock PC/CE maps for SAPP
- -- by H® Shaft
- -- Allows server admins to setup primary and secondary weapons per map, and grenade counts per map. See line 78 - load tables to modify.
- -- WILL work with custom CE maps which have stock weapon sets
- -- sapp api version
- api_version = "1.8.0.0"
- -- do not edit --
- game_started = false
- function OnScriptLoad()
- register_callback(cb['EVENT_GAME_START'], "NewGame")
- register_callback(cb['EVENT_GAME_END'], "GameEnd")
- register_callback(cb['EVENT_SPAWN'], "OnSpawn")
- map_name = get_var(0,"$map")
- Load_Tables()
- end
- function OnScriptUnload()
- primary_weapon = {}
- secondary_weapon = {}
- frag_count = {}
- plasma_count = {}
- end
- function NewGame()
- game_started = true
- map_name = get_var(0,"$map")
- Load_Tables()
- end
- function GameEnd()
- game_started = false
- end
- function OnSpawn(PlayerIndex)
- if player_alive(PlayerIndex) and game_started then
- -- destroy existing weapons
- local player_object = get_dynamic_player(PlayerIndex)
- for i = 0,3 do
- local weapID = read_dword(player_object + 0x2F8 + i*4)
- if weapID ~= 0xFFFFFFFF then
- destroy_object(weapID)
- end
- end
- -- initiate timer to assign scripted weapons
- gameweap = timer(33, "AssignGameWeapons", PlayerIndex)
- end
- end
- function AssignGameWeapons(PlayerIndex)
- if player_alive(PlayerIndex) and game_started then
- local player_object = get_dynamic_player(PlayerIndex)
- local player_static = get_player(PlayerIndex)
- local x,y,z = read_vector3d(player_object + 0x5C)
- local Z = z+0.5
- -- grenades
- safe_write(true)
- write_word(player_object + 0x31E, frag_count[map_name])
- write_word(player_object + 0x31F, plasma_count[map_name])
- safe_write(false)
- -- create and assign weapons
- if secondary_weapon[map_name] ~= nil then
- local secondary_id = spawn_object("weap", secondary_weapon[map_name],x,y,Z)
- assign_weapon(secondary_id, PlayerIndex)
- end
- if primary_weapon[map_name] ~= nil then
- local primary_id = spawn_object("weap", primary_weapon[map_name],x,y,Z)
- assign_weapon(primary_id, PlayerIndex)
- end
- end
- return false
- end
- function Load_Tables()
- -- WEAPON NAME list of weapon tag names (stock PC/CE weapons)
- PLASMA_PISTOL = "weapons\\plasma pistol\\plasma pistol"
- NEEDLER = "weapons\\needler\\mp_needler"
- SHOTGUN = "weapons\\shotgun\\shotgun"
- ASSAULT_RIFLE = "weapons\\assault rifle\\assault rifle"
- FLAME_THROWER = "weapons\\flamethrower\\flamethrower"
- PISTOL = "weapons\\pistol\\pistol"
- PLASMA_RIFLE = "weapons\\plasma rifle\\plasma rifle"
- PLASMA_CANNON = "weapons\\plasma_cannon\\plasma_cannon"
- ROCKET_LAUNCHER = "weapons\\rocket launcher\\rocket launcher"
- SNIPER_RIFLE = "weapons\\sniper rifle\\sniper rifle"
- DISABLED = "nil"
- -- first weapon: specify WEAPON NAME (as listed above/UPPERCASE) for each map, example: SHOTGUN
- -- each map in this table, must be separated with a comma
- primary_weapon = {
- beavercreek = SHOTGUN,
- bloodgulch = PISTOL,
- boardingaction = SNIPER_RIFLE,
- carousel = ASSAULT_RIFLE,
- chillout = PLASMA_RIFLE,
- damnation = PISTOL,
- dangercanyon = PISTOL,
- deathisland = PISTOL,
- gephyrophobia = PISTOL,
- hangemhigh = PISTOL,
- icefields = PISTOL,
- infinity = PISTOL,
- longest = PISTOL,
- prisoner = ROCKET_LAUNCHER,
- putput = SHOTGUN,
- ratrace = ASSAULT_RIFLE,
- sidewinder = PISTOL,
- timberland = PISTOL,
- wizard = SHOTGUN,
- }
- --second weapon: specify WEAPON NAME (as listed above) for each map, example: SHOTGUN
- -- to disable a secondary weapon for this map, use the weapon name: DISABLED (Do not use for primary weapon)
- -- each map in this table, must be separated with a comma
- secondary_weapon = {
- beavercreek = NEEDLER,
- bloodgulch = ASSAULT_RIFLE,
- boardingaction = PISTOL,
- carousel = PLASMA_RIFLE,
- chillout = SHOTGUN,
- damnation = PLASMA_PISTOL,
- dangercanyon = ASSAULT_RIFLE,
- deathisland = ASSAULT_RIFLE,
- gephyrophobia = ASSAULT_RIFLE,
- hangemhigh = SHOTGUN,
- icefields = ASSAULT_RIFLE,
- infinity = ASSAULT_RIFLE,
- longest = PLASMA_PISTOL,
- prisoner = DISABLED,
- putput = ASSAULT_RIFLE,
- ratrace = FLAME_THROWER,
- sidewinder = ASSAULT_RIFLE,
- timberland = ASSAULT_RIFLE,
- wizard = PLASMA_PISTOL,
- }
- -- specify the number of frag grenades when player spawns
- -- map name # count
- -- each map in this table, must be separated with a comma
- frag_count = {
- beavercreek = 2,
- beavercreek = 0,
- bloodgulch = 2,
- boardingaction = 2,
- carousel = 1,
- chillout = 0,
- damnation = 1,
- dangercanyon = 2,
- deathisland = 4,
- gephyrophobia = 2,
- hangemhigh = 1,
- icefields = 2,
- infinity = 4,
- longest = 1,
- prisoner = 2,
- putput = 0,
- ratrace = 1,
- sidewinder = 2,
- timberland = 2,
- wizard = 1,
- }
- -- specify the number of plasma grenades when player spawns
- -- map name # count
- plasma_count = {
- beavercreek = 0,
- bloodgulch = 2,
- boardingaction = 2,
- carousel = 1,
- chillout = 0,
- damnation = 1,
- dangercanyon = 2,
- deathisland = 4,
- gephyrophobia = 2,
- hangemhigh = 1,
- icefields = 2,
- infinity = 4,
- longest = 1,
- prisoner = 2,
- putput = 2,
- ratrace = 1,
- sidewinder = 2,
- timberland = 2,
- wizard = 1,
- }
- end
- function OnError(Message)
- print(debug.traceback())
- end
- -- Created by H® Shaft
- -- Visit Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement