Advertisement
Guest User

gooc

a guest
Feb 4th, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 76.43 KB | None | 0 0
  1. mysql = exports.mysql
  2.  
  3. function trunklateText(thePlayer, text, factor)
  4. if getElementData(thePlayer,"alcohollevel") and getElementData(thePlayer,"alcohollevel") > 0 then
  5. local level = math.ceil( getElementData(thePlayer,"alcohollevel") * #text / ( factor or 5.5 ) )
  6. for i = 1, level do
  7. x = math.random( 1, #text )
  8. -- dont replace spaces
  9. if text.sub( x, x ) == ' ' then
  10. i = i - 1
  11. else
  12. local a, b = text:sub( 1, x - 1 ) or "", text:sub( x + 1 ) or ""
  13. local c = ""
  14. if math.random( 1, 6 ) == 1 then
  15. c = string.char(math.random(65,90))
  16. else
  17. c = string.char(math.random(97,122))
  18. end
  19. text = a .. c .. b
  20. end
  21. end
  22. end
  23. return text
  24. end
  25.  
  26. function getElementDistance( a, b )
  27. if not isElement(a) or not isElement(b) or getElementDimension(a) ~= getElementDimension(b) then
  28. return math.huge
  29. else
  30. local x, y, z = getElementPosition( a )
  31. return getDistanceBetweenPoints3D( x, y, z, getElementPosition( b ) )
  32. end
  33. end
  34.  
  35. local gpn = getPlayerName
  36. function getPlayerName(p)
  37. local name = gpn(p) or getElementData(p, "ped:name")
  38. return string.gsub(name, "_", " ")
  39. end
  40.  
  41. -- /ad
  42. function advertMessage(thePlayer, commandName, showNumber, ...)
  43. local canIAD = getElementData(thePlayer, "sanAdvert") or 0
  44. if (canIAD == 0) then
  45. outputChatBox("(( Command Removed, please call number 7296 for advertisements.))", thePlayer)
  46. else
  47. local logged = tonumber(getElementData(thePlayer, "loggedin"))
  48.  
  49. if (logged==1) then
  50. if not (...) or not (showNumber) then
  51. outputChatBox("SYNTAX: /" .. commandName .. " [Show Phone Number 0/1] [Message]", thePlayer, 255, 194, 14)
  52. elseif getElementData(thePlayer, "adminjailed") then
  53. outputChatBox("You cannot advertise in jail.", thePlayer, 255, 0, 0)
  54. elseif getElementData(thePlayer, "alcohollevel") and getElementData(thePlayer, "alcohollevel") ~= 0 then
  55. outputChatBox("You are too drunk to advertise!", thePlayer, 255, 0, 0)
  56. else
  57. if (exports.global:hasItem(thePlayer, 2)) then
  58. if (getElementData(thePlayer, "ads") or 0) >= 2 then
  59. outputChatBox("You can only place 2 ads every 5 minutes.", thePlayer, 255, 0, 0)
  60. return
  61. end
  62. message = table.concat({...}, " ")
  63. if showNumber ~= "0" and showNumber ~= "1" then
  64. message = showNumber .. " " .. message
  65. showNumber = 0
  66. end
  67. if message:sub(-1) ~= "." then
  68. message = message .. "."
  69. end
  70.  
  71. local cost = math.ceil(string.len(message)/6)
  72. if exports.global:takeMoney(thePlayer, cost) then
  73. local name = getPlayerName(thePlayer)
  74. local phoneNumber = getElementData(thePlayer, "cellnumber")
  75.  
  76. exports.logs:logMessage("ADVERT: " .. message .. ". ((" .. name .. "))", 2)
  77. for key, value in ipairs(exports.pool:getPoolElementsByType("player")) do
  78. if (getElementData(value, "loggedin")==1 and not getElementData(value, "disableAds")) then
  79. outputChatBox(" ADVERT: " .. message .. " ((" .. name .. "))", value, 0, 255, 64)
  80.  
  81. if (tonumber(showNumber)==1) then
  82. outputChatBox(" Contact: #" .. phoneNumber .. ".", value, 0, 255, 64)
  83. end
  84. end
  85. end
  86. outputChatBox("Thank you for placing your advert. Total Cost: $" .. cost .. ".", thePlayer)
  87. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "ads", ( getElementData(thePlayer, "ads") or 0 ) + 1, false)
  88. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "sanAdvert", 0)
  89. setTimer(
  90. function(p)
  91. if isElement(p) then
  92. local c = getElementData(p, "ads") or 0
  93. if c > 1 then
  94. exports['anticheat-system']:changeProtectedElementDataEx(p, "ads", c-1, false)
  95. else
  96. exports['anticheat-system']:changeProtectedElementDataEx(p, "ads")
  97. end
  98. end
  99. end, 300000, 1, thePlayer
  100. )
  101. else
  102. outputChatBox("You cannot afford to place such an advert, try making it smaller.", thePlayer)
  103. end
  104. else
  105. outputChatBox("You do not have a cellphone to call the advertisement agency.", thePlayer, 255, 0, 0)
  106. end
  107. end
  108. end
  109. end
  110. end
  111. addCommandHandler("ad", advertMessage, false, false)
  112.  
  113. -- Main chat: Local IC, Me Actions & Faction IC Radio
  114. function localIC(source, message, language)
  115. if exports['freecam-tv']:isPlayerFreecamEnabled(source) then return end
  116.  
  117. local x, y, z = getElementPosition(source)
  118. local playerName = getPlayerName(source)
  119.  
  120. message = string.gsub(message, "#%x%x%x%x%x%x", "") -- Remove colour codes
  121. local languagename = call(getResourceFromName("language-system"), "getLanguageName", language)
  122. message = trunklateText( source, message )
  123.  
  124. local playerVehicle = getPedOccupiedVehicle(source)
  125. if playerVehicle then
  126. if (exports['vehicle-system']:isVehicleWindowUp(playerVehicle)) then
  127. exports.logs:logMessage("[IC: In Car] " .. playerName .. ": " .. message, 1)
  128. outputChatBox( "#EEEEEE [" .. languagename .. "] " .. playerName .. " ((In Car)) says: " .. message, source, 133, 44, getElementData(source, "chatbubbles") == 2 and 89 or 88, true)
  129. else
  130. exports.logs:logMessage("[IC: Local Chat] " .. playerName .. ": " .. message, 1)
  131. outputChatBox( "#EEEEEE [" .. languagename .. "] " .. playerName .. " says: " .. message, source, 133, 44, getElementData(source, "chatbubbles") == 2 and 89 or 88, true)
  132. end
  133. else
  134. exports.logs:logMessage("[IC: Local Chat] " .. playerName .. ": " .. message, 1)
  135. outputChatBox( "#EEEEEE [" .. languagename .. "] " .. playerName .. " says: " .. message, source, 133, 44, getElementData(source, "chatbubbles") == 2 and 89 or 88, true)
  136. end
  137.  
  138. local dimension = getElementDimension(source)
  139. local interior = getElementInterior(source)
  140. local shownto = 1
  141.  
  142. -- Chat Commands tooltip
  143. if(getResourceFromName("tooltips-system"))then
  144. triggerClientEvent(source,"tooltips:showHelp", source,17)
  145. end
  146.  
  147. for key, nearbyPlayer in ipairs(getElementsByType( "player" )) do
  148. local dist = getElementDistance( source, nearbyPlayer )
  149.  
  150. if dist < 20 then
  151. local nearbyPlayerDimension = getElementDimension(nearbyPlayer)
  152. local nearbyPlayerInterior = getElementInterior(nearbyPlayer)
  153.  
  154. if (nearbyPlayerDimension==dimension) and (nearbyPlayerInterior==interior) then
  155. local logged = tonumber(getElementData(nearbyPlayer, "loggedin"))
  156. if not (isPedDead(nearbyPlayer)) and (logged==1) and (nearbyPlayer~=source) then
  157. local message2 = call(getResourceFromName("language-system"), "applyLanguage", source, nearbyPlayer, message, language)
  158. message2 = trunklateText( nearbyPlayer, message2 )
  159.  
  160. local pveh = getPedOccupiedVehicle(source)
  161. local nbpveh = getPedOccupiedVehicle(nearbyPlayer)
  162. if pveh then
  163. if (exports['vehicle-system']:isVehicleWindowUp(pveh)) then
  164. for i = 0, getVehicleMaxPassengers(pveh) do
  165. local lp = getVehicleOccupant(pveh, i)
  166.  
  167. if (lp) and (lp~=source) then
  168. outputChatBox("#EEEEEE [" .. languagename .. "] " .. playerName .. " ((In Car)) says: " .. message2, lp, 133, 44, getElementData(lp, "chatbubbles") > 0 and 89 or 88, true)
  169. end
  170. end
  171. if (getElementData(nearbyPlayer, "adminduty") == 1) and (getPedOccupiedVehicle(nearbyPlayer) ~= pveh) then
  172. outputChatBox("#EEEEEE [" .. languagename .. "] " .. playerName .. " ((In Car)) says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  173. end
  174. return
  175. end
  176. end
  177. if nbpveh then
  178. if (exports['vehicle-system']:isVehicleWindowUp(nbpveh)) then
  179. if dist < 3 then
  180. outputChatBox( "#EEEEEE [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  181. elseif dist < 6 then
  182. outputChatBox( "#DDDDDD [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  183. elseif dist < 9 then
  184. outputChatBox( "#CCCCCC [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  185. elseif dist < 12 then
  186. outputChatBox( "#BBBBBB [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  187. else
  188. outputChatBox( "#AAAAAA [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  189. end
  190. else
  191. if dist < 4 then
  192. outputChatBox( "#EEEEEE [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  193. elseif dist < 8 then
  194. outputChatBox( "#DDDDDD [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  195. elseif dist < 12 then
  196. outputChatBox( "#CCCCCC [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  197. elseif dist < 16 then
  198. outputChatBox( "#BBBBBB [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  199. else
  200. outputChatBox( "#AAAAAA [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  201. end
  202. end
  203. elseif not nbpveh then
  204. if dist < 4 then
  205. outputChatBox( "#EEEEEE [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  206. elseif dist < 8 then
  207. outputChatBox( "#DDDDDD [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  208. elseif dist < 12 then
  209. outputChatBox( "#CCCCCC [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  210. elseif dist < 16 then
  211. outputChatBox( "#BBBBBB [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  212. else
  213. outputChatBox( "#AAAAAA [" .. languagename .. "] " .. playerName .. " says: " .. message2, nearbyPlayer, 133, 44, getElementData(nearbyPlayer, "chatbubbles") > 0 and 89 or 88, true)
  214. end
  215. end
  216.  
  217. shownto = shownto + 1
  218. end
  219. end
  220. end
  221. end
  222.  
  223. exports['freecam-tv']:add(shownto, playerName .. " says: " .. message, source)
  224. end
  225.  
  226. for i = 1, 3 do
  227. addCommandHandler( tostring( i ),
  228. function( thePlayer, commandName, ... )
  229. local lang = tonumber( getElementData( thePlayer, "languages.lang" .. i ) )
  230. if lang ~= 0 then
  231. localIC( thePlayer, table.concat({...}, " "), lang )
  232. end
  233. end
  234. )
  235. end
  236.  
  237. function meEmote(source, cmd, ...)
  238. local logged = getElementData(source, "loggedin")
  239. if not(isPedDead(source) and (logged == 1)) then
  240. local message = table.concat({...}, " ")
  241. if not (...) then
  242. outputChatBox("SYNTAX: /me [Action]", source, 255, 194, 14)
  243. else
  244. exports.global:sendLocalMeAction(source, message)
  245. exports.logs:logMessage("[IC OOC: ME ACTION] *" .. getPlayerName(source) .. " " .. message, 7)
  246. end
  247. end
  248. end
  249. addCommandHandler("ME", meEmote, false, true)
  250. addCommandHandler("Me", meEmote, false, true)
  251.  
  252. function radio(source, radioID, message)
  253. radioID = tonumber(radioID) or 1
  254. local hasRadio, itemKey, itemValue, itemID = exports.global:hasItem(source, 6)
  255. if hasRadio then
  256. local theChannel = itemValue
  257. if radioID ~= 1 then
  258. local count = 0
  259. local items = exports['item-system']:getItems(source)
  260. for k, v in ipairs(items) do
  261. if v[1] == 6 then
  262. count = count + 1
  263. if count == radioID then
  264. theChannel = v[2]
  265. break
  266. end
  267. end
  268. end
  269. end
  270.  
  271. if theChannel == 1 then
  272. outputChatBox("Please Tune your radio (( /tuneradio # ))", source, 255, 194, 14)
  273. elseif theChannel > 1 then
  274. triggerClientEvent (source, "playRadioSound", getRootElement())
  275. local username = getPlayerName(source)
  276. local languageslot = getElementData(source, "languages.current")
  277. local language = getElementData(source, "languages.lang" .. languageslot)
  278. local languagename = call(getResourceFromName("language-system"), "getLanguageName", language)
  279.  
  280. local factionID = getElementData(source,"faction")
  281. if not (factionID == -1) then
  282. local theTeam = getPlayerTeam(source)
  283. local factionrank = tonumber(getElementData(source,"factionrank"))
  284. local ranks = getElementData(theTeam,"ranks")
  285. factionRankTitle = ranks[factionrank] .. " - "
  286. else
  287. factionRankTitle = ""
  288. end
  289.  
  290. message = trunklateText( source, message )
  291. outputChatBox("[" .. languagename .. "] [RADIO #" .. theChannel .. "] " .. factionRankTitle .. username .. " says: " .. message, source, 0, 102, 255)
  292.  
  293. for key, value in ipairs(getElementsByType( "player" )) do
  294. local logged = getElementData(source, "loggedin")
  295.  
  296. if (isElement(value)) and (logged==1) and (value~=source) then
  297. if (exports.global:hasItem(value, 6, theChannel)) then
  298. triggerClientEvent (value, "playRadioSound", getRootElement())
  299.  
  300. local message2 = call(getResourceFromName("language-system"), "applyLanguage", source, value, message, language)
  301. outputChatBox("[" .. languagename .. "] [RADIO #" .. theChannel .. "] " .. factionRankTitle .. username .. " says: " .. trunklateText( value, message2 ), value, 0, 102, 255)
  302.  
  303.  
  304. if (exports.global:hasItem(value, 88) == false) then
  305. -- Show it to people near who can hear his radio
  306. for k, v in ipairs(exports.global:getNearbyElements(value, "player",7)) do
  307. local logged2 = getElementData(v, "loggedin")
  308. if (logged2==1) then
  309. if (exports.global:hasItem(v, 6, targetChannel) == false) then
  310. local message2 = call(getResourceFromName("language-system"), "applyLanguage", source, v, message, language)
  311. outputChatBox("[" .. languagename .. "] " .. getPlayerName(value) .. "'s Radio: " .. trunklateText( v, message2 ), v, 255, 255, 255)
  312. end
  313. end
  314. end
  315. end
  316. end
  317. end
  318. end
  319.  
  320. --Show the radio to nearby listening in people near the speaker
  321. for key, value in ipairs(getElementsByType("player")) do
  322. if getElementDistance(source, value) < 10 then
  323. if (value~=source) then
  324. local message2 = call(getResourceFromName("language-system"), "applyLanguage", source, value, message, language)
  325. outputChatBox("[" .. languagename .. "] " .. getPlayerName(source) .. " [RADIO] says: " .. message2, value, 255, 255, 255)
  326. end
  327. end
  328. end
  329. else
  330. outputChatBox("Your radio is off. ((/toggleradio))", source, 255, 0, 0)
  331. end
  332. else
  333. outputChatBox("You do not have a radio.", source, 255, 0, 0)
  334. end
  335. end
  336.  
  337. function chatMain(message, messageType)
  338. if exports['freecam-tv']:isPlayerFreecamEnabled(source) then cancelEvent() return end
  339.  
  340. local logged = getElementData(source, "loggedin")
  341.  
  342. if not (isPedDead(source)) and (logged==1) and not (messageType==2) then -- Player cannot chat while dead or not logged in, unless its OOC
  343. local dimension = getElementDimension(source)
  344. local interior = getElementInterior(source)
  345. -- Local IC
  346. if (messageType==0) then
  347. local languageslot = getElementData(source, "languages.current")
  348. local language = getElementData(source, "languages.lang" .. languageslot)
  349. localIC(source, message, language)
  350. elseif (messageType==1) then -- Local /me action
  351. meEmote(source, "me", message)
  352. end
  353. elseif (messageType==2) and (logged==1) then -- Radio
  354. radio(source, 1, message)
  355. end
  356. end
  357. addEventHandler("onPlayerChat", getRootElement(), chatMain)
  358.  
  359. function msgRadio(thePlayer, commandName, ...)
  360. if (...) then
  361. local message = table.concat({...}, " ")
  362. radio(thePlayer, 1, message)
  363. else
  364. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  365. end
  366. end
  367. addCommandHandler("r", msgRadio, false, false)
  368. addCommandHandler("radio", msgRadio, false, false)
  369.  
  370. for i = 1, 20 do
  371. addCommandHandler( "r" .. tostring( i ),
  372. function( thePlayer, commandName, ... )
  373. if i <= exports['item-system']:countItems(thePlayer, 6) then
  374. radio( thePlayer, i, table.concat({...}, " ") )
  375. end
  376. end
  377. )
  378. end
  379.  
  380. function govAnnouncement(thePlayer, commandName, ...)
  381. local theTeam = getPlayerTeam(thePlayer)
  382.  
  383. if (theTeam) then
  384. local teamID = tonumber(getElementData(theTeam, "id"))
  385.  
  386. if (teamID==1 or teamID==2 or teamID==3) then
  387. local message = table.concat({...}, " ")
  388. local factionRank = tonumber(getElementData(thePlayer,"factionrank"))
  389.  
  390. if (factionRank<10) then
  391. outputChatBox("You do not have permission to use this command.", thePlayer, 255, 0, 0)
  392. elseif #message == 0 then
  393. outputChatBox("SYNTAX: " .. commandName .. " [message]", thePlayer, 255, 194, 14)
  394. else
  395. local ranks = getElementData(theTeam,"ranks")
  396. local factionRankTitle = ranks[factionRank]
  397.  
  398. exports.logs:logMessage("[IC: Government Message] " .. factionRankTitle .. " " .. getPlayerName(thePlayer) .. ": " .. message, 6)
  399.  
  400. for key, value in ipairs(exports.pool:getPoolElementsByType("player")) do
  401. local logged = getElementData(value, "loggedin")
  402.  
  403. if (logged==1) then
  404. outputChatBox(">> Government Announcement from " .. factionRankTitle .. " " .. getPlayerName(thePlayer), value, 0, 183, 239)
  405. outputChatBox(message, value, 0, 183, 239)
  406. end
  407. end
  408. end
  409. end
  410. end
  411. end
  412. addCommandHandler("gov", govAnnouncement)
  413.  
  414. function playerToggleDonatorChat(thePlayer, commandName)
  415. local logged = getElementData(thePlayer, "loggedin")
  416.  
  417. if (logged==1) then
  418. local enabled = getElementData(thePlayer, "donatorchat")
  419.  
  420. if (enabled==1) then
  421. outputChatBox("You have now hidden Donator Chat.", thePlayer, 255, 194, 14)
  422. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "donatorchat", 0, false)
  423. else
  424. outputChatBox("You have now enabled Donator Chat.", thePlayer, 255, 194, 14)
  425. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "donatorchat", 1, false)
  426. end
  427. mysql:query_free("UPDATE accounts SET donatorchat=" .. mysql:escape_string(getElementData(thePlayer, "donatorchat")) .. " WHERE id = " .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")))
  428. end
  429. end
  430. addCommandHandler("toggledonatorchat", playerToggleDonatorChat, false, false)
  431. addCommandHandler("toggledon", playerToggleDonatorChat, false, false)
  432. addCommandHandler("toggledchat", playerToggleDonatorChat, false, false)
  433.  
  434. function donatorchat(thePlayer, commandName, ...)
  435. if ( exports.global:isPlayerBronzeDonator(thePlayer) or exports.global:isPlayerAdmin(thePlayer) ) then
  436. if not (...) then
  437. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  438. else
  439. local message = table.concat({...}, " ")
  440. local title = ""
  441. local hidden = getElementData(thePlayer, "hiddenadmin") or 0
  442.  
  443. if ( exports.global:isPlayerAdmin(thePlayer) ) then
  444. if (hidden == 1) or (exports.global:getPlayerAdminTitle(thePlayer) == "Player") then
  445. if not (exports.global:isPlayerBronzeDonator(thePlayer)) then
  446. title = "Bronze Donator"
  447. else
  448. title = exports.global:getPlayerDonatorTitle(thePlayer)
  449. end
  450. else
  451. title = exports.global:getPlayerAdminTitle(thePlayer)
  452. end
  453. elseif ( exports.global:isPlayerBronzeDonator(thePlayer) ) then
  454. title = exports.global:getPlayerDonatorTitle(thePlayer)
  455. end
  456.  
  457. for key, value in ipairs(getElementsByType("player")) do
  458. if ( exports.global:isPlayerBronzeDonator(value) or exports.global:isPlayerAdmin(value) ) then
  459. if ( getElementData(value, "donatorchat") == 1 ) then
  460. outputChatBox("[Donator] " .. title .. " " .. getPlayerName(thePlayer) .. ": " .. message, value, 160, 164, 104)
  461. end
  462. end
  463. end
  464. end
  465. end
  466. end
  467. addCommandHandler("donator", donatorchat, false, false)
  468. addCommandHandler("don", donatorchat, false, false)
  469. addCommandHandler("dchat", donatorchat, false, false)
  470.  
  471. function departmentradio(thePlayer, commandName, ...)
  472. local theTeam = getPlayerTeam(thePlayer)
  473.  
  474. if (theTeam) then
  475. local teamID = tonumber(getElementData(theTeam, "id"))
  476.  
  477. if (teamID==1 or teamID==2 or teamID==3 or teamID == 30) then
  478. if (...) then
  479.  
  480. local message = trunklateText( thePlayer, table.concat({...}, " ") )
  481. local PDFaction = getPlayersInTeam(getTeamFromName("Los Santos Police Department"))
  482. local ESFaction = getPlayersInTeam(getTeamFromName("Los Santos Emergency Services"))
  483. local GovFaction = getPlayersInTeam(getTeamFromName("Government of Los Santos"))
  484. local TowFaction = getPlayersInTeam(getTeamFromName("Los Santos Towing and Recovery"))
  485. local playerName = getPlayerName(thePlayer)
  486.  
  487. exports.logs:logMessage("[IC: Department Radio] " .. playerName .. ": " .. message, 6)
  488.  
  489. for key, value in ipairs(PDFaction) do
  490. outputChatBox("[" .. getTeamName(theTeam) .. "] " .. playerName .. " says: " .. message, value, 0, 102, 255)
  491. end
  492.  
  493. for key, value in ipairs(ESFaction) do
  494. outputChatBox("[" .. getTeamName(theTeam) .. "] " .. playerName .. " says: " .. message, value, 0, 102, 255)
  495. end
  496.  
  497. for key, value in ipairs(TowFaction) do
  498. outputChatBox("[" .. getTeamName(theTeam) .. "] " .. playerName .. " says: " .. message, value, 0, 102, 255)
  499. end
  500.  
  501. for key, value in ipairs(GovFaction) do
  502. outputChatBox("[" .. getTeamName(theTeam) .. "] " .. playerName .. " says: " .. message, value, 0, 102, 255)
  503. end
  504. else
  505. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  506. end
  507. end
  508. end
  509. end
  510. addCommandHandler("d", departmentradio, false, false)
  511. addCommandHandler("department", departmentradio, false, false)
  512.  
  513. function blockChatMessage()
  514. cancelEvent()
  515. end
  516.  
  517. addEventHandler("onPlayerChat", getRootElement(), blockChatMessage)
  518. -- End of Main Chat
  519.  
  520. function globalOOC(thePlayer, commandName, ...)
  521. local logged = tonumber(getElementData(thePlayer, "loggedin"))
  522.  
  523. if (logged==1) then
  524. if not (...) then
  525. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  526. else
  527. local oocEnabled = exports.global:getOOCState()
  528. message = table.concat({...}, " ")
  529. local muted = getElementData(thePlayer, "muted")
  530. if (oocEnabled==0) and not (exports.global:isPlayerAdmin(thePlayer)) then
  531. outputChatBox("OOC Chat is currently disabled.", thePlayer, 255, 0, 0)
  532. elseif (muted==1) then
  533. outputChatBox("You are currenty muted from the OOC Chat.", thePlayer, 255, 0, 0)
  534. else
  535. local players = exports.pool:getPoolElementsByType("player")
  536. local playerName = getPlayerName(thePlayer)
  537. local playerID = getElementData(thePlayer, "playerid")
  538.  
  539. exports.logs:logMessage("[OOC: Global Chat] " .. playerName .. ": " .. message, 1)
  540. for k, arrayPlayer in ipairs(players) do
  541. local logged = tonumber(getElementData(arrayPlayer, "loggedin"))
  542. local targetOOCEnabled = getElementData(arrayPlayer, "globalooc")
  543.  
  544. if (logged==1) and (targetOOCEnabled==1) then
  545. outputChatBox("(( [GOOC] (" .. playerID .. ") " .. playerName .. ": " .. message .. " ))", arrayPlayer, 255, 255, 204)
  546. end
  547. end
  548. end
  549. end
  550. end
  551. end
  552. addCommandHandler("o", globalOOC, false, false)
  553. addCommandHandler("GlobalOOC", globalOOC)
  554.  
  555. function playerToggleOOC(thePlayer, commandName)
  556. local logged = getElementData(thePlayer, "loggedin")
  557.  
  558. if (logged==1) then
  559. local playerOOCEnabled = getElementData(thePlayer, "globalooc")
  560.  
  561. if (playerOOCEnabled==1) then
  562. outputChatBox("You have now hidden Global OOC Chat.", thePlayer, 255, 194, 14)
  563. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "globalooc", 0, false)
  564. else
  565. outputChatBox("You have now enabled Global OOC Chat.", thePlayer, 255, 194, 14)
  566. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "globalooc", 1, false)
  567. end
  568. mysql:query_free("UPDATE accounts SET globalooc=" .. mysql:escape_string(getElementData(thePlayer, "globalooc")) .. " WHERE id = " .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")))
  569. end
  570. end
  571. addCommandHandler("toggleooc", playerToggleOOC, false, false)
  572.  
  573.  
  574. local advertisementMessages = { "samp", "SA-MP", "Kye", "server", "sincityrp", "ls-rp", "sincity", "eg", "tri0n3", "www.", ".com", ".net", ".co.uk", ".org", "join", "address", "come", "Bryan", "Danny", "everlast", "neverlast", "www.everlastgaming.com", "roleplay", "www.valhallagaming.net", "valhalla", "vg", "tomate", "fallenmaster1", "fallen", "mount", "script", "owner", "87.238175.150", "mta"}
  575.  
  576. function isFriendOf(thePlayer, targetPlayer)
  577. local friends = getElementData(targetPlayer, "friends")
  578. if friends then
  579. local targetID = tonumber( getElementData( thePlayer, "gameaccountid" ) )
  580. if friends[ targetID ] then
  581. return true
  582. end
  583. end
  584. return false
  585. end
  586.  
  587. function pmPlayer(thePlayer, commandName, who, ...)
  588. if not (who) or not (...) then
  589. outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick] [Message]", thePlayer, 255, 194, 14)
  590. else
  591. message = table.concat({...}, " ")
  592.  
  593. local loggedIn = getElementData(thePlayer, "loggedin")
  594. if (loggedIn==0) then
  595. return
  596. end
  597.  
  598. local targetPlayer, targetPlayerName
  599. if (isElement(who)) then
  600. if (getElementType(who)=="player") then
  601. targetPlayer = who
  602. targetPlayerName = getPlayerName(who)
  603. message = string.gsub(message, string.gsub(targetPlayerName, " ", "_", 1) .. " ", "", 1)
  604. end
  605. else
  606. targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, who)
  607. end
  608.  
  609. if (targetPlayer) then
  610. local logged = getElementData(targetPlayer, "loggedin")
  611. local pmblocked = getElementData(targetPlayer, "pmblocked")
  612.  
  613. if not (pmblocked) then
  614. pmblocked = 0
  615. exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "pmblocked", 0, false)
  616. end
  617.  
  618. if (logged==1) and not getElementData(targetPlayer, "disablePMs") and (pmblocked==0 or exports.global:isPlayerAdmin(thePlayer) or exports.global:isPlayerScripter(thePlayer) or getElementData(thePlayer, "reportadmin") == targetPlayer or isFriendOf(thePlayer, targetPlayer)) then
  619. local playerName = getPlayerName(thePlayer):gsub("_", " ")
  620.  
  621. if not exports.global:isPlayerScripter(thePlayer) and not exports.global:isPlayerScripter(targetPlayer) then
  622. -- Check for advertisements
  623. for k,v in ipairs(advertisementMessages) do
  624. local found = string.find(string.lower(message), "%s" .. tostring(v))
  625. local found2 = string.find(string.lower(message), tostring(v) .. "%s")
  626. if (found) or (found2) or (string.lower(message)==tostring(v)) then
  627. exports.global:sendMessageToAdmins("AdmWrn: " .. tostring(playerName) .. " sent a possible advertisement PM to " .. tostring(targetPlayerName) .. ".")
  628. exports.global:sendMessageToAdmins("AdmWrn: Message: " .. tostring(message))
  629. break
  630. end
  631. end
  632. end
  633.  
  634. -- Send the message
  635. local playerid = getElementData(thePlayer, "playerid")
  636. local targetid = getElementData(targetPlayer, "playerid")
  637. outputChatBox("PM From (" .. playerid .. ") " .. playerName .. ": " .. message, targetPlayer, 255, 255, 0)
  638. outputChatBox("PM Sent to (" .. targetid .. ") " .. targetPlayerName .. ": " .. message, thePlayer, 255, 255, 0)
  639.  
  640. exports.logs:logMessage("[PM From " ..playerName .. " TO " .. targetPlayerName .. "]" .. message, 8)
  641. outputDebugString("[PM From " ..playerName .. " TO " .. targetPlayerName .. "]" .. message)
  642.  
  643. if not exports.global:isPlayerScripter(thePlayer) and not exports.global:isPlayerScripter(targetPlayer) then
  644. -- big ears
  645. local received = {}
  646. received[thePlayer] = true
  647. received[targetPlayer] = true
  648. for key, value in pairs( getElementsByType( "player" ) ) do
  649. if isElement( value ) and not received[value] then
  650. local listening = getElementData( value, "bigears" )
  651. if listening == thePlayer or listening == targetPlayer then
  652. received[value] = true
  653. outputChatBox("(" .. playerid .. ") " .. playerName .. " -> (" .. targetid .. ") " .. targetPlayerName .. ": " .. message, value, 255, 255, 0)
  654. end
  655. end
  656. end
  657. end
  658. elseif (logged==0) then
  659. outputChatBox("Player is not logged in yet.", thePlayer, 255, 255, 0)
  660. elseif (pmblocked==1) then
  661. outputChatBox("Player is ignoring whispers!", thePlayer, 255, 255, 0)
  662. end
  663. end
  664. end
  665. end
  666. addCommandHandler("pm", pmPlayer, false, false)
  667.  
  668. function localOOC(thePlayer, commandName, ...)
  669. if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  670.  
  671. local logged = getElementData(thePlayer, "loggedin")
  672. local dimension = getElementDimension(thePlayer)
  673. local interior = getElementInterior(thePlayer)
  674.  
  675. if (logged==1) and not (isPedDead(thePlayer)) then
  676. local muted = getElementData(thePlayer, "muted")
  677. if not (...) then
  678. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  679. elseif (muted==1) then
  680. outputChatBox("You are currenty muted from the OOC Chat.", thePlayer, 255, 0, 0)
  681. else
  682. exports.global:sendLocalText(thePlayer, getPlayerName(thePlayer) .. ": (( " .. table.concat({...}, " ") .. " ))", 196, 255, 255)
  683. exports.logs:logMessage("[OOC: Local Chat] " .. getPlayerName(thePlayer) .. ": " .. table.concat({...}, " "), 1)
  684. end
  685. end
  686. end
  687. addCommandHandler("b", localOOC, false, false)
  688. addCommandHandler("LocalOOC", localOOC)
  689.  
  690. function districtIC(thePlayer, commandName, ...)
  691. if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  692.  
  693. local logged = getElementData(thePlayer, "loggedin")
  694. local dimension = getElementDimension(thePlayer)
  695. local interior = getElementInterior(thePlayer)
  696.  
  697. if (logged==1) and not (isPedDead(thePlayer)) then
  698. if not (...) then
  699. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  700. else
  701. local playerName = getPlayerName(thePlayer)
  702. local message = table.concat({...}, " ")
  703. local zonename = exports.global:getElementZoneName(thePlayer)
  704.  
  705. for key, value in ipairs(exports.pool:getPoolElementsByType("player")) do
  706. local playerzone = exports.global:getElementZoneName(value)
  707. local playerdimension = getElementDimension(value)
  708. local playerinterior = getElementInterior(value)
  709.  
  710. if (zonename==playerzone) and (dimension==playerdimension) and (interior==playerinterior) then
  711. local logged = getElementData(value, "loggedin")
  712. if (logged==1) then
  713. outputChatBox("District IC: " .. message .. " ((".. playerName .."))", value, 255, 255, 255)
  714. end
  715. end
  716. end
  717. end
  718. end
  719. end
  720. addCommandHandler("district", districtIC, false, false)
  721.  
  722. function localDo(thePlayer, commandName, ...)
  723. if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  724.  
  725. local logged = getElementData(thePlayer, "loggedin")
  726. local dimension = getElementDimension(thePlayer)
  727. local interior = getElementInterior(thePlayer)
  728.  
  729. if not (isPedDead(thePlayer)) and (logged==1) then
  730. if not (...) then
  731. outputChatBox("SYNTAX: /" .. commandName .. " [Action/Event]", thePlayer, 255, 194, 14)
  732. else
  733. local message = table.concat({...}, " ")
  734. exports.logs:logMessage("[IC: Local Do] * " .. message .. " * ((" .. getPlayerName(thePlayer) .. "))", 19)
  735. exports.global:sendLocalDoAction(thePlayer, message)
  736. end
  737. end
  738. end
  739. addCommandHandler("do", localDo, false, false)
  740.  
  741.  
  742. function localShout(thePlayer, commandName, ...)
  743. if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  744.  
  745. local logged = getElementData(thePlayer, "loggedin")
  746. local dimension = getElementDimension(thePlayer)
  747. local interior = getElementInterior(thePlayer)
  748.  
  749. if not (isPedDead(thePlayer)) and (logged==1) then
  750. if not (...) then
  751. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  752. else
  753. local playerName = getPlayerName(thePlayer)
  754.  
  755. local languageslot = getElementData(thePlayer, "languages.current")
  756. local language = getElementData(thePlayer, "languages.lang" .. languageslot)
  757. local languagename = call(getResourceFromName("language-system"), "getLanguageName", language)
  758.  
  759. local message = trunklateText(thePlayer, table.concat({...}, " "))
  760. outputChatBox("[" .. languagename .. "] " .. playerName .. " shouts: " .. message .. "!!", thePlayer, 255, 255, 255)
  761. exports.logs:logMessage("[IC: Local Shout] " .. playerName .. ": " .. message, 1)
  762. for index, nearbyPlayer in ipairs(getElementsByType("player")) do
  763. if getElementDistance( thePlayer, nearbyPlayer ) < 40 then
  764. local nearbyPlayerDimension = getElementDimension(nearbyPlayer)
  765. local nearbyPlayerInterior = getElementInterior(nearbyPlayer)
  766.  
  767. if (nearbyPlayerDimension==dimension) and (nearbyPlayerInterior==interior) and (nearbyPlayer~=thePlayer) then
  768. local logged = getElementData(nearbyPlayer, "loggedin")
  769.  
  770. if (logged==1) and not (isPedDead(nearbyPlayer)) then
  771. --local mode = tonumber(getElementData(nearbyPlayer, "chatbubbles"))
  772. local message2 = call(getResourceFromName("language-system"), "applyLanguage", thePlayer, nearbyPlayer, message, language)
  773. message2 = trunklateText(nearbyPlayer, message2)
  774. --if mode > 0 then
  775. -- triggerClientEvent(nearbyPlayer, "onMessageIncome", thePlayer, message2, mode)
  776. --end
  777. outputChatBox("[" .. languagename .. "] " .. playerName .. " shouts: " .. message2 .. "!!", nearbyPlayer, 255, 255, 255)
  778. end
  779. end
  780. end
  781. end
  782. end
  783. end
  784. end
  785. addCommandHandler("s", localShout, false, false)
  786.  
  787. function megaphoneShout(thePlayer, commandName, ...)
  788. if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  789.  
  790. local logged = getElementData(thePlayer, "loggedin")
  791. local dimension = getElementDimension(thePlayer)
  792. local interior = getElementInterior(thePlayer)
  793.  
  794. if not (isPedDead(thePlayer)) and (logged==1) then
  795. local faction = getPlayerTeam(thePlayer)
  796. local factiontype = getElementData(faction, "type")
  797.  
  798. if (factiontype==2) or (factiontype==3) or (factiontype==4) then
  799. if not (...) then
  800. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  801. else
  802. local playerName = getPlayerName(thePlayer)
  803. local message = trunklateText(thePlayer, table.concat({...}, " "))
  804.  
  805. local languageslot = getElementData(thePlayer, "languages.current")
  806. local language = getElementData(thePlayer, "languages.lang" .. languageslot)
  807. local langname = call(getResourceFromName("language-system"), "getLanguageName", language)
  808.  
  809. for index, nearbyPlayer in ipairs(getElementsByType("player")) do
  810. if getElementDistance( thePlayer, nearbyPlayer ) < 40 then
  811. local nearbyPlayerDimension = getElementDimension(nearbyPlayer)
  812. local nearbyPlayerInterior = getElementInterior(nearbyPlayer)
  813.  
  814. if (nearbyPlayerDimension==dimension) and (nearbyPlayerInterior==interior) then
  815. local logged = getElementData(nearbyPlayer, "loggedin")
  816.  
  817. if (logged==1) and not (isPedDead(nearbyPlayer)) then
  818. local message2 = message
  819. if nearbyPlayer ~= thePlayer then
  820. message2 = call(getResourceFromName("language-system"), "applyLanguage", thePlayer, nearbyPlayer, message, language)
  821. end
  822. outputChatBox(" [" .. langname .. "] ((" .. playerName .. ")) Megaphone <O: " .. trunklateText(nearbyPlayer, message2), nearbyPlayer, 255, 255, 0)
  823. end
  824. end
  825. end
  826. end
  827. end
  828. else
  829. outputChatBox("Believe it or not, it's hard to shout through a megaphone you do not have.", thePlayer, 255, 0 , 0)
  830. end
  831. end
  832. end
  833. addCommandHandler("m", megaphoneShout, false, false)
  834.  
  835. local togState = { }
  836. function toggleFaction(thePlayer, commandName, State)
  837. local pF = getElementData(thePlayer, "faction")
  838. local fL = getElementData(thePlayer, "factionleader")
  839. local theTeam = getPlayerTeam(thePlayer)
  840.  
  841. if fL == 1 then
  842. if togState[pF] == false or not togState[pF] then
  843. togState[pF] = true
  844. outputChatBox("Faction chat is now disabled.", thePlayer)
  845. for index, arrayPlayer in ipairs( getElementsByType( "player" ) ) do
  846. if isElement( arrayPlayer ) then
  847. if getPlayerTeam( arrayPlayer ) == theTeam and getElementData(thePlayer, "loggedin") == 1 then
  848. outputChatBox("OOC Faction Chat Disabled", arrayPlayer, 255, 0, 0)
  849. end
  850. end
  851. end
  852. else
  853. togState[pF] = false
  854. outputChatBox("Faction chat is now enabled.", thePlayer)
  855. for index, arrayPlayer in ipairs( getElementsByType( "player" ) ) do
  856. if isElement( arrayPlayer ) then
  857. if getPlayerTeam( arrayPlayer ) == theTeam and getElementData(thePlayer, "loggedin") == 1 then
  858. outputChatBox("OOC Faction Chat Enabled", arrayPlayer, 0, 255, 0)
  859. end
  860. end
  861. end
  862. end
  863. end
  864. end
  865. addCommandHandler("togglef", toggleFaction)
  866. addCommandHandler("togf", toggleFaction)
  867.  
  868. function factionOOC(thePlayer, commandName, ...)
  869. local logged = getElementData(thePlayer, "loggedin")
  870.  
  871. if (logged==1) then
  872. if not (...) then
  873. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  874. else
  875. local theTeam = getPlayerTeam(thePlayer)
  876. local theTeamName = getTeamName(theTeam)
  877. local playerName = getPlayerName(thePlayer)
  878. local playerFaction = getElementData(thePlayer, "faction")
  879.  
  880. if not(theTeam) or (theTeamName=="Citizen") then
  881. outputChatBox("You are not in a faction.", thePlayer)
  882. else
  883. local message = table.concat({...}, " ")
  884.  
  885. if (togState[playerFaction]) == true then
  886. return
  887. end
  888. exports.logs:logMessage("[OOC: " .. theTeamName .. "] " .. playerName .. ": " .. message, 6)
  889.  
  890. for index, arrayPlayer in ipairs( getElementsByType( "player" ) ) do
  891. if isElement( arrayPlayer ) then
  892. if getElementData( arrayPlayer, "bigearsfaction" ) == theTeam then
  893. outputChatBox("((" .. theTeamName .. ")) " .. playerName .. ": " .. message, arrayPlayer, 3, 157, 157)
  894. elseif getPlayerTeam( arrayPlayer ) == theTeam and getElementData(thePlayer, "loggedin") == 1 then
  895. outputChatBox("((OOC Faction Chat)) " .. playerName .. ": " .. message, arrayPlayer, 3, 237, 237)
  896. end
  897. end
  898. end
  899. end
  900. end
  901. end
  902. end
  903. addCommandHandler("f", factionOOC, false, false)
  904.  
  905. function setRadioChannel(thePlayer, commandName, slot, channel)
  906. slot = tonumber( slot )
  907. channel = tonumber( channel )
  908.  
  909. if not channel then
  910. channel = slot
  911. slot = 1
  912. end
  913.  
  914. if not (channel) then
  915. outputChatBox("SYNTAX: /" .. commandName .. " [Radio Slot] [Channel Number]", thePlayer, 255, 194, 14)
  916. else
  917. if (exports.global:hasItem(thePlayer, 6)) then
  918. local count = 0
  919. local items = exports['item-system']:getItems(thePlayer)
  920. for k, v in ipairs( items ) do
  921. if v[1] == 6 then
  922. count = count + 1
  923. if count == slot then
  924. if v[2] > 0 then
  925. if channel > 0 and channel < 1000000000 then
  926. if exports['item-system']:updateItemValue(thePlayer, k, channel) then
  927. outputChatBox("You retuned your radio to channel #" .. channel .. ".", thePlayer)
  928. exports.global:sendLocalMeAction(thePlayer, "retunes their radio.")
  929. end
  930. else
  931. outputChatBox("You can't tune your radio to that frequency!", thePlayer, 255, 0, 0)
  932. end
  933. else
  934. outputChatBox("Your radio is off. ((/toggleradio))", thePlayer, 255, 0, 0)
  935. end
  936. return
  937. end
  938. end
  939. end
  940. outputChatBox("You do not have that many radios.", thePlayer, 255, 0, 0)
  941. else
  942. outputChatBox("You do not have a radio!", thePlayer, 255, 0, 0)
  943. end
  944. end
  945. end
  946. addCommandHandler("tuneradio", setRadioChannel, false, false)
  947.  
  948. function toggleRadio(thePlayer, commandName, slot)
  949. if (exports.global:hasItem(thePlayer, 6)) then
  950. local slot = tonumber( slot )
  951. local items = exports['item-system']:getItems(thePlayer)
  952. local titemValue = false
  953. local count = 0
  954. for k, v in ipairs( items ) do
  955. if v[1] == 6 then
  956. if slot then
  957. count = count + 1
  958. if count == slot then
  959. titemValue = v[2]
  960. break
  961. end
  962. else
  963. titemValue = v[2]
  964. break
  965. end
  966. end
  967. end
  968.  
  969. -- gender switch for /me
  970. local genderm = getElementData(thePlayer, "gender") == 1 and "her" or "his"
  971.  
  972. if titemValue < 0 then
  973. outputChatBox("You turned your radio on.", thePlayer, 255, 194, 14)
  974. exports.global:sendLocalMeAction(thePlayer, "turns " .. genderm .. " radio on.")
  975. else
  976. outputChatBox("You turned your radio off.", thePlayer, 255, 194, 14)
  977. exports.global:sendLocalMeAction(thePlayer, "turns " .. genderm .. " radio off.")
  978. end
  979. --exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "radiochannel", channel, false)
  980.  
  981. local count = 0
  982. for k, v in ipairs( items ) do
  983. if v[1] == 6 then
  984. if slot then
  985. count = count + 1
  986. if count == slot then
  987. exports['item-system']:updateItemValue(thePlayer, k, ( titemValue < 0 and 1 or -1 ) * math.abs( v[2] or 1))
  988. break
  989. end
  990. else
  991. exports['item-system']:updateItemValue(thePlayer, k, ( titemValue < 0 and 1 or -1 ) * math.abs( v[2] or 1))
  992. end
  993. end
  994. end
  995. else
  996. outputChatBox("You do not have a radio!", thePlayer, 255, 0, 0)
  997. end
  998. end
  999. addCommandHandler("toggleradio", toggleRadio, false, false)
  1000.  
  1001. -- Admin chat
  1002. function adminChat(thePlayer, commandName, ...)
  1003. local logged = getElementData(thePlayer, "loggedin")
  1004.  
  1005. if(logged==1) and (exports.global:isPlayerAdmin(thePlayer)) then
  1006. if not (...) then
  1007. outputChatBox("SYNTAX: /a [Message]", thePlayer, 255, 194, 14)
  1008. else
  1009. local message = table.concat({...}, " ")
  1010. local players = exports.pool:getPoolElementsByType("player")
  1011. local username = getPlayerName(thePlayer)
  1012. local adminTitle = exports.global:getPlayerAdminTitle(thePlayer)
  1013. exports.logs:logMessage("[Admin Chat] " .. username .. ": " .. message, 3)
  1014. for k, arrayPlayer in ipairs(players) do
  1015. local logged = getElementData(arrayPlayer, "loggedin")
  1016.  
  1017. if(exports.global:isPlayerAdmin(arrayPlayer)) and (logged==1) then
  1018. outputChatBox(adminTitle .. " " .. username .. ": " .. message, arrayPlayer, 51, 255, 102)
  1019. end
  1020. end
  1021.  
  1022. end
  1023. end
  1024. end
  1025.  
  1026. addCommandHandler("a", adminChat, false, false)
  1027.  
  1028.  
  1029. -- Scripter Chat
  1030. function scripterChat(thePlayer, commandName, ...)
  1031. local logged = getElementData(thePlayer, "loggedin")
  1032.  
  1033. if(logged==1) and (exports.global:isPlayerScripter(thePlayer)) then
  1034. if not (...) then
  1035. outputChatBox("SYNTAX: /s [Message]", thePlayer, 255, 194, 14)
  1036. else
  1037. local message = table.concat({...}, " ")
  1038. local players = exports.pool:getPoolElementsByType("player")
  1039. local username = getPlayerName(thePlayer)
  1040.  
  1041. for k, arrayPlayer in ipairs(players) do
  1042. local logged = getElementData(arrayPlayer, "loggedin")
  1043.  
  1044. if(exports.global:isPlayerScripter(arrayPlayer)) and (logged==1) then
  1045. outputChatBox("~" .. username .. "~ " .. message, arrayPlayer, 255, 255, 128)
  1046. end
  1047. end
  1048. end
  1049. end
  1050. end
  1051. addCommandHandler("ss", scripterChat, false, false)
  1052. addCommandHandler("sc", scripterChat, false, false)
  1053.  
  1054. -- Admin announcement
  1055. function adminAnnouncement(thePlayer, commandName, ...)
  1056. local logged = getElementData(thePlayer, "loggedin")
  1057.  
  1058. if(logged==1) and (exports.global:isPlayerAdmin(thePlayer)) then
  1059. if not (...) then
  1060. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  1061. else
  1062. local message = table.concat({...}, " ")
  1063. local players = exports.pool:getPoolElementsByType("player")
  1064. local username = getPlayerName(thePlayer)
  1065.  
  1066. for k, arrayPlayer in ipairs(players) do
  1067. local logged = getElementData(arrayPlayer, "loggedin")
  1068.  
  1069. if (logged) then
  1070. if exports.global:isPlayerAdmin(arrayPlayer) then
  1071. outputChatBox( "Admin Announcement by " .. getPlayerName(thePlayer) .. ":", arrayPlayer, 255, 194, 14)
  1072. end
  1073. outputChatBox(" *** " .. message .. " ***", arrayPlayer, 255, 194, 14)
  1074. end
  1075. end
  1076. end
  1077. end
  1078. end
  1079. addCommandHandler("ann", adminAnnouncement, false, false)
  1080.  
  1081. function superAdminChat(thePlayer, commandName, ...)
  1082. local logged = getElementData(thePlayer, "loggedin")
  1083.  
  1084. if(logged==1) and (exports.global:isPlayerSuperAdmin(thePlayer)) then
  1085. if not (...) then
  1086. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  1087. else
  1088. local message = table.concat({...}, " ")
  1089. local players = exports.pool:getPoolElementsByType("player")
  1090. local username = getPlayerName(thePlayer)
  1091. local adminTitle = exports.global:getPlayerAdminTitle(thePlayer)
  1092.  
  1093. for k, arrayPlayer in ipairs(players) do
  1094. local logged = getElementData(arrayPlayer, "loggedin")
  1095.  
  1096. if (exports.global:isPlayerSuperAdmin(arrayPlayer)) and (logged==1) then
  1097. outputChatBox("*Super+* " ..adminTitle .. " " .. username .. ": " .. message, arrayPlayer, 0, 200, 128)
  1098. end
  1099. end
  1100. end
  1101. end
  1102. end
  1103.  
  1104. addCommandHandler("su", superAdminChat, false, false)
  1105.  
  1106. function leadAdminChat(thePlayer, commandName, ...)
  1107. local logged = getElementData(thePlayer, "loggedin")
  1108.  
  1109. if(logged==1) and (exports.global:isPlayerLeadAdmin(thePlayer)) then
  1110. if not (...) then
  1111. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  1112. else
  1113. local message = table.concat({...}, " ")
  1114. local players = exports.pool:getPoolElementsByType("player")
  1115. local username = getPlayerName(thePlayer)
  1116. local adminTitle = exports.global:getPlayerAdminTitle(thePlayer)
  1117.  
  1118. for k, arrayPlayer in ipairs(players) do
  1119. local logged = getElementData(arrayPlayer, "loggedin")
  1120.  
  1121. if (exports.global:isPlayerLeadAdmin(arrayPlayer)) and (logged==1) then
  1122. outputChatBox("*Lead+* " ..adminTitle .. " " .. username .. ": " .. message, arrayPlayer, 204, 102, 255)
  1123. end
  1124. end
  1125. end
  1126. end
  1127. end
  1128.  
  1129. addCommandHandler("l", leadAdminChat, false, false)
  1130.  
  1131. function headAdminChat(thePlayer, commandName, ...)
  1132. local logged = getElementData(thePlayer, "loggedin")
  1133.  
  1134. if(logged==1) and (exports.global:isPlayerHeadAdmin(thePlayer)) then
  1135. if not (...) then
  1136. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  1137. else
  1138. local message = table.concat({...}, " ")
  1139. local players = exports.pool:getPoolElementsByType("player")
  1140. local username = getPlayerName(thePlayer)
  1141. local adminTitle = exports.global:getPlayerAdminTitle(thePlayer)
  1142.  
  1143. for k, arrayPlayer in ipairs(players) do
  1144. local logged = getElementData(arrayPlayer, "loggedin")
  1145.  
  1146. if(exports.global:isPlayerHeadAdmin(arrayPlayer)) and (logged==1) then
  1147. outputChatBox("*Head+* " ..adminTitle .. " " .. username .. ": " .. message, arrayPlayer, 255, 204, 51)
  1148. end
  1149. end
  1150. end
  1151. end
  1152. end
  1153.  
  1154. addCommandHandler("h", headAdminChat, false, false)
  1155.  
  1156. -- Misc
  1157. local function sortTable( a, b )
  1158. if b[2] < a[2] then
  1159. return true
  1160. end
  1161.  
  1162. if b[2] == a[2] and b[4] > a[4] then
  1163. return true
  1164. end
  1165.  
  1166. return false
  1167. end
  1168.  
  1169. function showAdmins(thePlayer, commandName)
  1170. local logged = getElementData(thePlayer, "loggedin")
  1171.  
  1172. if(logged==1) then
  1173. local players = exports.global:getAdmins()
  1174. local counter = 0
  1175.  
  1176. admins = {}
  1177. outputChatBox("ADMINISTRATORS:", thePlayer)
  1178. for k, arrayPlayer in ipairs(players) do
  1179. local hiddenAdmin = getElementData(arrayPlayer, "hiddenadmin")
  1180. local logged = getElementData(arrayPlayer, "loggedin")
  1181.  
  1182. if logged == 1 then
  1183. if hiddenAdmin == 0 or exports.global:isPlayerAdmin(thePlayer) or exports.global:isPlayerScripter(thePlayer) then
  1184. admins[ #admins + 1 ] = { arrayPlayer, getElementData( arrayPlayer, "adminlevel" ), getElementData( arrayPlayer, "adminduty" ), getPlayerName( arrayPlayer ) }
  1185. end
  1186. end
  1187. end
  1188.  
  1189. table.sort( admins, sortTable )
  1190.  
  1191. for k, v in ipairs(admins) do
  1192. arrayPlayer = v[1]
  1193. local adminTitle = exports.global:getPlayerAdminTitle(arrayPlayer)
  1194.  
  1195. if exports.global:isPlayerAdmin(thePlayer) or exports.global:isPlayerScripter(thePlayer) then
  1196. v[4] = v[4] .. " (" .. tostring(getElementData(arrayPlayer, "gameaccountusername")) .. ")"
  1197. end
  1198.  
  1199. if(v[3]==1)then
  1200. outputChatBox(" " .. tostring(adminTitle) .. " " .. v[4].." - On Duty", thePlayer, 255, 194, 14)
  1201. else
  1202. outputChatBox(" " .. tostring(adminTitle) .. " " .. v[4], thePlayer)
  1203. end
  1204. end
  1205.  
  1206. if #admins == 0 then
  1207. outputChatBox(" Currently no administrators online.", thePlayer)
  1208. end
  1209. end
  1210. end
  1211. addCommandHandler("admins", showAdmins, false, false)
  1212.  
  1213. function playerChangeChatbubbleMode(thePlayer, commandName, mode)
  1214. local logged = getElementData(thePlayer, "loggedin")
  1215.  
  1216. if logged == 1 then
  1217. mode = tonumber(mode)
  1218. if not mode or mode < 0 or mode > 2 then
  1219. outputChatBox("SYNTAX: /" .. commandName .. " [Mode]", thePlayer, 255, 194, 14)
  1220. outputChatBox("0 = hide all 1 = hide own 2 = show all", thePlayer, 255, 194, 14)
  1221. else
  1222. if (mode == 0) then
  1223. outputChatBox("All chatbubbles are now hidden.", thePlayer, 255, 194, 14)
  1224. elseif (mode == 1) then
  1225. outputChatBox("Only your own chatbubbles are hidden others are visible.", thePlayer, 255, 194, 14)
  1226. elseif (mode == 2) then
  1227. outputChatBox("All chatbubbles are now visible.", thePlayer, 255, 194, 14)
  1228. end
  1229. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "chatbubbles", mode, false)
  1230. mysql:query_free("UPDATE accounts SET chatbubbles=" .. mysql:escape_string(mode) .. " WHERE id = " .. mysql:escape_string(getElementData( thePlayer, "gameaccountid" )) )
  1231. end
  1232. end
  1233. end
  1234. addCommandHandler("changecbmode", playerChangeChatbubbleMode, false, false)
  1235.  
  1236. function toggleOOC(thePlayer, commandName)
  1237. local logged = getElementData(thePlayer, "loggedin")
  1238.  
  1239. if(logged==1) and (exports.global:isPlayerAdmin(thePlayer)) then
  1240. local players = exports.pool:getPoolElementsByType("player")
  1241. local oocEnabled = exports.global:getOOCState()
  1242. if (commandName == "togooc") then
  1243. if (oocEnabled==0) then
  1244. exports.global:setOOCState(1)
  1245.  
  1246. for k, arrayPlayer in ipairs(players) do
  1247. local logged = getElementData(arrayPlayer, "loggedin")
  1248.  
  1249. if (logged==1) then
  1250. outputChatBox("OOC Chat Enabled by Admin.", arrayPlayer, 0, 255, 0)
  1251. end
  1252. end
  1253. elseif (oocEnabled==1) then
  1254. exports.global:setOOCState(0)
  1255.  
  1256. for k, arrayPlayer in ipairs(players) do
  1257. local logged = getElementData(arrayPlayer, "loggedin")
  1258.  
  1259. if (logged==1) then
  1260. outputChatBox("OOC Chat Disabled by Admin.", arrayPlayer, 255, 0, 0)
  1261. end
  1262. end
  1263. end
  1264. elseif (commandName == "stogooc") then
  1265. if (oocEnabled==0) then
  1266. exports.global:setOOCState(1)
  1267.  
  1268. for k, arrayPlayer in ipairs(players) do
  1269. local logged = getElementData(arrayPlayer, "loggedin")
  1270. local admin = getElementData(arrayPlayer, "adminlevel")
  1271.  
  1272. if (logged==1) and (tonumber(admin)>0)then
  1273. outputChatBox("OOC Chat Enabled Silently by Admin " .. getPlayerName(thePlayer) .. ".", arrayPlayer, 0, 255, 0)
  1274. end
  1275. end
  1276. elseif (oocEnabled==1) then
  1277. exports.global:setOOCState(0)
  1278.  
  1279. for k, arrayPlayer in ipairs(players) do
  1280. local logged = getElementData(arrayPlayer, "loggedin")
  1281. local admin = getElementData(arrayPlayer, "adminlevel")
  1282.  
  1283. if (logged==1) and (tonumber(admin)>0)then
  1284. outputChatBox("OOC Chat Disabled Silently by Admin " .. getPlayerName(thePlayer) .. ".", arrayPlayer, 255, 0, 0)
  1285. end
  1286. end
  1287. end
  1288. end
  1289. end
  1290. end
  1291.  
  1292. addCommandHandler("togooc", toggleOOC, false, false)
  1293. addCommandHandler("stogooc", toggleOOC, false, false)
  1294.  
  1295. function togglePM(thePlayer, commandName)
  1296. local logged = getElementData(thePlayer, "loggedin")
  1297.  
  1298. if(logged==1) and ((exports.global:isPlayerAdmin(thePlayer)) or (exports.global:isPlayerBronzeDonator(thePlayer)))then
  1299. local pmenabled = getElementData(thePlayer, "pmblocked")
  1300.  
  1301. if (pmenabled==1) then
  1302. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "pmblocked", 0, false)
  1303. outputChatBox("PM's are now enabled.", thePlayer, 0, 255, 0)
  1304. else
  1305. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "pmblocked", 1, false)
  1306. outputChatBox("PM's are now disabled.", thePlayer, 255, 0, 0)
  1307. end
  1308. mysql:query_free("UPDATE accounts SET pmblocked=" .. mysql:escape_string(getElementData(thePlayer, "pmblocked")) .. " WHERE id = " .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")))
  1309. end
  1310. end
  1311. addCommandHandler("togpm", togglePM)
  1312. addCommandHandler("togglepm", togglePM)
  1313.  
  1314. function toggleAds(thePlayer, commandName)
  1315. local logged = getElementData(thePlayer, "loggedin")
  1316.  
  1317. if(logged==1) and (exports.global:isPlayerGoldDonator(thePlayer))then
  1318. local adblocked = getElementData(thePlayer, "disableAds")
  1319. if (adblocked) then -- enable the ads again
  1320. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "disableAds", false, false)
  1321. outputChatBox("Ads are now enabled.", thePlayer, 0, 255, 0)
  1322. mysql:query_free("UPDATE accounts SET adblocked=0 WHERE id = " .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")) )
  1323. else -- disable them D:
  1324. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "disableAds", true, false)
  1325. outputChatBox("Ads are now disabled.", thePlayer, 255, 0, 0)
  1326. mysql:query_free("UPDATE accounts SET adblocked=1 WHERE id = " .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")) )
  1327. end
  1328. end
  1329. end
  1330. addCommandHandler("togad", toggleAds)
  1331. addCommandHandler("togglead", toggleAds)
  1332.  
  1333. -- /pay
  1334. function payPlayer(thePlayer, commandName, targetPlayerNick, amount)
  1335. if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  1336.  
  1337. local logged = getElementData(thePlayer, "loggedin")
  1338.  
  1339. if (logged==1) then
  1340. if not (targetPlayerNick) or not (amount) or not tonumber(amount) then
  1341. outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick] [Amount]", thePlayer, 255, 194, 14)
  1342. else
  1343. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayerNick)
  1344.  
  1345. if targetPlayer then
  1346. local x, y, z = getElementPosition(thePlayer)
  1347. local tx, ty, tz = getElementPosition(targetPlayer)
  1348.  
  1349. local distance = getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)
  1350.  
  1351. if (distance<=10) then
  1352. amount = math.floor(math.abs(tonumber(amount)))
  1353.  
  1354. local hoursplayed = getElementData(thePlayer, "hoursplayed")
  1355.  
  1356. if (targetPlayer==thePlayer) then
  1357. outputChatBox("You cannot pay money to yourself.", thePlayer, 255, 0, 0)
  1358. elseif amount == 0 then
  1359. outputChatBox("You need to enter an amount larger than 0.", thePlayer, 255, 0, 0)
  1360. elseif (hoursplayed<5) and (amount>50) and not exports.global:isPlayerAdmin(thePlayer) and not exports.global:isPlayerAdmin(targetPlayer) and not exports.global:isPlayerBronzeDonator(thePlayer) then
  1361. outputChatBox("You must play atleast 5 hours before transferring over 50$", thePlayer, 255, 0, 0)
  1362. elseif exports.global:takeMoney(thePlayer, amount) then
  1363. if hoursplayed < 5 and not exports.global:isPlayerAdmin(targetPlayer) and not exports.global:isPlayerBronzeDonator(thePlayer) then
  1364. local totalAmount = ( getElementData(thePlayer, "payAmount") or 0 ) + amount
  1365. if totalAmount > 200 then
  1366. outputChatBox( "You can only /pay $200 per five minutes. /report for an admin to transfer a larger amoutn of cash.", thePlayer, 255, 0, 0 )
  1367. return
  1368. end
  1369. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "payAmount", totalAmount, false)
  1370. setTimer(
  1371. function(thePlayer, amount)
  1372. if isElement(thePlayer) then
  1373. local totalAmount = ( getElementData(thePlayer, "payAmount") or 0 ) - amount
  1374. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "payAmount", totalAmount <= 0 and false or totalAmount, false)
  1375. end
  1376. end,
  1377. 300000, 1, thePlayer, amount
  1378. )
  1379. end
  1380.  
  1381. exports.logs:logMessage("[Money Transfer From " .. getPlayerName(thePlayer) .. " To: " .. targetPlayerName .. "] Value: " .. amount .. "$", 5)
  1382. if (hoursplayed<5) then
  1383. exports.global:sendMessageToAdmins("AdmWarn: New Player '" .. getPlayerName(thePlayer) .. "' transferred " .. amount .. "$ to '" .. targetPlayerName .. "'.")
  1384. end
  1385.  
  1386. exports.global:giveMoney(targetPlayer, amount)
  1387.  
  1388. local gender = getElementData(thePlayer, "gender")
  1389. local genderm = "his"
  1390. if (gender == 1) then
  1391. genderm = "her"
  1392. end
  1393.  
  1394. exports.global:sendLocalMeAction(thePlayer, "takes some dollar notes from " .. genderm .. " wallet and gives them to " .. targetPlayerName .. ".")
  1395. outputChatBox("You gave $" .. amount .. " to " .. targetPlayerName .. ".", thePlayer)
  1396. outputChatBox(getPlayerName(thePlayer) .. " gave you $" .. amount .. ".", targetPlayer)
  1397.  
  1398. exports.global:applyAnimation(thePlayer, "DEALER", "shop_pay", 4000, false, true, true)
  1399. else
  1400. outputChatBox("You do not have enough money.", thePlayer, 255, 0, 0)
  1401. end
  1402. else
  1403. outputChatBox("You are too far away from " .. targetPlayerName .. ".", thePlayer, 255, 0, 0)
  1404. end
  1405. end
  1406. end
  1407. end
  1408. end
  1409. addCommandHandler("pay", payPlayer, false, false)
  1410.  
  1411. function removeAnimation(thePlayer)
  1412. exports.global:removeAnimation(thePlayer)
  1413. end
  1414.  
  1415. -- /w(hisper)
  1416. function localWhisper(thePlayer, commandName, targetPlayerNick, ...)
  1417. if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  1418.  
  1419. local logged = tonumber(getElementData(thePlayer, "loggedin"))
  1420.  
  1421. if (logged==1) then
  1422. if not (targetPlayerNick) or not (...) then
  1423. outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick / ID] [Message]", thePlayer, 255, 194, 14)
  1424. else
  1425. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayerNick)
  1426.  
  1427. if targetPlayer then
  1428. local x, y, z = getElementPosition(thePlayer)
  1429. local tx, ty, tz = getElementPosition(targetPlayer)
  1430.  
  1431. if (getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)<3) then
  1432. local name = getPlayerName(thePlayer)
  1433. local message = table.concat({...}, " ")
  1434. exports.logs:logMessage("[IC: Whisper] " .. name .. " to " .. targetPlayerName .. ": " .. message, 1)
  1435. message = trunklateText( thePlayer, message )
  1436.  
  1437. local languageslot = getElementData(thePlayer, "languages.current")
  1438. local language = getElementData(thePlayer, "languages.lang" .. languageslot)
  1439. local languagename = call(getResourceFromName("language-system"), "getLanguageName", language)
  1440.  
  1441. message2 = trunklateText( targetPlayer, message2 )
  1442. local message2 = call(getResourceFromName("language-system"), "applyLanguage", thePlayer, targetPlayer, message, language)
  1443.  
  1444. exports.global:sendLocalMeAction(thePlayer, "whispers to " .. targetPlayerName .. ".")
  1445. outputChatBox("[" .. languagename .. "] " .. name .. " whispers: " .. message, thePlayer, 255, 255, 255)
  1446. outputChatBox("[" .. languagename .. "] " .. name .. " whispers: " .. message2, targetPlayer, 255, 255, 255)
  1447. for i,p in ipairs(getElementsByType( "player" )) do
  1448. if (getElementData(p, "adminduty") == 1) then
  1449. if p ~= targetPlayer and p ~= thePlayer then
  1450. local ax, ay, az = getElementPosition(p)
  1451. if (getDistanceBetweenPoints3D(x, y, z, ax, ay, az)<4) then
  1452. outputChatBox("[" .. languagename .. "] " .. name .. " whispers to " .. getPlayerName(targetPlayer):gsub("_"," ") .. ": " .. message, p, 255, 255, 255)
  1453. end
  1454. end
  1455. end
  1456. end
  1457. else
  1458. outputChatBox("You are too far away from " .. targetPlayerName .. ".", thePlayer, 255, 0, 0)
  1459. end
  1460. end
  1461. end
  1462. end
  1463. end
  1464. addCommandHandler("w", localWhisper, false, false)
  1465.  
  1466. -- /c(lose)
  1467. function localClose(thePlayer, commandName, ...)
  1468. if exports['freecam-tv']:isPlayerFreecamEnabled(thePlayer) then return end
  1469.  
  1470. local logged = tonumber(getElementData(thePlayer, "loggedin"))
  1471.  
  1472. if (logged==1) then
  1473. if not (...) then
  1474. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  1475. else
  1476. local name = getPlayerName(thePlayer)
  1477. local message = table.concat({...}, " ")
  1478. exports.logs:logMessage("[IC: Whisper] " .. name .. ": " .. message, 1)
  1479. message = trunklateText( thePlayer, message )
  1480.  
  1481. local languageslot = getElementData(thePlayer, "languages.current")
  1482. local language = getElementData(thePlayer, "languages.lang" .. languageslot)
  1483. local languagename = call(getResourceFromName("language-system"), "getLanguageName", language)
  1484.  
  1485. for index, targetPlayers in ipairs( getElementsByType( "player" ) ) do
  1486. if getElementDistance( thePlayer, targetPlayers ) < 5 then
  1487. local message2 = message
  1488. if targetPlayers ~= thePlayer then
  1489. message2 = call(getResourceFromName("language-system"), "applyLanguage", thePlayer, targetPlayers, message, language)
  1490. message2 = trunklateText( targetPlayers, message2 )
  1491. end
  1492. local pveh = getPedOccupiedVehicle(targetPlayers)
  1493. if pveh then
  1494. if (exports['vehicle-system']:isVehicleWindowUp(pveh)) then
  1495. outputChatBox( " [" .. languagename .. "] " .. name .. " whispers: " .. message2, targetPlayers, 255, 255, 255)
  1496. end
  1497. else
  1498. outputChatBox( " [" .. languagename .. "] " .. name .. " whispers: " .. message2, targetPlayers, 255, 255, 255)
  1499. end
  1500. end
  1501. end
  1502. end
  1503. end
  1504. end
  1505. addCommandHandler("c", localClose, false, false)
  1506.  
  1507. ------------------
  1508. -- News Faction --
  1509. ------------------
  1510. -- /n(ews)
  1511. function newsMessage(thePlayer, commandName, ...)
  1512. local logged = getElementData(thePlayer, "loggedin")
  1513.  
  1514. if (logged==1) then
  1515. local theTeam = getPlayerTeam(thePlayer)
  1516. local factionType = getElementData(theTeam, "type")
  1517. local faction = getElementData(thePlayer, "faction")
  1518.  
  1519. if(factionType==6)then -- news faction
  1520.  
  1521. if not(...)then
  1522. outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14)
  1523. else
  1524. local message = table.concat({...}, " ")
  1525. local name = getPlayerName(thePlayer)
  1526.  
  1527. local abuse = true
  1528. if (getElementDimension(thePlayer) == 9902) then
  1529. abuse = false
  1530. end
  1531. for index, nearbyVehicle in ipairs( exports.global:getNearbyElements(thePlayer, "vehicle", 25) ) do
  1532. if (getElementModel(nearbyVehicle) == 582) then
  1533. abuse = false
  1534. end
  1535. end
  1536.  
  1537. if not abuse then
  1538. exports.logs:logMessage("[IC: News] " .. name .. ": " .. message, 18)
  1539. else
  1540. exports.logs:logMessage("[A" .. getElementDimension(thePlayer) .. "][IC: News] " .. name .. ": " .. message, 18)
  1541. end
  1542.  
  1543. for key, value in ipairs(exports.pool:getPoolElementsByType("player")) do
  1544.  
  1545. if (getElementData(value, "loggedin")==1) then
  1546.  
  1547. if not(getElementData(value, "tognews")==1) then
  1548.  
  1549. if faction == 95 then
  1550. outputChatBox("[LSEI] ".. name .." says: ".. message, value, 200, 100, 200)
  1551. elseif faction == 20 then
  1552. outputChatBox("[NEWS] ".. name .." says: ".. message, value, 200, 100, 200)
  1553. end
  1554. end
  1555. end
  1556. end
  1557.  
  1558. exports.global:giveMoney(theTeam, 200)
  1559. end
  1560. end
  1561. end
  1562. end
  1563. addCommandHandler("n", newsMessage, false, false)
  1564.  
  1565. -- /tognews
  1566. function togNews(thePlayer, commandName)
  1567. local logged = getElementData(thePlayer, "loggedin")
  1568.  
  1569. if (logged==1) and (exports.global:isPlayerGoldDonator(thePlayer)) then
  1570. local newsTog = getElementData(thePlayer, "tognews")
  1571.  
  1572. if (newsTog~=1) then
  1573. outputChatBox("/news disabled.", thePlayer, 255, 194, 14)
  1574. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "tognews", 1, false)
  1575. else
  1576. outputChatBox("/news enabled.", thePlayer, 255, 194, 14)
  1577. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "tognews", 0, false)
  1578. end
  1579. mysql:query_free("UPDATE accounts SET newsblocked=" .. mysql:escape_string(getElementData(thePlayer, "tognews")) .. " WHERE id = " .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")) )
  1580. end
  1581. end
  1582. addCommandHandler("tognews", togNews, false, false)
  1583. addCommandHandler("togglenews", togNews, false, false)
  1584.  
  1585.  
  1586. -- /startinterview
  1587. function StartInterview(thePlayer, commandName, targetPartialPlayer)
  1588. local logged = getElementData(thePlayer, "loggedin")
  1589. if (logged==1) then
  1590. local theTeam = getPlayerTeam(thePlayer)
  1591. local factionType = getElementData(theTeam, "type")
  1592. if(factionType==6)then -- news faction
  1593. if not (targetPartialPlayer) then
  1594. outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick]", thePlayer, 255, 194, 14)
  1595. else
  1596. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPartialPlayer)
  1597. if targetPlayer then
  1598. local targetLogged = getElementData(targetPlayer, "loggedin")
  1599. if (targetLogged==1) then
  1600. if(getElementData(targetPlayer,"interview"))then
  1601. outputChatBox("This player is already being interviewed.", thePlayer, 255, 0, 0)
  1602. else
  1603. exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "interview", true, false)
  1604. local playerName = getPlayerName(thePlayer)
  1605. outputChatBox(playerName .." has offered you for an interview.", targetPlayer, 0, 255, 0)
  1606. outputChatBox("((Use /i to talk during the interview.))", targetPlayer, 0, 255, 0)
  1607. local NewsFaction = getPlayersInTeam(getPlayerTeam(thePlayer))
  1608. for key, value in ipairs(NewsFaction) do
  1609. outputChatBox("((".. playerName .." has invited " .. targetPlayerName .. " for an interview.))", value, 0, 255, 0)
  1610. end
  1611. end
  1612. end
  1613. end
  1614. end
  1615. end
  1616. end
  1617. end
  1618. addCommandHandler("interview", StartInterview, false, false)
  1619.  
  1620. -- /endinterview
  1621. function endInterview(thePlayer, commandName, targetPartialPlayer)
  1622. local logged = getElementData(thePlayer, "loggedin")
  1623. if (logged==1) then
  1624. local theTeam = getPlayerTeam(thePlayer)
  1625. local factionType = getElementData(theTeam, "type")
  1626. if(factionType==6)then -- news faction
  1627. if not (targetPartialPlayer) then
  1628. outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick]", thePlayer, 255, 194, 14)
  1629. else
  1630. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPartialPlayer)
  1631. if targetPlayer then
  1632. local targetLogged = getElementData(targetPlayer, "loggedin")
  1633. if (targetLogged==1) then
  1634. if not(getElementData(targetPlayer,"interview"))then
  1635. outputChatBox("This player is not being interviewed.", thePlayer, 255, 0, 0)
  1636. else
  1637. exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "interview")
  1638. local playerName = getPlayerName(thePlayer)
  1639. outputChatBox(playerName .." has ended your interview.", targetPlayer, 255, 0, 0)
  1640.  
  1641. local NewsFaction = getPlayersInTeam(getPlayerTeam(thePlayer))
  1642. for key, value in ipairs(NewsFaction) do
  1643. outputChatBox("((".. playerName .." has ended " .. targetPlayerName .. "'s interview.))", value, 255, 0, 0)
  1644. end
  1645. end
  1646. end
  1647. end
  1648. end
  1649. end
  1650. end
  1651. end
  1652. addCommandHandler("endinterview", endInterview, false, false)
  1653.  
  1654. -- /i
  1655. function interviewChat(thePlayer, commandName, ...)
  1656. local logged = getElementData(thePlayer, "loggedin")
  1657. if (logged==1) then
  1658. if(getElementData(thePlayer, "interview"))then
  1659. if not(...)then
  1660. outputChatBox("SYNTAX: /" .. commandName .. "[Message]", thePlayer, 255, 194, 14)
  1661. else
  1662. local message = table.concat({...}, " ")
  1663. local name = getPlayerName(thePlayer)
  1664.  
  1665. exports.logs:logMessage("[IC: Interview Guest] " .. name .. ": " .. message, 18)
  1666.  
  1667. for key, value in ipairs(exports.pool:getPoolElementsByType("player")) do
  1668. if (getElementData(value, "loggedin")==1) then
  1669. if not (getElementData(value, "tognews")==1) then
  1670. outputChatBox("[NEWS] Interview Guest " .. name .." says: ".. message, value, 200, 100, 200)
  1671. end
  1672. end
  1673. end
  1674.  
  1675. exports.global:giveMoney(getTeamFromName"San Andreas Network", 200)
  1676. end
  1677. end
  1678. end
  1679. end
  1680. addCommandHandler("i", interviewChat, false, false)
  1681.  
  1682. -- news hotline /news
  1683. function newsHotline(thePlayer, commandName, ...)
  1684. local logged = getElementData(thePlayer, "loggedin")
  1685.  
  1686. if (logged==1) then
  1687. if not (...) then
  1688. outputChatBox("SYNTAX: /" .. commandName .. " [Description of Situation]", thePlayer, 255, 194, 14)
  1689. else
  1690. local playerName = getPlayerName(thePlayer)
  1691. local dimension = getElementDimension(thePlayer)
  1692. local interior = getElementInterior(thePlayer)
  1693.  
  1694. local message = table.concat({...}, " ")
  1695. message = string.gsub(message, "#%x%x%x%x%x%x", "") -- Remove colour codes
  1696.  
  1697. -- Show chat to console, for admins + log
  1698. exports.global:sendLocalMeAction(thePlayer,"dials a number on their cellphone.")
  1699. for index, nearbyPlayer in ipairs(getElementsByType("player")) do
  1700. local dist = getElementDistance( thePlayer, targetPlayers )
  1701. if dist < 20 then
  1702. local nearbyPlayerDimension = getElementDimension(nearbyPlayer)
  1703. local nearbyPlayerInterior = getElementInterior(nearbyPlayer)
  1704. if (nearbyPlayerDimension==dimension) and (nearbyPlayerInterior==interior) then
  1705. local logged = tonumber(getElementData(nearbyPlayer, "loggedin"))
  1706. if not (isPedDead(nearbyPlayer)) and (logged==1) then
  1707. if dist < 4 then
  1708. outputChatBox( "#EEEEEE" .. playerName .. " [Cellphone]: " .. message, nearbyPlayer, 255, 255, 255, true)
  1709. elseif dist < 8 then
  1710. outputChatBox( "#DDDDDD" .. playerName .. " [Cellphone]: " .. message, nearbyPlayer, 255, 255, 255, true)
  1711. elseif dist < 12 then
  1712. outputChatBox( "#CCCCCC" .. playerName .. " [Cellphone]: " .. message, nearbyPlayer, 255, 255, 255, true)
  1713. elseif dist < 16 then
  1714. outputChatBox( "#BBBBBB" .. playerName .. " [Cellphone]: " .. message, nearbyPlayer, 255, 255, 255, true)
  1715. else
  1716. outputChatBox( "#AAAAAA" .. playerName .. " [Cellphone]: " .. message, nearbyPlayer, 255, 255, 255, true)
  1717. end
  1718. end
  1719. end
  1720. end
  1721. end
  1722.  
  1723. outputChatBox("Thank you for calling the San Andreas Network Desk. Your tip will be forwarded to our staff.", thePlayer, 255, 194, 14)
  1724. exports.global:sendLocalMeAction(thePlayer,"hangs up their cellphone.")
  1725.  
  1726. local playerNumber = getElementData(thePlayer, "cellnumber")
  1727. local theTeam = getTeamFromName("San Andreas Network")
  1728. local teamMembers = getPlayersInTeam(theTeam)
  1729.  
  1730. for key, value in ipairs(teamMembers) do
  1731. if(exports.global:hasItem(value,2))then
  1732. if getElementData( value, "phoneoff" ) ~= 1 then
  1733. for _,nearbyPlayer in ipairs(exports.global:getNearbyElements(value, "player")) do
  1734. triggerClientEvent(nearbyPlayer, "startRinging", value, 2)
  1735. end
  1736. exports.global:sendLocalMeAction(value,"receives a text message.")
  1737. end
  1738. outputChatBox("SMS From: News Desk - '".. message.."' Ph:".. playerNumber .." (("..getPlayerName(thePlayer) .."))", value)
  1739. end
  1740. end
  1741. end
  1742. end
  1743. end
  1744. addCommandHandler("news", newsHotline, false, false)
  1745.  
  1746. function showRoadmap(thePlayer)
  1747. local logged = getElementData(thePlayer, "loggedin")
  1748. if (logged==1) then
  1749. outputChatBox("Loading Progress... Please Wait...", thePlayer, 255, 194, 15)
  1750. callRemote("http://vg-lvpd.net/remote/roadmap.php", displayRoadmap, thePlayer)
  1751. end
  1752. end
  1753. addCommandHandler("roadmap", showRoadmap)
  1754. --addCommandHandler("progress", showRoadmap)
  1755.  
  1756. function displayRoadmap(thePlayer, version1, percent1, changes1, version2, percent2, changes2, version3, percent3, changes3, mtaversion, mtapercent, mtachanges)
  1757. if (thePlayer~="ERROR") then
  1758. outputChatBox("~~~~~~~~~~~~~~~~~~ Progress ~~~~~~~~~~~~~~~~~~", thePlayer, 255, 194, 15)
  1759. outputChatBox("vG " .. version1 .. ": " .. percent1 .. ". Changes: " .. changes1 .. ".", thePlayer, 255, 194, 15)
  1760. outputChatBox("vG " .. version2 .. ": " .. percent2 .. ". Changes: " .. changes2 .. ".", thePlayer, 255, 194, 15)
  1761. outputChatBox("vG " .. version3 .. ": " .. percent3 .. ". Changes: " .. changes3 .. ".", thePlayer, 255, 194, 15)
  1762. outputChatBox("MultiTheftAuto " .. mtaversion .. ": " .. mtapercent .. ". Changes: " .. mtachanges .. ".", thePlayer, 255, 194, 15)
  1763. end
  1764. end
  1765.  
  1766. -- /charity
  1767. function charityCash(thePlayer, commandName, amount)
  1768. if not (amount) then
  1769. outputChatBox("SYNTAX: /" .. commandName .. " [Amount]", thePlayer, 255, 194, 14)
  1770. else
  1771. local donation = tonumber(amount)
  1772. if (donation<=0) then
  1773. outputChatBox("You must enter an amount greater than zero.", thePlayer, 255, 0, 0)
  1774. else
  1775. if not exports.global:takeMoney(thePlayer, donation) then
  1776. outputChatBox("You don't have that much money to remove.", thePlayer, 255, 0, 0)
  1777. else
  1778. outputChatBox("You have donated $".. donation .." to charity.", thePlayer, 0, 255, 0)
  1779. if(donation>=1000)then
  1780. local name = getPlayerName(thePlayer)
  1781.  
  1782. local gender = getElementData(thePlayer, "gender")
  1783. local genderm = "his"
  1784. if (gender == 1) then
  1785. genderm = "her"
  1786. end
  1787. outputChatBox("The hungry orphans would like to thank " ..name.. " for " .. genderm .. " sizable $" ..donation.. " donation to charity.", getRootElement())
  1788. exports.global:givePlayerAchievement(thePlayer, 37) -- The Good Samaritan
  1789. end
  1790. end
  1791. end
  1792. end
  1793. end
  1794. addCommandHandler("charity", charityCash, false, false)
  1795.  
  1796. -- /bigears
  1797. function bigEars(thePlayer, commandName, targetPlayerNick)
  1798. if exports.global:isPlayerLeadAdmin(thePlayer) then
  1799. local current = getElementData(thePlayer, "bigears")
  1800. if not current and not targetPlayerNick then
  1801. outputChatBox("SYNTAX: /" .. commandName .. " [player]", thePlayer, 255, 194, 14)
  1802. elseif current and not targetPlayerNick then
  1803. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "bigears")
  1804. outputChatBox("Big Ears turned off.", thePlayer, 255, 0, 0)
  1805. else
  1806. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayerNick)
  1807.  
  1808. if targetPlayer then
  1809. outputChatBox("Now Listening to " .. targetPlayerName .. ".", thePlayer, 0, 255, 0)
  1810. exports.logs:logMessage("[/bigears] " .. getElementData(thePlayer, "gameaccountusername") .. "/".. getPlayerName(thePlayer) .." started bigear on " .. targetPlayerName, 4)
  1811. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "bigears", targetPlayer, false)
  1812. end
  1813. end
  1814. end
  1815. end
  1816. addCommandHandler("bigears", bigEars)
  1817.  
  1818. function removeBigEars()
  1819. for key, value in pairs( getElementsByType( "player" ) ) do
  1820. if isElement( value ) and getElementData( value, "bigears" ) == source then
  1821. exports['anticheat-system']:changeProtectedElementDataEx( value, "bigears" )
  1822. outputChatBox("Big Ears turned off (Player Left).", value, 255, 0, 0)
  1823. end
  1824. end
  1825. end
  1826. addEventHandler( "onPlayerQuit", getRootElement(), removeBigEars)
  1827.  
  1828. function bigEarsFaction(thePlayer, commandName, factionID)
  1829. if exports.global:isPlayerLeadAdmin(thePlayer) then
  1830. factionID = tonumber( factionID )
  1831. local current = getElementData(thePlayer, "bigearsfaction")
  1832. if not current and not factionID then
  1833. outputChatBox("SYNTAX: /" .. commandName .. " [faction id]", thePlayer, 255, 194, 14)
  1834. elseif current and not factionID then
  1835. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "bigearsfaction")
  1836. outputChatBox("Big Ears turned off.", thePlayer, 255, 0, 0)
  1837. else
  1838. local team = exports.pool:getElement("team", factionID)
  1839. if not team then
  1840. outputChatBox("No faction with that ID found.", thePlayer, 255, 0, 0)
  1841. else
  1842. outputChatBox("Now Listening to " .. getTeamName(team) .. " OOC Chat.", thePlayer, 0, 255, 0)
  1843. exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "bigearsfaction", team, false)
  1844. exports.logs:logMessage("[/bigearsf] " .. getElementData(thePlayer, "gameaccountusername") .. "/".. getPlayerName(thePlayer) .." started bigear on " .. getTeamName(team), 4)
  1845. end
  1846. end
  1847. end
  1848. end
  1849. addCommandHandler("bigearsf", bigEarsFaction)
  1850.  
  1851. function disableMsg(message, player)
  1852. cancelEvent()
  1853.  
  1854. -- send it using our own PM etiquette instead
  1855. pmPlayer(source, "pm", player, message)
  1856. end
  1857. addEventHandler("onPlayerPrivateMessage", getRootElement(), disableMsg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement