Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.10 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <mod name="Mod Cast" version="1.0" author="Martyx" contact="martyx@otland.net" enabled="yes">
  4.  
  5. <event type="logout" name="cast-log-out" event="script"><![CDATA[
  6.  
  7. function onLogout(cid, forceLogout)
  8.  
  9. db.executeQuery("UPDATE `players` SET `broadcasting` = 0, `viewers` = 0 WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
  10.  
  11. return true
  12.  
  13. end
  14.  
  15. ]]></event>
  16.  
  17. <globalevent name="viewers" interval="10000" event="script"><![CDATA[
  18.  
  19. function onThink(interval)
  20.  
  21. local players = getPlayersOnline()
  22.  
  23. for _, pid in ipairs(players) do
  24.  
  25. local data = getPlayerSpectators(pid)
  26.  
  27. if(data.broadcast) then
  28.  
  29. db.executeQuery("UPDATE `players` set `viewers` = " .. table.maxn(data.names) .. " where `id` = " .. getPlayerGUID(pid) .. ";")
  30.  
  31. end
  32.  
  33. end
  34.  
  35. return true
  36.  
  37. end
  38.  
  39. ]]></globalevent>
  40.  
  41. <talkaction words="/live;!live" event="script"><![CDATA[
  42.  
  43. function onSay(cid, words, param, channelId)
  44.  
  45. local t, data = string.explode(param, " ", 1), getPlayerSpectators(cid)
  46.  
  47. if(isInArray({'off', 'no', 'disable'}, t[1])) then
  48.  
  49. data.mutes = {}
  50.  
  51. data.broadcast = false
  52.  
  53. doPlayerSetSpectators(cid, data)
  54.  
  55. db.executeQuery("UPDATE `players` SET `broadcasting` = 0, `viewers` = 0 WHERE `id` = " .. getPlayerGUID(cid))
  56.  
  57. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have disabled your live stream.")
  58.  
  59. elseif(isInArray({'on', 'yes', 'enable'}, t[1])) then
  60.  
  61. data.broadcast = true
  62.  
  63. doPlayerSetSpectators(cid, data)
  64.  
  65. db.executeQuery("UPDATE `players` SET `broadcasting` = 1 WHERE `id` = " .. getPlayerGUID(cid))
  66.  
  67. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have enabled your live stream.")
  68.  
  69. elseif(isInArray({'show', 'count', 'see'}, t[1])) then
  70.  
  71. if(data.broadcast) then
  72.  
  73. local count = table.maxn(data.names)
  74.  
  75. if(count > 0) then
  76.  
  77. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are currently watched by " .. count .. " people.")
  78.  
  79. local str = ""
  80.  
  81. for _, name in ipairs(data.names) do
  82.  
  83. str = str .. (str:len() > 0 and ", " or "") .. name
  84.  
  85. end
  86.  
  87. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str .. ".")
  88.  
  89. else
  90.  
  91. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "None is watching your stream right now.")
  92.  
  93. end
  94.  
  95. else
  96.  
  97. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not streaming right now.")
  98.  
  99. end
  100.  
  101. elseif(isInArray({'kick', 'remove'}, t[1])) then
  102.  
  103. if(data.broadcast) then
  104.  
  105. if(t[2]) then
  106.  
  107. if(t[2] ~= "all") then
  108.  
  109. local found = false
  110.  
  111. for _, name in ipairs(data.names) do
  112.  
  113. if(t[2]:lower() == name:lower()) then
  114.  
  115. found = true
  116.  
  117. break
  118.  
  119. end
  120.  
  121. end
  122.  
  123. if(found) then
  124.  
  125. table.insert(data.kick, t[2])
  126.  
  127. doPlayerSetSpectators(cid, data)
  128.  
  129. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Spectator " .. t[2] .. " has been kicked.")
  130.  
  131. else
  132.  
  133. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Spectator " .. t[2] .. " not found.")
  134.  
  135. end
  136.  
  137. else
  138.  
  139. data.kick = data.names
  140.  
  141. doPlayerSetSpectators(cid, data)
  142.  
  143. end
  144.  
  145. else
  146.  
  147. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to type a name.")
  148.  
  149. end
  150.  
  151. else
  152.  
  153. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not streaming right now.")
  154.  
  155. end
  156.  
  157. elseif(isInArray({'ban', 'block'}, t[1])) then
  158.  
  159. if(data.broadcast) then
  160.  
  161. if(t[2]) then
  162.  
  163. local found = false
  164.  
  165. for _, name in ipairs(data.names) do
  166.  
  167. if(t[2]:lower() == name:lower()) then
  168.  
  169. found = true
  170.  
  171. break
  172.  
  173. end
  174.  
  175. end
  176.  
  177. if(found) then
  178.  
  179. table.insert(data.bans, t[2])
  180.  
  181. doPlayerSetSpectators(cid, data)
  182.  
  183. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Spectator " .. t[2] .. " has been banned.")
  184.  
  185. else
  186.  
  187. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Spectator " .. t[2] .. " not found.")
  188.  
  189. end
  190.  
  191. else
  192.  
  193. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to type a name.")
  194.  
  195. end
  196.  
  197. else
  198.  
  199. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not streaming right now.")
  200.  
  201. end
  202.  
  203. elseif(isInArray({'unban', 'unblock'}, t[1])) then
  204.  
  205. if(data.broadcast) then
  206.  
  207. if(t[2]) then
  208.  
  209. local found, i = 0, 1
  210.  
  211. for _, name in ipairs(data.bans) do
  212.  
  213. if(t[2]:lower() == name:lower()) then
  214.  
  215. found = i
  216.  
  217. break
  218.  
  219. end
  220.  
  221. i = i + 1
  222.  
  223. end
  224.  
  225. if(found > 0) then
  226.  
  227. table.remove(data.bans, found)
  228.  
  229. doPlayerSetSpectators(cid, data)
  230.  
  231. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Spectator " .. t[2] .. " has been unbanned.")
  232.  
  233. else
  234.  
  235. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Spectator " .. t[2] .. " not found.")
  236.  
  237. end
  238.  
  239. else
  240.  
  241. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to type a name.")
  242.  
  243. end
  244.  
  245. else
  246.  
  247. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not streaming right now.")
  248.  
  249. end
  250.  
  251. elseif(isInArray({'bans', 'banlist'}, t[1])) then
  252.  
  253. if(table.maxn(data.bans)) then
  254.  
  255. local str = ""
  256.  
  257. for _, name in ipairs(data.bans) do
  258.  
  259. str = str .. (str:len() > 0 and ", " or "") .. name
  260.  
  261. end
  262.  
  263. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently banned spectators: " .. str .. ".")
  264.  
  265. else
  266.  
  267. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your ban list is empty.")
  268.  
  269. end
  270.  
  271. elseif(isInArray({'mute', 'squelch'}, t[1])) then
  272.  
  273. if(data.broadcast) then
  274.  
  275. if(t[2]) then
  276.  
  277. local found = false
  278.  
  279. for _, name in ipairs(data.names) do
  280.  
  281. if(t[2]:lower() == name:lower()) then
  282.  
  283. found = true
  284.  
  285. break
  286.  
  287. end
  288.  
  289. end
  290.  
  291. if(found) then
  292.  
  293. table.insert(data.mutes, t[2])
  294.  
  295. doPlayerSetSpectators(cid, data)
  296.  
  297. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Spectator " .. t[2] .. " has been muted.")
  298.  
  299. else
  300.  
  301. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Spectator " .. t[2] .. " not found.")
  302.  
  303. end
  304.  
  305. else
  306.  
  307. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to type a name.")
  308.  
  309. end
  310.  
  311. else
  312.  
  313. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not streaming right now.")
  314.  
  315. end
  316.  
  317. elseif(isInArray({'unmute', 'unsquelch'}, t[1])) then
  318.  
  319. if(data.broadcast) then
  320.  
  321. if(t[2]) then
  322.  
  323. local found, i = 0, 1
  324.  
  325. for _, name in ipairs(data.mutes) do
  326.  
  327. if(t[2]:lower() == name:lower()) then
  328.  
  329. found = i
  330.  
  331. break
  332.  
  333. end
  334.  
  335. i = i + 1
  336.  
  337. end
  338.  
  339. if(found > 0) then
  340.  
  341. table.remove(data.mutes, found)
  342.  
  343. doPlayerSetSpectators(cid, data)
  344.  
  345. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Spectator " .. t[2] .. " has been unmuted.")
  346.  
  347. else
  348.  
  349. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Spectator " .. t[2] .. " not found.")
  350.  
  351. end
  352.  
  353. else
  354.  
  355. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to type a name.")
  356.  
  357. end
  358.  
  359. else
  360.  
  361. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not streaming right now.")
  362.  
  363. end
  364.  
  365. elseif(isInArray({'mutes', 'mutelist'}, t[1])) then
  366.  
  367. if(table.maxn(data.mutes)) then
  368.  
  369. local str = ""
  370.  
  371. for _, name in ipairs(data.mutes) do
  372.  
  373. str = str .. (str:len() > 0 and ", " or "") .. name
  374.  
  375. end
  376.  
  377. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Currently muted spectators: " .. str .. ".")
  378.  
  379. else
  380.  
  381. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your mute list is empty.")
  382.  
  383. end
  384.  
  385. elseif(isInArray({'auth', 'protect', 'protection', 'protected'}, t[1])) then
  386.  
  387. if(isInArray({'off', 'no', 'disable'}, t[2])) then
  388.  
  389. data.auth = false
  390.  
  391. doPlayerSetSpectators(cid, data)
  392.  
  393. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your chat is now unprotected, all spectators can chat without authentication.")
  394.  
  395. elseif(isInArray({'on', 'yes', 'enable'}, t[2])) then
  396.  
  397. data.auth = true
  398.  
  399. doPlayerSetSpectators(cid, data)
  400.  
  401. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your chat is now protected, all spectators have to authenticate before they can talk.")
  402.  
  403. else
  404.  
  405. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your chat is currently " .. (data.auth and "protected" or "unprotected") .. " from guests.")
  406.  
  407. end
  408.  
  409. elseif(isInArray({'password', 'guard'}, t[1])) then
  410.  
  411. if(t[2]) then
  412.  
  413. if(isInArray({'off', 'no', 'disable'}, t[2])) then
  414.  
  415. if(data.password:len() ~= 0) then
  416.  
  417. db.executeQuery("UPDATE `players` SET `broadcasting` = `broadcasting` - 2 WHERE `id` = " .. getPlayerGUID(cid))
  418.  
  419. end
  420.  
  421. data.password = ""
  422.  
  423. doPlayerSetSpectators(cid, data)
  424.  
  425. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have removed password for your stream.")
  426.  
  427. else
  428.  
  429. if(data.password:len() ~= 0) then
  430.  
  431. db.executeQuery("UPDATE `players` SET `broadcasting` = `broadcasting` + 2 WHERE `id` = " .. getPlayerGUID(cid))
  432.  
  433. end
  434.  
  435. data.password = string.trim(t[2])
  436.  
  437. doPlayerSetSpectators(cid, data)
  438.  
  439. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have set new password for your stream.")
  440.  
  441. end
  442.  
  443. elseif(data.password ~= "") then
  444.  
  445. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your stream is currently protected with password: " .. data.password .. ".")
  446.  
  447. else
  448.  
  449. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your stream is currently not protected.")
  450.  
  451. end
  452.  
  453. elseif(isInArray({'status', 'info'}, t[1])) then
  454.  
  455. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your stream is currently " .. (data.broadcast and "enabled" or "disabled") .. ".")
  456.  
  457. else
  458.  
  459. doPlayerPopupFYI(cid, "Available commands:\n\n/live on - enables the stream\n/live off - disables the stream\n/live password {password} - sets a password on the stream\n/live password off - disables the password protection\n/live auth on - enables requirement of authentication on chat\n/live auth off - disables requirement of authentication on chat\n/live kick {name} - kick a spectator from your stream\n/live ban {name} - locks spectator IP from joining your stream\n/live unban {name} - removes banishment lock\n/live bans - shows banished spectators list\n/live mute {name} - mutes selected spectator from chat\n/live unmute {name} - removes mute\n/live mutes - shows muted spectators list\n/live show - displays the amount and nicknames of current spectators\n/live status - displays stream status")
  460.  
  461. end
  462.  
  463. return true
  464.  
  465. end
  466.  
  467. ]]></talkaction>
  468.  
  469. </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement