Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Random Team and FFA Colors
- -- by H® Shaft for SAPP
- -- Team Games: Each game, team colors are randomly selected, and are never the same game to game
- -- FFA Games: Each time a player spawns, they are given a new random color
- -- inspired by 002's custom colors script
- api_version = "1.9.0.0"
- game_started = false
- team_play = false
- function OnScriptLoad()
- location_store = sig_scan("741F8B482085C9750C")
- if(location_store == 0) then
- location_store = sig_scan("EB1F8B482085C9750C")
- if(location_store == 0) then
- cprint("Failed to find color assignment signature")
- end
- end
- safe_write(true)
- write_char(location_store,235)
- safe_write(false)
- register_callback(cb['EVENT_JOIN'], "OnPlayerJoin")
- register_callback(cb['EVENT_TEAM_SWITCH'], "ChangeColor")
- register_callback(cb['EVENT_GAME_START'], "OnNewGame")
- register_callback(cb['EVENT_GAME_END'],"OnGameEnd")
- register_callback(cb['EVENT_DIE'], "OnPlayerDie")
- if get_var(0, "$gt") ~= "n/a" then
- OnNewGame()
- end
- end
- function OnNewGame()
- game_started = true
- team_play = getteamplay()
- LoadColors()
- end
- function OnGameEnd()
- game_started = false
- end
- function OnPlayerJoin(PlayerIndex)
- if (game_started == true) then
- ChangeColor(PlayerIndex)
- end
- end
- function OnPlayerDie(PlayerIndex, KillerIndex)
- if (game_started == true) then
- if (team_play == false) then
- ChangeColor(PlayerIndex)
- end
- end
- end
- function ChangeColor(PlayerIndex)
- if (game_started == true) then
- if (player_present(PlayerIndex) == true) then
- if (team_play == true) then
- if (get_var(PlayerIndex,"$team") == "red") then
- write_word(get_player(PlayerIndex) + 0x60, contrast_table[random_colors][1])
- else
- write_word(get_player(PlayerIndex) + 0x60, contrast_table[random_colors][2])
- end
- else
- local color = rand(1, #SKITTLES+1)
- write_word(get_player(PlayerIndex) + 0x60, color)
- end
- end
- end
- end
- function getteamplay()
- if get_var(0,"$ffa") == "0" then
- return true
- else
- return false
- end
- end
- -- 0 = white, 1 = black, 2 = red, 3 = blue, 4 = gray, 5 = yellow, 6 = green
- -- 7 = pink, 8 = purple, 9 = cyan, 10 = cobalt, 11 = orange, 12 = teal, 13 = sage,
- -- 14 = brown, 15 = tan, 16 = maroon, 17 = salmon
- -- skittles: no dank colors: no gray, brown, tan
- function LoadColors()
- contrast_table = {}
- contrast_table[1] = {0,1}
- contrast_table[2] = {2,3}
- contrast_table[3] = {5,6}
- contrast_table[4] = {7,8}
- contrast_table[5] = {9,13}
- contrast_table[6] = {10,11}
- contrast_table[7] = {11,1}
- contrast_table[8] = {6,11}
- contrast_table[9] = {16,12}
- contrast_table[10] = {16,10}
- contrast_table[11] = {10,7}
- contrast_table[12] = {8,1}
- contrast_table[13] = {12,8}
- contrast_table[14] = {13,5}
- contrast_table[15] = {5,0}
- contrast_table[16] = {7,6}
- contrast_table[17] = {8,9}
- contrast_table[18] = {13,3}
- contrast_table[19] = {6,10}
- contrast_table[20] = {5,1}
- contrast_table[21] = {2,9}
- random_colors = rand(1, #contrast_table+1)
- SKITTLES = {2,3,5,6,7,8,9,10,11,12,13,17,0}
- end
- function OnScriptUnload()
- if(location_store == 0) then return end
- safe_write(true)
- write_char(location_store,116)
- safe_write(false)
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement