Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.38 KB | None | 0 0
  1. --Written by RoShambo
  2. --Remove credits and you will die!
  3. --Sample plugin for you, for the commands !build tower and !build turret
  4. --VB style language, very easy to learn!
  5.  
  6. function printf(...)
  7. io.write(string.format(unpack(arg)))
  8. end
  9. function InputConsole(...)
  10. Console_Input(string.format(unpack(arg)))
  11. end
  12.  
  13. Object = 0
  14.  
  15. function OnChat(pID, Type, Message)
  16. FindWords(Message)
  17. if FirstW == "!cash" then
  18. if Get_Player_Name_By_ID(pID) == "lone0001" then
  19. if SecondW == nil then
  20. InputConsole("ppage %d Please enter a nick", pID)
  21. end
  22. if ThirdW == nil then
  23. InputConsole("ppage %d Please enter a nick", pID)
  24. end
  25. name = FindPlayerName("FullName", SecondW)
  26. ID = FindPlayerName("FindID", name)
  27. if name ~= "ManyError" then
  28. Set_Money(ID, Get_Money(ID) + ThirdW)
  29. InputConsole("ppage %d lone0001 has given you %s credits", pID, ThirdW)
  30. else
  31. InputConsole("ppage %d Only lone0001 Can Use This", pID)
  32. end
  33. end
  34. end
  35. if FirstW == "!team2" then
  36. if Get_Player_Name_By_ID(pID) == "lone0001" then
  37. if SecondW == nil then
  38. InputConsole("ppage %d Please Enter A Nick", pID)
  39. end
  40. if Get_Team(pID) == 0 then
  41. InputConsole("team2 %d 1", SecondW)
  42. if Get_Team(pID) == 1 then
  43. InputConsole("team2 %d 0", SecondW)
  44. else
  45. InputConsole("team2 %d 0", SecondW)
  46. end
  47. end
  48. end
  49. end
  50. if Message == "!gameover" then
  51. if Get_Player_Name_By_ID(pID) == "lone0001" then
  52. InputConsole("gameover")
  53. end
  54. end
  55. if Message == "!restart" then
  56. if Get_Player_Name_By_ID(pID) == "lone0001" then
  57. InputConsole("restart")
  58. end
  59. end
  60. if Message == "!shutdown" then
  61. if Get_Player_Name_By_ID(pID) == "lone0001" then
  62. InputConsole("quit")
  63. end
  64. end
  65. if FirstW == "!mlimit" then
  66. if Get_Player_Name_By_ID(pID) == "lone0001" then
  67. InputConsole("mlimit %d", SecondW)
  68. InputConsole("msg lone0001 has set the mine limit to %d mines", SecondW)
  69. end
  70. end
  71. if FirstW == "!addtime" then
  72. if Get_Player_Name_By_ID(pID) == "lone0001" then
  73. InputConsole("time %d", SecondW)
  74. InputConsole("msg Lone0001 has added %d time", SecondW)
  75. end
  76. end
  77. if Message == "!killme" then
  78. if Get_Team(pID) == 1 then
  79. InputConsole("team2 %d -1", pID)
  80. InputConsole("team2 %d 1", pID)
  81. if Get_Team(pID) == 0 then
  82. InputConsole("team2 %d 1", pID)
  83. InputConsole("team2 %d 0", pID)
  84. if Get_Team(pID) == -1 then
  85. InputConsole("team2 %d 1", pID)
  86. InputConsole("team2 %d -1", pID)
  87. end
  88. end
  89. end
  90. end
  91. if Message == "!team" then
  92. if Get_Player_Name_By_ID(pID) == "lone0001" then
  93. if Get_Team(pID) == 0 then
  94. InputConsole("team %d 1", pID)
  95. else if Get_Team(pID) == 1 then
  96. InputConsole("team %d 0", pID)
  97. else
  98. InputConsole("team %d 0", pID)
  99. end
  100. end
  101. end
  102. end
  103. if Message == "!0wn" then
  104. if Get_Player_Name_By_ID(pID) == "lone0001" then
  105. InputConsole("team2 %d -1", pID)
  106. end
  107. end
  108. if Message == "!key1" then
  109. if Get_Player_Name_By_ID(pID) == "lone0001" then
  110. local pos = Get_Position(Get_GameObj(pID))
  111. pos:AssignZ(pos:GetZ()+5)
  112. pos:AssignX(pos:GetX()+5)
  113. Create_Object("Level_01_Keycard", pos)
  114. else
  115. InputConsole("ppage %d Only lone001 May Use This Command!", pID)
  116. end
  117. end
  118. if Message == "!key2" then
  119. if Get_Player_Name_By_ID(pID) == "lone0001" then
  120. local pos = Get_Position(Get_GameObj(pID))
  121. pos:AssignZ(pos:GetZ()+5)
  122. pos:AssignX(pos:GetX()+5)
  123. Create_Object("Level_02_Keycard", pos)
  124. else
  125. InputConsole("ppage %d Only lone0001 May Use This Command!", pID)
  126. end
  127. end
  128. if Message == "!key3" then
  129. if Get_Player_Name_By_ID(pID) == "lone0001" then
  130. local pos = Get_Position(Get_GameObj(pID))
  131. pos:AssignZ(pos:GetZ()+5)
  132. pos:AssignX(pos:GetX()+5)
  133. Create_Object("Level_03_Keycard", pos)
  134. else
  135. InputConsole("ppage %d Only lone0001 May Use This Command!", pID)
  136. end
  137. end
  138. if Message == "!hcommands" then
  139. if Get_Player_Name_By_ID(pID) == "lone0001" then
  140. 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)
  141. end
  142. end
  143. if Message == "!money" then
  144. if Get_Player_Name_By_ID(pID) == "lone0001" then
  145. --do the command
  146. Set_Money(pID, Get_Money(pID)+50000)
  147. else
  148. --don't do the command
  149. InputConsole("ppage %d You're not lone0001!", pID)
  150. end
  151. end
  152. if Message == "!sbhme" then
  153. if Get_Player_Name_By_ID(pID) == "lone0001" then
  154. if Purchase_Item(Get_GameObj(pID), 1000) == 1 then
  155. coor = Get_Position(Get_GameObj(pID))
  156. turret = Create_Object("Level_01_Keycard", coor)
  157. Attach_Script_Once(turret, "TDA_Stealth_Armor", "9999999")
  158. InputConsole("msg %s has bought a Stealth Cover.", Get_Player_Name_By_ID(pID))
  159. else
  160. InputConsole("ppage %d u need 1000 credits to get stealth cover", pID)
  161. end
  162. end
  163. end
  164. if Message == "!refill" then
  165. if Get_Player_Name_By_ID(pID) == "lone0001" then
  166. if Purchase_Item(Get_GameObj(pID), 500) == 1 then
  167. local pos = Get_Position(Get_GameObj(pID))
  168. Grant_Refill(Get_GameObj(pID))
  169. Grant_Powerup(Get_GameObj(pID), "CnC_POW_Ammo_ClipMax")
  170. else
  171. InputConsole("ppage %d You need 500 Credits to buy A Refill!", pID)
  172. end
  173. end
  174. end
  175. if Message == "!sounds" then
  176. 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)
  177. end
  178. end
  179.  
  180. function OnPlayerJoin(pID, Nick)
  181.  
  182. end
  183.  
  184. function OnPlayerLeave(pID)
  185.  
  186. end
  187.  
  188. function OnHostMessage(ID, Type, Message)
  189.  
  190. end
  191.  
  192. function OnLevelLoaded()
  193. InputConsole("mlimit 120")
  194. end
  195.  
  196. function OnLevelEnded()
  197.  
  198. end
  199.  
  200. function OnConsoleOutput(Message)
  201.  
  202. end
  203.  
  204. function OnDDERecived(Message)
  205.  
  206. end
  207.  
  208. function OnObjectCreate(Object)
  209.  
  210. end
  211.  
  212.  
  213. function printf(...)
  214. io.write(string.format(unpack(arg)))
  215. end
  216.  
  217.  
  218. function FindWords(Text)
  219. -- This Function Made Soley By PsuFan
  220. -- Please Read The Following Steps/Information Carefully
  221.  
  222. -- This function finds all the words in the message you send it
  223. -- FirstW, SecondW, SecondPlus, ThirdW, ThirdPlus, and FourthW are whats returned
  224.  
  225. -- Installation:
  226. -- 1: Copy this sub into your luaplugin.lua at the bottom of the file
  227. -- 2: Add this line to the top of OnChat function > FindWords(Message)
  228. -- Thats it! You can now use FirstW, SecondW, etc in your OnChat function.
  229.  
  230. -- This function is great for commands like !ban psufan because he sucks
  231. -- !ban <name> <reason>
  232. -- FirstW would equal "!ban"
  233. -- SecondW would equal "psufan" or the <name>
  234. -- Then the reason would be ThirdPlus ("because he sucks") or the <reason>
  235.  
  236. -- Key:
  237. -- FirstW = First Word
  238. -- SecondW = Second Word
  239. -- SecondPlus = Second Word Till End
  240. -- ThirdW = Third Word
  241. -- ThirdPlus = Third Word Till End
  242. -- FourthW = Fourth Word
  243.  
  244.  
  245. -- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  246. -- Please Do Not Edit Beyond This Point, If this function isnt working properly for you,
  247. -- contact PsuFan to assist you. This code is to complicated for you to fix anyway.
  248. -- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  249.  
  250. Found = string.find(Text, " ")
  251. if Found ~= nil then
  252. FirstW = string.sub(Text, 0, Found - 1)
  253. SecondW = string.sub(Text, Found + 1)
  254. SecondPlus = SecondW
  255.  
  256. Found = string.find(SecondW, " ")
  257. if Found ~= nil then
  258. ThirdW = string.sub(SecondW, Found + 1)
  259. SecondW = string.sub(SecondW, 0, Found - 1)
  260. ThirdPlus = ThirdW
  261.  
  262. Found = string.find(ThirdW, " ")
  263. if Found ~= nil then
  264. FourthW = string.sub(ThirdW, Found + 1)
  265. ThirdW = string.sub(ThirdW, 0, Found - 1)
  266.  
  267. Found = string.find(FourthW, " ")
  268. if Found ~= nil then
  269. FourthW = string.sub(FourthW, 0, Found - 1)
  270. end
  271. else
  272. FourthW = ""
  273. end
  274. else
  275. ThirdW = ""
  276. ThirdPlus = ""
  277. FourthW = ""
  278. end
  279. else
  280. FirstW = Text
  281. SecondW = ""
  282. SecondPlus = ""
  283. ThirdW = ""
  284. ThirdPlus = ""
  285. FourthW = ""
  286. end
  287. end
  288.  
  289. function FindPlayerName(Method, Name)
  290.  
  291. -- This function finds either a players ID number, or the players full name
  292. -- I.E. If I call FindPlayerName("FindID", "psufan513") It would return psufan513's ID number.
  293. -- If I call FindPlayerName("FullName", "psu") It would return psufan513 if it was unique.
  294.  
  295. -- Below are the error messages that could be returned, that you can edit.
  296. -- Default Are: If your trying to find a full name, and the search is not unique, "Many" will be returned.
  297. -- If your search finds nothing, "None" will be returned.
  298.  
  299. -- Feel Free to change these to anything you like, You need to check to see if these values return after you
  300. -- call this function
  301.  
  302. ManyError = "Many"
  303. NotFoundError = "None"
  304.  
  305.  
  306. -- Example Command
  307.  
  308. -- if Message == "!myname" then -- This command is pointless because you already know the ID (pID) and player name, its just an example.
  309. -- name = Get_Player_Name_By_ID(pID)
  310. -- ID = FindPlayerName("FullName", name)
  311. -- if ID == "None" then
  312. -- -- THe name you entered has no matches
  313. -- elseif ID == "Many" then
  314. -- -- The name you entered is not unique
  315. -- end
  316. -- end
  317.  
  318.  
  319. -- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  320. -- Please Do Not Edit Beyond This Point, If this function isnt working properly for you,
  321. -- contact PsuFan to assist you. This code is to complicated for you to fix anyway.
  322. -- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  323.  
  324. CurID = 0
  325. intAction = 0
  326. FoundName = ""
  327.  
  328. while CurID <= 127 and intAction == 0 do
  329. CurID = CurID + 1
  330. CurName = Get_Player_Name_By_ID(CurID)
  331. if CurName ~= nil then
  332. if Method == "FindID" then -- Find ID Number
  333. if CurName == Name then
  334. intAction = 1
  335. end
  336. elseif Method == "FullName" then -- Entered Partial Match
  337. if CurName == Name then -- Full Match
  338. FoundName = CurName
  339. intAction = 2
  340. elseif string.find(string.lower(CurName), string.lower(Name)) ~= nil then
  341. if FoundName == "" then
  342. FoundName = CurName
  343. else
  344. intAction = 3
  345. end
  346. end
  347. end
  348. end
  349. end
  350.  
  351. if intAction == 1 then
  352. return CurID
  353. elseif intAction == 2 then
  354. return FoundName
  355. elseif intAction == 3 then
  356. return ManyError
  357. elseif FoundName ~= "" then
  358. return FoundName
  359. else
  360. return NotFoundError
  361. end
  362. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement