Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Alternating Camo for Sapp by H® Shaft
- -- If enabled, players will have alternating camouflage randomly lasting between 2 and 6 seconds, followed by 6 seconds of visibility
- -- You can enable or disable for each map, and - you can add your own maps see line 117: alternating_camo table of function SetDefaults()
- -- This will not affect the typical 30 seconds of invisibility a player gets when picking up the active camouflage
- -- Sapp Version 10 changed the duration of camo to be multiplied by 30 = 1 second, previous versions were multiplied by 1000 = 1 second
- -- if you are using an older version of sapp than 1.10.0.0 - set OLD_VERSION to true
- -- Sehe the author of sapp, was not around to verify which specific version he made this change - so, experiment if needed.
- OLD_VERSION = false
- api_version = "1.10.0.0"
- function OnScriptLoad()
- register_callback(cb['EVENT_GAME_START'], "OnNewGame")
- register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
- register_callback(cb['EVENT_SPAWN'], "OnPlayerSpawn")
- if get_var(0, "$gt") ~= "n/a" then
- game_started = true
- OnNewGame()
- else
- game_started = false
- end
- end
- function OnScriptUnload()
- alternating_camo = {}
- end
- function OnNewGame()
- game_started = true
- map_name = get_var(0,"$map")
- SetDefaults()
- end
- function OnGameEnd()
- game_started = false
- end
- function OnPlayerSpawn(PlayerIndex)
- if player_present(PlayerIndex) then
- if (alternating_camo[map_name] == true) then -- if enabled ...
- local random_start = rand(1, 6) -- between 1 and 5 seconds to start
- local start = (random_start * 1000)
- randomcamo = timer(start, "Random_Camo", PlayerIndex) -- begin first loop
- end
- end
- end
- function Random_Camo(PlayerIndex)
- if player_present(PlayerIndex) and game_started then
- local invis = tonumber(get_var(PlayerIndex, "$invis")) -- 1 if camo'd, 0 if not or dead
- local random_duration = rand(2, 7) -- between 2 and 6 seconds in duration
- local duration
- if not OLD_VERSION then
- duration = (random_duration * 30)
- else
- duration = (random_duration * 1000)
- end
- local start = (random_duration * 1000 + 8000)
- if invis == 0 and player_alive(PlayerIndex) then
- camo(PlayerIndex, duration)
- reapplycamo = timer(start, "Reapply_Camo", PlayerIndex) -- continue the loop
- else
- reapplycamo = timer(start, "Reapply_Camo", PlayerIndex) -- continue the loop
- end
- end
- return false
- end
- function Reapply_Camo(PlayerIndex)
- if player_present(PlayerIndex) and game_started then
- local invis = tonumber(get_var(PlayerIndex, "$invis")) -- 1 if camo'd, 0 if not or dead
- local random_duration = rand(2, 7) -- between 2 and 6 seconds in duration
- local duration
- if not OLD_VERSION then
- duration = (random_duration * 30)
- else
- duration = (random_duration * 1000)
- end
- local start = (random_duration * 1000 + 8000)
- if invis == 0 and player_alive(PlayerIndex) then
- camo(PlayerIndex, duration)
- randomcamo = timer(start, "Random_Camo", PlayerIndex) -- restart the loop +1 second later
- else
- recyclecamo = timer(start, "Recycle_Camo", PlayerIndex) -- continue the loop a bit later, player is either dead or still has camo
- end
- end
- return false
- end
- function Recycle_Camo(PlayerIndex)
- if player_present(PlayerIndex) and game_started then
- local invis = tonumber(get_var(PlayerIndex, "$invis")) -- 1 if camo'd, 0 if not or dead
- local random_duration = rand(2, 7) -- between 2 and 6 seconds in duration
- local duration
- if not OLD_VERSION then
- duration = (random_duration * 30)
- else
- duration = (random_duration * 1000)
- end
- local start = (random_duration * 1000 + 8000)
- if invis == 0 and player_alive(PlayerIndex) then
- camo(PlayerIndex, duration)
- randomcamo = timer(start, "Random_Camo", PlayerIndex) -- restart the loop +1 second later
- else
- randomcamo = timer(start, "Random_Camo", PlayerIndex) -- continue the loop a bit later, player is either dead or still has camo
- end
- end
- return false
- end
- function SetDefaults()
- -- EDIT HERE: enabled = true, disabled = false You can add your own maps, but be sure to separate each entry with a comma as seen below
- alternating_camo = {
- ["bloodgulch"] = true,
- ["dangercanyon"] = true,
- ["deathisland"] = true,
- ["gephyrophobia"] = true,
- ["icefields"] = true,
- ["infinity"] = true,
- ["sidewinder"] = true,
- ["timberland"] = true,
- ["hangemhigh"] = true,
- ["ratrace"] = true,
- ["beavercreek"] = true,
- ["damnation"] = true,
- ["boardingaction"] = true,
- ["carousel"] = true,
- ["putput"] = true,
- ["prisoner"] = true,
- ["wizard"] = true,
- }
- -- don't edit below this -- restart if script is reloaded during a game
- for i=1,16 do
- if player_alive(i) then
- if alternating_camo[map_name] == true and game_started then
- local invis = tonumber(get_var(i, "$invis"))
- local random_start = rand(1, 6) -- between 1 and 5 seconds to start
- local start = (random_start * 1000)
- if invis == 0 then
- randomcamo = timer(start, "Random_Camo", i)
- end
- end
- end
- end
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
- -- The player -db-GoNe/Juhleek - a well spoken liar, cheat.
- -- -db- is: "diverging from the believable" - How ironic. A race clan where admins use rcon to favor themselves to win.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement