function printf(...)
io.write(string.format(unpack(arg)))
end
function InputConsole(...)
Console_Input(string.format(unpack(arg)))
end
Players = {}
currentsong = "ammoclip.mp3"
Jukebox = {}
function Jukebox:Created(ID, obj)
playlist = {"ammoclip.mp3", "command&conquer.mp3", "defunkt.mp3", "in the line of fire.mp3", "level0_pt1_music.mp3", "level 0 hero.mp3", "level 0 nod base.mp3", "level 0 tank.mp3", "level 0 tiberium.mp3", "mechmansrevenge.mp3", "moveit.mp3", "onyourfeet.mp3", "raveshaw_act on instinct.mp3", "renegadejungle.mp3", "sakura battle theme.mp3", "sakura_dogfight.mp3", "sneakattack.mp3", "sniper.mp3", "stopthemagain.mp3"}
playlisttimes = {193, 175, 163, 235, 26, 31, 54, 51, 47, 227, 121, 234, 148, 141, 240, 280, 228, 196, 234}
Start_Timer(ID, obj, 1, 1)
end
function Jukebox:Timer_Expired(ID, obj, num)
if song == nil then
song = 0
end
if num == 1 then
if playlist[song + 1] ~= nil then
song = song + 1
else
song = 1
end
InputConsole("msg [DarkEVA]: Now playing %s.", playlist[song])
currentsong = playlist[song]
players = Get_All_Players()
for i = 1, #players do
pID = players[i]
music = Players[pID]
if music == "on" then
InputConsole("musicp %d %s", pID, playlist[song])
end
end
Start_Timer(ID, obj, playlisttimes[song], 1)
end
end
function Jukebox:Destroyed(ID, obj)
end
function Jukebox:Killed(ID, obj, killer)
end
Register_Script("Jukebox", "", Jukebox)
Object = 0
function OnChat(pID, Type, Message)
FindWords(Message)
if FirstW == "!playlist" then
InputConsole("ppage %d [DarkEVA]: Playlist: ammoclip.mp3, command&conquer.mp3, defunkt.mp3, in the line of fire.mp3, level0_pt1_music.mp3, level 0 hero.mp3, level 0 nod base.mp3, level 0 tank.mp3, level 0 tiberium.mp3, mechmansrevenge.mp3, moveit.mp3, onyourfeet.mp3, raveshaw_act on instinct.mp3, renegadejungle.mp3, sakura battle theme.mp3, sakura_dogfight.mp3, sneakattack.mp3, sniper.mp3, stopthemagain.mp3", pID)
end
if FirstW == "!music" then
if SecondW == "off" then
Players[pID]="off"
InputConsole("nomusicp %d", pID)
InputConsole("ppage %d [DarkEVA]: Music has been disabled for you.", pID)
elseif SecondW == "on" then
Players[pID]="on"
InputConsole("musicp %d %s", pID, currentsong)
InputConsole("ppage %d [DarkEVA]: Music has been enabled for you.", pID)
elseif SecondW == "" then
InputConsole("ppage %d [DarkEVA]: Usage: !music <on/off>.", pID)
end
end
return 1
end
function OnPlayerJoin(pID, Nick)
Players[pID]="off"
end
function OnPlayerLeave(pID)
end
function OnHostMessage(ID, Type, Message)
end
function OnLevelLoaded()
local pos = {X = 0, Y = 0, Z = -10}
oArrow = Create_Object("Daves Arrow", pos)
Attach_Script_Once(oArrow, "Jukebox", "")
end
function OnLevelEnded()
end
function OnConsoleOutput(Message)
end
function OnDDERecived(Message)
end
function OnObjectCreate(Object)
end
function FindWords(Text)
-- This Function Made Soley By PsuFan
-- Please Read The Following Steps/Information Carefully
-- This function finds all the words in the message you send it
-- FirstW, SecondW, SecondPlus, ThirdW, ThirdPlus, and FourthW are whats returned
-- Installation:
-- 1: Copy this sub into your luaplugin.lua at the bottom of the file
-- 2: Add this line to the top of OnChat function > FindWords(Message)
-- Thats it! You can now use FirstW, SecondW, etc in your OnChat function.
-- This function is great for commands like !ban psufan because he sucks
-- !ban <name> <reason>
-- FirstW would equal "!ban"
-- SecondW would equal "psufan" or the <name>
-- Then the reason would be ThirdPlus ("because he sucks") or the <reason>
-- Key:
-- FirstW = First Word
-- SecondW = Second Word
-- SecondPlus = Second Word Till End
-- ThirdW = Third Word
-- ThirdPlus = Third Word Till End
-- FourthW = Fourth Word
-- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-- Please Do Not Edit Beyond This Point, If this function isnt working properly for you,
-- contact PsuFan to assist you. This code is to complicated for you to fix anyway.
-- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Found = string.find(Text, " ")
if Found ~= nil then
FirstW = string.sub(Text, 0, Found - 1)
SecondW = string.sub(Text, Found + 1)
SecondPlus = SecondW
Found = string.find(SecondW, " ")
if Found ~= nil then
ThirdW = string.sub(SecondW, Found + 1)
SecondW = string.sub(SecondW, 0, Found - 1)
ThirdPlus = ThirdW
Found = string.find(ThirdW, " ")
if Found ~= nil then
FourthW = string.sub(ThirdW, Found + 1)
ThirdW = string.sub(ThirdW, 0, Found - 1)
Found = string.find(FourthW, " ")
if Found ~= nil then
FourthW = string.sub(FourthW, 0, Found - 1)
end
else
FourthW = ""
end
else
ThirdW = ""
ThirdPlus = ""
FourthW = ""
end
else
FirstW = Text
SecondW = ""
SecondPlus = ""
ThirdW = ""
ThirdPlus = ""
FourthW = ""
end
end