Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Setup Player Grenades 1.2 for SAPP
- -- by H® Shaft
- -- Allows server admins to set number of frag and plasma grenades per map, assigned when player spawns.
- -- Allows server admins to set maximum number of grenades a player may hold per map.
- -- See line 78 and below - 'load tables' to modify the grenade counts/maximums you prefer per map, and to add maps.
- -- WILL work with stock PC/CE maps, and CE maps with stock grenade sets (names)
- -- sapp api version
- api_version = "1.8.0.0"
- function OnScriptLoad()
- register_callback(cb['EVENT_GAME_START'], "OnNewGame")
- register_callback(cb["EVENT_WEAPON_PICKUP"],"OnWeaponPickup")
- register_callback(cb['EVENT_SPAWN'], "OnPlayerSpawn")
- map_name = get_var(0,"$map")
- Load_Tables()
- end
- function OnScriptUnload()
- frag_count = {}
- plasma_count = {}
- end
- function OnNewGame()
- map_name = get_var(0,"$map")
- Load_Tables()
- end
- function GameEnd()
- game_started = false
- end
- function OnPlayerSpawn(PlayerIndex)
- if player_alive(PlayerIndex) then
- local player_object = get_dynamic_player(PlayerIndex)
- if (player_object ~= 0) then
- write_word(player_object + 0x31E, frag_count[map_name])
- write_word(player_object + 0x31F, plasma_count[map_name])
- end
- end
- end
- function OnWeaponPickup(PlayerIndex, WeaponSlot, WeaponType)
- local player_object = get_dynamic_player(PlayerIndex)
- if (player_object ~= 0) then
- local x,y,z = read_vector3d(player_object + 0x5C)
- local fragcount = tonumber(read_word(player_object + 0x31E))
- local plasmacount = tonumber(read_word(player_object + 0x31F))
- if (WeaponType == "2") then
- if (WeaponSlot == "1") then
- if (fragcount > tonumber(max_frags[map_name])) then
- timer(1000, "DropFrag", PlayerIndex,x,y,z+0.15)
- end
- elseif (WeaponSlot == "2") then
- if (plasmacount > tonumber(max_plasmas[map_name])) then
- timer(1000, "DropPlasma", PlayerIndex,x,y,z+0.15)
- end
- end
- end
- end
- end
- function DropFrag(PlayerIndex,x,y,z)
- local repl_frag = spawn_object("eqip", "weapons\\frag grenade\\frag grenade", x, y, z+0.15)
- if player_alive(PlayerIndex) then
- execute_command('nades me ' .. max_frags[map_name] .. ' 1', PlayerIndex)
- end
- end
- function DropPlasma(PlayerIndex,x,y,z)
- local repl_plasma = spawn_object("eqip", "weapons\\plasma grenade\\plasma grenade", x, y, z+0.15)
- if player_alive(PlayerIndex) then
- execute_command('nades me ' .. max_plasmas[map_name] .. ' 2', PlayerIndex)
- end
- end
- function Load_Tables()
- -- specify the number of frag grenades when player spawns
- -- each map in this table, must be separated with a comma
- -- specify the number of frag grenades a player will spawn with
- -- map name # count
- frag_count = {
- beavercreek = 1,
- bloodgulch = 1,
- boardingaction = 1,
- carousel = 1,
- chillout = 1,
- damnation = 1,
- dangercanyon = 1,
- deathisland = 1,
- gephyrophobia = 1,
- hangemhigh = 1,
- icefields = 1,
- infinity = 1,
- longest = 1,
- prisoner = 1,
- putput = 1,
- ratrace = 1,
- sidewinder = 1,
- timberland = 1,
- wizard = 1,
- }
- -- specify the maximum number of frag grenades a player can hold
- -- map name # count
- max_frags = {
- beavercreek = 1,
- bloodgulch = 1,
- boardingaction = 1,
- carousel = 1,
- chillout = 1,
- damnation = 1,
- dangercanyon = 1,
- deathisland = 1,
- gephyrophobia = 1,
- hangemhigh = 1,
- icefields = 1,
- infinity = 1,
- longest = 1,
- prisoner = 1,
- putput = 1,
- ratrace = 1,
- sidewinder = 1,
- timberland = 1,
- wizard = 1,
- }
- -- specify the number of plasma grenades a player will spawn with
- -- map name # count
- plasma_count = {
- beavercreek = 1,
- bloodgulch = 1,
- boardingaction = 1,
- carousel = 1,
- chillout = 1,
- damnation = 1,
- dangercanyon = 1,
- deathisland = 1,
- gephyrophobia = 1,
- hangemhigh = 1,
- icefields = 1,
- infinity = 1,
- longest = 1,
- prisoner = 1,
- putput = 1,
- ratrace = 1,
- sidewinder = 1,
- timberland = 1,
- wizard = 1,
- }
- -- specify the maximum number of plasma grenades a player can hold
- -- map name # count
- max_plasmas = {
- beavercreek = 1,
- bloodgulch = 1,
- boardingaction = 1,
- carousel = 1,
- chillout = 1,
- damnation = 1,
- dangercanyon = 1,
- deathisland = 1,
- gephyrophobia = 1,
- hangemhigh = 1,
- icefields = 1,
- infinity = 1,
- longest = 1,
- prisoner = 1,
- putput = 1,
- ratrace = 1,
- sidewinder = 1,
- timberland = 1,
- wizard = 1,
- }
- end
- -- Created by H® Shaft
- -- Visit Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement