Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ ### Automatic Server Messages 1.0 ###]]--
- --[[ ### by H® Shaft for SAPP ###]]--
- -- Enable server admins to setup automatic server messages: single line messages that will be shown to players based on the delay frequency you set
- -- You can determine the order of the messages as sequential or random: default sequential (see random_order below)
- -- Spam Messages: Messages everyone sees based on the order and frequency you set. Defaults: Sequential order, 1 spam message shown every 60 seconds
- -- Join Message: Private messages only shown to the joining player
- -- End Messages: Private message shown to each player at games end.
- -- Team Switch Message: Message everyone sees when a player switches teams during team games, shows the team they switched to.
- -- Team Kill Message: Private message only the betrayer sees on team games.
- -- spam messages: add your own, ensure the messages are within quotes, and separated by a comma between each message
- -- add as many as you want
- SPAM_MESSAGES = {
- "Spam message 1",
- "Spam message 2",
- "Spam message 3",
- }
- -- message order: If set to true, spam messages will be in random order (1,4,2,5,3 etc). If false, it will be sequential (1,2,3,4,5 etc)
- -- random order only recommended when you have more than 5 spam messages
- RANDOM_ORDER = false
- -- delay in SECONDS between each spam message, if less than 60 seconds, it seems spammy. Too much spam causes players to ignore all messages.
- MESSAGE_DELAY = 30
- -- private message shown when player joins. Optional player name variable ($PLAYER) Example: Welcome to the best server H® Shaft!
- -- should not be more than 3 entries, ensure the messages are within quotes, and separated by a comma between each message
- JOIN_MESSAGES = {
- "Private join message 1: $PLAYER",
- "Private join message 2: $PLAYER",
- "Private join message 3: $PLAYER",
- }
- -- message shown when game ends. Optional player name variable ($PLAYER) Example: Thanks for playing in the best server H® Shaft!
- -- should not be more than 3 entries, ensure the messages are within quotes, and separated by a comma between each message
- END_MESSAGES = {
- "Private game end message 1: $PLAYER",
- "Private game end message 2: $PLAYER",
- "Private game end message 3: $PLAYER",
- }
- -- a single private message shown to betrayer when they team kill, Optional player name variable ($PLAYER)
- TK_MESSAGE = "$PLAYER !!: DON'T KILL YOUR OWN TEAM!!"
- -- sapp api version
- api_version = "1.8.0.0"
- game_started = false
- function OnScriptLoad()
- MESSAGE_NO = 1
- register_callback(cb['EVENT_GAME_START'],"OnNewGame")
- register_callback(cb['EVENT_GAME_END'],"OnGameEnd")
- register_callback(cb['EVENT_JOIN'],"OnPlayerJoin")
- register_callback(cb['EVENT_BETRAY'], "OnEventBetray")
- register_callback(cb['EVENT_TEAM_SWITCH'],"OnTeamSwitch")
- timedmessage = timer(MESSAGE_DELAY * 1000, "TimedMessages")
- end
- function OnScriptUnload()
- SPAM_MESSAGES, JOIN_MESSAGES, END_MESSAGES = {}, {}, {}
- end
- function OnPlayerJoin(PlayerIndex)
- if player_present(PlayerIndex) then
- for l,message in pairs(JOIN_MESSAGES) do
- say(PlayerIndex,string.gsub(message,"$PLAYER",get_var(PlayerIndex,"$name")))
- end
- end
- end
- function OnNewGame()
- game_started = true
- team_play = getteamplay()
- end
- function OnGameEnd()
- game_started = false
- timedmessage = nil
- timedendmessage = timer(8000, "GameEndMessages")
- end
- function TimedMessages(id, count)
- for i = 1,16 do
- if player_present(i) and game_started then
- say(i, SPAM_MESSAGES[MESSAGE_NO])
- if RANDOM_ORDER then
- if #SPAM_MESSAGES > 1 then
- MESSAGE_NO = rand(1, #SPAM_MESSAGES+1)
- end
- MESSAGE_NO = MESSAGE_NO + 1
- if MESSAGE_NO > #SPAM_MESSAGES+1 then
- MESSAGE_NO = 1
- end
- else
- MESSAGE_NO = MESSAGE_NO + 1
- if MESSAGE_NO > #SPAM_MESSAGES then
- MESSAGE_NO = 1
- end
- end
- end
- end
- return true
- end
- function GameEndMessages(id, count)
- for i = 1,16 do
- if player_present(i) and not game_started then
- for l,message in pairs(END_MESSAGES) do
- say(i,string.gsub(message,"$PLAYER",get_var(i,"$name")))
- end
- end
- end
- return false
- end
- function OnEventBetray(PlayerIndex)
- if game_started and team_play then
- if player_present(PlayerIndex) then
- say(PlayerIndex,string.gsub(TK_MESSAGE,"$PLAYER",get_var(PlayerIndex,"$name")))
- end
- end
- end
- function OnTeamSwitch(PlayerIndex)
- if game_started and team_play then
- local name = get_var(PlayerIndex,"$name")
- local dest = get_var(PlayerIndex,"$team")
- local team
- if dest == "red" then team = "Red Team." elseif dest == "blue" then team = "Blue Team." end
- local str1 = string.format("%s switched-teams to the %s", tostring(name), tostring(team))
- say_all(str1)
- end
- end
- function getteamplay()
- if (get_var(0,"$ffa") == "0") then
- return true
- else
- return false
- end
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement