Advertisement
HR_Shaft

Talk Like a Pirate for Halo! for Phasor v2+

Sep 19th, 2014
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.99 KB | None | 0 0
  1. --[[ ###  Talk Like a Pirate for Halo! ###]]--
  2. --[[ ###   by H® Shaft for Phasor v2+  ###]]--
  3.  
  4. -- EDITED 9/26/2014 corrected small error, re-download this it will work fine
  5.  
  6. game_started = false
  7. plfm = {}
  8. plfm[1] = "Yo ho, yo ho, a pirate's life for me,"
  9. plfm[2] = "We pillage plunder, we rifle and loot,"
  10. plfm[3] = "Drink up me hearties, yo ho!"
  11. plfm[4] = "We kidnap and ravage and don't give a hoot,"
  12. plfm[5] = "Drink up me hearties, yo ho!"
  13. plfm[6] = "Yo ho, yo ho, a pirate's life for me!"
  14. plfm[7] = "We extort and pilfer, we filch and sack,"
  15. plfm[8] = "Drink up me hearties, yo ho!"
  16. plfm[9] = "Maraud and embezzle and even highjack,"
  17. plfm[10] = "Drink up me hearties, yo ho!"
  18. plfm[11] = "We're rascals and scoundrels, we're villains and knaves,"
  19. plfm[12] = "Drink up me hearties, yo ho!"
  20. plfm[13] = "We're devils and black sheep, we're really bad eggs"
  21. plfm[14] = "Drink up me hearties, yo ho!"
  22. next_verse = 0
  23.  
  24. function GetRequiredVersion()
  25.     return 200
  26. end
  27.  
  28. function OnScriptLoad(process, game, persistent)
  29.     next_verse = 0
  30.     game_started = true
  31. end
  32.  
  33. function OnNewGame(map)
  34.     next_verse = 0
  35.     game_started = true
  36. end
  37.  
  38. function OnPlayerJoin(player)
  39.     if getplayer(player) and game_started then
  40.         welcome = registertimer(6000, "piratewelcome", player) 
  41.     end
  42. end
  43.  
  44. function OnPlayerLeave(player)
  45.     if getplayer(player) and game_started then
  46.         local insult = generateinsult(insult)
  47.         for i=0,15 do
  48.             if getplayer(i) and player ~= i then
  49.                 privatesay(i, "Arrrg! That " .. insult .. " has gone to swab the poop-deck! ")
  50.                 privatesay(i, "(I bet ye 10 coins he sniffs the mop!)")
  51.             end
  52.         end
  53.     end
  54. end
  55.  
  56. function piratewelcome(id, count, player)
  57.     if game_started then
  58.         if getplayer(player) then
  59.             local newpirate = getname(player)
  60.             local welcomemessage = generatewelcome(welcome)    
  61.             privatesay(player,"Ahoy! " .. newpirate .. "! " .. welcomemessage)
  62.             privatesay(player, "Tis 'Talk like a Pirate Day! type ARG to announce yer presence!")
  63.             privatesay(player, "If ye like me rum and wenches and desire to sing, type YOHO")
  64.         end
  65.     end
  66.     return false   
  67. end
  68.  
  69. function OnServerChat(player, type, message)
  70.     local response = nil
  71.     if player then
  72.         name = getname(player)
  73.         hash = gethash(player)
  74.    
  75.         local pirate = generateadverbinsult(adverbinsult)
  76.         local pirateinsult = generateinsult(insult)
  77.         local obj = generateobject(object)
  78.        
  79.         if string.lower(message) == "aarrg" or string.lower(message) == "arrg" or string.lower(message) == "arrrg" or string.lower(message) == "arg" then
  80.             response = false
  81.             say("That " .. pirate .. " " .. name .. " says: Ye are a " .. pirateinsult .. "!")
  82.             return response
  83.         end
  84.        
  85.         if string.lower(message) == "lol" or string.lower(message) == "rofl" or string.lower(message) == "haha" or
  86.             string.lower(message) == "hehe" or string.lower(message) == "jaja" then
  87.             response = false
  88.             say(name .. " says: AVAST! Ye tickled me " .. obj .. "!")
  89.             return response
  90.         end
  91.        
  92.         if string.lower(message) == "gg" then
  93.             response = false
  94.             say(name .. " says: Twas a fine game! Have some of me rum!")
  95.             return response
  96.         end
  97.  
  98.         if string.lower(message) == "yoho" then
  99.             response = false
  100.             if next_verse ~= 0 then
  101.                 privatesay(player, "Pirates Life for Me already playing, wait until it's complete")
  102.                 goto SKIPIT
  103.             else
  104.                 if next_verse == 0 then
  105.                     next_verse = 1
  106.                     say(name .. " says: Yo ho me hearties! Sing me a tune!")                   
  107.                     sayverse = registertimer(2400, "SayVerse")
  108.                 end
  109.             end
  110.             ::SKIPIT::
  111.             return response
  112.         end    
  113.        
  114.     end
  115.    
  116.     return response
  117. end
  118.    
  119. function OnPlayerKill(killer, victim, mode)
  120.     local response = false
  121.    
  122.     if mode == 4 then
  123.         local killedmsg = generatekilltype(killslang)
  124.         if getplayer(victim) then
  125.             if getplayer(killer) ~= nil then
  126.                 say(getname(killer) .. " sent " .. getname(victim) .. " to " .. killedmsg .. "!")
  127.             end
  128.         end
  129.         response = false
  130.     else
  131.         response = true
  132.     end
  133.    
  134.     return response
  135. end
  136.  
  137. function OnGameEnd(stage)
  138.     local pirateinsult = generateinsult(insult)
  139.    
  140.     if stage == 1 then
  141.         game_started = false
  142.     elseif stage == 2 then
  143.         for i=0,15 do
  144.             if getplayer(i) then
  145.                 privatesay(i, "AARG! Ye play halo like a " .. pirateinsult .. "!")
  146.                 privatesay(i, "Yoho! yoho! a pirates life for me! Is all the rum gone?!")
  147.             end
  148.         end
  149.     end
  150.    
  151. end
  152.  
  153. function generateinsult(insult)
  154.     local adjectivecount = #adjective
  155.     local adverbcount = #adverb
  156.     local nouncount = #noun
  157.     local rand_adjective = getrandomnumber(1, adjectivecount+1)
  158.     local rand_adverb = getrandomnumber(1, adverbcount+1)
  159.     local rand_noun = getrandomnumber(1, nouncount+1)
  160.     local insult = string.format("%s, %s, %s",  adjective[rand_adjective], adverb[rand_adverb], noun[rand_noun])
  161.     if insult then
  162.         return insult
  163.     else
  164.         return "villainous, clapper-flapped, slag-bucket"
  165.     end
  166. end
  167.  
  168. function generatesmallinsult(smallinsult)
  169.     local nouncount = #noun
  170.     local rand_noun = getrandomnumber(1, nouncount+1)
  171.     local smallinsult = string.format("%s!",  noun[rand_noun])
  172.     if smallinsult then
  173.         return smallinsult
  174.     else
  175.         return "seaman-barnacle"
  176.     end
  177. end
  178.  
  179. function generatewelcome(welcome)
  180.     local adverbcount = #adverb
  181.     local pronouncount = #pronoun
  182.     local rand_adverb = getrandomnumber(1, adverbcount+1)
  183.     local rand_pronoun = getrandomnumber(1, pronouncount+1)
  184.     local welcome = string.format("welcome ye %s pirate! join us %s !",  adverb[rand_adverb], pronoun[rand_pronoun])
  185.     if welcome then
  186.         return welcome
  187.     else
  188.         return "welcome ye weather-bitten pirate! join us Swashbucklers!"
  189.     end
  190. end
  191.  
  192. function generatekilltype(killslang)
  193.     local killcount = #killtype
  194.     local kill_verb = getrandomnumber(1, killcount+1)
  195.     local kill_type = string.format("%s",  killtype[kill_verb])
  196.     if kill_type then
  197.         return kill_type
  198.     else
  199.         return "swab the poop-deck"
  200.     end
  201. end
  202.  
  203. function generateadverbinsult(adverbinsult)
  204.     local adverbcount = #adverb
  205.     local rand_adverb = getrandomnumber(1, adverbcount+1)
  206.     local adverbinsult = string.format("%s",  adverb[rand_adverb])
  207.     if adverbinsult then
  208.         return adverbinsult
  209.     else
  210.         return "clapper-flapped"
  211.     end
  212. end
  213.  
  214. function generateobject(object)
  215.     local objcount = #object
  216.     local rand_obj = getrandomnumber(1, objcount+1)
  217.     local object = string.format("%s!", object[rand_obj])
  218.     if object then
  219.         return object
  220.     else
  221.         return "mudhole"
  222.     end
  223. end
  224.  
  225. function SayVerse(id, count)
  226.     if next_verse ~= 0 and game_started then
  227.         for i=0,15 do
  228.             if getplayer(i) then
  229.                 sendconsoletext(i, plfm[next_verse], 2, 0)
  230.             end
  231.         end
  232.         next_verse = next_verse + 1
  233.     end
  234.     if next_verse ~= 0 and next_verse < 15 and game_started then
  235.         return true
  236.     elseif next_verse > 14 then
  237.         next_verse = 0
  238.         return false
  239.     end
  240. end
  241.  
  242. adjective = {"toothless", "yellow", "drunken", "ugly", "unsightly", "hideous", "repulsive", "revolting", "nasty", "clouded",
  243. "unpleasant", "gutless", "cowardly", "scurvy", "bamboozling", "barbarous", "blagueuring", "bloody", "bumbooing", "clinkering",
  244. "jibless", "gangly", "dismasted", "dowsing", "foundering", "fouled", "mangy", "gafooning", "gibbeting", "tainted", "stinking",
  245. "soiled", "rank", "sullied", "polluted", "befouled", "infected", "adulterated", "swinely", "hornswoggling", "inbred", "lubbering",
  246. "oderous", "offwardly", "scuttling", "skiffless", "slackarding", "slushy", "squallardly", "wretchous", "skanky", "cantankerous",
  247. "conceited", "smutty", "vile", "lousy", "grotty", "crude", "disgusting", "revolting", "wicked", "despicable", "sinister", "lazy",
  248. "ugly", "clumsy", "ratty", "nasty", "scrawny", "dodgy", "stingy", "prickly", "horrible", "boring", "stupid", "creepy", "annoying",
  249. "motherless", "scurvy", "toothless", "hairless", "in-bred", "infected", "greasy", "pimply", "brainless", "fugly", "yawling",
  250. "bawdy", "beslubbering", "bootless", "churlish", "cockered", "dankish", "droning", "errant", "fobbing", "goatish", "logger-headed",
  251. "mewling", "paunchy", "roguish", "saucy", "ruttish", "spongy", "surly", "villainous", "yeasty", "warped", "goobellied" }
  252.  
  253. adverb = {"bat-fowling", "beef-witted", "beetle-headed", "boil-brained", "clapper-flapped", "clay-brained", "cousin-kissing",
  254. "crook-shanked", "dismal-dreaming", "dizzy-eyed", "dog-hearted", "dread-bolted", "eye-vexing", "elf-skinned", "fat-kidneyed",
  255. "rectum-suckled", "flap-mouthed", "fly-bitten", "folly-fallen", "fool-born", "full-gorged", "guts-griping", "half-faced",
  256. "hasty-witted", "hedge-born", "hell-hated", "idle-headed", "ill-breeding", "ill-nurtured", "knotty-pated", "milk-livered",
  257. "motley-minded", "plume-plucked", "pox-marked", "reeling-ripe", "rough-hewn", "rude-growing", "rump-fed", "shard-borne", "sheep-biting",
  258. "spur-galled", "swag-bellied", "tardy-gaited", "tickle-brained", "toad-spotted", "unchin-snouted", "weather-bitten", "puss-guzzling",
  259. "flea-bitten", "slow-witted", "foul-smelling", "big-mouthed", "two-faced", "fool-hardy", "toilet-licking", "big-headed",
  260. "scruffy-looking", "keister-spelunking", "double-chinned", "gimp-goosing", "vomit-spewing", "cross-eyed", "bow-legged", "slack-jawed" }
  261.  
  262. noun = {"barnacle", "bladder-puss", "boar-pig", "bum-bailey", "canker-blossom", "clack-dish", "clot-pole", "death-token",
  263. "flap-dragon", "flax-wench", "flirt-gill", "foot-licker", "fustilarian", "giglet", "gudgeon", "haggard", "harpy", "hedge-pig",
  264. "horn-beast", "lewdster", "lout", "maggot-pie", "malt-worm", "measle-wump", "miscreant", "nut-hook", "pigeon-fop", "pignut",
  265. "scat-muncher", "varlot", "vassal", "wagtail", "boar-tit", "turd-burglar", "goat-rapist", "slag-bucket", "syphilis-siphon",
  266. "yeasty-wench", "scabbard-swabber", "seaman-barnacle" }
  267.  
  268. pronoun = {"rapscallions", "ruffians", "hearties", "zeerovers", "swashbucklers", "savvy-scudds", "powder-monkeys", "plundering-picaroons",
  269. "nautical-whimseys", "jack-tar marooners", "leeward-loons" }
  270.  
  271. killtype = {"the watery deep", "Davey Jones' locker", "visit the shrimp", "the hellish bottom", "feed the fish", "walk the plank",
  272. "a watery grave", "visit Captain Nemo", "serve on the Black Pearl", "salute Blackbeards bones", "swab the poop-deck" }
  273.  
  274. object = {"porthole", "backstay", "bilge-pump", "bitts", "bollard", "cofferdam", "dead-eye", "forebitt", "futtock", "holystone", "jackstaff",
  275. "mizzenmast", "outrigger", "rostrum", "spar", "timberhead", "topsail", "whipstaff", "nauty-bits" }
  276.  
  277. -- Start sendconsoletext overloaded by Nugget
  278. console = {}
  279. console.__index = console
  280. consoletimer = registertimer(100, "ConsoleTimer")
  281. phasor_sendconsoletext = sendconsoletext
  282.  
  283. function sendconsoletext(player, message, time, order, align, height, func)
  284.     if player then
  285.         console[player] = console[player] or {}
  286.         local temp = {}
  287.         temp.player = player
  288.         temp.id = nextid(player, order)
  289.         temp.message = message or ""
  290.         temp.time = time or 0.7
  291.         temp.remain = temp.time
  292.         temp.align = align or "left"
  293.         temp.height = height or 0
  294.         if type(func) == "function" then
  295.             temp.func = func
  296.         elseif type(func) == "string" then
  297.             temp.func = _G[func]
  298.         end
  299.         console[player][temp.id] = temp
  300.         setmetatable(console[player][temp.id], console)
  301.         return console[player][temp.id]
  302.     end
  303. end
  304.  
  305. function nextid(player, order)
  306.     if not order then
  307.         local x = 0
  308.         for k,v in pairs(console[player]) do
  309.             if k > x + 1 then
  310.                 return x + 1
  311.             end
  312.             x = x + 1
  313.         end
  314.         return x + 1
  315.     else
  316.         local original = order
  317.         while console[player][order] do
  318.             order = order + 0.001
  319.             if order == original + 0.999 then break end
  320.         end
  321.         return order
  322.     end
  323. end
  324.  
  325. function getmessage(player, order)
  326.     if console[player] then
  327.         if order then
  328.             return console[player][order]
  329.         end
  330.     end
  331. end
  332.  
  333. function getmessages(player)
  334.     return console[player]
  335. end
  336.  
  337. function getmessageblock(player, order)
  338.     local temp = {}
  339.     for k,v in opairs(console[player]) do
  340.         if k >= order and k < order + 1 then
  341.             table.insert(temp, console[player][k])
  342.         end
  343.     end
  344.     return temp
  345. end
  346.  
  347. function console:getmessage()
  348.     return self.message
  349. end
  350.  
  351. function console:append(message, reset)
  352.     if console[self.player] then
  353.         if console[self.player][self.id] then
  354.             if getplayer(self.player) then
  355.                 if reset then
  356.                     if reset == true then
  357.                         console[self.player][self.id].remain = console[self.player][self.id].time
  358.                     elseif tonumber(reset) then
  359.                         console[self.player][self.id].time = tonumber(reset)
  360.                         console[self.player][self.id].remain = tonumber(reset)
  361.                     end
  362.                 end
  363.                 console[self.player][self.id].message = message or ""
  364.                 return true
  365.             end
  366.         end
  367.     end
  368. end
  369.  
  370. function console:shift(order)
  371.     local temp = console[self.player][self.id]
  372.     console[self.player][self.id] = console[self.player][order]
  373.     console[self.player][order] = temp
  374. end
  375.  
  376. function console:pause(time)
  377.     console[self.player][self.id].pausetime = time or 5
  378. end
  379.  
  380. function console:delete()
  381.     console[self.player][self.id] = nil
  382. end
  383.  
  384. function ConsoleTimer(id, count)
  385.     for i,_ in opairs(console) do
  386.         if tonumber(i) then
  387.             if getplayer(i) then
  388.                 for k,v in opairs(console[i]) do
  389.                     if console[i][k].pausetime then
  390.                         console[i][k].pausetime = console[i][k].pausetime - 0.1
  391.                         if console[i][k].pausetime <= 0 then
  392.                             console[i][k].pausetime = nil
  393.                         end
  394.                     else
  395.                         if console[i][k].func then
  396.                             if not console[i][k].func(i) then
  397.                                 console[i][k] = nil
  398.                             end
  399.                         end
  400.                         if console[i][k] then
  401.                             console[i][k].remain = console[i][k].remain - 0.1
  402.                             if console[i][k].remain <= 0 then
  403.                                 console[i][k] = nil
  404.                             end
  405.                         end
  406.                     end
  407.                 end
  408.                 if table.len(console[i]) > 0 then
  409.                     local paused = 0
  410.                     for k,v in pairs(console[i]) do
  411.                         if console[i][k].pausetime then
  412.                             paused = paused + 1
  413.                         end
  414.                     end
  415.                     if paused < table.len(console[i]) then
  416.                         local str = ""
  417.                         for i = 0,30 do
  418.                             str = str .. " \n"
  419.                         end
  420.                         phasor_sendconsoletext(i, str)
  421.                         for k,v in opairs(console[i]) do
  422.                             if not console[i][k].pausetime then
  423.                                 if console[i][k].align == "right" or console[i][k].align == "center" then
  424.                                     phasor_sendconsoletext(i, consolecenter(string.sub(console[i][k].message, 1, 78)))
  425.                                 else
  426.                                     phasor_sendconsoletext(i, string.sub(console[i][k].message, 1, 78))
  427.                                 end
  428.                             end
  429.                         end
  430.                     end
  431.                 end
  432.             else
  433.                 console[i] = nil
  434.             end
  435.         end
  436.     end
  437.    
  438.     return true
  439. end
  440.  
  441. function consolecenter(text)
  442.     if text then
  443.         local len = string.len(text)
  444.         for i = len + 1, 78 do
  445.             text = " " .. text
  446.         end
  447.         return text
  448.     end
  449. end
  450.  
  451. function opairs(t)
  452.     local keys = {}
  453.     for k,v in pairs(t) do
  454.         table.insert(keys, k)
  455.     end    
  456.     table.sort(keys,
  457.     function(a,b)
  458.         if type(a) == "number" and type(b) == "number" then
  459.             return a < b
  460.         end
  461.         an = string.lower(tostring(a))
  462.         bn = string.lower(tostring(b))
  463.         if an ~= bn then
  464.             return an < bn
  465.         else
  466.             return tostring(a) < tostring(b)
  467.         end
  468.     end)
  469.     local count = 1
  470.     return function()
  471.         if table.unpack(keys) then
  472.             local key = keys[count]
  473.             local value = t[key]
  474.             count = count + 1
  475.             return key,value
  476.         end
  477.     end
  478. end
  479.  
  480. function table.len(t)
  481.     local count = 0
  482.     for k,v in pairs(t) do
  483.         count = count + 1
  484.     end
  485.     return count
  486. end
  487. -- Stop sendconsoletext overloaded
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement