Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Written by RoShambo
- --Remove credits and you will die!
- --Sample plugin for you, for the commands !build tower and !build turret
- --VB style language, very easy to learn!
- function printf(...)
- io.write(string.format(unpack(arg)))
- end
- function InputConsole(...)
- Console_Input(string.format(unpack(arg)))
- end
- Object = 0
- function OnChat(pID, Type, Message)
- FindWords(Message)
- if FirstW == "!cash" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- if SecondW == nil then
- InputConsole("ppage %d Please enter a nick", pID)
- end
- if ThirdW == nil then
- InputConsole("ppage %d Please enter a nick", pID)
- end
- name = FindPlayerName("FullName", SecondW)
- ID = FindPlayerName("FindID", name)
- if name ~= "ManyError" then
- Set_Money(ID, Get_Money(ID) + ThirdW)
- InputConsole("ppage %d lone0001 has given you %s credits", pID, ThirdW)
- else
- InputConsole("ppage %d Only lone0001 Can Use This", pID)
- end
- end
- end
- if FirstW == "!team2" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- if SecondW == nil then
- InputConsole("ppage %d Please Enter A Nick", pID)
- end
- if Get_Team(pID) == 0 then
- InputConsole("team2 %d 1", SecondW)
- if Get_Team(pID) == 1 then
- InputConsole("team2 %d 0", SecondW)
- else
- InputConsole("team2 %d 0", SecondW)
- end
- end
- end
- end
- if Message == "!gameover" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- InputConsole("gameover")
- end
- end
- if Message == "!restart" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- InputConsole("restart")
- end
- end
- if Message == "!shutdown" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- InputConsole("quit")
- end
- end
- if FirstW == "!mlimit" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- InputConsole("mlimit %d", SecondW)
- InputConsole("msg lone0001 has set the mine limit to %d mines", SecondW)
- end
- end
- if FirstW == "!addtime" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- InputConsole("time %d", SecondW)
- InputConsole("msg Lone0001 has added %d time", SecondW)
- end
- end
- if Message == "!killme" then
- if Get_Team(pID) == 1 then
- InputConsole("team2 %d -1", pID)
- InputConsole("team2 %d 1", pID)
- if Get_Team(pID) == 0 then
- InputConsole("team2 %d 1", pID)
- InputConsole("team2 %d 0", pID)
- if Get_Team(pID) == -1 then
- InputConsole("team2 %d 1", pID)
- InputConsole("team2 %d -1", pID)
- end
- end
- end
- end
- if Message == "!team" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- if Get_Team(pID) == 0 then
- InputConsole("team %d 1", pID)
- else if Get_Team(pID) == 1 then
- InputConsole("team %d 0", pID)
- else
- InputConsole("team %d 0", pID)
- end
- end
- end
- end
- if Message == "!0wn" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- InputConsole("team2 %d -1", pID)
- end
- end
- if Message == "!key1" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- local pos = Get_Position(Get_GameObj(pID))
- pos:AssignZ(pos:GetZ()+5)
- pos:AssignX(pos:GetX()+5)
- Create_Object("Level_01_Keycard", pos)
- else
- InputConsole("ppage %d Only lone001 May Use This Command!", pID)
- end
- end
- if Message == "!key2" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- local pos = Get_Position(Get_GameObj(pID))
- pos:AssignZ(pos:GetZ()+5)
- pos:AssignX(pos:GetX()+5)
- Create_Object("Level_02_Keycard", pos)
- else
- InputConsole("ppage %d Only lone0001 May Use This Command!", pID)
- end
- end
- if Message == "!key3" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- local pos = Get_Position(Get_GameObj(pID))
- pos:AssignZ(pos:GetZ()+5)
- pos:AssignX(pos:GetX()+5)
- Create_Object("Level_03_Keycard", pos)
- else
- InputConsole("ppage %d Only lone0001 May Use This Command!", pID)
- end
- end
- if Message == "!hcommands" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- InputConsole("ppage lone0001 Host Commands: !team <name>, !team2 <name>, !0wn <name>, !mlimit <new mine limit>, !gameover, !fly, !cash, !key1, !key2, !key3, !w egame, !addtime <time>, !bot clonetrooper, !bot battledroid, !attack, !follow, !rain, !snow, !ash, !clear, !cash <player> <ammount>(WARNING IF NOT USED CORRECTLY CRASHES SERVER!), !sbhme, !refill", pID)
- end
- end
- if Message == "!money" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- --do the command
- Set_Money(pID, Get_Money(pID)+50000)
- else
- --don't do the command
- InputConsole("ppage %d You're not lone0001!", pID)
- end
- end
- if Message == "!sbhme" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- if Purchase_Item(Get_GameObj(pID), 1000) == 1 then
- coor = Get_Position(Get_GameObj(pID))
- turret = Create_Object("Level_01_Keycard", coor)
- Attach_Script_Once(turret, "TDA_Stealth_Armor", "9999999")
- InputConsole("msg %s has bought a Stealth Cover.", Get_Player_Name_By_ID(pID))
- else
- InputConsole("ppage %d u need 1000 credits to get stealth cover", pID)
- end
- end
- end
- if Message == "!refill" then
- if Get_Player_Name_By_ID(pID) == "lone0001" then
- if Purchase_Item(Get_GameObj(pID), 500) == 1 then
- local pos = Get_Position(Get_GameObj(pID))
- Grant_Refill(Get_GameObj(pID))
- Grant_Powerup(Get_GameObj(pID), "CnC_POW_Ammo_ClipMax")
- else
- InputConsole("ppage %d You need 500 Credits to buy A Refill!", pID)
- end
- end
- end
- if Message == "!sounds" then
- InputConsole("ppage %d gotya, chicky, skill, snipe, killem, guns, smile, toy, hehe, jerks, kills, ^^, waiting, haveya, tt, bwahaha, death, n00b, coffee, squirrel, sit, ask, die, fun, hunt, medic, run, daddy, shoot, haha, left, buuurrrn, stfu, burn, boink, more?, nonono, noes, udie, i smell, moo, cya, help, gg, lucky, urdead, finally, strike, wasted, present, pray, amateur, eye", pID)
- end
- end
- function OnPlayerJoin(pID, Nick)
- end
- function OnPlayerLeave(pID)
- end
- function OnHostMessage(ID, Type, Message)
- end
- function OnLevelLoaded()
- InputConsole("mlimit 120")
- end
- function OnLevelEnded()
- end
- function OnConsoleOutput(Message)
- end
- function OnDDERecived(Message)
- end
- function OnObjectCreate(Object)
- end
- function printf(...)
- io.write(string.format(unpack(arg)))
- 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
- function FindPlayerName(Method, Name)
- -- This function finds either a players ID number, or the players full name
- -- I.E. If I call FindPlayerName("FindID", "psufan513") It would return psufan513's ID number.
- -- If I call FindPlayerName("FullName", "psu") It would return psufan513 if it was unique.
- -- Below are the error messages that could be returned, that you can edit.
- -- Default Are: If your trying to find a full name, and the search is not unique, "Many" will be returned.
- -- If your search finds nothing, "None" will be returned.
- -- Feel Free to change these to anything you like, You need to check to see if these values return after you
- -- call this function
- ManyError = "Many"
- NotFoundError = "None"
- -- Example Command
- -- if Message == "!myname" then -- This command is pointless because you already know the ID (pID) and player name, its just an example.
- -- name = Get_Player_Name_By_ID(pID)
- -- ID = FindPlayerName("FullName", name)
- -- if ID == "None" then
- -- -- THe name you entered has no matches
- -- elseif ID == "Many" then
- -- -- The name you entered is not unique
- -- end
- -- end
- -- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- -- 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.
- -- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- CurID = 0
- intAction = 0
- FoundName = ""
- while CurID <= 127 and intAction == 0 do
- CurID = CurID + 1
- CurName = Get_Player_Name_By_ID(CurID)
- if CurName ~= nil then
- if Method == "FindID" then -- Find ID Number
- if CurName == Name then
- intAction = 1
- end
- elseif Method == "FullName" then -- Entered Partial Match
- if CurName == Name then -- Full Match
- FoundName = CurName
- intAction = 2
- elseif string.find(string.lower(CurName), string.lower(Name)) ~= nil then
- if FoundName == "" then
- FoundName = CurName
- else
- intAction = 3
- end
- end
- end
- end
- end
- if intAction == 1 then
- return CurID
- elseif intAction == 2 then
- return FoundName
- elseif intAction == 3 then
- return ManyError
- elseif FoundName ~= "" then
- return FoundName
- else
- return NotFoundError
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement